blob: fb4561e1e7b792e945f2faf660eab8634c05b8ac [file] [log] [blame]
romeromonser4edf7332020-04-02 15:54:38 +02001# 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
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
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.
12
13*** Variables ***
14${success_return_code} 0
15${ns_launch_max_wait_time} 5min
16${ns_launch_pol_time} 30sec
17${ns_delete_max_wait_time} 1min
18${ns_delete_pol_time} 15sec
limon7b58bc12020-05-14 18:32:51 +020019${ns_action_max_wait_time} 1min
20${ns_action_pol_time} 15sec
21${vnf_scale_max_wait_time} 5min
22${vnf_scale_pol_time} 30sec
23
romeromonser4edf7332020-04-02 15:54:38 +020024
25*** Keywords ***
26Create Network Service
27 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey}
28
29 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
30 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
31
32 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr}
33 log ${ns_id}
34
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}
37 [Return] ${ns_id}
38
Javier Melian80a16cf2020-05-19 07:39:12 +000039
romeromonser4edf7332020-04-02 15:54:38 +020040Instantiate Network Service
41 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
42
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}
44 log ${stdout}
45 Should Be Equal As Integers ${rc} ${success_return_code}
46 [Return] ${stdout}
47
Javier Melian80a16cf2020-05-19 07:39:12 +000048
romeromonser4edf7332020-04-02 15:54:38 +020049Get Vnf Management Ip Address
50 [Arguments] ${ns_id} ${vnf_member_index}
51
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
55 log ${stdout}
56 Should Be Equal As Integers ${rc} ${success_return_code}
57 [Return] ${stdout}
58
romeromonser4edf7332020-04-02 15:54:38 +020059
Javier Melian80a16cf2020-05-19 07:39:12 +000060Get Ns Vnf List
61 [Arguments] ${ns_id}
62
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]
67 Log List ${vnf_list}
68 [Return] @{vnf_list}
69
70
71Get Ns Ip List
72 [Arguments] @{vnf_list}
73
74 should not be empty @{vnf_list}
75 @{temp_list}= Create List
76 FOR ${vnf_id} IN @{vnf_list}
77 log ${vnf_id}
78 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
79 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
80 END
81 should not be empty ${temp_list}
82 [return] @{temp_list}
83
84
85Get Vnf Ip List
86 [arguments] ${vnf_id}
87
88 should not be empty ${vnf_id}
89 @{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
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}
96
97
98Check For Ns Instance To Configured
99 [arguments] ${ns_name}
100
101 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
romeromonser4edf7332020-04-02 15:54:38 +0200102 log ${stdout}
103 Should Be Equal As Integers ${rc} ${success_return_code}
104 Should Contain Any ${stdout} READY BROKEN
105
106Check For NS Instance For Failure
107 [Arguments] ${ns_name}
108
109 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
110 log ${stdout}
111 Should Be Equal As Integers ${rc} ${success_return_code}
112 Should Not Contain ${stdout} BROKEN
113
114Check For NS Instance To Be Deleted
115 [Arguments] ${ns}
116
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}
119
120Delete NS
121 [Documentation] Delete ns
122 [Arguments] ${ns}
123
124 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
125 log ${stdout}
126 Should Be Equal As Integers ${rc} ${success_return_code}
127
128 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
limon7b58bc12020-05-14 18:32:51 +0200129
130Execute NS Action
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}
137
138 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
139
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}",
144 END
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}
152 [Return] ${stdout}
153
154
155Execute Manual VNF Scale
156 [Documentation] Execute a manual VNF Scale action.
157 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
158 ... Return the ID of the operation associated to the executed scale action.
159
160 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
161
162 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
163 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
164 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
165 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
166 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
167 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
168 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
169 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
170 [Return] ${stdout}
171
172
173Get Operations List
174 [Arguments] ${ns_name}
175
176 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
177 log ${stdout}
178 log ${rc}
179 Should Be Equal As Integers ${rc} ${success_return_code}
180
181
182Check For NS Operation Completed
183 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
184
185 [Arguments] ${ns_operation_id}
186
187 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
188 log ${stdout}
189 Should Be Equal As Integers ${rc} ${success_return_code}
190 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
191
192
193Get Ns Vnfr Ids
194 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
195
196 [Arguments] ${ns_id}
197
198 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
199 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
200 @{vdur} = Split String ${stdout}
201 [Return] @{vdur}
202
203
204Get Vnf Vdur Names
205 [Documentation] Return a list with the names of the VDU records of a VNF instance.
206
207 [Arguments] ${vnf_id}
208
209 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq r - vdur.*.name
210 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
211 @{vdur} = Split String ${stdout}
212 [Return] @{vdur}
213