aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2018-02-21 19:15:35 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-02-21 19:15:35 +0000
commit3becae261a56ead94c400db618d801e4337ce4a8 (patch)
tree8800f607ebd30efc06cfb21add509362cb410210 /functest/opnfv_tests/vnf/router/cloudify_vrouter.py
parent8ca868e6a71520d151a405f01e4a5a77973b4956 (diff)
parentaa7f553ed8648b6f79a68f1c7075c2c4960aa8a3 (diff)
Merge "Print stdout and stderr when calling commands over SSH"
Diffstat (limited to 'functest/opnfv_tests/vnf/router/cloudify_vrouter.py')
-rw-r--r--functest/opnfv_tests/vnf/router/cloudify_vrouter.py24
1 files changed, 14 insertions, 10 deletions
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)