summaryrefslogtreecommitdiffstats
path: root/app/api/responders/resource
diff options
context:
space:
mode:
Diffstat (limited to 'app/api/responders/resource')
-rw-r--r--app/api/responders/resource/aggregates.py4
-rw-r--r--app/api/responders/resource/clique_constraints.py13
-rw-r--r--app/api/responders/resource/clique_types.py26
-rw-r--r--app/api/responders/resource/cliques.py17
-rw-r--r--app/api/responders/resource/connection_tests.py10
-rw-r--r--app/api/responders/resource/constants.py7
-rw-r--r--app/api/responders/resource/environment_configs.py41
-rw-r--r--app/api/responders/resource/inventory.py17
-rw-r--r--app/api/responders/resource/links.py21
-rw-r--r--app/api/responders/resource/messages.py19
-rw-r--r--app/api/responders/resource/monitoring_config_templates.py17
-rw-r--r--app/api/responders/resource/scans.py17
-rw-r--r--app/api/responders/resource/scheduled_scans.py33
13 files changed, 121 insertions, 121 deletions
diff --git a/app/api/responders/resource/aggregates.py b/app/api/responders/resource/aggregates.py
index d0b8031..ca4610e 100644
--- a/app/api/responders/resource/aggregates.py
+++ b/app/api/responders/resource/aggregates.py
@@ -12,9 +12,11 @@ from api.validation.data_validate import DataValidate
class Aggregates(ResponderBase):
+
+ AGGREGATE_TYPES = ["environment", "message", "constant"]
+
def __init__(self):
super().__init__()
- self.AGGREGATE_TYPES = ["environment", "message", "constant"]
self.AGGREGATES_MAP = {
"environment": self.get_environments_aggregates,
"message": self.get_messages_aggregates,
diff --git a/app/api/responders/resource/clique_constraints.py b/app/api/responders/resource/clique_constraints.py
index 09fa782..1761f8c 100644
--- a/app/api/responders/resource/clique_constraints.py
+++ b/app/api/responders/resource/clique_constraints.py
@@ -13,13 +13,12 @@ from bson.objectid import ObjectId
class CliqueConstraints(ResponderBase):
- def __init__(self):
- super().__init__()
- self.ID = '_id'
- self.PROJECTION = {
- self.ID: True
- }
- self.COLLECTION = 'clique_constraints'
+
+ COLLECTION = 'clique_constraints'
+ ID = '_id'
+ PROJECTION = {
+ ID: True
+ }
def on_get(self, req, resp):
self.log.debug("Getting clique_constraints")
diff --git a/app/api/responders/resource/clique_types.py b/app/api/responders/resource/clique_types.py
index a2bfa75..ff42f8c 100644
--- a/app/api/responders/resource/clique_types.py
+++ b/app/api/responders/resource/clique_types.py
@@ -13,17 +13,17 @@ from bson.objectid import ObjectId
class CliqueTypes(ResponderBase):
- def __init__(self):
- super().__init__()
- self.COLLECTION = "clique_types"
- self.ID = "_id"
- self.PROJECTION = {
- self.ID: True,
- "focal_point_type": True,
- "link_types": True,
- "environment": True,
- "name": True
- }
+
+ COLLECTION = "clique_types"
+ ID = "_id"
+ PROJECTION = {
+ ID: True,
+ "focal_point_type": True,
+ "link_types": True,
+ "environment": True,
+ "name": True
+ }
+ RESERVED_NAMES = ["ANY"]
def on_get(self, req, resp):
self.log.debug("Getting clique types")
@@ -83,7 +83,9 @@ class CliqueTypes(ResponderBase):
env_name = clique_type['environment']
if not self.check_environment_name(env_name):
- self.bad_request("unknown environment: " + env_name)
+ self.bad_request("Unknown environment: {}".format(env_name))
+ elif env_name.upper() in self.RESERVED_NAMES:
+ self.bad_request("Environment name '{}' is reserved".format(env_name))
self.write(clique_type, self.COLLECTION)
self.set_successful_response(resp,
diff --git a/app/api/responders/resource/cliques.py b/app/api/responders/resource/cliques.py
index a81ab00..60f1133 100644
--- a/app/api/responders/resource/cliques.py
+++ b/app/api/responders/resource/cliques.py
@@ -15,15 +15,14 @@ from utils.util import generate_object_ids
class Cliques(ResponderBase):
- def __init__(self):
- super().__init__()
- self.COLLECTION = "cliques"
- self.ID = '_id'
- self.PROJECTION = {
- self.ID: True,
- "focal_point_type": True,
- "environment": True
- }
+
+ COLLECTION = "cliques"
+ ID = '_id'
+ PROJECTION = {
+ ID: True,
+ "focal_point_type": True,
+ "environment": True
+ }
def on_get(self, req, resp):
self.log.debug("Getting cliques")
diff --git a/app/api/responders/resource/connection_tests.py b/app/api/responders/resource/connection_tests.py
index 8f8ab94..cb4865d 100644
--- a/app/api/responders/resource/connection_tests.py
+++ b/app/api/responders/resource/connection_tests.py
@@ -24,14 +24,14 @@ class ConnectionTests(ResponderBase):
RESULTS = "test_results"
CONFIGURATIONS = "targets_configuration"
STATUSES = ["request", "response"]
+ PROJECTION = {
+ ID: True,
+ TARGETS: True,
+ RESULTS: True
+ }
def __init__(self):
super().__init__()
- self.PROJECTION = {
- self.ID: True,
- self.TARGETS: True,
- self.RESULTS: True
- }
self.allowed_targets = \
self.get_constants_by_name("configuration_targets")
diff --git a/app/api/responders/resource/constants.py b/app/api/responders/resource/constants.py
index be71b5d..26fbbc3 100644
--- a/app/api/responders/resource/constants.py
+++ b/app/api/responders/resource/constants.py
@@ -12,10 +12,9 @@ from bson.objectid import ObjectId
class Constants(ResponderBase):
- def __init__(self):
- super().__init__()
- self.ID = '_id'
- self.COLLECTION = 'constants'
+
+ COLLECTION = 'constants'
+ ID = '_id'
def on_get(self, req, resp):
self.log.debug("Getting constants with name")
diff --git a/app/api/responders/resource/environment_configs.py b/app/api/responders/resource/environment_configs.py
index f54bea7..c24aec8 100644
--- a/app/api/responders/resource/environment_configs.py
+++ b/app/api/responders/resource/environment_configs.py
@@ -17,22 +17,22 @@ from utils.inventory_mgr import InventoryMgr
class EnvironmentConfigs(ResponderBase):
- def __init__(self):
- super(EnvironmentConfigs, self).__init__()
- self.inv = InventoryMgr()
- self.ID = "name"
- self.PROJECTION = {
- self.ID: True,
- "_id": False,
- "name": True,
- "distribution": True
- }
- self.COLLECTION = "environments_config"
- self.CONFIGURATIONS_NAMES = ["mysql", "OpenStack",
- "CLI", "AMQP", "Monitoring",
+
+ COLLECTION = "environments_config"
+ ID = "name"
+ PROJECTION = {
+ ID: True,
+ "_id": False,
+ "name": True,
+ "distribution": True
+ }
+ CONFIGURATIONS_NAMES = ["mysql", "OpenStack", "CLI", "AMQP",
+ "Monitoring", "NFV_provider", "ACI"]
+ OPTIONAL_CONFIGURATIONS_NAMES = ["AMQP", "Monitoring",
"NFV_provider", "ACI"]
- self.OPTIONAL_CONFIGURATIONS_NAMES = ["AMQP", "Monitoring",
- "NFV_provider", "ACI"]
+
+ def __init__(self):
+ super().__init__()
self.provision_types = self.\
get_constants_by_name("environment_provision_types")
@@ -41,6 +41,8 @@ class EnvironmentConfigs(ResponderBase):
get_constants_by_name("environment_monitoring_types")
self.distributions = self.\
get_constants_by_name("distributions")
+ self.distribution_versions = self.\
+ get_constants_by_name("distribution_versions")
self.mechanism_drivers = self.\
get_constants_by_name("mechanism_drivers")
self.operational_values = self.\
@@ -183,6 +185,9 @@ class EnvironmentConfigs(ResponderBase):
"distribution": self.require(str,
validate=DataValidate.LIST,
requirement=self.distributions),
+ "distribution_version": self.require(str,
+ validate=DataValidate.LIST,
+ requirement=self.distribution_versions),
"mechanism_drivers": self.require([str, list],
validate=DataValidate.LIST,
requirement=self.mechanism_drivers),
@@ -216,9 +221,9 @@ class EnvironmentConfigs(ResponderBase):
def build_query(self, filters):
query = {}
- filters_keys = ["name", "distribution", "type_drivers", "user",
- "listen", "monitoring_setup_done", "scanned",
- "operational"]
+ filters_keys = ["name", "distribution", "distribution_version",
+ "type_drivers", "user", "listen",
+ "monitoring_setup_done", "scanned", "operational"]
self.update_query_with_filters(filters, filters_keys, query)
mechanism_drivers = filters.get("mechanism_drivers")
if mechanism_drivers:
diff --git a/app/api/responders/resource/inventory.py b/app/api/responders/resource/inventory.py
index 6712197..5ae0bde 100644
--- a/app/api/responders/resource/inventory.py
+++ b/app/api/responders/resource/inventory.py
@@ -13,15 +13,14 @@ from datetime import datetime
class Inventory(ResponderBase):
- def __init__(self):
- super().__init__()
- self.COLLECTION = 'inventory'
- self.ID = 'id'
- self.PROJECTION = {
- self.ID: True,
- "name": True,
- "name_path": True
- }
+
+ COLLECTION = 'inventory'
+ ID = 'id'
+ PROJECTION = {
+ ID: True,
+ "name": True,
+ "name_path": True
+ }
def on_get(self, req, resp):
self.log.debug("Getting objects from inventory")
diff --git a/app/api/responders/resource/links.py b/app/api/responders/resource/links.py
index bd0a022..d700bad 100644
--- a/app/api/responders/resource/links.py
+++ b/app/api/responders/resource/links.py
@@ -13,17 +13,16 @@ from bson.objectid import ObjectId
class Links(ResponderBase):
- def __init__(self):
- super().__init__()
- self.COLLECTION = 'links'
- self.ID = '_id'
- self.PROJECTION = {
- self.ID: True,
- "link_name": True,
- "link_type": True,
- "environment": True,
- "host": True
- }
+
+ COLLECTION = 'links'
+ ID = '_id'
+ PROJECTION = {
+ ID: True,
+ "link_name": True,
+ "link_type": True,
+ "environment": True,
+ "host": True
+ }
def on_get(self, req, resp):
self.log.debug("Getting links from links")
diff --git a/app/api/responders/resource/messages.py b/app/api/responders/resource/messages.py
index 367bd34..ff64fbc 100644
--- a/app/api/responders/resource/messages.py
+++ b/app/api/responders/resource/messages.py
@@ -15,16 +15,15 @@ from bson.objectid import ObjectId
class Messages(ResponderBase):
- def __init__(self):
- super().__init__()
- self.ID = "id"
- self.COLLECTION = 'messages'
- self.PROJECTION = {
- self.ID: True,
- "environment": True,
- "source_system": True,
- "level": True
- }
+
+ COLLECTION = 'messages'
+ ID = "id"
+ PROJECTION = {
+ ID: True,
+ "environment": True,
+ "source_system": True,
+ "level": True
+ }
def on_get(self, req, resp):
self.log.debug("Getting messages from messages")
diff --git a/app/api/responders/resource/monitoring_config_templates.py b/app/api/responders/resource/monitoring_config_templates.py
index 8980cc9..3162168 100644
--- a/app/api/responders/resource/monitoring_config_templates.py
+++ b/app/api/responders/resource/monitoring_config_templates.py
@@ -13,15 +13,14 @@ from bson.objectid import ObjectId
class MonitoringConfigTemplates(ResponderBase):
- def __init__(self):
- super().__init__()
- self.ID = "_id"
- self.COLLECTION = "monitoring_config_templates"
- self.PROJECTION = {
- self.ID: True,
- "side": True,
- "type": True
- }
+
+ COLLECTION = "monitoring_config_templates"
+ ID = "_id"
+ PROJECTION = {
+ ID: True,
+ "side": True,
+ "type": True
+ }
def on_get(self, req, resp):
self.log.debug("Getting monitoring config template")
diff --git a/app/api/responders/resource/scans.py b/app/api/responders/resource/scans.py
index 6fc572d..30b8dd6 100644
--- a/app/api/responders/resource/scans.py
+++ b/app/api/responders/resource/scans.py
@@ -14,15 +14,14 @@ from datetime import datetime
class Scans(ResponderBase):
- def __init__(self):
- super().__init__()
- self.COLLECTION = "scans"
- self.ID = "_id"
- self.PROJECTION = {
- self.ID: True,
- "environment": True,
- "status": True
- }
+
+ COLLECTION = "scans"
+ ID = "_id"
+ PROJECTION = {
+ ID: True,
+ "environment": True,
+ "status": True
+ }
def on_get(self, req, resp):
self.log.debug("Getting scans")
diff --git a/app/api/responders/resource/scheduled_scans.py b/app/api/responders/resource/scheduled_scans.py
index f8cf92c..e9d6a34 100644
--- a/app/api/responders/resource/scheduled_scans.py
+++ b/app/api/responders/resource/scheduled_scans.py
@@ -14,23 +14,22 @@ from datetime import datetime
class ScheduledScans(ResponderBase):
- def __init__(self):
- super().__init__()
- self.COLLECTION = "scheduled_scans"
- self.ID = "_id"
- self.PROJECTION = {
- self.ID: True,
- "environment": True,
- "scheduled_timestamp": True,
- "freq": True
- }
- self.SCAN_FREQ = [
- "YEARLY",
- "MONTHLY",
- "WEEKLY",
- "DAILY",
- "HOURLY"
- ]
+
+ COLLECTION = "scheduled_scans"
+ ID = "_id"
+ PROJECTION = {
+ ID: True,
+ "environment": True,
+ "scheduled_timestamp": True,
+ "freq": True
+ }
+ SCAN_FREQ = [
+ "YEARLY",
+ "MONTHLY",
+ "WEEKLY",
+ "DAILY",
+ "HOURLY"
+ ]
def on_get(self, req, resp):
self.log.debug("Getting scheduled scans")