From 3b1e7793de7a4ba0433b780a509a7fca51baafc3 Mon Sep 17 00:00:00 2001
From: handreas <andreas.hamacher@monash.edu>
Date: Sun, 12 Apr 2020 03:41:39 +0000
Subject: [PATCH] adding a parameter file

Former-commit-id: f04522eeb90426c6ed2a8e91a0ac6e16d59a68df
---
 CICD/heat/gc_HOT.yaml                         | 18 +++++++++---------
 CICD/heat/heatcicdwrapper.sh                  |  6 +++---
 ...t_parameters_ansible_cluster_in_a_box.yaml | 19 +++++++++++++++++++
 ...rce_registry.ansible_cluster_in_a_box.yaml |  8 --------
 4 files changed, 31 insertions(+), 20 deletions(-)
 create mode 100644 CICD/heat_parameters_ansible_cluster_in_a_box.yaml
 delete 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 006fd8b5..cacc7c7c 100644
--- a/CICD/heat/gc_HOT.yaml
+++ b/CICD/heat/gc_HOT.yaml
@@ -114,12 +114,12 @@ resources:
     volume_id: { get_resource: DBVolume }
     instance_uuid: { get_resource: SQLNode0 }
 
-  MgmtNodesC:
+  MgmtNodesCentos7:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: My::Server::MgmtNodeCountCentos7
+    count: 0
     resource_def:
-      type: My::Server::MgmtNode
+      type: { get_param: MgmtNodeCountCentos7 }
       properties:
         #avz: { get_param: avz }
         image: { get_param: centos_7_image_id }
@@ -133,7 +133,7 @@ resources:
   MgmtNodesU:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: My::Server::MgmtNodeCountUbuntu
+    count: { get_param: MgmtNodeCountUbuntu }
     resource_def:
       type: My::Server::MgmtNode
       properties:
@@ -149,7 +149,7 @@ resources:
   LoginNodesC:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: My::Server::LoginNodeCountCentos
+    count: { get_param: LoginNodeCountCentos7 }
     resource_def:
      type: "OS::Nova::Server"
      properties:
@@ -170,7 +170,7 @@ resources:
   LoginNodesU:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: My::Server::LoginNodeCountUbuntu
+    count: { get_param: LoginNodeCountUbuntu }
     resource_def:
      type: "OS::Nova::Server"
      properties:
@@ -212,7 +212,7 @@ resources:
   ComputeNodesU:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: My::Server::ComputeNodeCountUbuntu
+    count: { get_param: ComputeNodeCountUbutnu }
     resource_def:
      type: "OS::Nova::Server"
      properties:
@@ -230,10 +230,10 @@ resources:
       networks:
        - network: { get_param: NetID }
 
-  ComputeNodesC:
+  ComputeNodesCentos7:
    type: "OS::Heat::ResourceGroup"
    properties:
-    count: My::Server::ComputeNodeCountCentos
+    count: { get_param: ComputeNodeCountCentos7 }
     resource_def:
      type: "OS::Nova::Server"
      properties:
diff --git a/CICD/heat/heatcicdwrapper.sh b/CICD/heat/heatcicdwrapper.sh
index 2d97a384..60720627 100644
--- a/CICD/heat/heatcicdwrapper.sh
+++ b/CICD/heat/heatcicdwrapper.sh
@@ -55,7 +55,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 ./resource_registry.${CI_PROJECT_NAME}.yaml $STACKNAME
+ openstack stack create --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./heat/resource_registry.yaml --parameter-file ./heat_parameters_${CI_PROJECT_NAME}.yaml $STACKNAME
  createreturn=$?
  if [ $createreturn -ne "0" ]
  then
@@ -78,14 +78,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 ./resource_registry.${CI_PROJECT_NAME}.yaml $STACKNAME
+            openstack stack update --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./heat/resource_registry.yaml --parameter-file ./heat_parameters_${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 ./resource_registry.${CI_PROJECT_NAME}.yaml $STACKNAME
+               openstack stack update --wait --template ./heat/gc_HOT.yaml --parameter "project_name=$STACKNAME" -e ./heat/resource_registry.yaml --parameter-file ./heat_parameters_${CI_PROJECT_NAME}.yaml $STACKNAME
                ret=$?
                exit $ret
             fi
diff --git a/CICD/heat_parameters_ansible_cluster_in_a_box.yaml b/CICD/heat_parameters_ansible_cluster_in_a_box.yaml
new file mode 100644
index 00000000..91a98743
--- /dev/null
+++ b/CICD/heat_parameters_ansible_cluster_in_a_box.yaml
@@ -0,0 +1,19 @@
+parameters:
+  MgmtNodeCountUbuntu:
+    type: number
+    default: 1
+  MgmtNodeCountCentos7:
+    type: number
+    default: 1
+  LoginNodeCountCentos7:
+    type: number
+    default: 1
+  LoginNodeCountUbuntu:
+    type: number
+    default: 1
+  ComputeNodeCountUbuntu:
+    type: number
+    default: 1
+  ComputeNodeCountCentos7:
+    type: number
+    default: 1
diff --git a/CICD/resource_registry.ansible_cluster_in_a_box.yaml b/CICD/resource_registry.ansible_cluster_in_a_box.yaml
deleted file mode 100644
index 8d9a1510..00000000
--- a/CICD/resource_registry.ansible_cluster_in_a_box.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-resource_registry:
-  My::Server::MgmtNode: ./heat/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
-- 
GitLab