Last change
on this file since 677 was
623,
checked in by price, 16 years ago
|
note host in listvms
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Line | |
---|
1 | #!/usr/bin/python |
---|
2 | |
---|
3 | """ |
---|
4 | Collates the results of listvms from multiple VM servers. Part of the xvm |
---|
5 | suite. |
---|
6 | """ |
---|
7 | |
---|
8 | from subprocess import PIPE, Popen |
---|
9 | import sys |
---|
10 | import yaml |
---|
11 | |
---|
12 | def main(argv): |
---|
13 | # Query each of the server for their VMs. |
---|
14 | # TODO get `servers` from a real list of all the VM hosts (instead of |
---|
15 | # hardcoding the list here) |
---|
16 | servers = ['black-mesa.mit.edu', 'sx-blade-2.mit.edu'] |
---|
17 | # XXX |
---|
18 | pipes = [(server, |
---|
19 | Popen(['remctl', server, 'remote', 'web', 'listvms'], stdout=PIPE)) |
---|
20 | for server in servers] |
---|
21 | outputs = [(s, p.communicate()[0]) for (s, p) in pipes] |
---|
22 | for (s, p) in pipes: |
---|
23 | if p.returncode != 0: |
---|
24 | raise RuntimeError("remctl to host %s returned non-zero exit status %d" |
---|
25 | % (s, p.returncode)) |
---|
26 | results = [(s, yaml.load(o, yaml.CSafeLoader)) for (s, o) in outputs] |
---|
27 | results = filter(lambda (_, x): x is not None, results) |
---|
28 | |
---|
29 | # Merge the results and print. |
---|
30 | merged = {} |
---|
31 | for server, result in results: |
---|
32 | for data in result.itervalues(): |
---|
33 | data['host'] = server |
---|
34 | merged.update(result) |
---|
35 | |
---|
36 | print yaml.dump(merged, Dumper=yaml.CSafeDumper, default_flow_style=False) |
---|
37 | |
---|
38 | if __name__ == '__main__': |
---|
39 | main(sys.argv) |
---|
40 | |
---|
41 | # vim:et:sw=4:ts=4 |
---|
Note: See
TracBrowser
for help on using the repository browser.