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/lib/ironic b/lib/ironic
index 8d7687b..1aa85ea 100644
--- a/lib/ironic
+++ b/lib/ironic
@@ -65,6 +65,10 @@
IRONIC_VM_MACS_CSV_FILE=${IRONIC_VM_MACS_CSV_FILE:-$IRONIC_DATA_DIR/ironic_macs.csv}
IRONIC_AUTHORIZED_KEYS_FILE=${IRONIC_AUTHORIZED_KEYS_FILE:-$HOME/.ssh/authorized_keys}
+# By default, baremetal VMs will console output to file.
+IRONIC_VM_LOG_CONSOLE=${IRONIC_VM_LOG_CONSOLE:-True}
+IRONIC_VM_LOG_DIR=${IRONIC_VM_LOG_DIR:-$IRONIC_DATA_DIR/logs/}
+
DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
# Use DIB to create deploy ramdisk and kernel.
@@ -177,6 +181,9 @@
iniset $IRONIC_CONF_FILE pxe tftp_server $HOST_IP
iniset $IRONIC_CONF_FILE pxe tftp_root $IRONIC_TFTPBOOT_DIR
iniset $IRONIC_CONF_FILE pxe tftp_master_path $IRONIC_TFTPBOOT_DIR/master_images
+ if [[ "$IRONIC_VM_LOG_CONSOLE" == "True" ]] ; then
+ iniset $IRONIC_CONF_FILE pxe pxe_append_params "nofb nomodeset vga=normal console=ttyS0"
+ fi
}
# create_ironic_cache_dir() - Part of the init_ironic() process
@@ -306,9 +313,15 @@
function create_bridge_and_vms {
# Call libvirt setup scripts in a new shell to ensure any new group membership
sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/setup-network"
+ if [[ "$IRONIC_VM_LOG_CONSOLE" == "True" ]] ; then
+ LOG_ARG="$IRONIC_VM_LOG_DIR"
+ else
+ LOG_ARG=""
+ fi
sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/create-nodes \
$IRONIC_VM_SPECS_CPU $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK \
- amd64 $IRONIC_VM_COUNT $IRONIC_VM_NETWORK_BRIDGE $IRONIC_VM_EMULATOR" >> $IRONIC_VM_MACS_CSV_FILE
+ amd64 $IRONIC_VM_COUNT $IRONIC_VM_NETWORK_BRIDGE $IRONIC_VM_EMULATOR \
+ $LOG_ARG" >> $IRONIC_VM_MACS_CSV_FILE
}
function enroll_vms {