Adding endpoint url definitions for tacker
[apex.git] / lib / virtual-setup-functions.sh
index 61dc679..c74a374 100755 (executable)
@@ -11,7 +11,7 @@
 ##Create virtual nodes in virsh
 ##params: vcpus, ramsize
 function setup_virtual_baremetal {
-  local vcpus ramsize
+  local vcpus ramsize held_ramsize
   if [ -z "$1" ]; then
     vcpus=4
     ramsize=8192
@@ -23,7 +23,7 @@ function setup_virtual_baremetal {
     ramsize=$(($2*1024))
   fi
   #start by generating the opening yaml for the inventory-virt.yaml file
-  cat > /tmp/inventory-virt.yaml << EOF
+  cat > $APEX_TMP_DIR/inventory-virt.yaml << EOF
 nodes:
 EOF
 
@@ -39,9 +39,15 @@ EOF
       fi
   fi
 
+  # tmp var to hold ramsize in case modified during detection
+  held_ramsize=${ramsize}
   for i in $(seq 0 $(($controller_index+$VM_COMPUTES))); do
-      if [ $i -gt $controller_index ]; then
+    ramsize=${held_ramsize}
+    if [ $i -gt $controller_index ]; then
       capability="profile:compute"
+      if [ -n "$VM_COMPUTE_RAM" ]; then
+        ramsize=$((${VM_COMPUTE_RAM}*1024))
+      fi
     else
       capability="profile:control"
       if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "$ramsize" -lt 10240 ]]; then
@@ -51,8 +57,8 @@ EOF
       fi
     fi
     if ! virsh list --all | grep baremetal${i} > /dev/null; then
-      define_vm baremetal${i} network 41 'admin_network' $vcpus $ramsize
-      for n in private_network public_network storage_network api_network; do
+      define_vm baremetal${i} network 41 'admin' $vcpus $ramsize
+      for n in tenant external storage api; do
         if [[ $enabled_network_list =~ $n ]]; then
           echo -n "$n "
           virsh attach-interface --domain baremetal${i} --type network --source $n --model virtio --config
@@ -62,9 +68,9 @@ EOF
       echo "Found baremetal${i} VM, using existing VM"
     fi
     #virsh vol-list default | grep baremetal${i} 2>&1> /dev/null || virsh vol-create-as default baremetal${i}.qcow2 41G --format qcow2
-    mac=$(virsh domiflist baremetal${i} | grep admin_network | awk '{ print $5 }')
+    mac=$(virsh domiflist baremetal${i} | grep admin | awk '{ print $5 }')
 
-    cat >> /tmp/inventory-virt.yaml << EOF
+    cat >> $APEX_TMP_DIR/inventory-virt.yaml << EOF
   node${i}:
     mac_address: "$mac"
     ipmi_ip: 192.168.122.1