From: Cedric Ollivier Date: Thu, 22 Feb 2018 07:48:49 +0000 (+0000) Subject: Merge "Unify security group operations" X-Git-Tag: 0.2~24 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=01b28068c727b54c34d5b20e3baad4c4e31d7761;hp=d7256df47ecbfb1cb0771a65f003a397a464d390;p=functest-xtesting.git Merge "Unify security group operations" --- 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 ad8f7613..eb1c4050 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py @@ -121,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") @@ -271,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) @@ -486,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)