Reboot HW servers for bm-depoyments (doesn'r require starting of deploy-bm job)

Also added TCP_QA_REFS option to deploy_bm job

PROD-36050

Change-Id: I413e3d34986fdb7a55967ba151a7a878c98535f2
diff --git a/jobs/pipelines/deploy-cicd-and-run-tests.groovy b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
index 7207b84..07684cf 100644
--- a/jobs/pipelines/deploy-cicd-and-run-tests.groovy
+++ b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
@@ -28,6 +28,18 @@
             shared.prepare_working_dir(env_manager)
         }
 
+        // Reboot Hardware before the BM deployments
+        if ("$ENV_NAME".contains("bm-")){
+            reboot_hw_nodes = env.REBOOT_HW_NODES ?: false
+            stage("Reboot HW nodes") {
+                if (reboot_hw_nodes) {
+                    shared.reboot_hardware_nodes()
+                } else {
+                    common.printMsg("REBOOT_HW_NODES is disabled. Skipping this stage...", "blue")
+                }
+            }
+        }
+
         stage("Create environment, generate model, bootstrap the salt-cluster") {
             // steps: "hardware,create_model,salt"
             if (env_manager == 'devops') {
diff --git a/jobs/pipelines/rotation_bm_deployments.groovy b/jobs/pipelines/rotation_bm_deployments.groovy
index 49103a9..222f96a 100644
--- a/jobs/pipelines/rotation_bm_deployments.groovy
+++ b/jobs/pipelines/rotation_bm_deployments.groovy
@@ -61,36 +61,6 @@
         }
     }
 
-    stage("Reboot HW nodes ") {
-        bm_ips = [
-        "185.8.59.227",
-        "185.8.59.229",
-        "5.43.225.88",
-        "5.43.225.112",
-        "5.43.225.208",
-        "5.43.227.118",
-        "185.8.58.248",
-        "185.8.59.222",
-        "5.43.225.228",
-        "5.43.229.28",
-        "5.43.225.23",
-        "185.8.58.9",
-        "185.8.58.246",
-        "185.8.58.243",
-        "185.8.58.244"
-        ]
-
-        withCredentials([
-           [$class          : 'UsernamePasswordMultiBinding',
-           credentialsId   : 'lab_engineer',
-           passwordVariable: 'lab_pass',
-           usernameVariable: 'lab_user']
-        ]) {
-            for (ip in bm_ips) { sh ("ipmitool -H ${ip} -U ${lab_user} -P ${lab_pass} chassis power off")}
-            for (ip in bm_ips) { sh ("ipmitool -H ${ip} -U ${lab_user} -P ${lab_pass} chassis bootdev pxe")}
-        }
-    }
-
     stage("Start deployment") {
       def jobs_map = [:]
       for (stack_name in stacks) {
@@ -106,7 +76,8 @@
       def deploy = build job: "${stack_to_deploy}",
       parameters: [
             string(name: 'PARENT_NODE_NAME', value: env.PARENT_NODE_NAME),
-            string(name: 'OS_CREDENTIALS', value: env.OS_CREDENTIALS)
+            string(name: 'OS_CREDENTIALS', value: env.OS_CREDENTIALS),
+            string(name: 'TCP_QA_REFS', value: env.TCP_QA_REFS)
         ]
     }
   }
diff --git a/jobs/templates/bm-cicd-pike-ovs-maas.yml b/jobs/templates/bm-cicd-pike-ovs-maas.yml
index 694630c..6b30a2a 100644
--- a/jobs/templates/bm-cicd-pike-ovs-maas.yml
+++ b/jobs/templates/bm-cicd-pike-ovs-maas.yml
@@ -2,7 +2,6 @@
     project-type: pipeline
     description: '{job-description}'
     concurrent: true
-    description: runs at H(5-15) 00 * * 1
     disabled: false
     name: bm-cicd-pike-ovs-maas
     parameters:
@@ -200,6 +199,10 @@
         default: true
         description: 'Works starting from MCP 2019.2.10 or master. Whether to apply saltstack updates on all nodes in cluster before deployment'
         name: UPGRADE_SALTSTACK
+    - bool:
+        default: true
+        description: Reboot hardware servers and set boot to PXE before the deployment
+        name: REBOOT_HW_NODES
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/jobs/templates/bm-cicd-queens-ovs-maas.yml b/jobs/templates/bm-cicd-queens-ovs-maas.yml
index ad40bdf..95b0343 100644
--- a/jobs/templates/bm-cicd-queens-ovs-maas.yml
+++ b/jobs/templates/bm-cicd-queens-ovs-maas.yml
@@ -212,6 +212,10 @@
         default: false
         description: 'Works starting from MCP 2019.2.10 or master. Whether to apply saltstack updates on all nodes in cluster before deployment'
         name: UPGRADE_SALTSTACK
+    - bool:
+        default: true
+        description: Reboot hardware servers and set boot to PXE before the deployment
+        name: REBOOT_HW_NODES
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/jobs/templates/heat-bm-cicd-pike-contrail-sl.yml b/jobs/templates/heat-bm-cicd-pike-contrail-sl.yml
index 3d9c175..531b1e9 100644
--- a/jobs/templates/heat-bm-cicd-pike-contrail-sl.yml
+++ b/jobs/templates/heat-bm-cicd-pike-contrail-sl.yml
@@ -225,6 +225,10 @@
         default: true
         description: 'Works starting from MCP 2019.2.10 or master. Whether to apply saltstack updates on all nodes in cluster before deployment'
         name: UPGRADE_SALTSTACK
+    - bool:
+        default: true
+        description: Reboot hardware servers and set boot to PXE before the deployment
+        name: REBOOT_HW_NODES
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/jobs/templates/heat-bm-cicd-queens-contrail-sl.yml b/jobs/templates/heat-bm-cicd-queens-contrail-sl.yml
index 2c0de61..09cd0fb 100644
--- a/jobs/templates/heat-bm-cicd-queens-contrail-sl.yml
+++ b/jobs/templates/heat-bm-cicd-queens-contrail-sl.yml
@@ -226,6 +226,10 @@
         default: false
         description: 'Works starting from MCP 2019.2.10 or master. Whether to apply saltstack updates on all nodes in cluster before deployment'
         name: UPGRADE_SALTSTACK
+    - bool:
+        default: true
+        description: Reboot hardware servers and set boot to PXE before the deployment
+        name: REBOOT_HW_NODES
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/src/com/mirantis/system_qa/SharedPipeline.groovy b/src/com/mirantis/system_qa/SharedPipeline.groovy
index ccb0163..1c6608c 100644
--- a/src/com/mirantis/system_qa/SharedPipeline.groovy
+++ b/src/com/mirantis/system_qa/SharedPipeline.groovy
@@ -776,4 +776,34 @@
     }
     return ret
   }
+}
+
+def reboot_hardware_nodes() {
+    bm_ips = [
+        "185.8.59.227",
+        "185.8.59.229",
+        "5.43.225.88",
+        "5.43.225.112",
+        "5.43.225.208",
+        "5.43.227.118",
+        "185.8.58.248",
+        "185.8.59.222",
+        "5.43.225.228",
+        "5.43.229.28",
+        "5.43.225.23",
+        "185.8.58.9",
+        "185.8.58.246",
+        "185.8.58.243",
+        "185.8.58.244"
+        ]
+
+    withCredentials([
+       [$class          : 'UsernamePasswordMultiBinding',
+       credentialsId   : 'lab_engineer',
+       passwordVariable: 'lab_pass',
+       usernameVariable: 'lab_user']
+    ]) {
+        for (ip in bm_ips) { sh ("ipmitool -H ${ip} -U ${lab_user} -P ${lab_pass} chassis power off")}
+        for (ip in bm_ips) { sh ("ipmitool -H ${ip} -U ${lab_user} -P ${lab_pass} chassis bootdev pxe")}
+    }
 }
\ No newline at end of file