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

View File

@ -9,18 +9,24 @@ set -ex
# Keep track of the DevStack directory
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
NAME=$1
CPU=$2
MEM=$(( 1024 * $3 ))
# Extra G to allow fuzz for partition table : flavor size and registered size
# need to be different to actual size.
DISK=$(( $4 + 1))
ARCH=$5
BRIDGE=$6
EMULATOR=$7
VBMC_PORT=$8
LOGDIR=$9
DISK_FORMAT=${10}
while getopts "n:c:m:d:a:b:e:p:v:f:l:" arg; do
case $arg in
n) NAME=$OPTARG;;
c) CPU=$OPTARG;;
m) MEM=$(( 1024 * OPTARG ));;
# Extra G to allow fuzz for partition table : flavor size and registered
# size need to be different to actual size.
d) DISK=$(( OPTARG + 1 ));;
a) ARCH=$OPTARG;;
b) BRIDGE=$OPTARG;;
e) EMULATOR=$OPTARG;;
p) VBMC_PORT=$OPTARG;;
f) DISK_FORMAT=$OPTARG;;
l) LOGDIR=$OPTARG;;
esac
done
shift $(( $OPTIND - 1 ))
LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"virtio"}
LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"}