-
Notifications
You must be signed in to change notification settings - Fork 2
/
measurements_downloader.py
executable file
·65 lines (52 loc) · 1.77 KB
/
measurements_downloader.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
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 02 08:59:22 2015
@author: Konstantin
"""
import configparser, csv
from fabric.api import env, execute, task, parallel, get
import cuisine
@task
@parallel
def collect_data():
"""
Fabric task to collect measurement data stored in VMs.
"""
get('/root/failures.csv',
'/root/failures.csv'+"."+env.host)
get('/root/response_time.csv',
'/root/response_time.csv'+"."+env.host)
@task
@parallel
def run_python_program(program=None, param='0', sudo=False):
cuisine.file_ensure('/usr/bin/python')
if sudo:
cuisine.sudo(('/usr/bin/python %s -n %s' % (program, param)))
else:
cuisine.run(('/usr/bin/python %s -n %s' % (program, param)))
def read_hosts_file(path):
with open(path, 'rb') as f:
reader = csv.reader(f, delimiter=';', quotechar='|')
host_ip_list = [row[0] for row in reader]
return host_ip_list
if __name__ == "__main__":
config = configparser.ConfigParser()
conf = open('config.ini', 'rb')
# conf.readline()
config.readfp(conf)
print(config.sections())
vm_credentials = dict(config['SSH_CREDENTIALS'])
ssh_username = str(vm_credentials['ssh.username'])
ssh_password = str(vm_credentials['ssh.password'])
ssh_key_filename = str(vm_credentials['ssh.key_filename'])
test_runs = dict(config['TEST_RUNS'])
test_start = str(test_runs['test_start'])
test_end = str(test_runs['test_end'])
vm_list = read_hosts_file('/etc/host_ips.csv')
print vm_list
env.hosts = vm_list
env.user = ssh_username
env.password = ssh_password
env.key_filename = ssh_key_filename
env.connection_attempts = 5
execute(collect_data)