aboutsummaryrefslogtreecommitdiffstats
path: root/test/vcpe/vcpecommon.py
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2019-10-16 15:28:23 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2019-10-16 15:28:23 +0200
commit9018a8458ca5cd3a39c9f2b6fb7eab8bc9284ac9 (patch)
treedc75b6c79d884d68093bc64fb7e48212753798ba /test/vcpe/vcpecommon.py
parentf2d8bca52e0ff36f3b114bc557e9b88c8aad6098 (diff)
Automate SDNC ip pool insertion into database
This patch automates SDNC ip pool generation in sdnctl database in the scope of vcpe.py 'init' stage. Change-Id: I6322ff2dadb069991be0eddbb0cf415baa7984f6 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com> Issue-ID: TEST-222
Diffstat (limited to 'test/vcpe/vcpecommon.py')
-rwxr-xr-xtest/vcpe/vcpecommon.py36
1 files changed, 36 insertions, 0 deletions
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'):