Get the BRG MAC address automatically 36/98136/5
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Thu, 7 Nov 2019 11:44:46 +0000 (12:44 +0100)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Tue, 19 Nov 2019 13:59:46 +0000 (13:59 +0000)
Sdnc db port was also adjusted as there's no sdnc-db
service anymore (since OOM-1651)

Change-Id: I154463224777f6fd76f5380253aa9130224fe3e4
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Issue-ID: INT-1365

docs/docs_vCPE.rst
test/vcpe/vcpe_custom_service.py
test/vcpe/vcpecommon.py

index ee830b5..a64a660 100644 (file)
@@ -118,13 +118,13 @@ Here are the main steps to run the use case in Integration lab environment, wher
 
     vcpe.py infra
 
-11. From Rancher node run vcpe healthcheck command to check connectivity from sdnc to brg and gmux, and vpp configuration of brg and gmux. Write down BRG MAC address printed out at the last line
+11. From Rancher node run vcpe healthcheck command to check connectivity from sdnc to brg and gmux, and vpp configuration of brg and gmux.
 
 ::
 
     healthcheck-k8s.py --namespace <namespace name> --environment <env name>
 
-12. Instantiate vCPE customer service. Input the BRG MAC when prompt
+12. Instantiate vCPE customer service.
 
 ::
 
index e2681fd..b3a26d1 100755 (executable)
@@ -68,10 +68,7 @@ class CustomService:
 
     def create_custom_service(self, csar_file, vgw_template_file, vgw_gra_template_file, preload_dict=None):
         name_suffix = datetime.now().strftime('%Y%m%d%H%M')
-        if self.vcpecommon.oom_mode:
-            brg_mac = str(raw_input("Enter the BRG MAC address: "))
-        else:
-            brg_mac = self.vcpecommon.get_brg_mac_from_sdnc()
+        brg_mac = self.vcpecommon.get_brg_mac_from_sdnc()
         brg_mac_enc = brg_mac.replace(':', '-')
         # get name index
         self.vgw_vfmod_name_index= self.vcpecommon.load_object(self.vcpecommon.vgw_vfmod_name_index_file)
index 7a54d1b..545524e 100755 (executable)
@@ -116,7 +116,7 @@ class VcpeCommon:
         self.aai_query_port = '30233' if self.oom_mode else '8443'
         self.sniro_port = '30288' if self.oom_mode else '8080'
 
-        self.host_names = ['sdc', 'so', 'sdnc', 'robot', 'aai-inst1', self.dcae_ves_collector_name]
+        self.host_names = ['sdc', 'so', 'sdnc', 'robot', 'aai-inst1', self.dcae_ves_collector_name, 'mariadb-galera']
         if extra_host_names:
             self.host_names.extend(extra_host_names)
         # get IP addresses
@@ -177,7 +177,7 @@ class VcpeCommon:
         self.sdnc_db_name = 'sdnctl'
         self.sdnc_db_user = 'sdnctl'
         self.sdnc_db_pass = 'gamma'
-        self.sdnc_db_port = '32774'
+        self.sdnc_db_port = self.get_k8s_service_endpoint_info('mariadb-galera','port') if self.oom_mode else '3306'
         self.sdnc_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
         self.sdnc_preload_network_url = 'https://' + self.hosts['sdnc'] + \
                                         ':' + self.sdnc_preloading_port + '/restconf/operations/VNF-API:preload-network-topology-operation'
@@ -244,8 +244,16 @@ class VcpeCommon:
         Check table DHCP_MAP in the SDNC DB. Find the newly instantiated BRG MAC address.
         Note that there might be multiple BRGs, the most recently instantiated BRG always has the largest IP address.
         """
-        cnx = mysql.connector.connect(user=self.sdnc_db_user, password=self.sdnc_db_pass, database=self.sdnc_db_name,
-                                      host=self.hosts['sdnc'], port=self.sdnc_db_port)
+        if self.oom_mode:
+            db_host=self.mariadb_galera_endpoint_ip
+        else:
+            db_host=self.hosts['mariadb-galera']
+
+        cnx = mysql.connector.connect(user=self.sdnc_db_user,
+                                      password=self.sdnc_db_pass,
+                                      database=self.sdnc_db_name,
+                                      host=db_host,
+                                      port=self.sdnc_db_port)
         cursor = cnx.cursor()
         query = "SELECT * from DHCP_MAP"
         cursor.execute(query)
@@ -254,7 +262,7 @@ class VcpeCommon:
         mac_recent = None
         host = -1
         for mac, ip in cursor:
-            self.logger.debug(mac + ':' + ip)
+            self.logger.debug(mac + ' - ' + ip)
             this_host = int(ip.split('.')[-1])
             if host < this_host:
                 host = this_host
@@ -262,7 +270,12 @@ class VcpeCommon:
 
         cnx.close()
 
-        assert mac_recent
+        try:
+            assert mac_recent
+        except AssertionError:
+            self.logger.error('Failed to obtain BRG MAC address from database')
+            sys.exit(1)
+
         return mac_recent
 
     def execute_cmds_mariadb(self, cmds):