added schemes to support new ui link options + fix api per new schemes 17/45117/1
authorKoren Lev <korenlev@gmail.com>
Sat, 14 Oct 2017 22:38:44 +0000 (01:38 +0300)
committerKoren Lev <korenlev@gmail.com>
Sat, 14 Oct 2017 22:38:44 +0000 (01:38 +0300)
Change-Id: I768233f13749d01d436c24c764cb903ca19d3d2a
Signed-off-by: Koren Lev <korenlev@gmail.com>
18 files changed:
app/api/responders/resource/aggregates.py
app/api/responders/resource/clique_constraints.py
app/api/responders/resource/clique_types.py
app/api/responders/resource/cliques.py
app/api/responders/resource/connection_tests.py
app/api/responders/resource/constants.py
app/api/responders/resource/environment_configs.py
app/api/responders/resource/inventory.py
app/api/responders/resource/links.py
app/api/responders/resource/messages.py
app/api/responders/resource/monitoring_config_templates.py
app/api/responders/resource/scans.py
app/api/responders/resource/scheduled_scans.py
app/discover/fetchers/cli/cli_fetch_bond_host_pnics.py
app/discover/fetchers/cli/cli_fetch_vservice_vnics.py
app/install/db/attributes_for_hover_on_data.json
app/install/db/constants.json
app/install/db/supported_environments.json

index d0b8031..ca4610e 100644 (file)
@@ -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,
index 09fa782..1761f8c 100644 (file)
@@ -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")
index a2bfa75..ff42f8c 100644 (file)
@@ -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,
index a81ab00..60f1133 100644 (file)
@@ -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")
index 8f8ab94..cb4865d 100644 (file)
@@ -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")
 
index be71b5d..26fbbc3 100644 (file)
@@ -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")
index f54bea7..c24aec8 100644 (file)
@@ -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:
index 6712197..5ae0bde 100644 (file)
@@ -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")
index bd0a022..d700bad 100644 (file)
@@ -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")
index 367bd34..ff64fbc 100644 (file)
@@ -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")
index 8980cc9..3162168 100644 (file)
@@ -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")
index 6fc572d..30b8dd6 100644 (file)
@@ -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")
index f8cf92c..e9d6a34 100644 (file)
@@ -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")
index 77f149f..d988c35 100644 (file)
@@ -37,7 +37,7 @@ class CliFetchBondHostPnics(CliAccess):
         if lines and 'No such file or directory' in lines[0]:
             return []  # no bonds so directory does not exist
         bonds = []
-        for line in lines:
+        for line in [l.strip() for l in lines]:
             bond = self.get_bond_details(host_id, line)
             if bond:
                 bonds.append(bond)
@@ -123,7 +123,7 @@ class CliFetchBondHostPnics(CliAccess):
         })
         if not pnic:
             self.log.error('unable to find slave pNIC {} under bond {}'
-                           .format(slave_id, interface_id))
+                           .format(slave['name'], interface_id))
             return
         mac_address = pnic['mac_address']
         slave_id = '{}-{}'.format(slave.get('name', ''), mac_address)
index 2e074f8..3bc3a5b 100644 (file)
@@ -21,7 +21,7 @@ class CliFetchVserviceVnics(CliAccess):
         self.regexps = [
             {'name': 'mac_address', 're': '^.*\slink/ether\s(\S+)\s'},
             {'name': 'IP Address', 're': '^\s*inet ([0-9.]+)/'},
-            {'name': 'netmask', 're': '^.*\slink/ether\s[^/]+/(\S+)'},
+            {'name': 'netmask', 're': '^\s*inet [0-9.]+/([0-9]+)'},
             {'name': 'IPv6 Address',
              're': '^\s*inet6 ([^/]+)/.* global '}
         ]
@@ -138,6 +138,8 @@ class CliFetchVserviceVnics(CliAccess):
     @staticmethod
     def convert_netmask(cidr):
         netmask_conversion = {
+            '32': '255.255.255.255',
+            '31': '255.255.255.254',
             '30': '255.255.255.252',
             '29': '255.255.255.248',
             '28': '255.255.255.240',
@@ -152,7 +154,23 @@ class CliFetchVserviceVnics(CliAccess):
             '19': '255.255.224.0',
             '18': '255.255.192.0',
             '17': '255.255.128.0',
-            '16': '255.255.0.0'
+            '16': '255.255.0.0',
+            '15': '255.254.0.0',
+            '14': '255.252.0.0',
+            '13': '255.248.0.0',
+            '12': '255.240.0.0',
+            '11': '255.224.0.0',
+            '10': '255.192.0.0',
+            '9': '255.128.0.0',
+            '8': '255.0.0.0',
+            '7': '254.0.0.0',
+            '6': '252.0.0.0',
+            '5': '248.0.0.0',
+            '4': '240.0.0.0',
+            '3': '224.0.0.0',
+            '2': '192.0.0.0',
+            '1': '128.0.0.0',
+            '0': '0.0.0.0'
         }
         if cidr not in netmask_conversion:
             raise ValueError('can''t convert to netmask: {}'.format(cidr))
index aadcbe8..d1fbe04 100644 (file)
@@ -3,9 +3,12 @@
     "attributes" : [
         "object_name", 
         "model", 
-        "mac_address", 
-        "type", 
-        "koren"
+        "mac_address",
+        "vnic_type",
+        "data",
+        "status", 
+        "status_timestamp", 
+        "status_text"
     ], 
     "type" : "vnic"
 },
         "object_name", 
         "connector_type", 
         "type", 
-        "interfaces"
+        "interfaces",
+        "status", 
+        "status_timestamp", 
+        "status_text"
     ], 
     "type" : "vconnector"
 },
         "object_name", 
         "host", 
         "service_type", 
-        "type"
+        "type",
+        "status_text",
+        "status",
+        "status_timestamp"
     ], 
     "type" : "vservice"
 },
         "object_name", 
         "host", 
         "agent_type", 
-        "binary", 
-        "type"
+        "binary",
+        "started_at",
+        "heartbeat_timestamp",
+        "type",
+        "status", 
+        "status_timestamp", 
+        "status_text"
     ], 
     "type" : "vedge"
 },
         "mac_address", 
         "Speed", 
         "Link detected", 
-        "type"
+        "type",
+        "Bonding Mode", 
+        "Ethernet Channel Bonding Driver", 
+        "members",
+        "status",
+        "status_timestamp",
+        "status_text"
     ], 
     "type" : "host_pnic"
 },
         "object_name", 
         "provider:segmentation_id", 
         "provider:network_type", 
-        "type"
+        "type",
+        "status",
+        "port_security_enabled",
+        "availability_zones",
+        "mtu"
     ], 
     "type" : "network"
 },
     "attributes" : [
         "object_name", 
         "host_type", 
-        "parent_id", 
-        "type"
+        "services", 
+        "type",
+        "status", 
+        "status_timestamp", 
+        "status_text"
     ], 
     "type" : "host"
 },
 { 
     "attributes" : [
-        "object_name", 
+        "object_name",
+        "local_name", 
         "host", 
         "project", 
         "type", 
-        "name_path"
+        "name_path",
+        "status", 
+        "status_timestamp", 
+        "status_text"
     ], 
     "type" : "instance"
 },
         "parent_id", 
         "role"
     ]
+},
+{ 
+    "attributes" : [
+        "link_type",
+        "status",
+        "status_timestamp",
+        "status_text"
+    ],
+    "type" : "link"
 }
 ]
index 15522b7..6912eeb 100644 (file)
         {
             "value" : "10918",
             "label" : "10918"
+        },
+        {
+            "label" : "11190", 
+            "value" : "11190"
         }
     ]
 },
index 0d507c3..c2c376b 100644 (file)
       "monitoring" : false
     }
   },
+  { 
+    "features" : {
+        "listening" : true, 
+        "scanning" : true, 
+        "monitoring" : true
+    }, 
+    "environment" : {
+        "type_drivers" : "vlan", 
+        "mechanism_drivers" : "OVS", 
+        "distribution" : "Mercury", 
+        "distribution_version" : ["11190"]
+    }
+  },
   { 
     "features" : {
         "listening" : true,