labs: new cmd syntax for config/scripts.*
This changeset introduces a new syntax for commands in the config/scripts.* files. Command lines start with "cmd " followed by a command (such as boot or snapshot) and its arguments (if any). This allows us to easily recognize command lines anywhere without having to keep a complete command list. Implements: blueprint openstack-training-labs Change-Id: I7a52476f5b9ba24c2746667b5a0b23b4b73d2e87
This commit is contained in:
parent
7a3e3269e9
commit
bd52a83713
@ -2,6 +2,6 @@
|
||||
scripts setup_nova_compute.sh
|
||||
scripts setup_neutron_compute.sh
|
||||
scripts shutdown.sh
|
||||
boot
|
||||
wait_for_shutdown
|
||||
snapshot "pre-installed"
|
||||
cmd boot
|
||||
cmd wait_for_shutdown
|
||||
cmd snapshot "pre-installed"
|
||||
|
@ -12,7 +12,7 @@ scripts config_external_network.sh
|
||||
scripts config_demo_user.sh
|
||||
scripts config_tenant_network.sh
|
||||
scripts shutdown.sh
|
||||
boot
|
||||
wait_for_shutdown
|
||||
snapshot "pre-installed"
|
||||
boot
|
||||
cmd boot
|
||||
cmd wait_for_shutdown
|
||||
cmd snapshot "pre-installed"
|
||||
cmd boot
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Scripts for network node
|
||||
scripts setup_neutron_network.sh
|
||||
scripts shutdown.sh
|
||||
boot
|
||||
wait_for_shutdown
|
||||
snapshot "pre-installed"
|
||||
cmd boot
|
||||
cmd wait_for_shutdown
|
||||
cmd snapshot "pre-installed"
|
||||
|
@ -3,6 +3,6 @@ scripts etc_hosts.sh
|
||||
osbash enable_vagrant_ssh_keys.sh
|
||||
#osbash wait_debug.sh
|
||||
scripts shutdown.sh
|
||||
boot
|
||||
wait_for_shutdown
|
||||
snapshot "network_configured"
|
||||
cmd boot
|
||||
cmd wait_for_shutdown
|
||||
cmd snapshot "network_configured"
|
||||
|
@ -252,6 +252,33 @@ function autostart {
|
||||
done
|
||||
}
|
||||
|
||||
# Parse command and arguments after a "cmd" token in config/scripts.*
|
||||
function command_from_config {
|
||||
local cmd_string=( $1 )
|
||||
local cmd=${cmd_string[0]}
|
||||
case "$cmd" in
|
||||
boot)
|
||||
# Boot with queued autostart files now, wait for shutdown
|
||||
echo >&2 _vbox_boot_with_autostart "$NODE_NAME" "$VM_SSH_PORT"
|
||||
_vbox_boot_with_autostart "$NODE_NAME" "$VM_SSH_PORT"
|
||||
;;
|
||||
snapshot)
|
||||
# Format: snapshot <snapshot_name>
|
||||
local shot_name=${cmd_string[1]}
|
||||
echo >&2 vm_snapshot "$NODE_NAME" "$shot_name"
|
||||
vm_snapshot "$NODE_NAME" "$shot_name"
|
||||
;;
|
||||
wait_for_shutdown)
|
||||
echo >&2 vm_wait_for_shutdown "$NODE_NAME"
|
||||
vm_wait_for_shutdown "$NODE_NAME"
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Error: invalid cmd: $cmd"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Parse config/scripts.* configuration files
|
||||
function autostart_from_config {
|
||||
local config_file=$1
|
||||
@ -271,17 +298,8 @@ function autostart_from_config {
|
||||
if [[ $field_1 =~ ^# ]]; then
|
||||
# Skip lines that are commented out
|
||||
continue
|
||||
elif [ "$field_1" == "boot" ]; then
|
||||
# Boot with queued autostart files now, wait for shutdown
|
||||
echo >&2 _vbox_boot_with_autostart "$NODE_NAME" "$VM_SSH_PORT"
|
||||
_vbox_boot_with_autostart "$NODE_NAME" "$VM_SSH_PORT"
|
||||
elif [ "$field_1" == "snapshot" ]; then
|
||||
# Format: snapshot <snapshot_name>
|
||||
echo >&2 vm_snapshot "$NODE_NAME" "$field_2"
|
||||
vm_snapshot "$NODE_NAME" "$field_2"
|
||||
elif [ "$field_1" == "wait_for_shutdown" ]; then
|
||||
echo >&2 vm_wait_for_shutdown "$NODE_NAME"
|
||||
vm_wait_for_shutdown "$NODE_NAME"
|
||||
elif [ "$field_1" == "cmd" ]; then
|
||||
command_from_config "$field_2"
|
||||
else
|
||||
# Queue a script for autostart
|
||||
# Format: <dircode> <script_name>
|
||||
|
@ -24,7 +24,7 @@ function vagrant_start_from_config {
|
||||
if [[ $field_1 =~ ^# ]]; then
|
||||
# Skip lines that are commented out
|
||||
continue
|
||||
elif [[ "$field_1" == "boot" || "$field_1" == "snapshot" ]]; then
|
||||
elif [[ "$field_1" = cmd ]]; then
|
||||
# Skip osbash commands, Vagrant ignores them
|
||||
continue
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user