From 4e9d10221a9828fabd7b29c0a3ed3341fedf579c Mon Sep 17 00:00:00 2001
From: handreas <andreas.hamacher@monash.edu>
Date: Sun, 12 Apr 2020 03:06:43 +0000
Subject: [PATCH] some refactoring in the heat templates to allow more diverse
 stacks

Former-commit-id: 7f85baf168a5c2601d4a7da3f6e94a4578201f60
---
 CICD/heat/gc_HOT.yaml                              | 12 ++++++------
 CICD/heat/heatcicdwrapper.sh                       | 14 +++++++-------
 CICD/heat/resource_registry.yaml                   |  2 --
 ...resource_registry.ansible_cluster_in_a_box.yaml |  8 ++++++++
 CICD/vars/slurm.yml                                |  2 +-
 5 files changed, 22 insertions(+), 16 deletions(-)
 delete mode 100644 CICD/heat/resource_registry.yaml
 create mode 100644 CICD/resource_registry.ansible_cluster_in_a_box.yaml

diff --git a/CICD/heat/gc_HOT.yaml b/CICD/heat/gc_HOT.yaml
index ab85600c..006fd8b5 100644
--- a/CICD/heat/gc_HOT.yaml
+++ b/CICD/heat/gc_HOT.yaml
@@ -117,7 +117,7 @@ resources:
   MgmtNodesC:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: 1
+    count: My::Server::MgmtNodeCountCentos7
     resource_def:
       type: My::Server::MgmtNode
       properties:
@@ -133,7 +133,7 @@ resources:
   MgmtNodesU:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: 1
+    count: My::Server::MgmtNodeCountUbuntu
     resource_def:
       type: My::Server::MgmtNode
       properties:
@@ -149,7 +149,7 @@ resources:
   LoginNodesC:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: 0
+    count: My::Server::LoginNodeCountCentos
     resource_def:
      type: "OS::Nova::Server"
      properties:
@@ -170,7 +170,7 @@ resources:
   LoginNodesU:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: 1
+    count: My::Server::LoginNodeCountUbuntu
     resource_def:
      type: "OS::Nova::Server"
      properties:
@@ -212,7 +212,7 @@ resources:
   ComputeNodesU:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: 1
+    count: My::Server::ComputeNodeCountUbuntu
     resource_def:
      type: "OS::Nova::Server"
      properties:
@@ -233,7 +233,7 @@ resources:
   ComputeNodesC:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: 1
+    count: My::Server::ComputeNodeCountCentos
     resource_def:
      type: "OS::Nova::Server"
      properties:
diff --git a/CICD/heat/heatcicdwrapper.sh b/CICD/heat/heatcicdwrapper.sh
index 26afdebd..80104742 100644
--- a/CICD/heat/heatcicdwrapper.sh
+++ b/CICD/heat/heatcicdwrapper.sh
@@ -4,17 +4,17 @@
 
 
 function usage {
-    echo $"Usage: $0 {create|update|show|create_or_update,delete_if_exists} STACKNAME"
+    echo $"Usage: $0 {create|update|show|create_or_update,delete_if_exists} STACKNAME CI_PROJECT_NAME"
     exit 1
 }
 
-if [ "$#" -ne 2 ]; then
-    echo "Illegal number of parameters expecting 2"
+if [ "$#" -ne 3 ]; then
+    echo "Illegal number of parameters expecting 3"
     usage
 fi
 
 STACKNAME=$2
-
+CI_PROJECT_NAME=$3
 
 if [[ "$STACKNAME" == "CICD"* ]]; then
   echo "CICD found in stackname. doing nothing"
@@ -60,7 +60,7 @@ function create_stack {
     echo "I will NOT create existing stack maybe use update"
     exit -44
  fi
- openstack stack create --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./heat/resource_registry.yaml $STACKNAME
+ openstack stack create --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./resource_registry.${CI_PROJECT_NAME}.yaml $STACKNAME
  createreturn=$?
  if [ $createreturn -ne "0" ]
  then
@@ -83,14 +83,14 @@ case "$1" in
                    echo "I cannot update a stack which does not exist"
                    exit -45
             fi
-            openstack stack update --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./heat/resource_registry.yaml $STACKNAME
+            openstack stack update --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./resource_registry.${CI_PROJECT_NAME}.yaml $STACKNAME
             ret=$?
             exit $ret
             ;;
         create_or_update)
             if  check_stack_exists
                then
-               openstack stack update --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./heat/resource_registry.yaml $STACKNAME
+               openstack stack update --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./resource_registry.${CI_PROJECT_NAME}.yaml $STACKNAME
                ret=$?
                exit $ret
             fi
diff --git a/CICD/heat/resource_registry.yaml b/CICD/heat/resource_registry.yaml
deleted file mode 100644
index 0638b887..00000000
--- a/CICD/heat/resource_registry.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-resource_registry:
-  My::Server::MgmtNode: mgmtnode_HOT.yaml
diff --git a/CICD/resource_registry.ansible_cluster_in_a_box.yaml b/CICD/resource_registry.ansible_cluster_in_a_box.yaml
new file mode 100644
index 00000000..a837c267
--- /dev/null
+++ b/CICD/resource_registry.ansible_cluster_in_a_box.yaml
@@ -0,0 +1,8 @@
+resource_registry:
+  My::Server::MgmtNode: mgmtnode_HOT.yaml
+  My::Server::MgmtNodeCountUbuntu: 1
+  My::Server::MgmtNodeCountCentos7: 1
+  My::Server::LoginNodeCountCentos: 0
+  My::Server::LoginNodeCountUbuntu: 1
+  My::Server::ComputeNodeCountUbuntu: 1
+  My::Server::ComputeNodeCountCentos: 1
diff --git a/CICD/vars/slurm.yml b/CICD/vars/slurm.yml
index 0d665291..09dfc0af 100644
--- a/CICD/vars/slurm.yml
+++ b/CICD/vars/slurm.yml
@@ -3,7 +3,7 @@ desktopNodeList:
   - { name : 'DesktopNodes', interface : 'eth0' }
 clustername: "m3"
 projectname: "m3"
-slurm_version: 19.05.3-2
+slurm_version: 19.05.4
 munge_version: 0.5.13
 nhc_version: 1.4.2
 munge_dir: /opt/munge-{{ munge_version }}
-- 
GitLab