get logical id of OLTs for collect logs if missing

Change-Id: I5779ab10c0040878e10e28570d8667bf70b2e90e
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index 8b9586d..3e552be 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -28,6 +28,21 @@
     ${new_timeout}=    Catenate    SEPARATOR=    ${new_timeout}    s
     [Return]    ${new_timeout}
 
+Get Logical Id of OLT
+    [Documentation]    Fills the logical id of OLT(s) if missing
+    FOR    ${I}    IN RANGE    0    ${num_olts}
+        # exit loop if logical id already known
+        Exit For Loop IF    "${olt_ids}[${I}][logical_id]" != "${EMPTY}"
+        #read current device values
+        ${olt}=    Get From List    ${olt_ids}    ${I}
+        ${olt_serial_number}=     Get From Dictionary    ${olt}    sn
+        # read logical id and store it
+        ${logical_id}=    Get Logical Device ID From SN    ${olt_serial_number}
+        Set To Dictionary    ${olt}    logical_id    ${logical_id}
+        Set List Value    ${olt_ids}    ${I}    ${olt}
+    END
+    Set Global Variable    ${olt_ids}
+
 Power On ONU Device
     [Documentation]    This keyword turns on the power for all onus.
     [Arguments]    ${namespace}
diff --git a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
index eab6545..14c7964 100755
--- a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
@@ -93,7 +93,8 @@
     ...    AND    Setup Test
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Do Reconcile In Determined State    starting-openomci
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Get Logical Id of OLT
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileStartingOpenOmciOnuGo
 
@@ -111,7 +112,8 @@
     ...    AND    Setup Test
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Do Reconcile In Determined State    initial-mib-downloaded
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Get Logical Id of OLT
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileInitialMibDownloadedOnuGo
 
@@ -135,7 +137,8 @@
     ...    AND    Setup Test
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Do Reconcile In Omci-Flows-Pushed
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Get Logical Id of OLT
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileOmciFlowsPushedOnuGo
 
@@ -158,7 +161,8 @@
     ...    AND    Setup Test
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Do Reconcile For Disabled Onu Device
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Get Logical Id of OLT
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileDisabledOnuDeviceOnuGo
 
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index ba3c207..4f653de 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -98,7 +98,8 @@
     ...    ELSE IF    "${testmode}"=="Up2State"    Do ONU Up To State Test
     ...    ELSE IF    "${testmode}"=="SingleStateTime"    Do ONU Single State Test Time
     ...    ELSE    Fail    The testmode (${testmode}) is not valid!
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Get Logical Id of OLT
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUStateTest
 
 Check Loaded Tech Profile