From e47910e863819ce9607b17e439cc2bb847f97b85 Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Sun, 31 Aug 2014 17:24:48 +0200 Subject: [PATCH] labs: separate vm_name, NODE_NAME Distinguish between the name of a node VM (vm_name) and the hostname used for the node VM. They just happened to have the same values until now. Change-Id: Idc457922fee886ebe504d5f56bbc86d0e5fbbd54 --- labs/lib/osbash/functions.host | 25 +++++++++++++------------ labs/lib/osbash/virtualbox.install_node | 18 +++++++++--------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/labs/lib/osbash/functions.host b/labs/lib/osbash/functions.host index 7332e93d..d5806cae 100644 --- a/labs/lib/osbash/functions.host +++ b/labs/lib/osbash/functions.host @@ -258,34 +258,35 @@ function autostart { function command_from_config { local cmd_string=( $1 ) local cmd=${cmd_string[0]} + local vm_name=$NODE_NAME 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" + echo >&2 _vbox_boot_with_autostart "$vm_name" "$VM_SSH_PORT" + _vbox_boot_with_autostart "$vm_name" "$VM_SSH_PORT" ;; snapshot) # Format: snapshot local shot_name=${cmd_string[1]} - echo >&2 vm_snapshot "$NODE_NAME" "$shot_name" - vm_snapshot "$NODE_NAME" "$shot_name" + echo >&2 vm_snapshot "$vm_name" "$shot_name" + vm_snapshot "$vm_name" "$shot_name" ;; wait_for_shutdown) - echo >&2 vm_wait_for_shutdown "$NODE_NAME" - vm_wait_for_shutdown "$NODE_NAME" + echo >&2 vm_wait_for_shutdown "$vm_name" + vm_wait_for_shutdown "$vm_name" ;; snapshot_cycle) # comprises shutdown, boot, wait_for_shutdown, snapshot local shot_name=${cmd_string[1]} - echo >&2 snapshot_cycle "$NODE_NAME" "$shot_name" + echo >&2 snapshot_cycle "$vm_name" "$shot_name" _autostart_queue "osbash/shutdown.sh" - _vbox_boot_with_autostart "$NODE_NAME" "$VM_SSH_PORT" - vm_wait_for_shutdown "$NODE_NAME" - vm_snapshot "$NODE_NAME" "$shot_name" + _vbox_boot_with_autostart "$vm_name" "$VM_SSH_PORT" + vm_wait_for_shutdown "$vm_name" + vm_snapshot "$vm_name" "$shot_name" ;; init_node) - echo >&2 vm_init_node "$NODE_NAME" - vm_init_node "$NODE_NAME" + echo >&2 vm_init_node "$vm_name" + vm_init_node "$vm_name" ;; *) echo >&2 "Error: invalid cmd: $cmd" diff --git a/labs/lib/osbash/virtualbox.install_node b/labs/lib/osbash/virtualbox.install_node index 546377fd..e09ce580 100644 --- a/labs/lib/osbash/virtualbox.install_node +++ b/labs/lib/osbash/virtualbox.install_node @@ -37,31 +37,31 @@ function _vbox_boot_with_autostart { # Create a new node VM and run basic configuration scripts function vm_init_node { - node_name=$1 + vm_name=$1 - vm_create "$node_name" + vm_create "$vm_name" # Set VM_MEM in config/config.NODE_NAME to override - vm_mem "$node_name" "${VM_MEM:-512}" + vm_mem "$vm_name" "${VM_MEM:-512}" # Set VM_CPUS in config/config.NODE_NAME to override - vm_cpus "$node_name" "${VM_CPUS:-1}" + vm_cpus "$vm_name" "${VM_CPUS:-1}" _vbox_configure_ifs # Port forwarding if [ -n "${VM_SSH_PORT:-}" ]; then - vm_port "$node_name" ssh "$VM_SSH_PORT" 22 + vm_port "$vm_name" ssh "$VM_SSH_PORT" 22 fi if [ -n "${VM_WWW_PORT:-}" ]; then - vm_port "$node_name" http "$VM_WWW_PORT" 80 + vm_port "$vm_name" http "$VM_WWW_PORT" 80 fi - vm_add_share "$node_name" "$SHARE_DIR" "$SHARE_NAME" - vm_attach_disk_multi "$node_name" "$BASE_DISK" + vm_add_share "$vm_name" "$SHARE_DIR" "$SHARE_NAME" + vm_attach_disk_multi "$vm_name" "$BASE_DISK" #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Rename to pass the node name to the script - autostart_and_rename osbash init_xxx_node.sh "init_${node_name}_node.sh" + autostart_and_rename osbash init_xxx_node.sh "init_${NODE_NAME}_node.sh" } function vm_build_node {