Parametrizing timer for OLT bringup

Change-Id: I4bb7f9368d353ad4304e23112c9a4c3ab1ffc876
diff --git a/jjb/cord-test/nightly-build-pipeline.yaml b/jjb/cord-test/nightly-build-pipeline.yaml
index 940b610..7ff3007 100644
--- a/jjb/cord-test/nightly-build-pipeline.yaml
+++ b/jjb/cord-test/nightly-build-pipeline.yaml
@@ -27,6 +27,8 @@
 
     oltAdapterReleaseName: open-olt
 
+    waitTimerForOltUp: 360
+
     <<: *test-pipe-job-boiler-plate
 
     parameters:
@@ -149,6 +151,11 @@
           default: '{oltAdapterReleaseName}'
           description: 'Olt adapter release name'
 
+      - string:
+          name: waitTimerForOltUp
+          default: '{waitTimerForOltUp}'
+          description: 'Wait timer for the OLT to come up after reboot'
+
     concurrent: true
 
     pipeline-scm:
@@ -175,6 +182,8 @@
 
     oltAdapterReleaseName: open-olt
 
+    waitTimerForOltUp: 360
+
     parameters:
       - string:
           name: buildNode
@@ -265,6 +274,11 @@
           default: '{oltAdapterReleaseName}'
           description: 'Olt adapter release name'
 
+      - string:
+          name: waitTimerForOltUp
+          default: '{waitTimerForOltUp}'
+          description: 'Wait timer for the OLT to come up after reboot'
+
     concurrent: true
 
     pipeline-scm:
diff --git a/jjb/pipeline/voltha/master/physical-build.groovy b/jjb/pipeline/voltha/master/physical-build.groovy
index 1026b4a..7fa2529 100644
--- a/jjb/pipeline/voltha/master/physical-build.groovy
+++ b/jjb/pipeline/voltha/master/physical-build.groovy
@@ -332,28 +332,39 @@
     stage('Restart OLT processes') {
       steps {
         script {
+          //rebooting OLTs
           for(int i=0; i < deployment_config.olts.size(); i++) {
-            int waitTimerForOltUp = 360
-            if ( params.inBandManagement ) {
-              waitTimerForOltUp = 540
-            }
-            timeout(15) {
+            if ( params.oltAdapterReleaseName != "open-olt" ) {
+              timeout(15) {
+                sh returnStdout: true, script: """
+                ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
+                sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/openolt_process_watchdog.log; reboot > /dev/null &' || true
+                """
+              }
+            } else {
               sh returnStdout: true, script: """
               ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
-              sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/openolt_process_watchdog.log; reboot > /dev/null &' || true
-              sleep ${waitTimerForOltUp}
+              sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'reboot > /dev/null &' || true
               """
             }
-            timeout(15) {
-              waitUntil {
-                devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
-                return devprocess.toInteger() > 0
+          }
+          sh returnStdout: true, script: """
+          sleep ${params.waitTimerForOltUp}
+          """
+          //Checking dev_management_deamon and openoltprocesses
+          for(int i=0; i < deployment_config.olts.size(); i++) {
+            if ( params.oltAdapterReleaseName != "open-olt" ) {
+              timeout(15) {
+                waitUntil {
+                  devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
+                  return devprocess.toInteger() > 0
+                }
               }
-            }
-            timeout(15) {
-              waitUntil {
-                openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep openolt | wc -l'"
-                return openoltprocess.toInteger() > 0
+              timeout(15) {
+                waitUntil {
+                  openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep openolt | wc -l'"
+                  return openoltprocess.toInteger() > 0
+                }
               }
             }
           }
diff --git a/jjb/pipeline/voltha/voltha-2.8/physical-build.groovy b/jjb/pipeline/voltha/voltha-2.8/physical-build.groovy
index e7a37fe..007da19 100644
--- a/jjb/pipeline/voltha/voltha-2.8/physical-build.groovy
+++ b/jjb/pipeline/voltha/voltha-2.8/physical-build.groovy
@@ -332,28 +332,39 @@
     stage('Restart OLT processes') {
       steps {
         script {
+          //rebooting OLTs
           for(int i=0; i < deployment_config.olts.size(); i++) {
-            int waitTimerForOltUp = 360
-            if ( params.inBandManagement ) {
-              waitTimerForOltUp = 540
-            }
-            timeout(15) {
+            if ( params.oltAdapterReleaseName != "open-olt" ) {
+              timeout(15) {
+                sh returnStdout: true, script: """
+                ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
+                sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/openolt_process_watchdog.log; reboot > /dev/null &' || true
+                """
+              }
+            } else {
               sh returnStdout: true, script: """
               ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
-              sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/openolt_process_watchdog.log; reboot > /dev/null &' || true
-              sleep ${waitTimerForOltUp}
+              sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'reboot > /dev/null &' || true
               """
             }
-            timeout(15) {
-              waitUntil {
-                devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
-                return devprocess.toInteger() > 0
+          }
+          sh returnStdout: true, script: """
+          sleep ${params.waitTimerForOltUp}
+          """
+          //Checking dev_management_deamon and openoltprocesses
+          for(int i=0; i < deployment_config.olts.size(); i++) {
+            if ( params.oltAdapterReleaseName != "open-olt" ) {
+              timeout(15) {
+                waitUntil {
+                  devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
+                  return devprocess.toInteger() > 0
+                }
               }
-            }
-            timeout(15) {
-              waitUntil {
-                openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep openolt | wc -l'"
-                return openoltprocess.toInteger() > 0
+              timeout(15) {
+                waitUntil {
+                  openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep openolt | wc -l'"
+                  return openoltprocess.toInteger() > 0
+                }
               }
             }
           }
diff --git a/jjb/voltha-test/voltha-nightly-jobs.yaml b/jjb/voltha-test/voltha-nightly-jobs.yaml
index 978aaf4..a6bc3f5 100644
--- a/jjb/voltha-test/voltha-nightly-jobs.yaml
+++ b/jjb/voltha-test/voltha-nightly-jobs.yaml
@@ -9,6 +9,8 @@
 
     oltAdapterReleaseName: open-olt
 
+    waitTimerForOltUp: 360
+
     parameters:
       - string:
           name: buildNode
@@ -172,11 +174,17 @@
           default: '{openoltAdapterChart}'
           description: 'Olt adapter chart name (or location on file system)'
 
+      # this is used in the Adtran DT job
       - string:
           name: oltAdapterReleaseName
           default: '{oltAdapterReleaseName}'
           description: 'Olt adapter release name'
 
+      - string:
+          name: waitTimerForOltUp
+          default: '{waitTimerForOltUp}'
+          description: 'Wait timer for the OLT to come up after reboot'
+
 # defualt properties for the VOLTHA scale jobs
 - voltha-pipe-job-boiler-plate: &voltha-pipe-job-boiler-plate
     name: voltha-pipe-job-boiler-plate
diff --git a/jjb/voltha-test/voltha.yaml b/jjb/voltha-test/voltha.yaml
index ef81e3f..5de874a 100644
--- a/jjb/voltha-test/voltha.yaml
+++ b/jjb/voltha-test/voltha.yaml
@@ -189,6 +189,7 @@
           num-of-onos: '3'
           num-of-atomix: '3'
           in-band-management: true
+          waitTimerForOltUp: 540
           VolthaEtcdPort: 9999
           time: '1'
 
@@ -213,6 +214,7 @@
           num-of-atomix: '3'
           VolthaEtcdPort: 9999
           in-band-management: true
+          waitTimerForOltUp: 540
           time: '4'
 
       # Menlo pod test job - uses tech profile on voltha branch
@@ -501,6 +503,7 @@
           VolthaEtcdPort: 9999
           openoltAdapterChart: '/home/community/adtran-21.4-voltha-2.8/voltha-adapter-adtran-olt'
           oltAdapterReleaseName: 'adtran-olt'
+          waitTimerForOltUp: 420
           time: '21'
 
       # Berlin POD adtran test job - 2.8 versions: uses 1T8GEM tech profile on voltha branch