large commit. new code, with sensors, line count dropped, etc
diff --git a/ssh_utils.py b/ssh_utils.py
index 7c859cf..e546b72 100644
--- a/ssh_utils.py
+++ b/ssh_utils.py
@@ -1,19 +1,14 @@
import re
import time
-import Queue
import logging
import os.path
import getpass
-import threading
import socket
import paramiko
-from concurrent.futures import ThreadPoolExecutor
-from utils import get_barrier
logger = logging.getLogger("io-perf-tool")
-conn_uri_attrs = ("user", "passwd", "host", "port", "path")
def ssh_connect(creds, retry_count=60, timeout=1):
@@ -67,7 +62,10 @@
return dirpath
-def ssh_mkdir(sftp, remotepath, mode=0777, intermediate=False):
+ALL_RWX_MODE = ((1 << 9) - 1)
+
+
+def ssh_mkdir(sftp, remotepath, mode=ALL_RWX_MODE, intermediate=False):
remotepath = normalize_dirpath(remotepath)
if intermediate:
try:
@@ -83,7 +81,7 @@
def ssh_copy_file(sftp, localfile, remfile, preserve_perm=True):
sftp.put(localfile, remfile)
if preserve_perm:
- sftp.chmod(remfile, os.stat(localfile).st_mode & 0777)
+ sftp.chmod(remfile, os.stat(localfile).st_mode & ALL_RWX_MODE)
def put_dir_recursively(sftp, localpath, remotepath, preserve_perm=True):
@@ -121,9 +119,9 @@
sftp.chdir(remroot)
except IOError:
if preserve_perm:
- mode = os.stat(root).st_mode & 0777
+ mode = os.stat(root).st_mode & ALL_RWX_MODE
else:
- mode = 0777
+ mode = ALL_RWX_MODE
ssh_mkdir(sftp, remroot, mode=mode, intermediate=True)
sftp.chdir(remroot)
@@ -156,8 +154,10 @@
class ConnCreds(object):
+ conn_uri_attrs = ("user", "passwd", "host", "port", "path")
+
def __init__(self):
- for name in conn_uri_attrs:
+ for name in self.conn_uri_attrs:
setattr(self, name, None)
@@ -224,43 +224,42 @@
return ssh_connect(creds)
-def get_ssh_runner(uris,
- conn_func,
- latest_start_time=None,
- keep_temp_files=False):
- logger.debug("Connecting to servers")
+# def get_ssh_runner(uris,
+# conn_func,
+# latest_start_time=None,
+# keep_temp_files=False):
+# logger.debug("Connecting to servers")
- with ThreadPoolExecutor(max_workers=16) as executor:
- connections = list(executor.map(connect, uris))
+# with ThreadPoolExecutor(max_workers=16) as executor:
+# connections = list(executor.map(connect, uris))
- result_queue = Queue.Queue()
- barrier = get_barrier(len(uris), threaded=True)
+# result_queue = Queue.Queue()
+# barrier = get_barrier(len(uris), threaded=True)
- def closure(obj):
- ths = []
- obj.set_result_cb(result_queue.put)
+# def closure(obj):
+# ths = []
+# obj.set_result_cb(result_queue.put)
- params = (obj, barrier, latest_start_time)
+# params = (obj, barrier, latest_start_time)
- logger.debug("Start tests")
- for conn in connections:
- th = threading.Thread(None, conn_func, None,
- params + (conn,))
- th.daemon = True
- th.start()
- ths.append(th)
+# logger.debug("Start tests")
+# for conn in connections:
+# th = threading.Thread(None, conn_func, None,
+# params + (conn,))
+# th.daemon = True
+# th.start()
+# ths.append(th)
- for th in ths:
- th.join()
+# for th in ths:
+# th.join()
- test_result = []
- while not result_queue.empty():
- test_result.append(result_queue.get())
+# test_result = []
+# while not result_queue.empty():
+# test_result.append(result_queue.get())
- logger.debug("Done. Closing connection")
- for conn in connections:
- conn.close()
+# logger.debug("Done. Closing connection")
+# for conn in connections:
+# conn.close()
- return test_result
-
- return closure
+# return test_result
+# return closure