Deploy all the components at once in CICD jobs

Respect the mk-pipelines logic that expects the complete
list of components to select proper deployment steps.

Change-Id: I4ad62ea361b778e2bda8c255e01309590f833a61
diff --git a/jobs/pipelines/deploy-cicd-and-run-tests.groovy b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
index 8d356e4..9ceea67 100644
--- a/jobs/pipelines/deploy-cicd-and-run-tests.groovy
+++ b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
@@ -21,12 +21,12 @@
 
         stage("Install core infrastructure and deploy CICD nodes") {
             // steps: env.DRIVETRAIN_STACK_INSTALL
-            shared.swarm_deploy_cicd(env.DRIVETRAIN_STACK_INSTALL)
+            shared.swarm_deploy_cicd(env.DRIVETRAIN_STACK_INSTALL, env.DRIVETRAIN_STACK_INSTALL_TIMEOUT)
         }
 
         stage("Deploy platform components") {
             // steps: env.PLATFORM_STACK_INSTALL
-            shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL)
+            shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL, env.PLATFORM_STACK_INSTALL_TIMEOUT)
         }
 
         currentBuild.result = 'SUCCESS'
diff --git a/jobs/pipelines/swarm-deploy-cicd.groovy b/jobs/pipelines/swarm-deploy-cicd.groovy
index 7d7fd63..b6f47ee 100644
--- a/jobs/pipelines/swarm-deploy-cicd.groovy
+++ b/jobs/pipelines/swarm-deploy-cicd.groovy
@@ -7,7 +7,8 @@
  *   PARENT_NODE_NAME              Name of the jenkins slave to create the environment
  *   PARENT_WORKSPACE              Path to the workspace of the parent job to use tcp-qa repo
  *   ENV_NAME                      Fuel-devops environment name
- *   STACK_INSTALL                 Stacks to install using Jenkins on cfg01 node: "core:1800,cicd:1800", where 1800 is timeout
+ *   STACK_INSTALL                 Stacks to install using Jenkins on cfg01 node: "core,cicd"
+ *   STACK_INSTALL_TIMEOUT         Stacks installation timeout
  *   TCP_QA_REFS                   Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
  *   SHUTDOWN_ENV_ON_TEARDOWN      optional, shutdown fuel-devops environment at the end of the job
  *
@@ -24,46 +25,44 @@
 
 currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
 
-node ("${PARENT_NODE_NAME}") {
-    if (! fileExists("${PARENT_WORKSPACE}")) {
-        error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
-    }
-    dir("${PARENT_WORKSPACE}") {
+def install_timeout = env.STACK_INSTALL_TIMEOUT.toInteger()
 
-        if (! env.STACK_INSTALL) {
-            error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline"
+timeout(time: install_timeout + 600, unit: 'SECONDS') {
+
+    node ("${PARENT_NODE_NAME}") {
+        if (! fileExists("${PARENT_WORKSPACE}")) {
+            error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
         }
+        dir("${PARENT_WORKSPACE}") {
 
-        if (env.TCP_QA_REFS) {
-            stage("Update working dir to patch ${TCP_QA_REFS}") {
-                shared.update_working_dir()
+            if (! env.STACK_INSTALL) {
+                error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline"
             }
-        }
 
-        // Install core and cicd
-        def stack
-        def timeout
-
-        for (element in "${env.STACK_INSTALL}".split(",")) {
-            if (element.contains(':')) {
-                (stack, timeout) = element.split(':')
-            } else {
-                stack = element
-                timeout = '1800'
+            if (env.TCP_QA_REFS) {
+                stage("Update working dir to patch ${TCP_QA_REFS}") {
+                    shared.update_working_dir()
+                }
             }
 
             try {
-                stage("Run Jenkins job on salt-master [deploy_openstack:${stack}]") {
-                    shared.run_job_on_day01_node(stack, timeout)
+                // Install core and cicd
+                stage("Run Jenkins job on salt-master [deploy_openstack:drivetrain]") {
+                    shared.run_job_on_day01_node(env.STACK_INSTALL, install_timeout)
                 }
 
-                stage("Sanity check the deployed component [${stack}]") {
-                    shared.sanity_check_component(stack)
-                }
+                for (stack in "${env.STACK_INSTALL}".split(",")) {
+                    stage("Sanity check the deployed component [${stack}]") {
+                        shared.sanity_check_component(stack)
+                    }
+                    stage("Make environment snapshot [${stack}_deployed]") {
+                        shared.devops_snapshot(stack)
+                    }
+                } // for
 
             } catch (e) {
                 common.printMsg("Job is failed", "purple")
-                shared.download_logs("deploy_${stack}")
+                shared.download_logs("deploy_drivetrain")
                 throw e
             } finally {
                 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
@@ -76,10 +75,6 @@
                 }
             }
 
-            stage("Make environment snapshot [${stack}_deployed]") {
-                shared.devops_snapshot(stack)
-            }
-
-        } // for
-    } // dir
-} // node
+        } // dir
+    } // node
+}
\ No newline at end of file
diff --git a/jobs/pipelines/swarm-deploy-platform.groovy b/jobs/pipelines/swarm-deploy-platform.groovy
index 42ebc7e..c8dd78b 100644
--- a/jobs/pipelines/swarm-deploy-platform.groovy
+++ b/jobs/pipelines/swarm-deploy-platform.groovy
@@ -7,7 +7,8 @@
  *   PARENT_NODE_NAME              Name of the jenkins slave to create the environment
  *   PARENT_WORKSPACE              Path to the workspace of the parent job to use tcp-qa repo
  *   ENV_NAME                      Fuel-devops environment name
- *   STACK_INSTALL                 Stacks to install using Jenkins on CICD cluster: "openstack:3200,stacklight:2400", where 3200 and 2400 are timeouts
+ *   STACK_INSTALL                 Stacks to install using Jenkins on CICD cluster: "openstack,stacklight"
+ *   STACK_INSTALL_TIMEOUT         Stacks installation timeout
  *   TCP_QA_REFS                   Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
  *   SHUTDOWN_ENV_ON_TEARDOWN      optional, shutdown fuel-devops environment at the end of the job
  *
@@ -24,47 +25,44 @@
 
 currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
 
-node ("${PARENT_NODE_NAME}") {
-    if (! fileExists("${PARENT_WORKSPACE}")) {
-        error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
-    }
-    dir("${PARENT_WORKSPACE}") {
+def install_timeout = env.STACK_INSTALL_TIMEOUT.toInteger()
 
-        if (! env.STACK_INSTALL) {
-            error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline"
+timeout(time: install_timeout + 600, unit: 'SECONDS') {
+
+    node ("${PARENT_NODE_NAME}") {
+        if (! fileExists("${PARENT_WORKSPACE}")) {
+            error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
         }
+        dir("${PARENT_WORKSPACE}") {
 
-        if (env.TCP_QA_REFS) {
-            stage("Update working dir to patch ${TCP_QA_REFS}") {
-                shared.update_working_dir()
+            if (! env.STACK_INSTALL) {
+                error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline"
             }
-        }
 
-        // Install the cluster
-        def stack
-        def timeout
-
-        for (element in "${STACK_INSTALL}".split(",")) {
-            if (element.contains(':')) {
-                (stack, timeout) = element.split(':')
-            } else {
-                stack = element
-                timeout = '1800'
+            if (env.TCP_QA_REFS) {
+                stage("Update working dir to patch ${TCP_QA_REFS}") {
+                    shared.update_working_dir()
+                }
             }
 
             try {
-
-                stage("Run Jenkins job on CICD [deploy_openstack:${stack}]") {
-                    shared.run_job_on_cicd_nodes(stack, timeout)
+                // Install the cluster
+                stage("Run Jenkins job on CICD [deploy_openstack:platform]") {
+                    shared.run_job_on_cicd_nodes(env.STACK_INSTALL, install_timeout)
                 }
 
-                stage("Sanity check the deployed component [${stack}]") {
-                    shared.sanity_check_component(stack)
-                }
+                for (stack in "${env.STACK_INSTALL}".split(",")) {
+                    stage("Sanity check the deployed component [${stack}]") {
+                        shared.sanity_check_component(stack)
+                    }
+                    stage("Make environment snapshot [${stack}_deployed]") {
+                        shared.devops_snapshot(stack)
+                    }
+                } // for
 
             } catch (e) {
                 common.printMsg("Job is failed", "purple")
-                shared.download_logs("deploy_${stack}")
+                shared.download_logs("deploy_platform")
                 throw e
             } finally {
                 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
@@ -77,10 +75,6 @@
                 }
             }
 
-            stage("Make environment snapshot [${stack}_deployed]") {
-                shared.devops_snapshot(stack)
-            }
-
-        } // for
-    } // dir
-} // node
+        } // dir
+    } // node
+}
\ No newline at end of file
diff --git a/src/com/mirantis/system_qa/SharedPipeline.groovy b/src/com/mirantis/system_qa/SharedPipeline.groovy
index 9b5621d..4a0a134 100644
--- a/src/com/mirantis/system_qa/SharedPipeline.groovy
+++ b/src/com/mirantis/system_qa/SharedPipeline.groovy
@@ -168,7 +168,7 @@
         build_pipeline_job('swarm-bootstrap-salt-cluster-devops', parameters)
 }
 
-def swarm_deploy_cicd(String stack_to_install='core,cicd') {
+def swarm_deploy_cicd(String stack_to_install, String install_timeout) {
         // Run openstack_deploy job on cfg01 Jenkins for specified stacks
         def common = new com.mirantis.mk.Common()
         def tcp_qa_refs = env.TCP_QA_REFS ?: ''
@@ -177,13 +177,14 @@
                 string(name: 'PARENT_WORKSPACE', value: pwd()),
                 string(name: 'ENV_NAME', value: "${ENV_NAME}"),
                 string(name: 'STACK_INSTALL', value: stack_to_install),
+                string(name: 'STACK_INSTALL_TIMEOUT', value: install_timeout),
                 string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"),
                 booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false),
             ]
         build_pipeline_job('swarm-deploy-cicd', parameters)
 }
 
-def swarm_deploy_platform(String stack_to_install) {
+def swarm_deploy_platform(String stack_to_install, String install_timeout) {
         // Run openstack_deploy job on CICD Jenkins for specified stacks
         def common = new com.mirantis.mk.Common()
         def tcp_qa_refs = env.TCP_QA_REFS ?: ''
@@ -192,6 +193,7 @@
                 string(name: 'PARENT_WORKSPACE', value: pwd()),
                 string(name: 'ENV_NAME', value: "${ENV_NAME}"),
                 string(name: 'STACK_INSTALL', value: stack_to_install),
+                string(name: 'STACK_INSTALL_TIMEOUT', value: install_timeout),
                 string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"),
                 booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false),
             ]