From 7e1864c7ba5787d8126afe09c6ecef31b4d30afd Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Tue, 19 Aug 2014 16:50:08 +0200 Subject: [PATCH] labs: add init_node command This changeset adds a new init_node command for config/scripts.* and uses it to merge scripts.nodeinit_osbash and scripts.nodeinit_vagrant into the node specific config/scripts.*. This results in some redundancy, but it (hopefully) makes the script configuration easier to follow. It also makes the initial creation and configuration of the VM just another step that can be picked or omitted from script configuration. Implements: blueprint openstack-training-labs Change-Id: Ieadfe2b9540710556100051723e3e6f08855efa3 --- labs/config/scripts.compute | 9 +++++++++ labs/config/scripts.controller | 9 +++++++++ labs/config/scripts.network | 9 +++++++++ labs/config/scripts.nodeinit_osbash | 8 -------- labs/config/scripts.nodeinit_vagrant | 2 -- labs/lib/osbash/functions.host | 4 ++++ labs/lib/osbash/virtualbox.install_node | 6 +----- labs/scripts/vagrant/run_scripts.sh | 2 +- 8 files changed, 33 insertions(+), 16 deletions(-) delete mode 100644 labs/config/scripts.nodeinit_osbash delete mode 100644 labs/config/scripts.nodeinit_vagrant diff --git a/labs/config/scripts.compute b/labs/config/scripts.compute index 7c3ac071..addd977f 100644 --- a/labs/config/scripts.compute +++ b/labs/config/scripts.compute @@ -1,4 +1,13 @@ # Scripts for compute node +cmd init_node +scripts etc_hosts.sh +osbash enable_vagrant_ssh_keys.sh +#osbash wait_debug.sh +# Using scripts/osbash/shutdown.sh because we want Vagrant to ignore this +osbash shutdown.sh +cmd boot +cmd wait_for_shutdown +cmd snapshot "network_configured" scripts setup_nova_compute.sh scripts setup_neutron_compute.sh scripts shutdown.sh diff --git a/labs/config/scripts.controller b/labs/config/scripts.controller index a09782cf..b25b0fcb 100644 --- a/labs/config/scripts.controller +++ b/labs/config/scripts.controller @@ -1,4 +1,13 @@ # Scripts for controller node +cmd init_node +scripts etc_hosts.sh +osbash enable_vagrant_ssh_keys.sh +#osbash wait_debug.sh +# Using scripts/osbash/shutdown.sh because we want Vagrant to ignore this +osbash shutdown.sh +cmd boot +cmd wait_for_shutdown +cmd snapshot "network_configured" scripts apt_install_mysql.sh scripts install_rabbitmq.sh scripts setup_keystone.sh diff --git a/labs/config/scripts.network b/labs/config/scripts.network index f651807b..75eb4559 100644 --- a/labs/config/scripts.network +++ b/labs/config/scripts.network @@ -1,4 +1,13 @@ # Scripts for network node +cmd init_node +scripts etc_hosts.sh +osbash enable_vagrant_ssh_keys.sh +#osbash wait_debug.sh +# Using scripts/osbash/shutdown.sh because we want Vagrant to ignore this +osbash shutdown.sh +cmd boot +cmd wait_for_shutdown +cmd snapshot "network_configured" scripts setup_neutron_network.sh scripts shutdown.sh cmd boot diff --git a/labs/config/scripts.nodeinit_osbash b/labs/config/scripts.nodeinit_osbash deleted file mode 100644 index 2b6969e5..00000000 --- a/labs/config/scripts.nodeinit_osbash +++ /dev/null @@ -1,8 +0,0 @@ -# Scripts for all nodes built by osbash -scripts etc_hosts.sh -osbash enable_vagrant_ssh_keys.sh -#osbash wait_debug.sh -scripts shutdown.sh -cmd boot -cmd wait_for_shutdown -cmd snapshot "network_configured" diff --git a/labs/config/scripts.nodeinit_vagrant b/labs/config/scripts.nodeinit_vagrant deleted file mode 100644 index d30f5561..00000000 --- a/labs/config/scripts.nodeinit_vagrant +++ /dev/null @@ -1,2 +0,0 @@ -# Scripts for all nodes built using Vagrant -scripts etc_hosts.sh diff --git a/labs/lib/osbash/functions.host b/labs/lib/osbash/functions.host index 7d20be83..639c74cd 100644 --- a/labs/lib/osbash/functions.host +++ b/labs/lib/osbash/functions.host @@ -273,6 +273,10 @@ function command_from_config { echo >&2 vm_wait_for_shutdown "$NODE_NAME" vm_wait_for_shutdown "$NODE_NAME" ;; + init_node) + echo >&2 vm_init_node "$NODE_NAME" + vm_init_node "$NODE_NAME" + ;; *) echo >&2 "Error: invalid cmd: $cmd" exit 1 diff --git a/labs/lib/osbash/virtualbox.install_node b/labs/lib/osbash/virtualbox.install_node index 1d64e962..1c89ad1b 100644 --- a/labs/lib/osbash/virtualbox.install_node +++ b/labs/lib/osbash/virtualbox.install_node @@ -39,8 +39,6 @@ function _vbox_boot_with_autostart { function vm_init_node { NODE_NAME=$1 - ${WBATCH:-:} wbatch_begin_node "$NODE_NAME" - vm_create "$NODE_NAME" # Set VM_MEM in config/config.NODE_NAME to override @@ -62,10 +60,8 @@ function vm_init_node { vm_add_share "$NODE_NAME" "$SHARE_DIR" "$SHARE_NAME" vm_attach_disk_multi "$NODE_NAME" "$BASE_DISK" #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - autostart_reset # Rename to pass the node name to the script autostart_and_rename osbash init_xxx_node.sh "init_${NODE_NAME}_node.sh" - autostart_from_config scripts.nodeinit_osbash } function vm_build_node { @@ -76,7 +72,7 @@ function vm_build_node { NODE_NAME=$1 source "$CONFIG_DIR/config.$NODE_NAME" - vm_init_node "$NODE_NAME" + ${WBATCH:-:} wbatch_begin_node "$NODE_NAME" #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - autostart_reset autostart_from_config "scripts.$NODE_NAME" diff --git a/labs/scripts/vagrant/run_scripts.sh b/labs/scripts/vagrant/run_scripts.sh index bd5e241f..3b79bde8 100755 --- a/labs/scripts/vagrant/run_scripts.sh +++ b/labs/scripts/vagrant/run_scripts.sh @@ -37,7 +37,7 @@ function vagrant_start_from_config { } # The Vagrantfile uses Ubuntu -for config_file in "scripts.nodeinit_vagrant" "scripts.ubuntu" "scripts.$HOSTNAME"; do +for config_file in "scripts.ubuntu" "scripts.$HOSTNAME"; do echo "Config file $config_file" vagrant_start_from_config "$config_file" done