|
Last change
on this file since 2187 was
1822,
checked in by broder, 17 years ago
|
|
Merge invirt-remote-host and invirt-remote-server into invirt-remote
|
-
Property svn:executable set to
*
|
|
File size:
853 bytes
|
| Rev | Line | |
|---|
| [661] | 1 | #!/usr/bin/python |
|---|
| 2 | """ |
|---|
| 3 | Say what host a running VM is on. |
|---|
| 4 | """ |
|---|
| 5 | |
|---|
| 6 | from subprocess import PIPE, Popen, call |
|---|
| 7 | import sys |
|---|
| 8 | import yaml |
|---|
| 9 | |
|---|
| 10 | def main(argv): |
|---|
| 11 | if len(argv) < 2: |
|---|
| [1176] | 12 | print >>sys.stderr, "usage: invirt-remote-listhost <machine>" |
|---|
| [661] | 13 | return 2 |
|---|
| 14 | machine_name = argv[1] |
|---|
| 15 | |
|---|
| [1176] | 16 | p = Popen(['/usr/sbin/invirt-remote-proxy-web', 'listvms'], stdout=PIPE) |
|---|
| [661] | 17 | output = p.communicate()[0] |
|---|
| 18 | if p.returncode != 0: |
|---|
| 19 | raise RuntimeError("Command '%s' returned non-zero exit status %d" |
|---|
| [1176] | 20 | % ('invirt-remote-proxy-web', p.returncode)) |
|---|
| [661] | 21 | vms = yaml.load(output, yaml.CSafeLoader) |
|---|
| 22 | |
|---|
| 23 | if machine_name not in vms: |
|---|
| 24 | print >>sys.stderr, "machine '%s' is not on" % machine_name |
|---|
| 25 | return 2 |
|---|
| 26 | |
|---|
| 27 | print vms[machine_name]['host'] |
|---|
| 28 | return 0 |
|---|
| 29 | |
|---|
| 30 | if __name__ == '__main__': |
|---|
| 31 | sys.exit(main(sys.argv)) |
|---|
| 32 | |
|---|
| 33 | # vim:et:sw=4:ts=4 |
|---|
Note: See
TracBrowser
for help on using the repository browser.