[VOL-2052] Bandwidth Profile Validation
Change-Id: Icdf6ab05435d5359158dabb704e5cecb7f7d4b37
diff --git a/libraries/onos.robot b/libraries/onos.robot
index 4d10af5..69ee7e2 100644
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -361,3 +361,30 @@
${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Wait Until Keyword Succeeds 10m 5s Count ADDED flows
... ${onos_ip} ${onos_port} ${targetFlows}
+
+Get Bandwidth Details
+ [Arguments] ${bandwidth_profile_name}
+ [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
+ ... returns the limiting bandwidth
+ ${bandwidth_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
+ ... bandwidthprofile ${bandwidth_profile_name}
+ @{bandwidth_profile_array}= Split String ${bandwidth_profile_values} ,
+ @{parameter_value_pair}= Split String ${bandwidth_profile_array[1]} =
+ ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
+ ${value}= Set Variable ${parameter_value_pair[1]}
+ ${cir_value} Run Keyword If '${bandwidthparameter}' == ' committedInformationRate'
+ ... Set Variable ${value}
+ @{parameter_value_pair}= Split String ${bandwidth_profile_array[2]} =
+ ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
+ ${value}= Set Variable ${parameter_value_pair[1]}
+ ${cbs_value} Run Keyword If '${bandwidthparameter}' == ' committedBurstSize' Set Variable ${value}
+ @{parameter_value_pair}= Split String ${bandwidth_profile_array[3]} =
+ ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
+ ${value}= Set Variable ${parameter_value_pair[1]}
+ ${eir_value} Run Keyword If '${bandwidthparameter}' == ' exceededInformationRate' Set Variable ${value}
+ @{parameter_value_pair}= Split String ${bandwidth_profile_array[4]} =
+ ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
+ ${value}= Set Variable ${parameter_value_pair[1]}
+ ${ebs_value} Run Keyword If '${bandwidthparameter}' == ' exceededBurstSize' Set Variable ${value}
+ ${limiting_BW}= Evaluate ${cir_value}+${eir_value}
+ [Return] ${limiting_BW}
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}