From 19199daa61a83f6bc5e6f8fc3965f13f09f2d7ed Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Thu, 7 Nov 2019 12:44:46 +0100 Subject: Get the BRG MAC address automatically 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 Issue-ID: INT-1365 --- test/vcpe/vcpe_custom_service.py | 5 +---- test/vcpe/vcpecommon.py | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/vcpe/vcpe_custom_service.py b/test/vcpe/vcpe_custom_service.py index e2681fd11..b3a26d174 100755 --- a/test/vcpe/vcpe_custom_service.py +++ b/test/vcpe/vcpe_custom_service.py @@ -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) diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py index 7a54d1b1e..545524e6f 100755 --- a/test/vcpe/vcpecommon.py +++ b/test/vcpe/vcpecommon.py @@ -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): -- cgit 1.2.3-korg