Wrong yamllint disable command
[doctor.git] / doctor_tests / common / utils.py
index 2e823ac..1a8840d 100644 (file)
@@ -47,13 +47,17 @@ def match_rep_in_file(regex, full_path):
     return None
 
 
+def get_doctor_test_root_dir():
+    current_dir = os.path.split(os.path.realpath(__file__))[0]
+    return os.path.dirname(current_dir)
+
+
 class SSHClient(object):
     def __init__(self, ip, username, password=None, pkey=None,
                  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,
@@ -63,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)
@@ -71,9 +75,10 @@ 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))
+                self.log.info("*** FAILED to run command %s (%s)"
+                              % (command, ret))
             raise Exception(
                 "Unable to run \ncommand: %s\nret: %s"
                 % (command, ret))