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
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}
63 Should Not Be Empty ${ns_id}
64 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
65 # Returns a String of vnf_id and needs to be converted into a list
66 @{vnf_list} = Split String ${vnf_list_string}[1]
72 [Arguments] @{vnf_list}
74 should not be empty @{vnf_list}
75 @{temp_list}= Create List
76 FOR ${vnf_id} IN @{vnf_list}
78 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
79 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
81 should not be empty ${temp_list}
88 should not be empty ${vnf_id}
89 @{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
90 # returns a string of ip addresses and needs to be converted into a list
91 should not be empty ${vnf_ip_list_string}[1]
92 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
93 log list ${vnf_ip_list}
94 should not be empty ${vnf_ip_list}
95 [return] @{vnf_ip_list}
98 Check For Ns Instance To Configured
99 [arguments] ${ns_name}
101 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
103 Should Be Equal As Integers ${rc} ${success_return_code}
104 Should Contain Any ${stdout} READY BROKEN
106 Check For NS Instance For Failure
107 [Arguments] ${ns_name}
109 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
111 Should Be Equal As Integers ${rc} ${success_return_code}
112 Should Not Contain ${stdout} BROKEN
114 Check For NS Instance To Be Deleted
117 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
118 Should Not Be Equal As Strings ${stdout} ${ns}
121 [Documentation] Delete ns
124 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
126 Should Be Equal As Integers ${rc} ${success_return_code}
128 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
131 [Documentation] Execute an action over the desired NS.
132 ... Parameters are given to this function in key=value format (one argument per key/value pair).
133 ... Return the ID of the operation associated to the executed action.
134 ... Examples of execution:
135 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
136 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
138 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
140 ${params}= Set Variable ${EMPTY}
141 FOR ${param} IN @{action_params}
142 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
143 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
145 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
146 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
147 ... ELSE Set Variable ${osm_ns_action_command}
148 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
149 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
150 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
151 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
155 Execute NS K8s Action
156 [Documentation] Execute an action over the desired K8s NS.
157 ... Parameters are given to this function in key=value format (one argument per key/value pair).
158 ... Return the ID of the operation associated to the executed action.
159 ... Examples of execution:
160 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
161 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
163 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
165 ${params}= Set Variable ${EMPTY}
166 FOR ${param} IN @{action_params}
167 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
168 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
170 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
171 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
172 ... ELSE Set Variable ${osm_ns_action_command}
173 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
174 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
175 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
176 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
180 Execute Manual VNF Scale
181 [Documentation] Execute a manual VNF Scale action.
182 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
183 ... Return the ID of the operation associated to the executed scale action.
185 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
187 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
188 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
189 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
190 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
191 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
192 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
193 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
194 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
199 [Arguments] ${ns_name}
201 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
204 Should Be Equal As Integers ${rc} ${success_return_code}
207 Check For NS Operation Completed
208 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
210 [Arguments] ${ns_operation_id}
212 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
214 Should Be Equal As Integers ${rc} ${success_return_code}
215 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
219 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
223 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
224 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
225 @{vdur} = Split String ${stdout}
230 [Documentation] Return a list with the names of the VDU records of a VNF instance.
232 [Arguments] ${vnf_id}
234 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq r - vdur.*.name
235 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
236 @{vdur} = Split String ${stdout}