Kailash | 9276492 | 2019-07-25 08:21:39 -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 | |
| 15 | # robot test functions |
| 16 | |
| 17 | *** Settings *** |
| 18 | Documentation Library for various utilities |
| 19 | Library SSHLibrary |
| 20 | Library HttpLibrary.HTTP |
| 21 | Library String |
| 22 | Library DateTime |
| 23 | Library Process |
| 24 | Library Collections |
| 25 | Library RequestsLibrary |
| 26 | Library OperatingSystem |
| 27 | |
| 28 | *** Keywords *** |
| 29 | Execute ONOS Command |
| 30 | [Arguments] ${cmd} |
| 31 | [Documentation] Establishes an ssh connection to the onos contoller and executes a command |
| 32 | ${conn_id}= SSHLibrary.Open Connection localhost port=8101 prompt=onos> timeout=300s |
| 33 | SSHLibrary.Login karaf karaf |
| 34 | ${output}= SSHLibrary.Execute Command ${cmd} |
| 35 | SSHLibrary.Close Connection |
| 36 | [Return] ${output} |
| 37 | |
| 38 | Validate Device |
| 39 | [Arguments] ${serial_number} ${admin_state} ${oper_status} ${connect_status} |
| 40 | [Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number} |
| 41 | ... Arguments are matched for device states of: "admin_state", "oper_status", and "connect_status" |
| 42 | ${output}= Run voltctl device list -o json |
| 43 | ${jsondata}= To Json ${output} |
| 44 | Log ${jsondata} |
| 45 | ${length}= Get Length ${jsondata} |
| 46 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 47 | \ ${value}= Get From List ${jsondata} ${INDEX} |
| 48 | \ ${astate}= Get From Dictionary ${value} adminstate |
| 49 | \ ${opstatus}= Get From Dictionary ${value} operstatus |
| 50 | \ ${cstatus}= Get From Dictionary ${value} connectstatus |
| 51 | \ ${sn}= Get From Dictionary ${value} serialnumber |
| 52 | \ Run Keyword If '${sn}' == '${serial_number}' Exit For Loop |
| 53 | Should Be Equal ${astate} ${admin_state} Device ${serial_number} admin_state != ENABLED values=False |
| 54 | Should Be Equal ${opstatus} ${oper_status} Device ${serial_number} oper_status != ACTIVE values=False |
| 55 | Should Be Equal ${cstatus} ${connect_status} Device ${serial_number} connect_status != REACHABLE values=False |