[VOL-2052] Bandwidth Profile Validation

Change-Id: Icdf6ab05435d5359158dabb704e5cecb7f7d4b37
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 258b465..8c9f655 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -529,4 +529,52 @@
         ...     Evaluate    (${olt_count} * 2)
         ...     ELSE
         ...     Evaluate    (${uni_count} * 6) + (${olt_count} * 1)
-    Return From Keyword     ${flow_count}
\ No newline at end of file
+    Return From Keyword     ${flow_count}
+
+Get Bandwidth Profile Name For Given Subscriber
+    [Arguments]    ${subscriber_id}   ${stream_type}=upstreamBandwidthProfile
+    [Documentation]    Keyword to get the bandwidth details of the given subscriber
+    ${bandwidth_profile_output}=    Execute ONOS CLI Command    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
+    ...    volt-programmed-subscribers | grep ${subscriber_id}
+    @{bandwidth_profile_array}=    Split String    ${bandwidth_profile_output}    ,
+    Log    ${bandwidth_profile_array}
+    FOR    ${value}    IN    @{bandwidth_profile_array}
+        @{row_value}=    Split String    ${value}    =
+        ${bandwidth_profile_name}=    Set Variable If    '${row_value[0]}' == ' ${stream_type}'
+        ...    ${row_value[1]}
+        ${bandwidth_profile_name}=    Convert To String    ${bandwidth_profile_name}
+        Run Keyword If    "${bandwidth_profile_name}" != "None"    Exit For Loop
+    END
+    Log    ${bandwidth_profile_name}
+    [Return]    ${bandwidth_profile_name}
+
+Execute Remote Command
+    [Documentation]    SSH into a remote host and execute a command on the bare host or in a container.
+    ...    This replaces and simplifies the Login And Run Command On Remote System keyword in CORDRobot.
+    [Arguments]    ${cmd}    ${ip}    ${user}    ${pass}=${None}
+    ...    ${container_type}=${None}    ${container_name}=${None}
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}
+    Run Keyword If    '${pass}' != '${None}'
+    ...    SSHLibrary.Login    ${user}    ${pass}
+    ...    ELSE
+    ...    SSHLibrary.Login With Public Key    ${user}    %{HOME}/.ssh/id_rsa
+    ${namespace}=    Run Keyword If    '${container_type}' == 'K8S'    SSHLibrary.Execute Command
+    ...    kubectl get pods --all-namespaces | grep ${container_name} | awk '{print $1}'
+    ${output}=    Run Keyword If    '${container_type}' == 'LXC'
+    ...    SSHLibrary.Execute Command    lxc exec ${container_name} -- ${cmd}
+    ...    ELSE IF    '${container_type}' == 'K8S'
+    ...    SSHLibrary.Execute Command    kubectl -n ${namespace} exec ${container_name} -- ${cmd}
+    ...    ELSE
+    ...    SSHLibrary.Execute Command    ${cmd}
+    Log    ${output}
+    SSHLibrary.Close Connection
+    [Return]    ${output}
+
+Run Iperf3 Test Client
+    [Arguments]    ${src}    ${server}    ${args}
+    [Documentation]    Login to ${src} and run the iperf3 client against ${server} using ${args}.
+    ...    Return a Dictionary containing the results of the test.
+    ${output}=    Execute Remote Command    iperf3 -J -c ${server} ${args} | jq -M -c '.'
+    ...    ${src['ip']}    ${src['user']}    ${src['pass']}    ${src['container_type']}    ${src['container_name']}
+    ${object}=    Evaluate    json.loads(r'''${output}''')    json
+    [Return]    ${object}