[VOL-4516] OpenOnuAdapter output assignment of ONU serial-number to device-ID

Change-Id: I4caab18610dff88d83afd16570ecb1907f43560e
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index 4309899..c3eda8a 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -18,6 +18,20 @@
 
 
 *** Keywords ***
+Printout ONU Serial Number and Device Id
+    [Documentation]    Printouts the ONU serial number and corresponding device id.
+    [Arguments]    ${onu_sn}=${EMPTY}    ${print2console}=False
+    ${output}=    Set Variable    \r\n
+    ${onu_sn_list}    Create List
+    Run Keyword If    "${onu_sn}"=="${EMPTY}"     Build ONU SN List    ${onu_sn_list}
+    ...               ELSE     Append To List    ${onu_sn_list}    ${onu_sn}
+    FOR    ${sn}    IN    @{onu_sn_list}
+        ${device_id}=    Get Device ID From SN    ${sn}
+        ${output}=    Catenate    ${output}    ONU Serial Number: ${sn} ONU Device ID: ${device_id}\r\n
+    END
+    Log    ${output}
+    Run Keyword If    ${print2console}    Log    ${output}    console=yes
+
 Calculate Timeout
     [Documentation]    Calculates the timeout regarding num-onus in case of more than 4 onus
     [Arguments]    ${basetimeout}=60s
diff --git a/tests/openonu-go-adapter/Voltha_ONUFlowChecks.robot b/tests/openonu-go-adapter/Voltha_ONUFlowChecks.robot
index c9d8818..739605f 100755
--- a/tests/openonu-go-adapter/Voltha_ONUFlowChecks.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUFlowChecks.robot
@@ -104,7 +104,8 @@
     log     ${flowsresult}
     Wait Until Keyword Succeeds    ${timeout}    2s    Run Keyword And Continue On Failure    Run Keyword And Continue On Failure
     ...    Validate Etcd Vlan Rules Added Subscriber    ${onu_tags_dict}    defaultkvstoreprefix=${kvstoreprefix}
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id
+    ...           AND    Run Keyword If    ${logging}    Collect Logs
     ...           AND    Stop Logging    FlowsTest
 
 *** Keywords ***
diff --git a/tests/openonu-go-adapter/Voltha_ONUNegativeStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUNegativeStateTests.robot
index 012c724..3e57095 100755
--- a/tests/openonu-go-adapter/Voltha_ONUNegativeStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUNegativeStateTests.robot
@@ -90,7 +90,8 @@
         Current State Test All Onus    starting-openomci    timeout=1x
         Exit For Loop If    not ${StateTestAllONUs}
     END
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords   Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUStateTest
 
 
diff --git a/tests/openonu-go-adapter/Voltha_ONUOmciGetTest.robot b/tests/openonu-go-adapter/Voltha_ONUOmciGetTest.robot
index 8961c34..69ad4b4 100755
--- a/tests/openonu-go-adapter/Voltha_ONUOmciGetTest.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUOmciGetTest.robot
@@ -30,6 +30,7 @@
 Resource          ../../libraries/voltha.robot
 Resource          ../../libraries/utils.robot
 Resource          ../../libraries/k8s.robot
+Resource          ../../libraries/onu_utilities.robot
 Resource          ../../variables/variables.robot
 Resource          ../../libraries/power_switch.robot
 
@@ -78,7 +79,8 @@
         Should Contain    ${output}    LASER_BIAS_CURRENT__mA:
         Should Contain    ${output}    TEMPERATURE__Celsius:
     END
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id
+    ...           AND    Run Keyword If    ${logging}    Collect Logs
     ...           AND    Stop Logging    SanityTestOnuGo
 
 *** Keywords ***
diff --git a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
index 1cf19cf..9b4ab93 100755
--- a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
@@ -99,7 +99,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}    Get Logical Id of OLT
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Get Logical Id of OLT
     ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileStartingOpenOmciOnuGo
@@ -118,7 +119,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}    Get Logical Id of OLT
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Get Logical Id of OLT
     ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileInitialMibDownloadedOnuGo
@@ -143,7 +145,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}    Get Logical Id of OLT
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Get Logical Id of OLT
     ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileOmciFlowsPushedOnuGo
@@ -167,7 +170,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}    Get Logical Id of OLT
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Get Logical Id of OLT
     ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    ReconcileDisabledOnuDeviceOnuGo
@@ -191,7 +195,8 @@
     ...    AND    Setup Test
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Do Olt Deletion After Adapter Restart
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Get Logical Id of OLT
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Get Logical Id of OLT
     ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    OltDeletionAfterAdapterRestartOnuGo
@@ -209,7 +214,8 @@
     ...    AND    Setup Test
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Do Flow Deletion After Adapter Restart
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Get Logical Id of OLT
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Get Logical Id of OLT
     ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Teardown Test
     ...    AND    Stop Logging    FlowDeletionAfterAdapterRestartOnuGo
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index a9372a5..67f7b4c 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -104,7 +104,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}    Get Logical Id of OLT
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Get Logical Id of OLT
     ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUStateTest
 
@@ -117,7 +118,8 @@
     Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
     ...    Do Check Tech Profile    ${INFRA_NAMESPACE}
     ...    ELSE    Pass Execution    ${skip_message}    skipped
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUCheckTechProfile
 
 Onu Port Check
@@ -128,7 +130,8 @@
     Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
     ...    Do Onu Port Check
     ...    ELSE    Pass Execution    ${skip_message}    skipped
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUPortTest
 
 Onu Etcd Data Check
@@ -139,7 +142,8 @@
     Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
     ...    Do Onu Etcd Data Check
     ...    ELSE    Pass Execution    ${skip_message}    skipped
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUEtcdDataTest
 
 Onu Flow Check
@@ -149,7 +153,8 @@
     [Setup]    Start Logging    ONUFlowTest
     Run Keyword If    '${onu_state}'=='omci-flows-pushed'    Do Onu Flow Check
     ...    ELSE    Pass Execution    ${skip_message}    skipped
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUFlowTest
 
 Disable Enable Onu Device
@@ -160,7 +165,8 @@
     Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
     ...    Do Disable Enable Onu Test
     ...    ELSE    Pass Execution    ${skip_message}    skipped
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    DisableEnableONUDevice
 
 Power Off Power On Onu Device
@@ -171,7 +177,8 @@
     Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
     ...    Do Power Off Power On Onu Device    ${NAMESPACE}
     ...    ELSE    Pass Execution    ${skip_message}    skipped
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    PowerOffPowerOnONUDevice
 
 Soft Reboot Onu Device
@@ -182,7 +189,8 @@
     Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
     ...    Do Soft Reboot Onu Device
     ...    ELSE    Pass Execution    ${skip_message}    skipped
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id    print2console=${print2console}
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    SoftRebootONUDevice
 
 *** Keywords ***
diff --git a/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot b/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot
index f4bbe9b..7dd266f 100755
--- a/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot
@@ -83,7 +83,8 @@
     [Setup]    Run Keywords    Start Logging    ONUMibTemplateTest
     ...    AND    Setup
     Perform ONU MIB Template Data Test
-    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    [Teardown]    Run Keywords    Printout ONU Serial Number and Device Id
+    ...    AND    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUMibTemplateTest