The attached patch adds the following options to the xenguest-install.py script: -U, --genuuid Generate a random UUID and exit -M, --genmac Generate a random MAC address and exit -C CONFOUT, --genconf=CONFOUT Generate a template guest config file Is this something that people think might be useful? If so I'll raise an RFE in bugzilla. Take care, Gawain
--- xenguest-install.py.orig 2006-06-14 01:21:31.000000000 +1000 +++ xenguest-install.py 2006-06-14 01:27:50.000000000 +1000 @@ -5,6 +5,7 @@ # Copyright 2005-2006 Red Hat, Inc. # Jeremy Katz <katzj@xxxxxxxxxx> # Option handling added by Andrew Puch <apuch@xxxxxxxxxx> +# Options for -U -M -C added by Gawain Lynch <gawain.lynch@xxxxxxxxx> # # This software may be freely redistributed under the terms of the GNU # general public license. @@ -374,7 +375,26 @@ else: print ("You can reconnect to the console of your guest by running\n" "'xm console %s'" %(name,)) - + +def write_templconf(cfg, mac, uuid): + cfgdict = {'mac': mac, 'uuid': uuid} + + f = open(cfg, "w+") + buf = """# Automatically generated xen config file +name = "" +memory = "" +disk = [ ',xvda,w' ] +vif = [ 'mac=%(mac)s' ] +uuid = "%(uuid)s" +bootloader="/usr/bin/pygrub" + +on_reboot = 'restart' +on_crash = 'restart' +""" % cfgdict + + f.write(buf) + f.close() + def parse_args(): parser = OptionParser() @@ -407,7 +427,14 @@ dest="extra", default="", help="Additional arguments to pass to the installer with paravirt guests") - + # MAC and UUID generation options + parser.add_option("-U", "--genuuid", action="store_true", dest="genuuid", + help="Generate a random UUID and exit") + parser.add_option("-M", "--genmac", action="store_true", dest="genmac", + help="Generate a random MAC address and exit") + parser.add_option("-C", "--genconf", action="store", dest="confout", + help="Generate a template guest config file") + (options,args) = parser.parse_args() return options @@ -436,6 +463,17 @@ def main(): options = parse_args() + if options.genuuid: + print "%s" % get_uuid(options) + sys.exit() + elif options.genmac: + print "%s" % randomMAC() + sys.exit() + elif options.confout: + print "Writing template config file to %s" % options.confout + write_templconf(options.confout, randomMAC(), get_uuid(options)) + sys.exit() + hvm = False name = get_name(options) ram = get_ram(options)
-- Fedora-xen@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-xen