[VOL-3739] Update Disable/Enable PON port test case with multi-olt framework

Change-Id: Ib83fb4a1ff1a19a65a36606ff02667023eafd2d6
diff --git a/Makefile b/Makefile
index 5612ea8..68b25ae 100755
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@
              --configure TooManyTestCases:50 -e TooManyTestCases \
              --configure TooFewTestSteps:1 \
              --configure TooFewKeywordSteps:1 \
-             --configure FileTooLong:1300 -e FileTooLong \
+             --configure FileTooLong:1500 -e FileTooLong \
              -e TrailingWhitespace
 
 PYTHON_FILES := $(wildcard libraries/*.py)
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 139bb26..247d870 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -679,15 +679,46 @@
         Run Keyword and Ignore Error   Collect Logs
     END
 
+Disable Enable PON Port Per OLT
+    [Arguments]    ${olt_serial_number}
+    [Documentation]    This keyword disables and then enables OLT PON port and
+    ...    also validate ONUs for each corresponding case
+    ${olt_device_id}=    Get OLTDeviceID From OLT List    ${olt_serial_number}
+    ${olt_pon_port_list}=    Retrieve OLT PON Ports    ${olt_device_id}
+    ${olt_pon_port_list_len}=    Get Length    ${olt_pon_port_list}
+    FOR    ${INDEX0}    IN RANGE    0    ${olt_pon_port_list_len}
+        ${olt_pon_port}=    Get From List    ${olt_pon_port_list}    ${INDEX0}
+        ${olt_peer_list}=    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}
+        # Disable the OLT PON Port and Validate OLT Device
+        DisableOrEnable OLT PON Port    disable    ${olt_device_id}    ${olt_pon_port}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
+        ...    DISABLED    DISCOVERED
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT Device    ENABLED    ACTIVE    REACHABLE
+        ...    ${olt_serial_number}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate ONUs for PON OLT Disable    ${olt_serial_number}    ${olt_peer_list}
+        # Enable the OLT PON Port back, and check ONU status are back to "ACTIVE"
+        DisableOrEnable OLT PON Port    enable    ${olt_device_id}    ${olt_pon_port}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
+        ...    ENABLED    ACTIVE
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate ONUs for PON OLT Enable    ${olt_serial_number}    ${olt_peer_list}
+    END
+
 Validate ONUs for PON OLT Disable
-    [Arguments]    ${olt_peer_list}
+    [Arguments]    ${olt_sn}    ${olt_peer_list}
     [Documentation]     This keyword validates that Ping fails for ONUs connected to Disabled OLT PON port
     ...    And Pings succeed for other Active OLT PON port ONUs
     ...    Also it removes subscriber for Disabled OLT PON port ONUs to replicate ATT workflow
-    FOR    ${I}    IN RANGE    0    ${num_all_nus}
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_sn}"!="${src['olt']}"
         ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS    ${src['olt']}
         ${onu_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get ONU Port in ONOS    ${src['onu']}
         ...    ${of_id}
         ${matched}=    Match ONU in PON OLT Peer List    ${olt_peer_list}    ${onu_device_id}
@@ -695,7 +726,7 @@
         ...    Run Keywords
         ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
         ...    Validate Device    ENABLED    DISCOVERED
-        ...    UNREACHABLE    ${src['onu']}    onu=True    onu_reason=stopping-openomci
+        ...    UNREACHABLE    ${src['onu']}    onu=True    onu_reason=omci-flows-deleted
         ...    AND    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds   ${timeout}    2s
         ...    Verify ONU Port Is Disabled   ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${src['onu']}
         ...    AND    Run Keyword If    ${has_dataplane}    Run Keyword And Continue On Failure
@@ -716,13 +747,15 @@
     END
 
 Validate ONUs for PON OLT Enable
-    [Arguments]    ${olt_peer_list}
+    [Arguments]    ${olt_sn}    ${olt_peer_list}
     [Documentation]    This keyword validates Ping succeeds for all Enabled/Acitve OLT PON ports
     ...    Also performs Auth/subscriberAdd/DHCP/Ping for the ONUs on Re-Enabled OLT PON port
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_sn}"!="${src['olt']}"
         ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS    ${src['olt']}
         ${onu_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get ONU Port in ONOS    ${src['onu']}
         ...    ${of_id}
         ${matched}=    Match ONU in PON OLT Peer List    ${olt_peer_list}    ${onu_device_id}
@@ -778,15 +811,50 @@
         Run Keyword and Ignore Error    Collect Logs
     END
 
+Disable Enable PON Port Per OLT DT
+    [Arguments]    ${olt_serial_number}
+    [Documentation]    This keyword disables and then enables OLT PON port and
+    ...    also validate ONUs for each corresponding case
+    ${olt_device_id}=    Get OLTDeviceID From OLT List    ${olt_serial_number}
+    ${olt_pon_port_list}=    Retrieve OLT PON Ports    ${olt_device_id}
+    ${olt_pon_port_list_len}=    Get Length    ${olt_pon_port_list}
+    FOR    ${INDEX0}    IN RANGE    0    ${olt_pon_port_list_len}
+        ${olt_pon_port}=    Get From List    ${olt_pon_port_list}    ${INDEX0}
+        ${olt_peer_list}=    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}
+        # Disable the OLT PON Port and Validate OLT Device
+        DisableOrEnable OLT PON Port    disable    ${olt_device_id}    ${olt_pon_port}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
+        ...    DISABLED    DISCOVERED
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT Device    ENABLED    ACTIVE    REACHABLE
+        ...    ${olt_serial_number}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate ONUs for PON OLT Disable DT    ${olt_serial_number}    ${olt_peer_list}
+        Sleep    15s
+        # Enable the OLT PON Port back, and check ONU status are back to "ACTIVE"
+        DisableOrEnable OLT PON Port    enable    ${olt_device_id}    ${olt_pon_port}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
+        ...    ENABLED    ACTIVE
+        # Waiting extra time for the ONUs to come up
+        Sleep    60s
+        ${olt_peer_list_new}=    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate ONUs for PON OLT Enable DT    ${olt_serial_number}    ${olt_peer_list_new}
+    END
+
 Validate ONUs for PON OLT Disable DT
-    [Arguments]    ${olt_peer_list}
+    [Arguments]    ${olt_sn}    ${olt_peer_list}
     [Documentation]     This keyword validates that Ping fails for ONUs connected to Disabled OLT PON port
     ...    And Pings succeed for other Active OLT PON port ONUs
     ...    Also it removes subscriber and deletes ONUs for Disabled OLT PON port to replicate DT workflow
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_sn}"!="${src['olt']}"
         ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS    ${src['olt']}
         ${onu_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get ONU Port in ONOS    ${src['onu']}
         ...    ${of_id}
         ${matched}=    Match ONU in PON OLT Peer List    ${olt_peer_list}    ${onu_device_id}
@@ -819,13 +887,15 @@
     END
 
 Validate ONUs for PON OLT Enable DT
-    [Arguments]    ${olt_peer_list}
+    [Arguments]    ${olt_sn}    ${olt_peer_list}
     [Documentation]    This keyword validates Ping succeeds for all Enabled/Acitve OLT PON ports
     ...    Also performs subscriberAdd/DHCP/Ping for the ONUs on Re-Enabled OLT PON port
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_sn}"!="${src['olt']}"
         ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS    ${src['olt']}
         ${onu_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get ONU Port in ONOS    ${src['onu']}
         ...    ${of_id}
         ${matched}=    Match ONU in PON OLT Peer List    ${olt_peer_list}    ${onu_device_id}
@@ -1016,7 +1086,7 @@
 
 Clean dhclient
     [Documentation]    Kills dhclient processes only for all RGs
-    FOR    ${I}    IN RANGE    0    ${num_all_nus}
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
         Execute Remote Command    sudo pkill dhclient    ${src['ip']}
diff --git a/tests/dt-workflow/Voltha_DT_PODTests.robot b/tests/dt-workflow/Voltha_DT_PODTests.robot
index 869d7ac..14c759f 100644
--- a/tests/dt-workflow/Voltha_DT_PODTests.robot
+++ b/tests/dt-workflow/Voltha_DT_PODTests.robot
@@ -600,37 +600,13 @@
     ...    Assuming that all the ONUs are DHCP/pingable (i.e. assuming sanityDt test was executed)
     ...    Perform disable on the OLT PON Port and validate that the pings do not succeed
     ...    Perform enable on the OLT PON Port and validate that the pings are successful
-    [Tags]    functionalDt    DisableEnableOltPonPortDt    VOL-2577    notready
+    [Tags]    functionalDt    DisableEnableOltPonPortDt    VOL-2577
     [Setup]    Start Logging    DisableEnableOltPonPortDt
     [Teardown]    Run Keywords    Collect Logs
     ...           AND             Stop Logging    DisableEnableOltPonPortDt
-    TODO: Fix the keywords and test later
-    ${olt_pon_port_list}=    Retrieve OLT PON Ports    ${olt_device_id}
-    ${olt_pon_port_list_len}=    Get Length    ${olt_pon_port_list}
-    FOR    ${INDEX0}    IN RANGE    0    ${olt_pon_port_list_len}
-        ${olt_pon_port}=    Get From List    ${olt_pon_port_list}    ${INDEX0}
-        ${olt_peer_list}=    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}
-        # Disable the OLT PON Port and Validate OLT Device
-        DisableOrEnable OLT PON Port    disable    ${olt_device_id}    ${olt_pon_port}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
-        ...    DISABLED    DISCOVERED
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT Device    ENABLED    ACTIVE    REACHABLE
-        ...    ${olt_serial_number}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate ONUs for PON OLT Disable DT    ${olt_peer_list}
-        Sleep    15s
-        # Enable the OLT PON Port back, and check ONU status are back to "ACTIVE"
-        DisableOrEnable OLT PON Port    enable    ${olt_device_id}    ${olt_pon_port}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
-        ...    ENABLED    ACTIVE
-        # Waiting extra time for the ONUs to come up
-        Sleep    60s
-        ${olt_peer_list_new}=    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate ONUs for PON OLT Enable DT    ${olt_peer_list_new}
+    FOR   ${I}    IN RANGE    0    ${olt_count}
+        ${olt_serial_number}=    Get From Dictionary    ${olt_ids}[${I}]    sn
+        Disable Enable PON Port Per OLT DT    ${olt_serial_number}
     END
 
 *** Keywords ***
@@ -649,4 +625,3 @@
     Delete All Devices and Verify
     # Execute normal test Setup Keyword
     Setup
-
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index 7c2ee38..1fb30f8 100644
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_PODTests.robot
@@ -683,37 +683,18 @@
     ...    Assuming that all the ONUs are DHCP/pingable (i.e. assuming sanityDt test was executed)
     ...    Perform disable on the OLT PON Port and validate that the pings do not succeed
     ...    Perform enable on the OLT PON Port and validate that the pings are successful
-    [Tags]    functional    DisableEnableOltPonPort    VOL-2577    notready
+    [Tags]    functional    DisableEnableOltPonPort    VOL-2577
     [Setup]    Run Keywords    Start Logging    DisableEnableOltPonPort
     ...        AND    Setup
     [Teardown]    Run Keywords    Collect Logs
     ...           AND             Stop Logging    DisableEnableOltPonPort
-    ...           AND             Delete Device and Verify
-    #TODO: Update this test for new framework changes
+    ...           AND             Delete All Devices and Verify
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
-    ${olt_pon_port_list}=    Retrieve OLT PON Ports    ${olt_device_id}
-    ${olt_pon_port_list_len}=    Get Length    ${olt_pon_port_list}
-    FOR    ${INDEX0}    IN RANGE    0    ${olt_pon_port_list_len}
-        ${olt_pon_port}=    Get From List    ${olt_pon_port_list}    ${INDEX0}
-        ${olt_peer_list}=    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}
-        # Disable the OLT PON Port and Validate OLT Device
-        DisableOrEnable OLT PON Port    disable    ${olt_device_id}    ${olt_pon_port}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
-        ...    DISABLED    DISCOVERED
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT Device    ENABLED    ACTIVE    REACHABLE
-        ...    ${olt_serial_number}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate ONUs for PON OLT Disable    ${olt_peer_list}
-        # Enable the OLT PON Port back, and check ONU status are back to "ACTIVE"
-        DisableOrEnable OLT PON Port    enable    ${olt_device_id}    ${olt_pon_port}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT PON Port Status    ${olt_device_id}    ${olt_pon_port}
-        ...    ENABLED    ACTIVE
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate ONUs for PON OLT Enable    ${olt_peer_list}
+    # Multi-OLTs
+    FOR   ${I}    IN RANGE    0    ${olt_count}
+        ${olt_serial_number}=    Get From Dictionary    ${olt_ids}[${I}]    sn
+        Disable Enable PON Port Per OLT    ${olt_serial_number}
     END
 
 *** Keywords ***