jenkins file to reboot compute nodes

Change-Id: I6c13d7ddebe1339ce0fb2b164f7087d348ddcddb
diff --git a/Jenkinsfile b/Jenkinsfile
index 3cc1f13..4bee85a 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -51,6 +51,29 @@
             stage 'Deploy'
             sh 'vagrant ssh -c "cd /cord/build; ./gradlew -PtargetReg=10.90.0.251:5000 -PdeployConfig=config/onlab_develop_pod.yml deploy" corddev'
 
+            stage 'Power cycle compute nodes'
+            parallel(
+                compute_1: {
+                    sh "ipmitool -U admin -P admin -H 10.90.0.10 power cycle"
+                }, compute_2: {
+                    sh "ipmitool -U admin -P admin -H 10.90.0.11 power cycle"
+                }, failfast : true
+            )
+
+            stage 'Wait for compute nodes to get deployed'
+            def cordapikey = sh(returnStdout: true, script: 'sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 sudo maas-region-admin apikey --username cord') 
+            sh 'sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 maas login pod-maas http://10.90.0.251/MAAS/api/1.0 $cordapikey'
+            timeout(time: 30) {
+                waitUntil {
+                    try {
+                        num = sh(returnStdout: true, script: 'sshpass -p ${headnodepass} ssh -l ${headnodeuser} 10.90.0.251  maas pod-maas nodes list | grep Deployed')
+                        return num == 2
+                    } catch (exception) {
+                        return false
+                    }
+                }
+            }
+
             currentBuild.result = 'SUCCESS'
             step([$class: 'Mailer', recipients: 'cord-dev@opencord.org', sendToIndividuals: false])
         } catch (err) {