1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
14 ${success_return_code} 0
15 ${ns_launch_pol_time} 30sec
16 ${ns_delete_max_wait_time} 4min
17 ${ns_delete_pol_time} 15sec
18 ${ns_action_max_wait_time} 1min
19 ${ns_action_pol_time} 15sec
20 ${vnf_scale_max_wait_time} 2min
21 ${vnf_scale_pol_time} 15sec
25 Create Network Service
26 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min ${config_file}=${EMPTY}
28 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
29 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
30 ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
32 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
35 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
36 Check For NS Instance For Failure ${ns_name}
40 Instantiate Network Service
41 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
43 ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} ${ns_extra_args}
45 Should Be Equal As Integers ${rc} ${success_return_code}
49 Get Vnf Management Ip Address
50 [Arguments] ${ns_id} ${vnf_member_index}
52 Should Not Be Empty ${ns_id}
53 Should Not Be Empty ${vnf_member_index}
54 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list --filter member-vnf-index-ref=${vnf_member_index} | grep ${ns_id} | awk '{print $14}' 2>&1
56 Should Be Equal As Integers ${rc} ${success_return_code}
61 [Arguments] ${ns_id} ${vnf_member_index}
63 Should Not Be Empty ${ns_id}
64 Should Not Be Empty ${vnf_member_index}
65 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list --filter member-vnf-index-ref=${vnf_member_index} | grep ${ns_id} | awk '{print $2}' 2>&1
67 Should Be Equal As Integers ${rc} ${success_return_code}
74 Should Not Be Empty ${ns_id}
75 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
76 # Returns a String of vnf_id and needs to be converted into a list
77 @{vnf_list} = Split String ${vnf_list_string}[1]
83 [Arguments] @{vnf_list}
85 should not be empty @{vnf_list}
86 @{temp_list}= Create List
87 FOR ${vnf_id} IN @{vnf_list}
89 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
90 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
92 should not be empty ${temp_list}
99 should not be empty ${vnf_id}
100 @{vnf_ip_list_string}= run and return rc and output osm vnf-list --filter id=${vnf_id} | grep -o '[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}' | sort -t: -u -k1,1 2>&1
101 # returns a string of ip addresses and needs to be converted into a list
102 should not be empty ${vnf_ip_list_string}[1]
103 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
104 log list ${vnf_ip_list}
105 should not be empty ${vnf_ip_list}
106 [return] @{vnf_ip_list}
109 Check For Ns Instance To Configured
110 [arguments] ${ns_name}
112 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
114 Should Be Equal As Integers ${rc} ${success_return_code}
115 Should Contain Any ${stdout} READY BROKEN
117 Check For NS Instance For Failure
118 [Arguments] ${ns_name}
120 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
122 Should Be Equal As Integers ${rc} ${success_return_code}
123 Should Not Contain ${stdout} BROKEN
125 Check For NS Instance To Be Deleted
128 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
129 Should Not Be Equal As Strings ${stdout} ${ns}
132 [Documentation] Delete ns
135 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
137 Should Be Equal As Integers ${rc} ${success_return_code}
139 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
142 [Documentation] Execute an action over the desired NS.
143 ... Parameters are given to this function in key=value format (one argument per key/value pair).
144 ... Return the ID of the operation associated to the executed action.
145 ... Examples of execution:
146 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
147 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
149 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
151 ${params}= Set Variable ${EMPTY}
152 FOR ${param} IN @{action_params}
153 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
154 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
156 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
157 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
158 ... ELSE Set Variable ${osm_ns_action_command}
159 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
160 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
161 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
162 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
166 Execute NS K8s Action
167 [Documentation] Execute an action over the desired K8s NS.
168 ... Parameters are given to this function in key=value format (one argument per key/value pair).
169 ... Return the ID of the operation associated to the executed action.
170 ... Examples of execution:
171 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
172 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
174 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
176 ${params}= Set Variable ${EMPTY}
177 FOR ${param} IN @{action_params}
178 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
179 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
181 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
182 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
183 ... ELSE Set Variable ${osm_ns_action_command}
184 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
185 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
186 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
187 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
191 Execute Manual VNF Scale
192 [Documentation] Execute a manual VNF Scale action.
193 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
194 ... Return the ID of the operation associated to the executed scale action.
196 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
198 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
199 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
200 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
201 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
202 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
203 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
204 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
205 Wait Until Keyword Succeeds ${vnf_scale_max_wait_time} ${vnf_scale_pol_time} Check For NS Operation Completed ${stdout}
210 [Arguments] ${ns_name}
212 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
215 Should Be Equal As Integers ${rc} ${success_return_code}
218 Check For NS Operation Completed
219 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
221 [Arguments] ${ns_operation_id}
223 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
225 Should Be Equal As Integers ${rc} ${success_return_code}
226 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
230 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
234 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
235 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
236 @{vdur} = Split String ${stdout}
241 [Documentation] Return a list with the names of the VDU records of a VNF instance.
243 [Arguments] ${vnf_id}
245 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq r - vdur.*.name
246 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
247 @{vdur} = Split String ${stdout}