From 8e173b4be781e614b444326166a38e4bbdf70cc8 Mon Sep 17 00:00:00 2001 From: soumaya Date: Fri, 22 Dec 2017 11:43:42 +0530 Subject: Dynamic region name of juju cloud Region name in juju cloud has been made dynamic now, region name will be added in cloud file from os environment variable. It fixes the issues when runnit juju_epc vs Apex [1]. It also updates ubuntu images to xenial. [1] https://build.opnfv.org/ci/job/functest-apex-baremetal-daily-master/628/console Change-Id: I9422af3086141cd40b99e6482883a7081f58c2ea Signed-off-by: soumaya --- functest/opnfv_tests/vnf/epc/juju_epc.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py index be0f3ab2..3146b935 100644 --- a/functest/opnfv_tests/vnf/epc/juju_epc.py +++ b/functest/opnfv_tests/vnf/epc/juju_epc.py @@ -43,6 +43,8 @@ class JujuEpc(vnf.VnfOnBoarding): __logger = logging.getLogger(__name__) + default_region_name = "RegionOne" + def __init__(self, **kwargs): if "case_name" not in kwargs: kwargs["case_name"] = "juju_epc" @@ -133,7 +135,9 @@ class JujuEpc(vnf.VnfOnBoarding): 'url': self.public_auth_url, 'pass': self.tenant_name, 'tenant_n': self.tenant_name, - 'user_n': self.tenant_name + 'user_n': self.tenant_name, + 'region': os.environ.get( + "OS_REGION_NAME", self.default_region_name) } self.__logger.info("Cloud DATA: %s", cloud_data) self.filename = os.path.join(self.case_dir, 'abot-epc.yaml') @@ -143,8 +147,7 @@ class JujuEpc(vnf.VnfOnBoarding): if self.snaps_creds.identity_api_version == 3: append_config(self.filename, '{}'.format( os_utils.get_credentials()['project_domain_name']), - '{}'.format(os_utils.get_credentials() - ['user_domain_name'])) + '{}'.format(os_utils.get_credentials()['user_domain_name'])) self.__logger.info("Upload some OS images if it doesn't exist") for image_name, image_file in self.images.iteritems(): @@ -231,17 +234,19 @@ class JujuEpc(vnf.VnfOnBoarding): for image_name in self.images.keys(): self.__logger.info("Generating Metadata for %s", image_name) image_id = os_utils.get_image_id(self.glance_client, image_name) - os.system('juju metadata generate-image -d ~ -i {} -s {} -r ' - 'RegionOne -u {}'.format(image_id, - image_name, - self.public_auth_url)) + os.system( + 'juju metadata generate-image -d ~ -i {} -s {} -r ' + '{} -u {}'.format( + image_id, image_name, + os.environ.get("OS_REGION_NAME", self.default_region_name), + self.public_auth_url)) net_id = os_utils.get_network_id(self.neutron_client, private_net_name) self.__logger.info("Credential information : %s", net_id) juju_bootstrap_command = ('juju bootstrap abot-epc abot-controller ' '--config network={} --metadata-source ~ ' '--config ssl-hostname-verification=false ' '--constraints mem=2G --bootstrap-series ' - 'trusty ' + 'xenial ' '--config use-floating-ip=true --debug'. format(net_id)) os.system(juju_bootstrap_command) @@ -487,7 +492,7 @@ CLOUD_TEMPLATE = """clouds: auth-types: [userpass] endpoint: {url} regions: - RegionOne: + {region}: endpoint: {url} credentials: abot-epc: -- cgit 1.2.3-korg