diff options
Diffstat (limited to 'test/vcpe')
-rwxr-xr-x | test/vcpe/config_sdnc_so.py | 13 | ||||
-rwxr-xr-x | test/vcpe/vcpe.py | 1 | ||||
-rwxr-xr-x | test/vcpe/vcpecommon.py | 36 |
3 files changed, 50 insertions, 0 deletions
diff --git a/test/vcpe/config_sdnc_so.py b/test/vcpe/config_sdnc_so.py index 46d4c1c4c..13ac47bee 100755 --- a/test/vcpe/config_sdnc_so.py +++ b/test/vcpe/config_sdnc_so.py @@ -81,3 +81,16 @@ def insert_customer_service_to_so(vcpecommon): 'Please manually run the following sql command in SO catalogdb database to insert customer service recipe') logger.info('\n'.join(cmds)) #vcpecommon.execute_cmds_so_db(cmds) + +def insert_sdnc_ip_pool(vcpecommon): + logger = logging.getLogger(__name__) + logger.info('Inserting SDNC ip pool to SDNC DB') + cmds = [] + # Get the VGWs network address + vgw_net = '.'.join(vcpecommon.preload_network_config['mux_gw'][0].split('.')[:3]) + row_values = [] + # Prepare single INSERT statement with all IP values + for ip in range(22,250): + row_values.append("('', 'VGW', 'AVAILABLE','{0}.{1}')".format(vgw_net,ip)) + cmds.append("INSERT INTO IPV4_ADDRESS_POOL VALUES" + ', '.join(row_values) + ';') + vcpecommon.execute_cmds_mariadb(cmds) diff --git a/test/vcpe/vcpe.py b/test/vcpe/vcpe.py index 49fc0e488..9c533a065 100755 --- a/test/vcpe/vcpe.py +++ b/test/vcpe/vcpe.py @@ -182,6 +182,7 @@ def closed_loop(lossrate=0): def init_so_sdnc(): logger = logging.getLogger('__name__') vcpecommon = VcpeCommon() + config_sdnc_so.insert_sdnc_ip_pool(vcpecommon) config_sdnc_so.insert_customer_service_to_so(vcpecommon) #config_sdnc_so.insert_customer_service_to_sdnc(vcpecommon) vgw_vfmod_name_index= 0 diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py index 4b69fe429..4a393f53d 100755 --- a/test/vcpe/vcpecommon.py +++ b/test/vcpe/vcpecommon.py @@ -211,6 +211,11 @@ class VcpeCommon: self.policy_api_service_name = 'policy-api' self.policy_pap_service_name = 'policy-pap' + ############################################################################################# + # MARIADB-GALERA settings + self.mariadb_galera_endpoint_ip = self.get_k8s_service_endpoint_info('mariadb-galera','ip') + self.mariadb_galera_endpoint_port = self.get_k8s_service_endpoint_info('mariadb-galera','port') + def heatbridge(self, openstack_stack_name, svc_instance_uuid): """ Add vserver information to AAI @@ -253,6 +258,11 @@ class VcpeCommon: assert mac_recent return mac_recent + def execute_cmds_mariadb(self, cmds): + self.execute_cmds_db(cmds, self.sdnc_db_user, self.sdnc_db_pass, + self.sdnc_db_name, self.mariadb_galera_endpoint_ip, + self.mariadb_galera_endpoint_port) + def execute_cmds_sdnc_db(self, cmds): self.execute_cmds_db(cmds, self.sdnc_db_user, self.sdnc_db_pass, self.sdnc_db_name, self.hosts['sdnc'], self.sdnc_db_port) @@ -564,6 +574,32 @@ class VcpeCommon: return resp.spec.cluster_ip + def get_k8s_service_endpoint_info(self, service, subset): + """ + Returns endpoint data for a given service and subset. If there + is more than one endpoint returns data for the first one from + the list that API returned. + :param service: name of the service + :param subset: subset name, one of "ip","port" + :return: endpoint ip + """ + config.load_kube_config() + api = client.CoreV1Api() + kslogger = logging.getLogger('kubernetes') + kslogger.setLevel(logging.INFO) + try: + resp = api.read_namespaced_endpoints(service, self.onap_namespace) + except client.rest.ApiException as e: + self.logger.error('Error while making k8s API request: ' + e.body) + sys.exit() + + if subset == "ip": + return resp.subsets[0].addresses[0].ip + elif subset == "port": + return resp.subsets[0].ports[0].port + else: + self.logger.error("Unsupported subset type") + def extract_vm_ip_as_dict(self, novalist_results, net_addr, net_addr_len): vm_ip_dict = {} for line in novalist_results.split('\n'): |