forked from weka/wekatester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkers.py
65 lines (44 loc) · 1.63 KB
/
workers.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#import os
from logging import getLogger
#from wekapyutils.wekassh import parallel, RemoteServer
#import getpass
#import paramiko
#from paramiko import SSHClient, AutoAddPolicy, SSHConfig
#from scp import SCPClient
#from wekalib.sthreads import threaded, default_threader
log = getLogger(__name__)
def start_fio_servers(servers, fio_bin='/tmp/fio'):
for server in servers:
server.run_unending(fio_bin + " --server")
#def pdsh(servers, command):
# parallel(servers, RemoteServer.run, command)
#def pscp(servers, source, dest):
# log.debug(f"setting up parallel copy to {servers}")
# parallel(servers, RemoteServer.scp, source, dest)
def get_workers(wekacluster, workertype):
if workertype not in ["backend","client"]:
raise Exception("invalid workertype - must be 'backend' or 'client'")
workerlist = list()
try:
api_return = wekacluster.call_api(method="hosts_list", parms={})
except:
raise
for host in api_return.values():
hostname = host["hostname"]
if host["mode"] == workertype:
if host["state"] == "ACTIVE" and host["status"] == "UP":
if hostname not in workerlist:
workerlist.append(hostname)
return workerlist
def get_clients(wekacluster):
clientlist = list()
try:
api_return = wekacluster.call_api(method="hosts_list", parms={})
except:
raise
for host in api_return:
hostname = host["hostname"]
if host["mode"] == "client":
if host["state"] == "ACTIVE" and host["status"] == "UP":
clientlist.append(hostname)
return clientlist