X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=doctor_tests%2Fcommon%2Futils.py;h=1a8840dd2e6f5a4f8c6ac900a8ad7b18624fa2e8;hb=a6575910a137f8932e294f66c9da3194ad937691;hp=0e2c8752623273630bf9d120e8499f3effff48ef;hpb=754b94bba6df6e7aafd5f1ffb8432a40cb815649;p=doctor.git diff --git a/doctor_tests/common/utils.py b/doctor_tests/common/utils.py index 0e2c8752..1a8840dd 100644 --- a/doctor_tests/common/utils.py +++ b/doctor_tests/common/utils.py @@ -57,8 +57,7 @@ class SSHClient(object): key_filename=None, log=None, look_for_keys=False, allow_agent=False): self.client = paramiko.SSHClient() - self.client.load_system_host_keys() - self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + self.client.set_missing_host_key_policy(paramiko.WarningPolicy()) self.client.connect(ip, username=username, password=password, pkey=pkey, key_filename=key_filename, look_for_keys=look_for_keys, @@ -68,7 +67,7 @@ class SSHClient(object): def __del__(self): self.client.close() - def ssh(self, command): + def ssh(self, command, raise_enabled=True): if self.log: self.log.info("Executing: %s" % command) stdin, stdout, stderr = self.client.exec_command(command) @@ -76,7 +75,7 @@ class SSHClient(object): output = list() for line in stdout.read().splitlines(): output.append(line.decode('utf-8')) - if ret: + if ret and raise_enabled: if self.log: self.log.info("*** FAILED to run command %s (%s)" % (command, ret))