summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py4
-rw-r--r--functest/opnfv_tests/vnf/epc/juju_epc.py82
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py3
-rw-r--r--functest/opnfv_tests/vnf/router/cloudify_vrouter.py3
4 files changed, 75 insertions, 17 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index d62f3daa0..88ad3b2d9 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -207,8 +207,8 @@ def configure_tempest_update_params(
# enable multinode tests
rconfig.set('compute', 'min_compute_nodes', compute_cnt)
rconfig.set('compute-feature-enabled', 'live_migration', True)
-
- rconfig.set('identity', 'region', os.environ.get('OS_REGION_NAME'))
+ if os.environ.get('OS_REGION_NAME'):
+ rconfig.set('identity', 'region', os.environ.get('OS_REGION_NAME'))
identity_api_version = os.environ.get("OS_IDENTITY_API_VERSION", '3')
if identity_api_version == '3':
auth_version = 'v3'
diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py
index 75d3157b7..3f2a9ff93 100644
--- a/functest/opnfv_tests/vnf/epc/juju_epc.py
+++ b/functest/opnfv_tests/vnf/epc/juju_epc.py
@@ -37,6 +37,7 @@ from snaps.openstack.create_security_group import OpenStackSecurityGroup
from snaps.openstack.create_user import OpenStackUser
from snaps.openstack.utils import keystone_utils
from snaps.openstack.utils import nova_utils
+from snaps.openstack.utils import neutron_utils
from functest.core import vnf
from functest.opnfv_tests.openstack.snaps import snaps_utils
@@ -148,7 +149,8 @@ class JujuEpc(vnf.VnfOnBoarding):
clouds_yaml = os.path.join(self.res_dir, "clouds.yaml")
cloud_data = {
'url': self.public_auth_url,
- 'region': self.snaps_creds.region_name}
+ 'region': self.snaps_creds.region_name if (
+ self.snaps_creds.region_name) else 'RegionOne'}
with open(clouds_yaml, 'w') as yfile:
yfile.write(CLOUD_TEMPLATE.format(**cloud_data))
cmd = ['juju', 'add-cloud', 'abot-epc', '-f', clouds_yaml, '--replace']
@@ -195,18 +197,25 @@ class JujuEpc(vnf.VnfOnBoarding):
def _add_custom_rule(self, sec_grp_name):
""" To add custom rule for SCTP Traffic """
- sec_grp_rules = list()
- sec_grp_rules.append(
- SecurityGroupRuleConfig(
- sec_grp_name=sec_grp_name, direction=Direction.ingress,
- protocol=Protocol.sctp))
+
security_group = OpenStackSecurityGroup(
self.snaps_creds,
SecurityGroupConfig(
- name=sec_grp_name,
- rule_settings=sec_grp_rules))
+ name=sec_grp_name))
+
security_group.create()
- self.created_object.append(security_group)
+
+ # Add custom security rule to the obtained Security Group
+ self.__logger.info("Adding SCTP ingress rule to SG:%s",
+ security_group.sec_grp_settings.name)
+
+ try:
+ security_group.add_rule(SecurityGroupRuleConfig(
+ sec_grp_name=sec_grp_name, direction=Direction.ingress,
+ protocol=Protocol.sctp))
+ except Exception: # pylint: disable=broad-except
+ self.__logger.exception(
+ "Some issue encountered with adding SCTP security rule ...")
def prepare(self):
"""Prepare testcase (Additional pre-configuration steps)."""
@@ -295,8 +304,9 @@ class JujuEpc(vnf.VnfOnBoarding):
image_file=image_file))
image_id = image_creator.create().id
cmd = ['juju', 'metadata', 'generate-image', '-d', '/root',
- '-i', image_id, '-s', image_name,
- '-r', self.snaps_creds.region_name,
+ '-i', image_id, '-s', image_name, '-r',
+ self.snaps_creds.region_name if (
+ self.snaps_creds.region_name) else 'RegionOne',
'-u', self.public_auth_url]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
self.__logger.info("%s\n%s", " ".join(cmd), output)
@@ -353,6 +363,7 @@ class JujuEpc(vnf.VnfOnBoarding):
flavor_creator = OpenStackFlavor(self.snaps_creds, flavor_settings)
flavor_creator.create()
self.created_object.append(flavor_creator)
+
self.__logger.info("Deploying Abot-epc bundle file ...")
cmd = ['juju', 'deploy', '{}'.format(descriptor.get('file_name'))]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
@@ -448,8 +459,46 @@ class JujuEpc(vnf.VnfOnBoarding):
short_result['failures'], short_result['skipped'])
return True
+ def _get_floating_ips(self):
+ """Get the list of floating IPs associated with the current project"""
+
+ project_id = self.os_project.get_project().id
+
+ neutron_client = neutron_utils.neutron_client(self.snaps_creds)
+ floating_ips = neutron_utils.get_floating_ips(neutron_client)
+
+ project_floating_ip_list = list()
+ for floating_ip in floating_ips:
+ if project_id and project_id == floating_ip.project_id:
+ project_floating_ip_list.append(floating_ip)
+
+ return project_floating_ip_list
+
+ def _release_floating_ips(self, fip_list):
+ """
+ Responsible for deleting a list of floating IPs
+ :param fip_list: A list of SNAPS FloatingIp objects
+ :return:
+ """
+ if not fip_list:
+ return
+
+ neutron_client = neutron_utils.neutron_client(self.snaps_creds)
+
+ for floating_ip in fip_list:
+ neutron_utils.delete_floating_ip(neutron_client, floating_ip)
+
def clean(self):
"""Clean created objects/functions."""
+
+ # Store Floating IPs of instances created by Juju
+ fip_list = self._get_floating_ips()
+ self.__logger.info("Floating IPs assigned to project:%s",
+ self.os_project.get_project().name)
+ for floating_ip in fip_list:
+ self.__logger.debug("%s:%s", floating_ip.ip,
+ floating_ip.description)
+
try:
cmd = ['juju', 'debug-log', '--replay', '--no-tail']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
@@ -469,7 +518,14 @@ class JujuEpc(vnf.VnfOnBoarding):
self.__logger.exception("General issue during the undeployment ..")
if not self.orchestrator['requirements']['preserve_setup']:
- self.__logger.info('Remove the Abot_epc OS object ..')
+ try:
+ self.__logger.info('Release floating IPs assigned by Juju...')
+ self._release_floating_ips(fip_list)
+ except Exception: # pylint: disable=broad-except
+ self.__logger.exception(
+ "Exception while releasing floating IPs ...")
+
+ self.__logger.info('Remove the Abot_epc OS objects ..')
super(JujuEpc, self).clean()
return True
@@ -531,7 +587,7 @@ def process_abot_test_result(file_path):
for steps in flatten_steps:
steps['result'] = steps['step_status']
res.append(steps)
- except:
+ except Exception: # pylint: disable=broad-except
logging.error("Could not post data to ElasticSearch host")
raise
return res
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index 4ac79b55d..786c535ed 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -250,7 +250,8 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
keystone_password=snaps_creds.password,
keystone_tenant_name=snaps_creds.project_name,
keystone_url=public_auth_url,
- region=snaps_creds.region_name,
+ region=snaps_creds.region_name if snaps_creds.region_name else (
+ 'RegionOne'),
user_domain_name=snaps_creds.user_domain_name,
project_domain_name=snaps_creds.project_domain_name)
self.__logger.info("Set creds for cloudify manager %s", cfy_creds)
diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
index a88200339..e56f23cfc 100644
--- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
+++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
@@ -335,7 +335,8 @@ class CloudifyVrouter(vrouter_base.VrouterOnBoardingBase):
self.vnf['inputs'].update(dict(
keystone_project_domain_name=snaps_creds.project_domain_name))
self.vnf['inputs'].update(dict(
- region=snaps_creds.region_name))
+ region=snaps_creds.region_name if snaps_creds.region_name else (
+ 'RegionOne')))
self.vnf['inputs'].update(dict(
keystone_url=keystone_utils.get_endpoint(
snaps_creds, 'identity')))