[VOL-4174] Updated Validate Device keyword to use filter

Change-Id: I0b4239e81780d299027302f5684c205007663ca2
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 19e9c2d..25840e9 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -618,7 +618,7 @@
         #Set Suite Variable    ${olt_device_id}
         #validate olt states
         Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${olt_device_id}
+        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${olt_device_id}    by_dev_id=True
         Sleep    5s
         Enable Device    ${olt_device_id}
         # Increasing the timer to incorporate wait time for in-band
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index b9d6844..9e4f2c7 100755
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -165,9 +165,14 @@
     ...    Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
     ...    the serial number or device ID. Arguments are matched for device states of: "admin_state",
     ...    "oper_status", and "connect_status"
+    ...    Note: Set "by_dev_id" to True if Device Id is passed for validation
+    ...    otherwise look up will be based on Device Serial Number
     [Arguments]    ${admin_state}    ${oper_status}    ${connect_status}
-    ...    ${id}=${EMPTY}    ${onu_reason}=${EMPTY}    ${onu}=False
-    ${rc}    ${output}=    Run and Return Rc and Output    voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -o json
+    ...    ${id}    ${onu_reason}=${EMPTY}    ${onu}=False    ${by_dev_id}=False
+    ${rc}    ${output}=    Run Keyword If    ${by_dev_id}    Run and Return Rc and Output
+    ...    voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Id=${id} -o json
+    ...    ELSE    Run and Return Rc and Output
+    ...    voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f SerialNumber=${id} -o json
     Should Be Equal As Integers    ${rc}    0
     ${jsondata}=    To Json    ${output}
     Log     ${output}
@@ -210,10 +215,12 @@
     ...    Device ${sn} mib_state incorrect (${mib_state}) values=False
 
 Validate OLT Device
-    [Arguments]    ${admin_state}    ${oper_status}    ${connect_status}    ${id}=${EMPTY}
+    [Arguments]    ${admin_state}    ${oper_status}    ${connect_status}    ${id}    ${by_dev_id}=False
     [Documentation]    Parses the output of "voltctl device list" and inspects device ${id}, specified
     ...    as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
-    Validate Device    ${admin_state}    ${oper_status}    ${connect_status}    ${id}
+    ...    Note: Set "by_dev_id" to True if Device Id is passed for validation
+    ...    otherwise look up will be based on Device Serial Number
+    Validate Device    ${admin_state}    ${oper_status}    ${connect_status}    ${id}    by_dev_id=${by_dev_id}
 
 Validate OLT Devices
     [Arguments]    ${admin_state}    ${oper_status}    ${connect_status}    ${ids}=${EMPTY}
@@ -222,7 +229,7 @@
     FOR   ${I}    IN RANGE    0    ${olt_count}
         ${olt_serial_number}=    Get From Dictionary    ${olt_ids}[${I}]    sn
         ${olt_device_id}=    Get OLTDeviceID From OLT List    ${olt_serial_number}
-        Validate Device    ${admin_state}    ${oper_status}    ${connect_status}    ${olt_device_id}
+        Validate Device    ${admin_state}    ${oper_status}    ${connect_status}    ${olt_device_id}    by_dev_id=True
     END
 
 Validate ONU Devices
diff --git a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
index 92ad026..910ff28 100755
--- a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
+++ b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
@@ -262,7 +262,7 @@
         ...    ${of_id}
         # Bring up the device and verify it authenticates
         Wait Until Keyword Succeeds    360s    5s    Validate Device        ENABLED    ACTIVE    REACHABLE
-        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed
+        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed    by_dev_id=True
     END
     # Scale down the open OLT adapter deployment to 0 PODs and once confirmed, scale it back to 1
     Scale K8s Deployment by Pod Label    ${NAMESPACE}    app    ${OLT_ADAPTER_APP_LABEL}    0
@@ -394,7 +394,7 @@
         ...    ${of_id}
         # Bring up the device and verify it authenticates
         Wait Until Keyword Succeeds    360s    5s    Validate Device    ENABLED    ACTIVE    REACHABLE
-        ...    ${onu_device_id}    onu=True    onu_reason=initial-mib-downloaded
+        ...    ${onu_device_id}    onu=True    onu_reason=initial-mib-downloaded    by_dev_id=True
     END
 
     # Scale down the rw-core deployment to 0 PODs and once confirmed, scale it back to 1
diff --git a/tests/dt-workflow/Voltha_DT_PODTests.robot b/tests/dt-workflow/Voltha_DT_PODTests.robot
index db84926..ff9d47e 100644
--- a/tests/dt-workflow/Voltha_DT_PODTests.robot
+++ b/tests/dt-workflow/Voltha_DT_PODTests.robot
@@ -104,7 +104,7 @@
         ${bbsim_olt_device_id}=    Create Device    ${ip}    ${bbsim_port}
         Log    ${bbsim_olt_device_id}
         Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${bbsim_olt_device_id}
+        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${bbsim_olt_device_id}    by_dev_id=True
         Enable Device    ${bbsim_olt_device_id}
         Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
         ...    Validate OLT Device    ENABLED    ACTIVE    REACHABLE    ${serial_number}
diff --git a/tests/functional/Voltha_ErrorScenarios.robot b/tests/functional/Voltha_ErrorScenarios.robot
index 8637d2d..ec1a9a0 100644
--- a/tests/functional/Voltha_ErrorScenarios.robot
+++ b/tests/functional/Voltha_ErrorScenarios.robot
@@ -82,7 +82,7 @@
         ...    ELSE    Create Device    ${olt_ip}    ${olt_port}    ${list_olts}[${I}][type]
         Set Suite Variable    ${olt_device_id}
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN
-        ...    ${olt_device_id}
+        ...    ${olt_device_id}    by_dev_id=True
         ${rc}    ${output}=    Run and Return Rc and Output
         ...    voltctl -c ${VOLTCTL_CONFIG} device create -t openolt -H ${olt_ip}:${olt_port}
         Should Not Be Equal As Integers    ${rc}    0
@@ -202,7 +202,7 @@
         Set Suite Variable    ${olt_device_id}
         #validate olt states
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    PREPROVISIONED    UNKNOWN
-        ...    UNKNOWN    ${olt_device_id}
+        ...    UNKNOWN    ${olt_device_id}    by_dev_id=True
         #Try disabling pre-provisioned OLT
         ${rc}    ${output}=    Run and Return Rc and Output
         ...    voltctl -c ${VOLTCTL_CONFIG} device disable ${olt_device_id}
@@ -250,7 +250,7 @@
         Set Suite Variable    ${olt_device_id}
         #validate olt states
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    PREPROVISIONED    UNKNOWN
-        ...    UNKNOWN    ${olt_device_id}
+        ...    UNKNOWN    ${olt_device_id}    by_dev_id=True
         #Enable the created OLT device
         Enable Device    ${olt_device_id}
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    ENABLED    ACTIVE
@@ -300,7 +300,7 @@
         ...    ELSE    Create Device    ${olt_ip}    ${olt_port}    ${list_olts}[${I}][type]
         Set Suite Variable    ${olt_device_id}
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    PREPROVISIONED    UNKNOWN
-        ...    UNKNOWN    ${olt_device_id}
+        ...    UNKNOWN    ${olt_device_id}    by_dev_id=True
         Enable Device    ${olt_device_id}
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    ENABLED    ACTIVE    REACHABLE
         ...    ${olt_serial_number}
diff --git a/tests/functional/Voltha_FailureScenarios.robot b/tests/functional/Voltha_FailureScenarios.robot
index 1e29331..859e1f2 100644
--- a/tests/functional/Voltha_FailureScenarios.robot
+++ b/tests/functional/Voltha_FailureScenarios.robot
@@ -284,7 +284,7 @@
 
         # Bring up the device and verify it authenticates
         Wait Until Keyword Succeeds    360s    5s    Validate Device        ENABLED    ACTIVE    REACHABLE
-        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed
+        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed    by_dev_id=True
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify Eapol Flows Added For ONU    ${ONOS_SSH_IP}
         ...    ${ONOS_SSH_PORT}    ${onu_port}
         ${wpa_log}=    Run Keyword If    ${has_dataplane}    Catenate    SEPARATOR=.
@@ -519,7 +519,7 @@
         ...    ${of_id}
         # Bring up the device and verify it authenticates
         Wait Until Keyword Succeeds    360s    5s    Validate Device    ENABLED    ACTIVE    REACHABLE
-        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed
+        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed    by_dev_id=True
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify Eapol Flows Added For ONU    ${ONOS_SSH_IP}
         ...    ${ONOS_SSH_PORT}    ${onu_port}
         ${wpa_log}=    Run Keyword If    ${has_dataplane}    Catenate    SEPARATOR=.
@@ -649,7 +649,7 @@
         ...    ${of_id}
         # Bring up the device and verify it authenticates
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate Device        ENABLED    ACTIVE    REACHABLE
-        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed
+        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed    by_dev_id=True
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify Eapol Flows Added For ONU    ${ONOS_SSH_IP}
         ...    ${ONOS_SSH_PORT}    ${onu_port}
         ${wpa_log}=    Run Keyword If    ${has_dataplane}    Catenate    SEPARATOR=.
diff --git a/tests/functional/Voltha_FailureScenarios2.robot b/tests/functional/Voltha_FailureScenarios2.robot
index ab21938..289cca7 100644
--- a/tests/functional/Voltha_FailureScenarios2.robot
+++ b/tests/functional/Voltha_FailureScenarios2.robot
@@ -108,7 +108,7 @@
         ...    ${of_id}
         # Bring up the device and verify it authenticates
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate Device        ENABLED    ACTIVE    REACHABLE
-        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed
+        ...    ${onu_device_id}    onu=True    onu_reason=omci-flows-pushed    by_dev_id=True
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify Eapol Flows Added For ONU    ${ONOS_SSH_IP}
         ...    ${ONOS_SSH_PORT}    ${onu_port}
         ${wpa_log}=    Run Keyword If    ${has_dataplane}    Catenate    SEPARATOR=.
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index 52acdb3..23147c9 100644
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_PODTests.robot
@@ -376,7 +376,7 @@
     ...    ELSE    Create Device    ${list_olts}[${I}][ip]    ${list_olts}[${I}][oltport]    ${list_olts}[${I}][type]
     Set Suite Variable    ${olt_device_id}
     Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    PREPROVISIONED
-    ...    UNKNOWN    UNKNOWN    ${olt_device_id}
+    ...    UNKNOWN    UNKNOWN    ${olt_device_id}    by_dev_id=True
     Enable Device    ${olt_device_id}
     Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device    ENABLED    ACTIVE    REACHABLE
     ...    ${olt_serial_number}
diff --git a/tests/functional/Voltha_ScaleFunctionalTests.robot b/tests/functional/Voltha_ScaleFunctionalTests.robot
index deb6251..f7b0cc9 100644
--- a/tests/functional/Voltha_ScaleFunctionalTests.robot
+++ b/tests/functional/Voltha_ScaleFunctionalTests.robot
@@ -50,12 +50,12 @@
     Set Global Variable    ${olt_device_id}
     #validate olt states
     Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device   PREPROVISIONED    UNKNOWN    UNKNOWN
-    ...    ${olt_device_id}
+    ...    ${olt_device_id}    by_dev_id=True
     #enable device
     Enable Device    ${olt_device_id}
     #validate olt states
     Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Device   ENABLED    ACTIVE    REACHABLE
-    ...    ${olt_device_id}
+    ...    ${olt_device_id}    by_dev_id=True
 
 ONU Discovery
     [Documentation]    Discover lists of ONUS, their Serial Numbers and device id
diff --git a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
index 8aa9ccb..8e8bf03 100755
--- a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
@@ -212,7 +212,7 @@
         ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
         #validate olt states
         Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${olt_device_id}
+        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${olt_device_id}    by_dev_id=True
         Sleep    5s
         ${logical_id}=    Get Logical Device ID From SN    ${olt_serial_number}
         ${olt}    Create Dictionary    device_id    ${olt_device_id}    logical_id    ${logical_id}
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index ff7f136..68a86ff 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -247,7 +247,7 @@
         ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
         #validate olt states
         Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${olt_device_id}
+        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${olt_device_id}    by_dev_id=True
         Sleep    5s
         ${logical_id}=    Get Logical Device ID From SN    ${olt_serial_number}
         ${olt}    Create Dictionary    device_id    ${olt_device_id}    logical_id    ${logical_id}
diff --git a/tests/tt-workflow/Voltha_TT_FailureScenarios.robot b/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
index 065a191..8cef76e 100755
--- a/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
+++ b/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
@@ -436,7 +436,7 @@
         ...    ${of_id}
         # Bring up the device and verify it authenticates
         Wait Until Keyword Succeeds    360s    5s    Validate Device    ENABLED    ACTIVE    REACHABLE
-        ...    ${onu_device_id}    onu=True    onu_reason=initial-mib-downloaded
+        ...    ${onu_device_id}    onu=True    onu_reason=initial-mib-downloaded    by_dev_id=True
     END
 
     # Scale down the rw-core deployment to 0 PODs and once confirmed, scale it back to 1