Ignore:
Timestamp:
Oct 9, 2008, 2:12:32 AM (16 years ago)
Author:
broder
Message:

Expose an interface to the autoinstaller over remctl and validate options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-remote-server/files/usr/sbin/sipb-xen-remote-create

    r816 r1088  
    2121
    2222def main(argv):
    23     if len(argv) < 2:
    24         print >> sys.stderr, "usage: sipb-xen-remote-create <machine> [<other args...>]"
     23    if len(argv) < 3:
     24        print >> sys.stderr, "usage: sipb-xen-remote-create <operation> <machine> [<other args...>]"
    2525        return 2
    26     machine_name = argv[1]
    27     args = argv[2:]
     26    operation = argv[1]
     27    machine_name = argv[2]
     28    args = argv[3:]
     29   
     30    if operation == 'install':
     31        options = dict(arg.split('=', 1) for arg in args)
     32        valid_keys = set(('mirror', 'dist', 'arch', 'imagesize', 'noinstall'))
     33        if not set(options.keys()).issubset(valid_keys):
     34            print >> sys.stderr, "Invalid argument. Use the help command to see valid arguments to install"
     35            return 1
     36        if any(' ' in val for val in options.values()):
     37            print >> sys.stderr, "Arguments to the autoinstaller cannot contain spaces"
     38            return 1
    2839
    2940    p = Popen(['/usr/sbin/sipb-xen-remote-proxy-web', 'listvms'], stdout=PIPE)
     
    4455    sys.stdout.flush()
    4556    return call(['remctl', host, 'remote', 'control',
    46                  machine_name, 'create'] + args)
     57                 machine_name, operation] + args)
    4758
    4859if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.