optimize keyword Wait for ONU Adapter Reconcile

Keyword 'Wait for Onu Adapter Reconcile' was removed and new keyword
'Reconcile Onu Adapter' was introduced instead. New keyword does all
needed actions for reconcilation:
- reboot onu-adapter
- check onu-adapter was really rebooted by ready timestamp comparison
- validate connection rw-core <-> onu-adapter established
- check accessability of onu-adapter
- validate oper-state is same as before reconcile

Change-Id: Ib9e97f2e3662ef34fd658e89270e35ba44f3ee01
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index f0e873a..2814990 100755
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -434,6 +434,39 @@
     Should Be Equal    '${mib_state}'    '${onu_reason}'
     ...    Device ${sn} mib_state incorrect (${mib_state}) values=False
 
+Check all ONU OperStatus
+    [Documentation]     Checks that all ONUs OperStatus is the required one.
+    [Arguments]     ${List_ONU_Serial}   ${oper_status}
+    ${cmd}=    Catenate    voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=brcm_openomci_onu
+    ...    --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}"
+    ...     | grep -v SERIALNUMBER | grep ${oper_status}
+    ${rc}    ${output}=    Run and Return Rc and Output    ${cmd}
+    Should Be Equal As Integers    ${rc}    0
+    @{Results}=    Split String    ${output}    \n
+    FOR    ${Line}    IN     @{Results}
+        @{words}=    Split String    ${Line}    \t
+        ${sn}=    Set Variable    ${words[0]}
+        Remove Values From List    ${List_ONU_Serial}    ${sn}
+    END
+    Should Be Empty    ${List_ONU_Serial}    For ONUs ${List_ONU_Serial} OperStatus ${oper_status} not matched!
+
+Validate Last ONU Communication
+    [Documentation]     Validates last communication with ONU.
+    [Arguments]     ${validation_duration}=5s
+    ${cmd}=    Catenate    voltctl -c ${VOLTCTL_CONFIG} adapter list -f Type=brcm_openomci_onu
+    ...    --format '{{gosince .LastCommunication}}'
+    ${rc}    ${output}=    Run and Return Rc and Output    ${cmd}
+    Should Be Equal As Integers    ${rc}    0
+    ${lastcomm}= 	Convert Time 	${output}
+    ${validduration}= 	Convert Time 	${validation_duration}
+    Should Be True    ${lastcomm}<=${validduration}
+
+Get Onu Image List
+    [Documentation]    Delivers the ONU device image list
+    [Arguments]    ${dev_id}
+    ${rc}    ${output}=    Run and Return Rc and Output
+    ...    voltctl -c ${VOLTCTL_CONFIG} device onuimage list ${dev_id}
+    [return]    ${rc}    ${output}
 
 Compare Lists
     [Documentation]
@@ -700,8 +733,12 @@
     [Arguments]    ${serial_numbers}    ${olt_serial_number}=${EMPTY}    ${num_onus}=${num_all_onus}
     [Documentation]    Appends all ONU SNs for the given OLT to the ${serial_numbers} list
     FOR    ${INDEX}    IN RANGE    0    ${num_onus}
-    Run Keyword IF  "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
-    ...   Append To List    ${serial_numbers}    ${hosts.src[${INDEX}].onu}
+        ${onu_sn}=  Set Variable    ${hosts.src[${INDEX}]['onu']}
+        # skip if we have already append this ONU
+        ${onu_id}=    Get Index From List    ${serial_numbers}   ${onu_sn}
+        Continue For Loop If    -1 != ${onu_id}
+        Run Keyword IF  "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
+        ...   Append To List    ${serial_numbers}    ${onu_sn}
     END
 
 Get SN From Device ID