Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # onos common functions |
| 15 | |
| 16 | *** Settings *** |
| 17 | Documentation Library for ONOS Functions |
| 18 | Library SSHLibrary |
| 19 | |
| 20 | *** Keywords *** |
| 21 | Execute ONOS CLI Command |
| 22 | [Documentation] Establishes an ssh connection to ONOS contoller and executes a command |
| 23 | [Arguments] ${host} ${port} ${cmd} ${user}=karaf ${pass}=karaf |
| 24 | ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} timeout=300s |
| 25 | SSHLibrary.Login ${user} ${pass} |
| 26 | @{result_values} SSHLibrary.Execute Command ${cmd} return_rc=True |
| 27 | ... return_stderr=True return_stdout=True |
| 28 | ${output} Set Variable @{result_values}[0] |
| 29 | Log ${output} |
| 30 | Should Be Empty @{result_values}[1] |
| 31 | Should Be Equal As Integers @{result_values}[2] 0 |
| 32 | SSHLibrary.Close Connection |
| 33 | [Return] ${output} |
| 34 | |
| 35 | Validate XConnect in ONOS |
| 36 | [Documentation] Check if Fabric Crossconnnect matches exists value |
| 37 | [Arguments] ${server_ip} ${stag} ${exists}=True ${port}=30120 |
| 38 | # FIXME: use Robot-based JSON manipulation, shorten line |
| 39 | ${rc}= Run And Return RC |
| 40 | ... http -a karaf:karaf GET http://${server_ip}:${port}/onos/segmentrouting/xconnect|jq -r '.xconnects[].vlanId'|grep ${stag} |
| 41 | Run Keyword If '${exists}' == 'True' |
| 42 | ... Should Be Equal As Integers ${rc} 0 |
| 43 | ... ELSE |
| 44 | ... Should Be Equal As Integers ${rc} 1 |
| 45 | |
| 46 | Get ONOS Status |
| 47 | [Documentation] Obtain and log output of ONOS diagnostic commands |
| 48 | [Arguments] ${server_ip}=${None} ${server_port}=30115 |
| 49 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 50 | ... onos_apps.log apps -a -s |
| 51 | ... host=${server_ip} port=${server_port} |
| 52 | ${onos_apps} Get Binary File /tmp/onos_apps.log |
| 53 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 54 | ... onos_devices.log devices |
| 55 | ... host=${server_ip} port=${server_port} |
| 56 | ${onos_devices} Get Binary File /tmp/onos_devices.log |
| 57 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 58 | ... onos_ports.log ports |
| 59 | ... host=${server_ip} port=${server_port} |
| 60 | ${onos_ports} Get Binary File /tmp/onos_ports.log |
| 61 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 62 | ... onos_flows.log flows -s |
| 63 | ... host=${server_ip} port=${server_port} |
| 64 | ${onos_flows} Get Binary File /tmp/onos_flows.log |
| 65 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 66 | ... onos_meters.log meters |
| 67 | ... host=${server_ip} port=${server_port} |
| 68 | ${onos_meters} Get Binary File /tmp/onos_meters.log |
| 69 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 70 | ... onos_volt_prog_subscribers.log volt-programmed-subscribers |
| 71 | ... host=${server_ip} port=${server_port} |
| 72 | ${onos_volt_prog_subscribers} Get Binary File /tmp/onos_volt_prog_subscribers.log |
| 73 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 74 | ... onos_volt_prog_meters.log volt-programmed-meters |
| 75 | ... host=${server_ip} port=${server_port} |
| 76 | ${onos_volt_prog_meters} Get Binary File /tmp/onos_volt_prog_meters.log |
| 77 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 78 | ... onos_volt_bp_meters.log volt-bpmeter-mappings |
| 79 | ... host=${server_ip} port=${server_port} |
| 80 | ${onos_volt_bp_meters} Get Binary File /tmp/onos_volt_bp_meters.log |
| 81 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 82 | ... onos_dhcpl2.log dhcpl2relay-allocations |
| 83 | ... host=${server_ip} port=${server_port} |
| 84 | ${onos_dhcpl2} Get Binary File /tmp/onos_dhcpl2.log |
| 85 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 86 | ... onos_aaa_users.log aaa-users |
| 87 | ... host=${server_ip} port=${server_port} |
| 88 | ${onos_aaa_users} Get Binary File /tmp/onos_aaa_users.log |
| 89 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 90 | ... onos_netcfg.log netcfg |
| 91 | ... host=${server_ip} port=${server_port} |
| 92 | ${onos_netcfg} Get Binary File /tmp/onos_netcfg.log |
| 93 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 94 | ... onos_groups.log groups |
| 95 | ... host=${server_ip} port=${server_port} |
| 96 | ${onos_groups} Get Binary File /tmp/onos_groups.log |
| 97 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 98 | ... onos_hosts.log hosts |
| 99 | ... host=${server_ip} port=${server_port} |
| 100 | ${onos_hosts} Get Binary File /tmp/onos_hosts.log |
| 101 | CORDRobot.write_log_of_onos_cli_command /tmp |
| 102 | ... onos_links.log links |
| 103 | ... host=${server_ip} port=${server_port} |
| 104 | ${onos_links} Get Binary File /tmp/onos_links.log |
| 105 | Log ${onos_apps} |
| 106 | Log ${onos_devices} |
| 107 | Log ${onos_ports} |
| 108 | Log ${onos_flows} |
| 109 | Log ${onos_meters} |
| 110 | Log ${onos_aaa_users} |
| 111 | Log ${onos_volt_prog_subscribers} |
| 112 | Log ${onos_volt_prog_meters} |
| 113 | Log ${onos_volt_bp_meters} |
| 114 | Log ${onos_hosts} |
| 115 | Log ${onos_dhcpl2} |
| 116 | Log ${onos_netcfg} |
| 117 | Log ${onos_groups} |
| 118 | Log ${onos_links} |