aboutsummaryrefslogtreecommitdiffstats
path: root/test/vcpe
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-01-29 14:06:41 +0100
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-01-29 14:06:41 +0100
commit8eb99ceaae49e635eb518ca985f8ee5cbe6449c6 (patch)
treea7d09995b062cb3976ac885efbedd65eee7efcc8 /test/vcpe
parent62b5908c21e1fdb4335d01fc43936a6986857395 (diff)
Support reading cloud settings from clouds.yaml
clouds.yaml is a default cloud configuration file for openstacksdk library. Using it deduplicates cloud settings from vcpeconfig.yaml and makes CI setup easier. Change-Id: Iaf81bcaa3c27dae7c1619690da45e6b7feee7768 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com> Issue-ID: INT-1409
Diffstat (limited to 'test/vcpe')
-rwxr-xr-xtest/vcpe/vcpecommon.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py
index 8ae81016c..42edffd5b 100755
--- a/test/vcpe/vcpecommon.py
+++ b/test/vcpe/vcpecommon.py
@@ -14,6 +14,7 @@ import commands
import time
import yaml
from novaclient import client as openstackclient
+from openstack.config import loader
from kubernetes import client, config
from netaddr import IPAddress, IPNetwork
@@ -27,6 +28,8 @@ class VcpeCommon:
# Read configuration from config file
self._load_config(cfg_file)
+ # Load OpenStack settings
+ self._load_os_config()
self.sdnc_controller_pod = '-'.join([self.onap_environment, 'sdnc-sdnc-0'])
# OOM: this is the address that the brg and bng will nat for sdnc access - 10.0.0.x address of k8 host for sdnc-0 container
@@ -184,6 +187,34 @@ class VcpeCommon:
self.logger.error('Unable to parse config file: ' + str(e))
sys.exit(1)
+ def _load_os_config(self):
+ """
+ Reads cloud settings and sets them as object's 'cloud' attribute
+ """
+ # Create OpenStackConfig config instance
+ os_config = loader.OpenStackConfig()
+ # Try reading cloud settings for self.cloud_name
+ try:
+ os_cloud = os_config.cloud_config['clouds'][self.cloud_name]
+ except KeyError:
+ self.logger.error('Error fetching cloud settings for cloud "{0}"'
+ .format(self.cloud_name))
+ sys.exit(1)
+ self.logger.debug('Cloud config:\n {0}'.format(json.dumps(
+ os_cloud,indent=4)))
+
+ # Extract all OS settings keys and alter their names
+ # to conform to openstack cli client
+ self.cloud = {}
+ for k in os_cloud:
+ if isinstance(os_cloud[k],dict):
+ for sub_k in os_cloud[k]:
+ os_setting_name = '--os-' + sub_k.replace('_','-')
+ self.cloud[os_setting_name] = os_cloud[k][sub_k]
+ else:
+ os_setting_name = '--os-' + k.replace('_','-')
+ self.cloud[os_setting_name] = os_cloud[k]
+
def heatbridge(self, openstack_stack_name, svc_instance_uuid):
"""
Add vserver information to AAI