Enable console logging for Ironic baremetal VMs
Logs console output of VMs created for use by Ironic to
$DATA_DIR/ironic/logs. This gives Jenkins something to archive
that will be useful for debugging any deployment ramdisk issue
blocking provisioning.
Change-Id: I7d234a6a13dbe8579f685e46d7712dae497272a5
diff --git a/tools/ironic/scripts/configure-vm b/tools/ironic/scripts/configure-vm
index 9936b76..4c42c49 100755
--- a/tools/ironic/scripts/configure-vm
+++ b/tools/ironic/scripts/configure-vm
@@ -9,6 +9,25 @@
'templates')
+CONSOLE_LOG = """
+ <serial type='file'>
+ <source path='%(console_log)s'/>
+ <target port='0'/>
+ <alias name='serial0'/>
+ </serial>
+ <serial type='pty'>
+ <source path='/dev/pts/49'/>
+ <target port='1'/>
+ <alias name='serial1'/>
+ </serial>
+ <console type='file'>
+ <source path='%(console_log)s'/>
+ <target type='serial' port='0'/>
+ <alias name='serial0'/>
+ </console>
+"""
+
+
def main():
parser = argparse.ArgumentParser(
description="Configure a kvm virtual machine for the seed image.")
@@ -30,6 +49,8 @@
help='The libvirt network name to use')
parser.add_argument('--libvirt-nic-driver', default='e1000',
help='The libvirt network driver to use')
+ parser.add_argument('--console-log',
+ help='File to log console')
parser.add_argument('--emulator', default=None,
help='Path to emulator bin for vm template')
args = parser.parse_args()
@@ -44,6 +65,7 @@
'cpus': args.cpus,
'bootdev': args.bootdev,
'network': args.network,
+ 'nicdriver': args.libvirt_nic_driver,
'emulator': args.emulator,
}
@@ -55,22 +77,13 @@
elif os.path.exists("/usr/bin/qemu-kvm"): # Redhat
params['emulator'] = "/usr/bin/qemu-kvm"
- nicparams = {
- 'nicdriver': args.libvirt_nic_driver,
- 'network': args.network,
- }
-
- params['bm_network'] = """
-<!-- neutron friendly 'bare metal' network -->
-<interface type='network'>
- <source network='%(network)s'/>
- <virtualport type='openvswitch'/>
- <model type='%(nicdriver)s'/>
- <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
-</interface>""" % nicparams
-
+ if args.console_log:
+ params['console_log'] = CONSOLE_LOG % {'console_log': args.console_log}
+ else:
+ params['console_log'] = ''
libvirt_template = source_template % params
conn = libvirt.open("qemu:///system")
+
a = conn.defineXML(libvirt_template)
print ("Created machine %s with UUID %s" % (args.name, a.UUIDString()))