diff options
-rw-r--r-- | functest/opnfv_tests/vnf/epc/juju_epc.py | 23 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/cloudify_ims.py | 29 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/router/cloudify_vrouter.py | 47 |
3 files changed, 57 insertions, 42 deletions
diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py index dc92bc92..68979186 100644 --- a/functest/opnfv_tests/vnf/epc/juju_epc.py +++ b/functest/opnfv_tests/vnf/epc/juju_epc.py @@ -79,8 +79,6 @@ 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" @@ -142,8 +140,7 @@ class JujuEpc(vnf.VnfOnBoarding): clouds_yaml = os.path.join(self.res_dir, "clouds.yaml") cloud_data = { 'url': self.public_auth_url, - 'region': os.environ.get( - "OS_REGION_NAME", self.default_region_name)} + 'region': self.snaps_creds.region_name} with open(clouds_yaml, 'w') as yfile: yfile.write(CLOUD_TEMPLATE.format(**cloud_data)) if os.system( @@ -189,17 +186,17 @@ class JujuEpc(vnf.VnfOnBoarding): def _add_custom_rule(self, sec_grp_name): """ To add custom rule for SCTP Traffic """ sec_grp_rules = list() - security_group_init = OpenStackSecurityGroup( + 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)) - security_group_init.initialize() - sctp_rule = SecurityGroupRuleConfig( - sec_grp_name=sec_grp_name, direction=Direction.ingress, - protocol=Protocol.sctp) - security_group_init.add_rule(sctp_rule) - self.created_object.append(security_group_init) + security_group.create() + self.created_object.append(security_group) def prepare(self): """Prepare testcase (Additional pre-configuration steps).""" @@ -278,9 +275,7 @@ class JujuEpc(vnf.VnfOnBoarding): 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), + image_id, image_name, self.snaps_creds.region_name, self.public_auth_url)) self.created_object.append(image_creator) self.__logger.info("Network ID : %s", net_id) diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index a6b87ea3..aa1256ab 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -278,12 +278,12 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): scp = SCPClient(ssh.get_transport(), socket_timeout=15.0) scp.put(kp_file, '~/') cmd = "sudo cp ~/cloudify_ims.pem /etc/cloudify/" - run_blocking_ssh_command(ssh, cmd) + self.run_blocking_ssh_command(ssh, cmd) cmd = "sudo chmod 444 /etc/cloudify/cloudify_ims.pem" - run_blocking_ssh_command(ssh, cmd) + self.run_blocking_ssh_command(ssh, cmd) cmd = "sudo yum install -y gcc python-devel" - run_blocking_ssh_command(ssh, cmd, "Unable to install packages \ - on manager") + self.run_blocking_ssh_command( + ssh, cmd, "Unable to install packages on manager") self.details['orchestrator'].update(status='PASS', duration=duration) @@ -397,7 +397,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): try: cfy_client.executions.cancel(execution['id'], force=True) - except: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except self.__logger.warn("Can't cancel the current exec") execution = cfy_client.executions.start( @@ -409,12 +409,22 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): wait_for_execution(cfy_client, execution, self.__logger) cfy_client.deployments.delete(self.vnf['descriptor'].get('name')) cfy_client.blueprints.delete(self.vnf['descriptor'].get('name')) - except: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except self.__logger.warn("Some issue during the undeployment ..") self.__logger.warn("Tenant clean continue ..") super(CloudifyIms, self).clean() + @staticmethod + def run_blocking_ssh_command(ssh, cmd, + error_msg="Unable to run this command"): + """Command to run ssh command with the exit status.""" + _, stdout, stderr = ssh.exec_command(cmd) + CloudifyIms.__logger.debug("SSH %s stdout: %s", cmd, stdout.read()) + if stdout.channel.recv_exit_status() != 0: + CloudifyIms.__logger.error("SSH %s stderr: %s", cmd, stderr.read()) + raise Exception(error_msg) + @energy.enable_recording def run(self, **kwargs): """Execute CloudifyIms test case.""" @@ -528,10 +538,3 @@ def sig_test_format(sig_test): short_sig_test_result['skipped'] = nb_skipped nb_test = nb_passed + nb_skipped return (short_sig_test_result, nb_test) - - -def run_blocking_ssh_command(ssh, cmd, error_msg="Unable to run this command"): - """Command to run ssh command with the exit status.""" - stdin, stdout, stderr = ssh.exec_command(cmd) - if stdout.channel.recv_exit_status() != 0: - raise Exception(error_msg) diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py index 829206d6..eb1c4050 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py @@ -14,6 +14,7 @@ import logging import os import time +import uuid from cloudify_rest_client import CloudifyClient from cloudify_rest_client.executions import Execution @@ -34,6 +35,7 @@ from snaps.config.network import NetworkConfig, PortConfig, SubnetConfig from snaps.config.router import RouterConfig from snaps.config.security_group import ( Direction, Protocol, SecurityGroupConfig, SecurityGroupRuleConfig) +from snaps.config.user import UserConfig from snaps.config.vm_inst import FloatingIpConfig, VmInstanceConfig from snaps.openstack.create_flavor import OpenStackFlavor @@ -43,6 +45,7 @@ from snaps.openstack.create_keypairs import OpenStackKeypair from snaps.openstack.create_network import OpenStackNetwork from snaps.openstack.create_security_group import OpenStackSecurityGroup from snaps.openstack.create_router import OpenStackRouter +from snaps.openstack.create_user import OpenStackUser import snaps.openstack.utils.glance_utils as glance_utils from snaps.openstack.utils import keystone_utils @@ -118,6 +121,17 @@ class CloudifyVrouter(vrouter_base.VrouterOnBoardingBase): "tenant_images", config_file) self.__logger.info("Images needed for vrouter: %s", self.images) + @staticmethod + def run_blocking_ssh_command(ssh, cmd, + error_msg="Unable to run this command"): + """Command to run ssh command with the exit status.""" + (_, stdout, stderr) = ssh.exec_command(cmd) + CloudifyVrouter.__logger.debug("SSH %s stdout: %s", cmd, stdout.read()) + if stdout.channel.recv_exit_status() != 0: + CloudifyVrouter.__logger.error( + "SSH %s stderr: %s", cmd, stderr.read()) + raise Exception(error_msg) + def prepare(self): super(CloudifyVrouter, self).prepare() self.__logger.info("Additional pre-configuration steps") @@ -268,11 +282,11 @@ class CloudifyVrouter(vrouter_base.VrouterOnBoardingBase): scp = SCPClient(ssh.get_transport(), socket_timeout=15.0) scp.put(kp_file, '~/') cmd = "sudo cp ~/cloudify_vrouter.pem /etc/cloudify/" - run_blocking_ssh_command(ssh, cmd) + self.run_blocking_ssh_command(ssh, cmd) cmd = "sudo chmod 444 /etc/cloudify/cloudify_vrouter.pem" - run_blocking_ssh_command(ssh, cmd) + self.run_blocking_ssh_command(ssh, cmd) cmd = "sudo yum install -y gcc python-devel" - run_blocking_ssh_command( + self.run_blocking_ssh_command( ssh, cmd, "Unable to install packages on manager") self.details['orchestrator'].update(status='PASS', duration=duration) @@ -313,21 +327,31 @@ class CloudifyVrouter(vrouter_base.VrouterOnBoardingBase): glance = glance_utils.glance_client(self.snaps_creds) image = glance_utils.get_image(glance, "vyos1.1.7") + user_creator = OpenStackUser( + self.snaps_creds, + UserConfig( + name='cloudify_network_bug-{}'.format(self.uuid), + password=str(uuid.uuid4()), + roles={'_member_': self.tenant_name})) + user_creator.create() + self.created_object.append(user_creator) + snaps_creds = user_creator.get_os_creds(self.snaps_creds.project_name) + self.vnf['inputs'].update(dict(target_vnf_image_id=image.id)) self.vnf['inputs'].update(dict(reference_vnf_image_id=image.id)) self.vnf['inputs'].update(dict(target_vnf_flavor_id=flavor.id)) self.vnf['inputs'].update(dict(reference_vnf_flavor_id=flavor.id)) self.vnf['inputs'].update(dict( - keystone_username=self.snaps_creds.username)) + keystone_username=snaps_creds.username)) self.vnf['inputs'].update(dict( - keystone_password=self.snaps_creds.password)) + keystone_password=snaps_creds.password)) self.vnf['inputs'].update(dict( - keystone_tenant_name=self.snaps_creds.project_name)) + keystone_tenant_name=snaps_creds.project_name)) self.vnf['inputs'].update(dict( - region=self.snaps_creds.region_name)) + region=snaps_creds.region_name)) self.vnf['inputs'].update(dict( keystone_url=keystone_utils.get_endpoint( - self.snaps_creds, 'identity'))) + snaps_creds, 'identity'))) self.__logger.info("Create VNF Instance") cfy_client.deployments.create( @@ -473,10 +497,3 @@ def get_execution_id(client, deployment_id): raise RuntimeError('Failed to get create_deployment_environment ' 'workflow execution.' 'Available executions: {0}'.format(executions)) - - -def run_blocking_ssh_command(ssh, cmd, error_msg="Unable to run this command"): - """Command to run ssh command with the exit status.""" - (_, stdout, _) = ssh.exec_command(cmd) - if stdout.channel.recv_exit_status() != 0: - raise Exception(error_msg) |