Merge "Enable console logging for Ironic baremetal VMs"
This commit is contained in:
commit
a6c21928d2
15
lib/ironic
15
lib/ironic
@ -66,6 +66,10 @@ IRONIC_VM_NETWORK_RANGE=${IRONIC_VM_NETWORK_RANGE:-192.0.2.0/24}
|
|||||||
IRONIC_VM_MACS_CSV_FILE=${IRONIC_VM_MACS_CSV_FILE:-$IRONIC_DATA_DIR/ironic_macs.csv}
|
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}
|
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}
|
DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
|
||||||
|
|
||||||
# Use DIB to create deploy ramdisk and kernel.
|
# Use DIB to create deploy ramdisk and kernel.
|
||||||
@ -187,6 +191,9 @@ function configure_ironic_conductor {
|
|||||||
iniset $IRONIC_CONF_FILE pxe tftp_server $HOST_IP
|
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_root $IRONIC_TFTPBOOT_DIR
|
||||||
iniset $IRONIC_CONF_FILE pxe tftp_master_path $IRONIC_TFTPBOOT_DIR/master_images
|
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
|
# create_ironic_cache_dir() - Part of the init_ironic() process
|
||||||
@ -316,9 +323,15 @@ function configure_ironic_dirs {
|
|||||||
function create_bridge_and_vms {
|
function create_bridge_and_vms {
|
||||||
# Call libvirt setup scripts in a new shell to ensure any new group membership
|
# Call libvirt setup scripts in a new shell to ensure any new group membership
|
||||||
sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/setup-network"
|
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 \
|
sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/create-nodes \
|
||||||
$IRONIC_VM_SPECS_CPU $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK \
|
$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 {
|
function enroll_vms {
|
||||||
|
@ -9,6 +9,25 @@ templatedir = os.path.join(os.path.dirname(os.path.dirname(__file__)),
|
|||||||
'templates')
|
'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():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Configure a kvm virtual machine for the seed image.")
|
description="Configure a kvm virtual machine for the seed image.")
|
||||||
@ -30,6 +49,8 @@ def main():
|
|||||||
help='The libvirt network name to use')
|
help='The libvirt network name to use')
|
||||||
parser.add_argument('--libvirt-nic-driver', default='e1000',
|
parser.add_argument('--libvirt-nic-driver', default='e1000',
|
||||||
help='The libvirt network driver to use')
|
help='The libvirt network driver to use')
|
||||||
|
parser.add_argument('--console-log',
|
||||||
|
help='File to log console')
|
||||||
parser.add_argument('--emulator', default=None,
|
parser.add_argument('--emulator', default=None,
|
||||||
help='Path to emulator bin for vm template')
|
help='Path to emulator bin for vm template')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -44,6 +65,7 @@ def main():
|
|||||||
'cpus': args.cpus,
|
'cpus': args.cpus,
|
||||||
'bootdev': args.bootdev,
|
'bootdev': args.bootdev,
|
||||||
'network': args.network,
|
'network': args.network,
|
||||||
|
'nicdriver': args.libvirt_nic_driver,
|
||||||
'emulator': args.emulator,
|
'emulator': args.emulator,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,22 +77,13 @@ def main():
|
|||||||
elif os.path.exists("/usr/bin/qemu-kvm"): # Redhat
|
elif os.path.exists("/usr/bin/qemu-kvm"): # Redhat
|
||||||
params['emulator'] = "/usr/bin/qemu-kvm"
|
params['emulator'] = "/usr/bin/qemu-kvm"
|
||||||
|
|
||||||
nicparams = {
|
if args.console_log:
|
||||||
'nicdriver': args.libvirt_nic_driver,
|
params['console_log'] = CONSOLE_LOG % {'console_log': args.console_log}
|
||||||
'network': args.network,
|
else:
|
||||||
}
|
params['console_log'] = ''
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
libvirt_template = source_template % params
|
libvirt_template = source_template % params
|
||||||
conn = libvirt.open("qemu:///system")
|
conn = libvirt.open("qemu:///system")
|
||||||
|
|
||||||
a = conn.defineXML(libvirt_template)
|
a = conn.defineXML(libvirt_template)
|
||||||
print ("Created machine %s with UUID %s" % (args.name, a.UUIDString()))
|
print ("Created machine %s with UUID %s" % (args.name, a.UUIDString()))
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
# Creates baremetal poseur nodes for ironic testing purposes
|
# Creates baremetal poseur nodes for ironic testing purposes
|
||||||
|
|
||||||
set -exu
|
set -ex
|
||||||
|
|
||||||
# Keep track of the devstack directory
|
# Keep track of the devstack directory
|
||||||
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
||||||
@ -24,6 +24,7 @@ esac
|
|||||||
TOTAL=$(($5 - 1))
|
TOTAL=$(($5 - 1))
|
||||||
BRIDGE=$6
|
BRIDGE=$6
|
||||||
EMULATOR=$7
|
EMULATOR=$7
|
||||||
|
LOGDIR=$8
|
||||||
|
|
||||||
LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"e1000"}
|
LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"e1000"}
|
||||||
LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"}
|
LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"}
|
||||||
@ -43,6 +44,10 @@ if [ "$pool_state" != "running" ] ; then
|
|||||||
virsh pool-start $LIBVIRT_STORAGE_POOL >&2
|
virsh pool-start $LIBVIRT_STORAGE_POOL >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$LOGDIR" ] ; then
|
||||||
|
mkdir -p "$LOGDIR"
|
||||||
|
fi
|
||||||
|
|
||||||
PREALLOC=
|
PREALLOC=
|
||||||
if [ -f /etc/debian_version ]; then
|
if [ -f /etc/debian_version ]; then
|
||||||
PREALLOC="--prealloc-metadata"
|
PREALLOC="--prealloc-metadata"
|
||||||
@ -51,6 +56,11 @@ fi
|
|||||||
DOMS=""
|
DOMS=""
|
||||||
for idx in $(seq 0 $TOTAL) ; do
|
for idx in $(seq 0 $TOTAL) ; do
|
||||||
NAME="baremetal${BRIDGE}_${idx}"
|
NAME="baremetal${BRIDGE}_${idx}"
|
||||||
|
if [ -n "$LOGDIR" ] ; then
|
||||||
|
VM_LOGGING="--console-log $LOGDIR/${NAME}_console.log"
|
||||||
|
else
|
||||||
|
VM_LOGGING=""
|
||||||
|
fi
|
||||||
DOMS="$DOMS $NAME"
|
DOMS="$DOMS $NAME"
|
||||||
VOL_NAME="baremetal${BRIDGE}-${idx}.qcow2"
|
VOL_NAME="baremetal${BRIDGE}-${idx}.qcow2"
|
||||||
(virsh list --all | grep -q $NAME) && continue
|
(virsh list --all | grep -q $NAME) && continue
|
||||||
@ -62,7 +72,10 @@ for idx in $(seq 0 $TOTAL) ; do
|
|||||||
# Pre-touch the VM to set +C, as it can only be set on empty files.
|
# Pre-touch the VM to set +C, as it can only be set on empty files.
|
||||||
sudo touch "$volume_path"
|
sudo touch "$volume_path"
|
||||||
sudo chattr +C "$volume_path" || true
|
sudo chattr +C "$volume_path" || true
|
||||||
$TOP_DIR/scripts/configure-vm --bootdev network --name $NAME --image "$volume_path" --arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER --emulator $EMULATOR --network $BRIDGE >&2
|
$TOP_DIR/scripts/configure-vm \
|
||||||
|
--bootdev network --name $NAME --image "$volume_path" \
|
||||||
|
--arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER \
|
||||||
|
--emulator $EMULATOR --network $BRIDGE $VM_LOGGING >&2
|
||||||
done
|
done
|
||||||
|
|
||||||
for dom in $DOMS ; do
|
for dom in $DOMS ; do
|
||||||
|
@ -27,14 +27,19 @@
|
|||||||
<controller type='ide' index='0'>
|
<controller type='ide' index='0'>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
</controller>
|
</controller>
|
||||||
%(network)s
|
<interface type='network'>
|
||||||
%(bm_network)s
|
<source network='%(network)s'/>
|
||||||
|
<virtualport type='openvswitch'/>
|
||||||
|
<model type='%(nicdriver)s'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</interface>
|
||||||
<input type='mouse' bus='ps2'/>
|
<input type='mouse' bus='ps2'/>
|
||||||
<graphics type='vnc' port='-1' autoport='yes'/>
|
<graphics type='vnc' port='-1' autoport='yes'/>
|
||||||
<video>
|
<video>
|
||||||
<model type='cirrus' vram='9216' heads='1'/>
|
<model type='cirrus' vram='9216' heads='1'/>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||||
</video>
|
</video>
|
||||||
|
%(console_log)s
|
||||||
<memballoon model='virtio'>
|
<memballoon model='virtio'>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
||||||
</memballoon>
|
</memballoon>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user