improve read new peers list for DT

Change-Id: I3566e307495a24b0111f8aac6ce4b77c8ea76ce3
diff --git a/libraries/utils.robot b/libraries/utils.robot
index c2f04a9..294e6c4 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -922,6 +922,7 @@
     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}
+        ${olt_peer_list_len}=    Get Length    ${olt_peer_list}
         # 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
@@ -937,9 +938,8 @@
         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    30s
-        ${olt_peer_list_new}=    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}
+        ${olt_peer_list_new}=    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Retrieve Peer List From OLT PON Port    ${olt_device_id}    ${olt_pon_port}    ${olt_peer_list_len}
         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
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index 7a1ead6..e926c0d 100755
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -531,7 +531,7 @@
     [Return]    ${olt_pon_list}
 
 Retrieve Peer List From OLT PON Port
-    [Arguments]    ${olt_device_id}    ${pon_port}
+    [Arguments]    ${olt_device_id}    ${pon_port}    ${expected_num_peers}=0
     [Documentation]    Retrieves the list of peer device ids list from the OLT PON port
     ${rc}    ${output}=    Run and Return Rc and Output
     ...    voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
@@ -550,6 +550,8 @@
     END
     Should Be True    ${matched}    No PON port found for OLT ${olt_device_id}
     ${length}=    Get Length    ${peers}
+    Run Keyword If     ${expected_num_peers}>0    Should Be Equal As Integers    ${length}    ${expected_num_peers}
+    ...    Number of found peers does not match expected number ${length}:${expected_num_peers}
     ${olt_peer_list}=    Create List
     FOR    ${INDEX}    IN RANGE    0    ${length}
         ${value}=    Get From List    ${peers}    ${INDEX}