| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 1 | *** Comments *** |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | # you may not use this file except in compliance with the License. |
| 4 | # You may obtain a copy of the License at |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. |
| 13 | |
| 14 | |
| 15 | *** Settings *** |
| 16 | Documentation Library providing keywords for CRUD operations over VNF instances with OSM client. |
| 17 | Library OperatingSystem |
| 18 | Library String |
| 19 | |
| 20 | |
| 21 | *** Variables *** |
| 22 | ${SUCCESS_RETURN_CODE} 0 |
| 23 | |
| 24 | |
| 25 | *** Keywords *** |
| 26 | Get Vnf List |
| 27 | [Documentation] Get the list of VNF instances and return it. |
| 28 | ${rc} ${stdout}= Run And Return Rc And Output osm vnf-list 2>&1 |
| 29 | Log ${stdout} |
| 30 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 31 | RETURN ${stdout} |
| 32 | |
| 33 | Get VNF VIM ID |
| 34 | [Documentation] Get the identifier of the first VDU of a VNF instance. Useful to get the id when a VNF has a single VDU. |
| 35 | [Arguments] ${vnf_id} |
| 36 | Should Not Be Empty ${vnf_id} |
| 37 | ${rc} ${stdout}= Run And Return Rc And Output osm vnf-show ${vnf_id} --literal | yq -r '.vdur[]."vim-id"' |
| 38 | Log ${stdout} |
| 39 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 40 | RETURN ${stdout} |
| 41 | |
| 42 | Get VDU List From VNF |
| 43 | [Documentation] Return a list of the VDU instance ids of a VNF instance |
| 44 | [Arguments] ${vnf_id} |
| 45 | Should Not Be Empty ${vnf_id} |
| 46 | ${rc} ${stdout}= Run And Return Rc And Output osm vnf-show ${vnf_id} --literal | yq '.vdur[].id' |
| 47 | Log ${stdout} |
| 48 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False |
| 49 | @{vdur_ids}= Split String ${stdout} |
| 50 | RETURN @{vdur_ids} |
| 51 | |
| 52 | Get VDU VIM Id |
| 53 | [Documentation] Return the VIM VM ID for a VDU |
| 54 | [Arguments] ${vnf_id} ${vdur_id} |
| 55 | Should Not Be Empty ${vnf_id} |
| 56 | ${rc} ${vm_vim_id}= Run And Return Rc And Output osm vnf-show ${vnf_id} --literal | yq '.vdur[] | select(.id == "'${vdur_id}'")' | yq -r '."vim-id"' |
| 57 | Log ${vm_vim_id} |
| 58 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${vm_vim_id} values=False |
| 59 | RETURN ${vm_vim_id} |
| 60 | |
| 61 | Get Vnf Vdur IPs |
| 62 | [Documentation] Return a list with the IP addresses of the VDU records of a VNF instance. |
| 63 | [Arguments] ${vnf_id} |
| 64 | Should Not Be Empty ${vnf_id} |
| 65 | ${rc} ${stdout}= Run And Return Rc And Output osm vnf-show ${vnf_id} --literal | yq -r '.vdur[].interfaces[]."ip-address"' |
| 66 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False |
| 67 | @{ip}= Split String ${stdout} |
| 68 | RETURN @{ip} |
| 69 | |
| 70 | Get Vdu Attribute |
| 71 | [Documentation] Return an attribute from VDU records selected by count_index of a VNF instance. |
| 72 | [Arguments] ${vnf_id} ${attribute} ${count_index}=0 |
| 73 | Should Not Be Empty ${vnf_id} |
| 74 | Should Not Be Empty ${attribute} |
| 75 | ${rc} ${stdout}= Run And Return Rc And Output osm vnf-show ${vnf_id} --literal | yq '.vdur[] | select(."count-index" == ${count_index})' | yq -r '."${attribute}"' |
| 76 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False |
| 77 | RETURN ${stdout} |