[VOL-3780] Add Restart Pod By Label keyword and use it in the Restart And Check Onu Adaptor test

Change-Id: I764af63c52a46ab48fd412ca682c7190ebf7a185
diff --git a/libraries/k8s.robot b/libraries/k8s.robot
index 557158e..815cec4 100755
--- a/libraries/k8s.robot
+++ b/libraries/k8s.robot
@@ -42,7 +42,7 @@
 
 Restart Pod
     [Arguments]    ${namespace}    ${name}
-    [Documentation]    Uses kubectl to force delete pod
+    [Documentation]    *DEPRECATED* Use Restart Pod By Label instead
     ${rc}    ${restart_pod_name}=    Run and Return Rc and Output
     ...    kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}'
     Log    ${restart_pod_name}
@@ -51,6 +51,17 @@
     ...    kubectl delete pod ${restart_pod_name} -n ${namespace} --grace-period=0 --force
     Log    ${output}
 
+Restart Pod By Label
+    [Arguments]    ${namespace}    ${label_key}   ${label_value}
+    [Documentation]    Uses kubectl to force delete pod
+    ${rc}    ${restart_pod_name}=    Run and Return Rc and Output
+    ...    kubectl get pods -n ${namespace} -l ${label_key}=${label_value} --no-headers | awk '{print $1}'
+    Log    ${restart_pod_name}
+    Should Not Be Empty    ${restart_pod_name}    Unable to parse pod name
+    ${rc}    ${output}=    Run and Return Rc and Output
+    ...    kubectl delete pod ${restart_pod_name} -n ${namespace} --grace-period=0 --force
+    Log    ${output}
+
 Exec Pod
     [Arguments]    ${namespace}    ${name}    ${command}
     [Documentation]    Uses kubectl to execute a command in the pod and return the output
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index b19a9c4..478bc56 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -132,8 +132,9 @@
     ...    - check openonu adaptor is ready again
     [Arguments]    ${namespace}
     ${list_openonu_apps}   Create List    adapter-open-onu
-    ${adaptorname}=    Set Variable    open-onu
-    Restart Pod    ${namespace}    ${adaptorname}
+    ${openonu_label_key}    Set Variable   app
+    ${openonu_label_value}    Set Variable   adapter-open-onu
+    Restart Pod By Label    ${namespace}    ${openonu_label_key}    ${openonu_label_value}
     Sleep    5s
     Wait For Pods Ready    ${namespace}    ${list_openonu_apps}
 
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index 4aa50d4..79c61e3 100755
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -319,7 +319,7 @@
     ...    ${List_ONU_Serial}   ${startTime}    ${print2console}=False    ${output_file}=${EMPTY}
     ...    ${alternate_reason}=${EMPTY}
     ${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
+    ...    --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}" | grep -v SERIALNUMBER
     ${rc}    ${output}=    Run and Return Rc and Output    ${cmd}
     Should Be Equal As Integers    ${rc}    0
     ${timeCurrent} =    Get Current Date