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
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 Documentation Library providing keywords for CRUD operations over VNF instances with OSM client.
17 Library OperatingSystem
22 ${SUCCESS_RETURN_CODE} 0
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
30 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
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.
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"'
39 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
43 [Documentation] Return a list of the VDU instance ids of a VNF instance
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'
48 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
49 @{vdur_ids}= Split String ${stdout}
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"'
58 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${vm_vim_id} values=False
62 [Documentation] Return a list with the IP addresses of the VDU records of a VNF instance.
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}
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