-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabric_test.py
38 lines (31 loc) · 1.33 KB
/
fabric_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from click import echo
from fabric import *
import time
import logging
start = time.time()
hosts = ('192.168.254.250', '192.168.255.2')
#hosts = ('192.168.248.74', '192.168.249.134', '192.168.254.108') #'192.168.255.68',
mygroup = ThreadingGroup(*hosts, user='admin', port=22, connect_kwargs={'password':'admin','look_for_keys':False}) #1s
#mygroup = SerialGroup(*hosts, user='admin', port=22, connect_kwargs={'password':'admin','look_for_keys':False}) #2.5s
logging.basicConfig(level=logging.DEBUG, format='%(levelname)s:%(thread)d:%(asctime)s:%(message)s',filename='ssh_test/fabric.log', filemode='w')
results = mygroup.run("version")
print(results)
end = time.time()
print("The time of execution of above program is :", end-start)
# for k,v in results.items():
# print (k,v)
# def test_connection():
# try:
# logging.basicConfig(level=logging.DEBUG, format='%(levelname)s:%(threadName)s:%(asctime)s:%(message)s',filename='ssh_test/fabric.log', filemode='w')
# result = group.run("version", echo=True)
# if result.failed:
# print ("This failed", result)
# else:
# print ("This succeded", result)
# except Exception as e:
# print(e)
# if __name__ == "__main__":
# start = time.time()
# test_connection()
# end = time.time()
# print("The time of execution of above program is :", end-start)