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} 1min
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
28 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
29 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
31 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr}
34 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
35 Check For NS Instance For Failure ${ns_name}
39 Instantiate Network Service
40 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
42 ${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}
44 Should Be Equal As Integers ${rc} ${success_return_code}
48 Get Vnf Management Ip Address
49 [Arguments] ${ns_id} ${vnf_member_index}
51 Should Not Be Empty ${ns_id}
52 Should Not Be Empty ${vnf_member_index}
53 ${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
55 Should Be Equal As Integers ${rc} ${success_return_code}
62 Should Not Be Empty ${ns_id}
63 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
64 # Returns a String of vnf_id and needs to be converted into a list
65 @{vnf_list} = Split String ${vnf_list_string}[1]
71 [Arguments] @{vnf_list}
73 should not be empty @{vnf_list}
74 @{temp_list}= Create List
75 FOR ${vnf_id} IN @{vnf_list}
77 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
78 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
80 should not be empty ${temp_list}
87 should not be empty ${vnf_id}
88 @{vnf_ip_list_string}= run and return rc and output osm vnf-show ${vnf_id} --filter vdur --literal | 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
89 # returns a string of ip addresses and needs to be converted into a list
90 should not be empty ${vnf_ip_list_string}[1]
91 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
92 log list ${vnf_ip_list}
93 should not be empty ${vnf_ip_list}
94 [return] @{vnf_ip_list}
97 Check For Ns Instance To Configured
98 [arguments] ${ns_name}
100 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
102 Should Be Equal As Integers ${rc} ${success_return_code}
103 Should Contain Any ${stdout} READY BROKEN
105 Check For NS Instance For Failure
106 [Arguments] ${ns_name}
108 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
110 Should Be Equal As Integers ${rc} ${success_return_code}
111 Should Not Contain ${stdout} BROKEN
113 Check For NS Instance To Be Deleted
116 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
117 Should Not Be Equal As Strings ${stdout} ${ns}
120 [Documentation] Delete ns
123 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
125 Should Be Equal As Integers ${rc} ${success_return_code}
127 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
130 [Documentation] Execute an action over the desired NS.
131 ... Parameters are given to this function in key=value format (one argument per key/value pair).
132 ... Return the ID of the operation associated to the executed action.
133 ... Examples of execution:
134 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
135 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
137 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
139 ${params}= Set Variable ${EMPTY}
140 FOR ${param} IN @{action_params}
141 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
142 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
144 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
145 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
146 ... ELSE Set Variable ${osm_ns_action_command}
147 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
148 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
149 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
150 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
154 Execute Manual VNF Scale
155 [Documentation] Execute a manual VNF Scale action.
156 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
157 ... Return the ID of the operation associated to the executed scale action.
159 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
161 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
162 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
163 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
164 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
165 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
166 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
167 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
168 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
173 [Arguments] ${ns_name}
175 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
178 Should Be Equal As Integers ${rc} ${success_return_code}
181 Check For NS Operation Completed
182 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
184 [Arguments] ${ns_operation_id}
186 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
188 Should Be Equal As Integers ${rc} ${success_return_code}
189 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
193 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
197 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
198 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
199 @{vdur} = Split String ${stdout}
204 [Documentation] Return a list with the names of the VDU records of a VNF instance.
206 [Arguments] ${vnf_id}
208 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq r - vdur.*.name
209 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
210 @{vdur} = Split String ${stdout}