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} 5min
21 ${vnf_scale_pol_time} 30sec
22 # If env variable "OSM_NS_TIMEOUT" exists, it prevails over the default timeout
23 ${default_ns_launch_max_wait_time}= Get Environment Variable OSM_NS_TIMEOUT default=5min
27 Create Network Service
28 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=${default_ns_launch_max_wait_time} ${config_file}=${EMPTY}
30 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
31 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
32 ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
34 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
37 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
38 Check For NS Instance For Failure ${ns_name}
42 Instantiate Network Service
43 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
45 ${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}
47 Should Be Equal As Integers ${rc} ${success_return_code}
51 Get Vnf Management Ip Address
52 [Arguments] ${ns_id} ${vnf_member_index}
54 Should Not Be Empty ${ns_id}
55 Should Not Be Empty ${vnf_member_index}
56 ${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
58 Should Be Equal As Integers ${rc} ${success_return_code}
63 [Arguments] ${ns_id} ${vnf_member_index}
65 Should Not Be Empty ${ns_id}
66 Should Not Be Empty ${vnf_member_index}
67 ${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
69 Should Be Equal As Integers ${rc} ${success_return_code}
76 Should Not Be Empty ${ns_id}
77 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
78 # Returns a String of vnf_id and needs to be converted into a list
79 @{vnf_list} = Split String ${vnf_list_string}[1]
85 [Arguments] @{vnf_list}
87 should not be empty @{vnf_list}
88 @{temp_list}= Create List
89 FOR ${vnf_id} IN @{vnf_list}
91 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
92 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
94 should not be empty ${temp_list}
101 should not be empty ${vnf_id}
102 @{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
103 # returns a string of ip addresses and needs to be converted into a list
104 should not be empty ${vnf_ip_list_string}[1]
105 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
106 log list ${vnf_ip_list}
107 should not be empty ${vnf_ip_list}
108 [return] @{vnf_ip_list}
111 Check For Ns Instance To Configured
112 [arguments] ${ns_name}
114 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
116 Should Be Equal As Integers ${rc} ${success_return_code}
117 Should Contain Any ${stdout} READY BROKEN
119 Check For NS Instance For Failure
120 [Arguments] ${ns_name}
122 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
124 Should Be Equal As Integers ${rc} ${success_return_code}
125 Should Not Contain ${stdout} BROKEN
127 Check For NS Instance To Be Deleted
130 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
131 Should Not Be Equal As Strings ${stdout} ${ns}
134 [Documentation] Delete ns
137 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
139 Should Be Equal As Integers ${rc} ${success_return_code}
141 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
144 [Documentation] Execute an action over the desired NS.
145 ... Parameters are given to this function in key=value format (one argument per key/value pair).
146 ... Return the ID of the operation associated to the executed action.
147 ... Examples of execution:
148 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
149 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
151 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
153 ${params}= Set Variable ${EMPTY}
154 FOR ${param} IN @{action_params}
155 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
156 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
158 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
159 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
160 ... ELSE Set Variable ${osm_ns_action_command}
161 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
162 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
163 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
164 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
168 Execute NS K8s Action
169 [Documentation] Execute an action over the desired K8s NS.
170 ... Parameters are given to this function in key=value format (one argument per key/value pair).
171 ... Return the ID of the operation associated to the executed action.
172 ... Examples of execution:
173 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
174 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
176 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
178 ${params}= Set Variable ${EMPTY}
179 FOR ${param} IN @{action_params}
180 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
181 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
183 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
184 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
185 ... ELSE Set Variable ${osm_ns_action_command}
186 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
187 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
188 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
189 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
193 Execute Manual VNF Scale
194 [Documentation] Execute a manual VNF Scale action.
195 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
196 ... Return the ID of the operation associated to the executed scale action.
198 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
200 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
201 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
202 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
203 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
204 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
205 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
206 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
207 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
212 [Arguments] ${ns_name}
214 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
217 Should Be Equal As Integers ${rc} ${success_return_code}
220 Check For NS Operation Completed
221 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
223 [Arguments] ${ns_operation_id}
225 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
227 Should Be Equal As Integers ${rc} ${success_return_code}
228 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
232 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
236 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
237 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
238 @{vdur} = Split String ${stdout}
243 [Documentation] Return a list with the names of the VDU records of a VNF instance.
245 [Arguments] ${vnf_id}
247 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq r - vdur.*.name
248 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
249 @{vdur} = Split String ${stdout}