From 1ef3c3600d5b1692f65a445cf9e1c2e10a46314e Mon Sep 17 00:00:00 2001
From: Tim Rozet <trozet@redhat.com>
Date: Mon, 20 Feb 2017 12:38:54 -0500
Subject: Allows for specifying compute node RAM

Currently we allow specifying ram per Overcloud VM.  If the node is
detected as ODL, we bump the RAM to a minimum of 10GB.  There is a need
to be able to specify the RAM per compute node in cases where we need
controller RAM to be high, but want compute nodes to be low (like CSIT)
- in order to keep the memory footprint as small as possible.

Changes Include:
 - Adds '--virtual-compute-ram' argument that will override the
   '--virtual-ram' param for compute nodes
 - Fixes a bug where if ODL is used and RAM is overridden to 10GB for
   Control nodes, it was also accidentally being set for compute nodes
 - Modifies '--virtual-ram' to be '--virtual-default-ram' in order to
   clarify this parameter sets the default amount of RAM for all
   overcloud nodes which may be overridden by a role specific arg

Change-Id: Ia36082aa2167d9897f3ec6753d08804352301c63
Signed-off-by: Tim Rozet <trozet@redhat.com>
---
 ci/deploy.sh                   | 12 +++++++++---
 lib/virtual-setup-functions.sh | 10 ++++++++--
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/ci/deploy.sh b/ci/deploy.sh
index b55f47ee..4df2d6a8 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -103,7 +103,8 @@ display_usage() {
   echo -e "   --debug : enable debug output."
   echo -e "   --interactive : enable interactive deployment mode which requires user to confirm steps of deployment."
   echo -e "   --virtual-cpus : Number of CPUs to use per Overcloud VM in a virtual deployment (defaults to 4)."
-  echo -e "   --virtual-ram : Amount of RAM to use per Overcloud VM in GB (defaults to 8)."
+  echo -e "   --virtual-default-ram : Amount of default RAM to use per Overcloud VM in GB (defaults to 8)."
+  echo -e "   --virtual-compute-ram : Amount of RAM to use per Overcloud Compute VM in GB (defaults to 8). Overrides --virtual-default-ram arg for computes"
 }
 
 ##translates the command line parameters into variables
@@ -174,9 +175,9 @@ parse_cmdline() {
                 echo "Number of CPUs per VM set to $VM_CPUS"
                 shift 2
             ;;
-        --virtual-ram )
+        --virtual-default-ram )
                 VM_RAM=$2
-                echo "Amount of RAM per VM set to $VM_RAM"
+                echo "Amount of Default RAM per VM set to $VM_RAM"
                 shift 2
             ;;
         --virtual-computes )
@@ -184,6 +185,11 @@ parse_cmdline() {
                 echo "Virtual Compute nodes set to $VM_COMPUTES"
                 shift 2
             ;;
+        --virtual-compute-ram )
+                VM_COMPUTE_RAM=$2
+                echo "Virtual Compute RAM set to $VM_COMPUTE_RAM"
+                shift 2
+            ;;
         *)
                 display_usage
                 exit 1
diff --git a/lib/virtual-setup-functions.sh b/lib/virtual-setup-functions.sh
index 8aaa3594..c74a374b 100755
--- a/lib/virtual-setup-functions.sh
+++ b/lib/virtual-setup-functions.sh
@@ -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
@@ -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
-- 
cgit