3 Sends remctl commands about a running VM to the host it's running on.
6 from subprocess import PIPE, Popen, call
12 print >>sys.stderr, "usage: invirt-remote-control <machine> <command>"
14 machine_name = argv[1]
17 p = Popen(['/usr/sbin/invirt-remote-proxy-web', 'listvms'], stdout=PIPE)
18 output = p.communicate()[0]
20 raise RuntimeError("Command '%s' returned non-zero exit status %d"
21 % ('invirt-remote-proxy-web', p.returncode))
22 vms = yaml.load(output, yaml.CSafeLoader)
24 if machine_name not in vms:
25 print >>sys.stderr, "machine '%s' is not on" % machine_name
27 host = vms[machine_name]['host']
29 p = Popen(['remctl', host, 'remote', 'control'] + argv[1:],
30 stdout=PIPE, stderr=PIPE)
31 (out, err) = p.communicate()
33 print >>sys.stderr, "machine '%s' is not on" % machine_name
35 elif p.returncode == 34:
36 print >>sys.stderr, "ERROR: invalid command"
42 if __name__ == '__main__':
43 sys.exit(main(sys.argv))