From 939c2443773c9c0225caf740aa6c69204dd7c780 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Mota Date: Fri, 12 Aug 2016 17:52:16 +0200 Subject: [PATCH] Allow to define vms with independent names This is useful when we need to give the vms a more descriptive name, and also when we need to set the hostname properly with simple-init element. Change-Id: I4c9eec82882d94649ee0e6bdb7e2ce033c29e44a --- .../files/create_vm_nodes-for-role.sh | 13 ++++++++++++- ...reate-vm-with-custom-names-0d655bc02e141ec9.yaml | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/allow-create-vm-with-custom-names-0d655bc02e141ec9.yaml diff --git a/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh b/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh index c6e052299..ad9f24fd4 100755 --- a/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh +++ b/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh @@ -20,6 +20,9 @@ # # Create 2 nodes that use KVM acceleration # sudo VM_DOMAIN_TYPE=kvm NODECOUNT=2 create_nodes.sh # +# # Create 3 nodes with different naming +# sudo TEST_VM_NODE_NAMES="controller00 compute00 compute01" create_nodes.sh +# # THANKS # Thanks to the author(s) of the ironic-supporting code within devstack, # from which all of this is derived. @@ -229,6 +232,7 @@ function create_node { NODEBASE=${NODEBASE:-testvm} NODECOUNT=${NODECOUNT:-1} +TEST_VM_NODE_NAMES=${TEST_VM_NODE_NAMES:-""} NODEOUTPUT=${NODEOUTPUT:-"/tmp/baremetal.csv"} TEMPFILE=`mktemp` @@ -243,7 +247,14 @@ fi for (( i=1; i<=${NODECOUNT}; i++ )) do - name=${NODEBASE}${i} + if [ -z "${TEST_VM_NODE_NAMES}" ]; then + name=${NODEBASE}${i} + else + names=($TEST_VM_NODE_NAMES) + arrayindex=$(($i-1)) + name=${names[$arrayindex]} + fi + mac=$(create_node $name $VM_CPU $VM_RAM $VM_DISK amd64 $VM_NET_BRIDGE $VM_EMULATOR $VM_LOGDIR $VM_DOMAIN_TYPE) printf "$mac,root,undefined,192.168.122.1,$VM_CPU,$VM_RAM,$VM_DISK,flavor,type,a8cb6624-0d9f-c882-affc-046ebb96ec0${i},$name,192.168.122.$((i+1))\n" >>$TEMPFILE diff --git a/releasenotes/notes/allow-create-vm-with-custom-names-0d655bc02e141ec9.yaml b/releasenotes/notes/allow-create-vm-with-custom-names-0d655bc02e141ec9.yaml new file mode 100644 index 000000000..99aa8bcd9 --- /dev/null +++ b/releasenotes/notes/allow-create-vm-with-custom-names-0d655bc02e141ec9.yaml @@ -0,0 +1,6 @@ +--- +features: + - Allows to create VMs with custom names instead + of using testvm or NODE_BASE and sequential + prefixes. This can be achieved by passing the + TEST_VM_NODE_NAMES env var.