From c7a4b1ed77b6091d7a9bf27c59e098bdff84474e Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 9 Oct 2008 02:12:32 -0400 Subject: [PATCH] Expose an interface to the autoinstaller over remctl and validate options svn path=/trunk/packages/sipb-xen-remote-server/; revision=1088 --- debian/changelog | 8 ++++++++ files/usr/sbin/sipb-xen-remctl-help | 2 +- files/usr/sbin/sipb-xen-remote-create | 21 ++++++++++++++++----- files/usr/sbin/sipb-xen-remote-proxy | 4 ++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index dfab6d7..ee59165 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +sipb-xen-remote-server (0.9.2) unstable; urgency=low + + * Expose an interface to the autoinstaller over remctl + * Validate options to be passed to the autoinstaller on the remctl + server + + -- Evan Broder Thu, 09 Oct 2008 02:06:00 -0400 + sipb-xen-remote-server (0.9.1) unstable; urgency=low * Fix a bug in the database handling code diff --git a/files/usr/sbin/sipb-xen-remctl-help b/files/usr/sbin/sipb-xen-remctl-help index 2646fbd..4f71e99 100755 --- a/files/usr/sbin/sipb-xen-remctl-help +++ b/files/usr/sbin/sipb-xen-remctl-help @@ -15,7 +15,7 @@ help = [ ('shutdown', 'shut down your VM, softly if paravm (with xm shutdown)'), ('create', 'start up your VM (with xm create)'), ('reboot', 'reboot your VM (with xm destroy and xm create)'), - #also install + ('install', 'autoinstall your VM (takes a series of key=value pairs; \n\t\tvalid arguments include mirror, dist, arch, imagesize,\n\t\tand noinstall)'), #also CD images on create/reboot ] helpdict = dict(help) diff --git a/files/usr/sbin/sipb-xen-remote-create b/files/usr/sbin/sipb-xen-remote-create index 32e875a..f957a59 100755 --- a/files/usr/sbin/sipb-xen-remote-create +++ b/files/usr/sbin/sipb-xen-remote-create @@ -20,11 +20,22 @@ def choose_host(): return max((int(o['free_memory']), s) for (s, o) in results)[1] def main(argv): - if len(argv) < 2: - print >> sys.stderr, "usage: sipb-xen-remote-create []" + if len(argv) < 3: + print >> sys.stderr, "usage: sipb-xen-remote-create []" return 2 - machine_name = argv[1] - args = argv[2:] + operation = argv[1] + machine_name = argv[2] + args = argv[3:] + + if operation == 'install': + options = dict(arg.split('=', 1) for arg in args) + valid_keys = set(('mirror', 'dist', 'arch', 'imagesize', 'noinstall')) + if not set(options.keys()).issubset(valid_keys): + print >> sys.stderr, "Invalid argument. Use the help command to see valid arguments to install" + return 1 + if any(' ' in val for val in options.values()): + print >> sys.stderr, "Arguments to the autoinstaller cannot contain spaces" + return 1 p = Popen(['/usr/sbin/sipb-xen-remote-proxy-web', 'listvms'], stdout=PIPE) output = p.communicate()[0] @@ -43,7 +54,7 @@ def main(argv): print 'Creating on host %s...' % host sys.stdout.flush() return call(['remctl', host, 'remote', 'control', - machine_name, 'create'] + args) + machine_name, operation] + args) if __name__ == '__main__': sys.exit(main(sys.argv)) diff --git a/files/usr/sbin/sipb-xen-remote-proxy b/files/usr/sbin/sipb-xen-remote-proxy index c94a764..9d7d0bd 100755 --- a/files/usr/sbin/sipb-xen-remote-proxy +++ b/files/usr/sbin/sipb-xen-remote-proxy @@ -14,8 +14,8 @@ esac case "$TYPE/$SERVICE" in web/listvms ) sipb-xen-remote-listvms "$@" ;; - control/create ) - sipb-xen-remote-create "$MACHINE" "$@" ;; + control/create|control/install ) + sipb-xen-remote-create "$SERVICE" "$MACHINE" "$@" ;; control/listhost ) sipb-xen-remote-listhost "$MACHINE" "$@" ;; control/* ) -- 1.7.9.5