DevStack support
[doctor.git] / doctor_tests / common / utils.py
index 1a8840d..67ca4f4 100644 (file)
@@ -10,6 +10,7 @@ import json
 import os
 import paramiko
 import re
+import subprocess
 
 
 def load_json_file(full_path):
@@ -97,6 +98,27 @@ class SSHClient(object):
         ftp.close()
 
 
+class LocalSSH(object):
+
+    def __init__(self, log):
+        self.log = log
+        self.log.info('Init local ssh client')
+
+    def ssh(self, cmd):
+        ret = 0
+        output = "%s failed!!!" % cmd
+        try:
+            output = subprocess.check_output((cmd), shell=True,
+                                             universal_newlines=True)
+        except subprocess.CalledProcessError:
+            ret = 1
+        return ret, output
+
+    def scp(self, src_file, dst_file):
+        return subprocess.check_output("cp %s %s" % (src_file, dst_file),
+                                       shell=True)
+
+
 def run_async(func):
     from threading import Thread
     from functools import wraps