Fix stack readiness

The patch reworks heat templates to ensure stack is ready
only when all nodes are bootstrapped and wait conditions
are completed.

Related-Prod: PRODX-2063
Change-Id: I03905a80c05ab5933d8641529f97afe4d0097825
diff --git a/de/heat-templates/srv-group.yaml b/de/heat-templates/srv-group.yaml
index e654bb2..a2cf684 100644
--- a/de/heat-templates/srv-group.yaml
+++ b/de/heat-templates/srv-group.yaml
@@ -23,13 +23,33 @@
   private_floating_network:
     type: string
     description: ID of network that will be used for floating in nested openstack
-  user_data:
-    type: string
+  boot_timeout:
+    type: number
+    description: Boot timeout for instance
+    default: 1200
   metadata:
     type: json
+  node_type:
+    type: string
+  ucp_master_host:
+    type: string
+    default: ''
 
 resources:
 
+  software_config:
+    type: OS::Heat::SoftwareConfig
+    properties:
+      group: ungrouped
+      config:
+        str_replace:
+          template: { get_file: ./scripts/instance_boot.sh }
+          params:
+            $node_type:  { get_param: node_type }
+            $wait_condition_notify: { get_attr: [ wait_handle, curl_cli ] }
+            $ucp_license_key: { get_file: ./scripts/license.lic }
+            $ucp_master_host: { get_param: ucp_master_host }
+
   server:
     type: OS::Nova::Server
     properties:
@@ -41,7 +61,7 @@
         - port: { get_resource: server_port }
         - network: { get_param: private_floating_network }
       user_data_format: RAW
-      user_data: { get_param: user_data }
+      user_data: { get_resource: software_config }
       metadata: { get_param: metadata }
 
   server_port:
@@ -58,6 +78,13 @@
       floating_network_id: { get_param: public_net_id }
       port_id: { get_resource: server_port }
 
+  wait_handle:
+    type: OS::Heat::WaitConditionHandle
+  wait_condition:
+    type: OS::Heat::WaitCondition
+    properties:
+      handle: { get_resource: wait_handle }
+      timeout: { get_param: boot_timeout }
 
 outputs:
   server_private_ip: