X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-remote.git/blobdiff_plain/d7f33e5a8eba8e45cb5ad588a644a5482e82f7d4..227cb65ae3d4b0fd6636700595df6f00b18d4f37:/files/usr/sbin/sipb-xen-remote-control diff --git a/files/usr/sbin/sipb-xen-remote-control b/files/usr/sbin/sipb-xen-remote-control deleted file mode 100755 index 6d30d71..0000000 --- a/files/usr/sbin/sipb-xen-remote-control +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python -""" -Sends remctl commands about a running VM to the host it's running on. -""" - -from subprocess import PIPE, Popen, call -import sys -import yaml - -def main(argv): - if len(argv) < 3: - print >>sys.stderr, "usage: sipb-xen-remote-control " - return 2 - machine_name = argv[1] - command = argv[2] - - p = Popen(['/usr/sbin/sipb-xen-remote-proxy-web', 'listvms'], stdout=PIPE) - output = p.communicate()[0] - if p.returncode != 0: - raise RuntimeError("Command '%s' returned non-zero exit status %d" - % ('sipb-xen-remote-proxy-web', p.returncode)) - vms = yaml.load(output, yaml.CSafeLoader) - - if machine_name not in vms: - print >>sys.stderr, "machine '%s' is not on" % machine_name - return 1 - host = vms[machine_name]['host'] - - p = Popen(['remctl', host, 'remote', 'control'] + argv[1:], - stdout=PIPE, stderr=PIPE) - (out, err) = p.communicate() - if p.returncode == 1: - print >>sys.stderr, "machine '%s' is not on" % machine_name - return 1 - elif p.returncode == 34: - print >>sys.stderr, "ERROR: invalid command" - return 34 - sys.stderr.write(err) - sys.stdout.write(out) - return p.returncode - -if __name__ == '__main__': - sys.exit(main(sys.argv)) - -# vim:et:sw=4:ts=4