Add validation for "caas_oam" networking type 76/1676/6
authorKrisztian Lengyel <krisztian.lengyel@nokia.com>
Mon, 16 Sep 2019 17:57:16 +0000 (13:57 -0400)
committerKrisztian Lengyel <krisztian.lengyel@nokia.com>
Fri, 18 Oct 2019 13:10:48 +0000 (15:10 +0200)
Change-Id: I7124ab816e986a83a02c7885a76ab8f0337d1f89

validators/src/HostsValidation.py
validators/src/NetworkingValidation.py

index e59ed26..9fd3577 100644 (file)
@@ -43,6 +43,7 @@ class HostsValidation(cmvalidator.CMValidator):
     performance_profile_attr = 'cloud.performance_profiles'
     networking_attr = 'cloud.networking'
     MIN_PASSWORD_LENGTH = 8
+    caas_service_profiles = (caas_master_profile, caas_worker_profile)
 
     def get_subscription_info(self):
         logging.debug('get_subscription info called')
@@ -97,6 +98,8 @@ class HostsValidation(cmvalidator.CMValidator):
 
                 self.validate_network_ranges(host_dict, net_profile_dict, networking_dict)
 
+                is_caas_oam_mapped_on_any_hosts = False
+
                 for host_name, host_data in host_dict.iteritems():
                     attr = 'network_profiles'
                     profiles = host_data.get(attr)
@@ -147,6 +150,14 @@ class HostsValidation(cmvalidator.CMValidator):
                             raise validation.ValidationError('%s is not mapped for %s' %
                                                              (subnet_name, host_name))
 
+                    if self.is_host_caas_node(host_data):
+                        subnet_name = 'caas_oam'
+                        if self.network_is_mapped(value_dict.get(profile_name), subnet_name):
+                            is_caas_oam_mapped_on_any_hosts = True
+                        elif is_caas_oam_mapped_on_any_hosts:
+                            raise validation.ValidationError('%s is not mapped for %s' %
+                                                             (subnet_name, host_name))
+
             elif key == self.storage_profile_attr:
                 profile_list = [] if not value_dict else value_dict.keys()
 
@@ -563,6 +574,9 @@ class HostsValidation(cmvalidator.CMValidator):
                 return True
         return False
 
+    def is_host_caas_node(self, host):
+        return bool(set(self.caas_service_profiles).intersection(host['service_profiles']))
+
     def _get_type_of_nodes(self, nodetype, config):
         nodes = [k for k, v in config.iteritems() if nodetype in v['service_profiles']]
         return nodes
index a36c9d1..89b8019 100644 (file)
@@ -40,9 +40,11 @@ class NetworkingValidation(cmvalidator.CMValidator):
     INFRA_EXTERNAL = 'infra_external'
     INFRA_INTERNAL = 'infra_internal'
     INFRA_STORAGE_CLUSTER = 'infra_storage_cluster'
+    CAAS_OAM = 'caas_oam'
     INFRA_NETWORKS = [INFRA_EXTERNAL,
                       INFRA_INTERNAL,
-                      INFRA_STORAGE_CLUSTER]
+                      INFRA_STORAGE_CLUSTER,
+                      CAAS_OAM]
 
     DNS = 'dns'
     MTU = 'mtu'
@@ -319,6 +321,7 @@ class NetworkingValidation(cmvalidator.CMValidator):
         self.validate_infra_internal()
         self.validate_infra_external()
         self.validate_infra_storage_cluster()
+        self.validate_caas_oam()
         self.validate_no_duplicate_infra_vlans()
 
     def validate_infra_internal(self):
@@ -337,6 +340,15 @@ class NetworkingValidation(cmvalidator.CMValidator):
             self.validate_infra_network(self.INFRA_STORAGE_CLUSTER)
             self.validate_no_gateway(self.INFRA_STORAGE_CLUSTER)
 
+    def validate_caas_oam(self):
+        if self.network_exists(self.CAAS_OAM):
+            self.validate_infra_network(self.CAAS_OAM)
+            if self.gateway_exists(self.CAAS_OAM):
+                self.validate_gateway(self.CAAS_OAM)
+
+    def gateway_exists(self, network):
+        return self.exists_as_dict(self.conf[self.DOMAIN], network, 'gateway')
+
     def validate_infra_network(self, network, vlan_must_exist=False):
         self.validate_mtu(self.net_conf, network)
         self.validate_cidr(network)