3 Say what host a running VM is on.
6 from subprocess import PIPE, Popen, call
12 print >>sys.stderr, "usage: invirt-remote-listhost <machine>"
14 machine_name = argv[1]
16 p = Popen(['/usr/sbin/invirt-remote-proxy-web', 'listvms'], stdout=PIPE)
17 output = p.communicate()[0]
19 raise RuntimeError("Command '%s' returned non-zero exit status %d"
20 % ('invirt-remote-proxy-web', p.returncode))
21 vms = yaml.load(output, yaml.CSafeLoader)
23 if machine_name not in vms:
24 print >>sys.stderr, "machine '%s' is not on" % machine_name
27 print vms[machine_name]['host']
30 if __name__ == '__main__':
31 sys.exit(main(sys.argv))