From 2176cbdb63ce8467dcb5282f7f59a14e5d6154b3 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sat, 21 Jun 2008 20:49:47 -0400 Subject: [PATCH] remote: proxy control requests on running VMs to right host svn path=/trunk/packages/sipb-xen-remote-server/; revision=625 --- files/usr/sbin/sipb-xen-remote-control | 34 ++++++++++++++++++++++++++++++++ files/usr/sbin/sipb-xen-remote-proxy | 5 +++++ 2 files changed, 39 insertions(+) create mode 100755 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 new file mode 100755 index 0000000..1ad8721 --- /dev/null +++ b/files/usr/sbin/sipb-xen-remote-control @@ -0,0 +1,34 @@ +#!/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 2 + host = vms[machine_name]['host'] + + return call(['remctl', host, 'remote', 'control'] + argv[1:]) + +if __name__ == '__main__': + sys.exit(main(sys.argv)) + +# vim:et:sw=4:ts=4 diff --git a/files/usr/sbin/sipb-xen-remote-proxy b/files/usr/sbin/sipb-xen-remote-proxy index cb81f08..91dceda 100755 --- a/files/usr/sbin/sipb-xen-remote-proxy +++ b/files/usr/sbin/sipb-xen-remote-proxy @@ -13,6 +13,11 @@ esac case "$TYPE/$SERVICE" in web/listvms ) shift; sipb-xen-remote-listvms "$@" ;; + control/create ) + remctl black-mesa remote "$TYPE" "$@" ;; + control/* ) + # Everything but create must go where the VM is already running. + sipb-xen-remote-control "$@" ;; * ) remctl black-mesa remote "$TYPE" "$@" ;; esac -- 1.7.9.5