Fix parameter create-node.sh

When IRONIC_VM_LOG_CONSOLE is set in devstack/local.conf,
devstack/tools/ironic/scripts/create-node.sh fails with below error message.

expected syntax: --format <string>

This error occurs because when IRONIC_VM_LOG_CONSOLE is set False,
log_arg is passed with empty string to
devstack/tools/ironic/scripts/create-node.sh.
This patch set fixes parameter order of
devstack/tools/ironic/scripts/create-node.sh, and also
create-node.sh has too many parameters, so fix to use getopts.

Change-Id: Ibdfff27e2c0119f8261f2324233acbeea6612d79
Closes-bug: #1589370
This commit is contained in:
Yuiko Takada Mori 2016-06-06 14:39:20 +09:00
parent 8b75becccb
commit 9a1aeb76da
2 changed files with 23 additions and 17 deletions

View File

@ -751,7 +751,7 @@ 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.sh" sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/setup-network.sh"
if [[ "$IRONIC_VM_LOG_CONSOLE" == "True" ]] ; then if [[ "$IRONIC_VM_LOG_CONSOLE" == "True" ]] ; then
local log_arg="$IRONIC_VM_LOG_DIR" local log_arg="-l $IRONIC_VM_LOG_DIR"
if [[ "$IRONIC_VM_LOG_ROTATE" == "True" ]] ; then if [[ "$IRONIC_VM_LOG_ROTATE" == "True" ]] ; then
setup_qemu_log_hook setup_qemu_log_hook
@ -763,10 +763,10 @@ function create_bridge_and_vms {
local vbmc_port=$IRONIC_VBMC_PORT_RANGE_START local vbmc_port=$IRONIC_VBMC_PORT_RANGE_START
local vm_name local vm_name
for vm_name in $(_ironic_bm_vm_names); do for vm_name in $(_ironic_bm_vm_names); do
sudo -E su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/create-node.sh $vm_name \ sudo -E su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/create-node.sh -n $vm_name \
$IRONIC_VM_SPECS_CPU $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK \ -c $IRONIC_VM_SPECS_CPU -m $IRONIC_VM_SPECS_RAM -d $IRONIC_VM_SPECS_DISK \
$IRONIC_VM_SPECS_CPU_ARCH $IRONIC_VM_NETWORK_BRIDGE $IRONIC_VM_EMULATOR \ -a $IRONIC_VM_SPECS_CPU_ARCH -b $IRONIC_VM_NETWORK_BRIDGE -e $IRONIC_VM_EMULATOR \
$vbmc_port $log_arg $IRONIC_VM_SPECS_DISK_FORMAT" >> $IRONIC_VM_MACS_CSV_FILE -p $vbmc_port -f $IRONIC_VM_SPECS_DISK_FORMAT $log_arg" >> $IRONIC_VM_MACS_CSV_FILE
vbmc_port=$((vbmc_port+1)) vbmc_port=$((vbmc_port+1))
done done
local ironic_net_id local ironic_net_id

View File

@ -9,18 +9,24 @@ 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)
NAME=$1 while getopts "n:c:m:d:a:b:e:p:v:f:l:" arg; do
CPU=$2 case $arg in
MEM=$(( 1024 * $3 )) n) NAME=$OPTARG;;
# Extra G to allow fuzz for partition table : flavor size and registered size c) CPU=$OPTARG;;
# need to be different to actual size. m) MEM=$(( 1024 * OPTARG ));;
DISK=$(( $4 + 1)) # Extra G to allow fuzz for partition table : flavor size and registered
ARCH=$5 # size need to be different to actual size.
BRIDGE=$6 d) DISK=$(( OPTARG + 1 ));;
EMULATOR=$7 a) ARCH=$OPTARG;;
VBMC_PORT=$8 b) BRIDGE=$OPTARG;;
LOGDIR=$9 e) EMULATOR=$OPTARG;;
DISK_FORMAT=${10} p) VBMC_PORT=$OPTARG;;
f) DISK_FORMAT=$OPTARG;;
l) LOGDIR=$OPTARG;;
esac
done
shift $(( $OPTIND - 1 ))
LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"virtio"} LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"virtio"}
LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"} LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"}