[VOL-3345] changes for in-band in voltha-2.4

Change-Id: Ibe72d06aee75adb1b108d8d5e89b2b696ee7fb21
diff --git a/.gitreview b/.gitreview
index 4e39788..603661b 100644
--- a/.gitreview
+++ b/.gitreview
@@ -3,3 +3,4 @@
 port=29418
 project=voltha-system-tests.git
 defaultremote=origin
+defaultbranch=voltha-2.4
diff --git a/Jenkinsfile-voltha-build b/Jenkinsfile-voltha-build
index f51a11d..d472d68 100644
--- a/Jenkinsfile-voltha-build
+++ b/Jenkinsfile-voltha-build
@@ -260,8 +260,12 @@
             if ( deployment_config.fabric_switches.size() > 0 ) {
                 stage('Switch Configurations in ONOS') {
                     timeout(1) {
+                        def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
+                        if (params.inBandManagement){
+                             netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
+                        }
                         netcfg_out = sh returnStatus: true, script: """
-                        curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json
+                        curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @${netcfg}
                         curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
 
                         """
@@ -307,7 +311,35 @@
                     }
                 }
             }
-            currentBuild.result = 'SUCCESS'
+
+
+
+          if ( params.inBandManagement ) {
+                stage('Reboot OLT') {
+                    for(int i=0; i < deployment_config.olts.size(); i++) {
+                        timeout(5) {
+                            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; reboot' || true
+                            sleep 200
+                            """
+                        }
+                        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
+                            }
+                        }
+                    }
+                }
+            }
+  currentBuild.result = 'SUCCESS'
         } catch (err) {
             currentBuild.result = 'FAILURE'
             step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 43872e8..9822186 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -62,6 +62,7 @@
     ${HEADERS}    Create Dictionary    Content-Type=application/json
     Create Session    ONOS    http://${ONOS_REST_IP}:${ONOS_REST_PORT}    auth=${ONOS_AUTH}
     ${olt_ip}=    Evaluate    ${olts}[0].get("ip")
+    ${olt_ssh_ip}=    Evaluate    ${olts}[0].get("sship")
     ${olt_user}=    Evaluate    ${olts}[0].get("user")
     ${olt_pass}=    Evaluate    ${olts}[0].get("pass")
     ${olt_serial_number}=    Evaluate    ${olts}[0].get("serial")
@@ -74,6 +75,7 @@
     Set Suite Variable    ${num_onus}
     Set Suite Variable    ${olt_serial_number}
     Set Suite Variable    ${olt_ip}
+    Set Suite Variable    ${olt_sship}
     Set Suite Variable    ${olt_user}
     Set Suite Variable    ${olt_pass}
     @{container_list}=    Create List    adapter-open-olt    adapter-open-onu    voltha-api-server
@@ -444,10 +446,10 @@
     [Documentation]     Echoes ${message} into the OLT logs
     Wait Until Keyword Succeeds    180s    10s    Execute Remote Command
     ...    printf '%s\n' '' '' '${message}' '' >> /var/log/openolt.log
-    ...    ${olt_ip}    ${olt_user}    ${olt_pass}
+    ...    ${olt_ssh_ip}    ${olt_user}    ${olt_pass}
     Wait Until Keyword Succeeds    180s    10s    Execute Remote Command
     ...    printf '%s\n' '' '' '${message}' '' >> /var/log/dev_mgmt_daemon.log
-    ...    ${olt_ip}    ${olt_user}    ${olt_pass}
+    ...    ${olt_ssh_ip}    ${olt_user}    ${olt_pass}
 
 Start Logging
     [Arguments]    ${label}
diff --git a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
index 9ceb958..60c7fa7 100644
--- a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
+++ b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
@@ -153,7 +153,7 @@
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test DT
     # Reboot the OLT from the OLT CLI
     Run Keyword If    ${has_dataplane}    Login And Run Command On Remote System
-    ...    sudo reboot    ${olt_ip}    ${olt_user}    ${olt_pass}   prompt=#
+    ...    sudo reboot    ${olt_ssh_ip}    ${olt_user}    ${olt_pass}   prompt=#
     Run Keyword And Ignore Error    Collect Logs
     FOR    ${I}    IN RANGE    0    ${num_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
@@ -165,7 +165,7 @@
     END
     # Wait for the OLT to come back up
     Run Keyword If    ${has_dataplane}    Wait Until Keyword Succeeds    120s    10s
-    ...    Check Remote System Reachability    True    ${olt_ip}
+    ...    Check Remote System Reachability    True    ${olt_ssh_ip}
     # Waiting extra time for the ONUs to come up
     Sleep    60s
     Run Keyword And Ignore Error    Collect Logs
@@ -414,7 +414,7 @@
     END
     # Wait for the OLT to come back up
     Run Keyword If    ${has_dataplane}    Wait Until Keyword Succeeds    120s    10s
-    ...    Check Remote System Reachability    True    ${olt_ip}
+    ...    Check Remote System Reachability    True    ${olt_ssh_ip}
     # Waiting extra time for the ONUs to come up
     Sleep    60s
     # Check OLT states
diff --git a/tests/functional/Voltha_FailureScenarios.robot b/tests/functional/Voltha_FailureScenarios.robot
index 6193a61..b0f2f58 100644
--- a/tests/functional/Voltha_FailureScenarios.robot
+++ b/tests/functional/Voltha_FailureScenarios.robot
@@ -148,7 +148,7 @@
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
     # Reboot the OLT from the OLT CLI
     Run Keyword If    ${has_dataplane}    Login And Run Command On Remote System
-    ...    sudo reboot    ${olt_ip}    ${olt_user}    ${olt_pass}   prompt=#
+    ...    sudo reboot    ${olt_ssh_ip}    ${olt_user}    ${olt_pass}   prompt=#
     Run Keyword And Ignore Error    Collect Logs
     FOR    ${I}    IN RANGE    0    ${num_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
@@ -160,7 +160,7 @@
     END
     # Wait for the OLT to come back up
     Run Keyword If    ${has_dataplane}    Wait Until Keyword Succeeds    120s    10s
-    ...    Check Remote System Reachability    True    ${olt_ip}
+    ...    Check Remote System Reachability    True    ${olt_ssh_ip}
     # Waiting extra time for the ONUs to come up
     Sleep    60s
     Run Keyword And Ignore Error    Collect Logs
diff --git a/tests/functional/Voltha_FailureScenarios2.robot b/tests/functional/Voltha_FailureScenarios2.robot
index 0cd53f0..5c3c3d3 100644
--- a/tests/functional/Voltha_FailureScenarios2.robot
+++ b/tests/functional/Voltha_FailureScenarios2.robot
@@ -81,7 +81,7 @@
     END
     # Wait for the OLT to come back up
     Run Keyword If    ${has_dataplane}    Wait Until Keyword Succeeds    120s    10s
-    ...    Check Remote System Reachability    True    ${olt_ip}
+    ...    Check Remote System Reachability    True    ${olt_ssh_ip}
     # Waiting extra time for the ONUs to come up
     Sleep    60s
     # Check OLT states
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index 692df08..929f815 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -91,7 +91,7 @@
     #test for empty device list
     Test Empty Device List
     Run Keyword If    ${has_dataplane}    Wait Until Keyword Succeeds    120s    10s    Openolt is Up
-    ...    ${olt_ip}    ${olt_user}    ${olt_pass}
+    ...    ${olt_ssh_ip}    ${olt_user}    ${olt_pass}
     Run Keyword If    ${has_dataplane}    Sleep    60s
     #create/preprovision device
     ${olt_device_id}=    Create Device    ${olt_ip}    ${OLT_PORT}