blob: 6a8c84bf721cb411df2f173c6c4072387cb4e306 [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
romeromonser4edf7332020-04-02 15:54:38 +020015${ns_launch_pol_time} 30sec
16${ns_delete_max_wait_time} 1min
17${ns_delete_pol_time} 15sec
limon7b58bc12020-05-14 18:32:51 +020018${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
romeromonser4edf7332020-04-02 15:54:38 +020023
24*** Keywords ***
25Create Network Service
ramonsalguer543d7062020-06-15 13:37:28 +000026 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min
romeromonser4edf7332020-04-02 15:54:38 +020027
28 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
29 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
30
31 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr}
32 log ${ns_id}
33
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}
36 [Return] ${ns_id}
37
Javier Melian80a16cf2020-05-19 07:39:12 +000038
romeromonser4edf7332020-04-02 15:54:38 +020039Instantiate Network Service
40 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
41
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}
43 log ${stdout}
44 Should Be Equal As Integers ${rc} ${success_return_code}
45 [Return] ${stdout}
46
Javier Melian80a16cf2020-05-19 07:39:12 +000047
romeromonser4edf7332020-04-02 15:54:38 +020048Get Vnf Management Ip Address
49 [Arguments] ${ns_id} ${vnf_member_index}
50
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
54 log ${stdout}
55 Should Be Equal As Integers ${rc} ${success_return_code}
56 [Return] ${stdout}
57
romeromonser4edf7332020-04-02 15:54:38 +020058
Javier Melian80a16cf2020-05-19 07:39:12 +000059Get Ns Vnf List
60 [Arguments] ${ns_id}
61
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]
66 Log List ${vnf_list}
67 [Return] @{vnf_list}
68
69
70Get Ns Ip List
71 [Arguments] @{vnf_list}
72
73 should not be empty @{vnf_list}
74 @{temp_list}= Create List
75 FOR ${vnf_id} IN @{vnf_list}
76 log ${vnf_id}
77 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
78 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
79 END
80 should not be empty ${temp_list}
81 [return] @{temp_list}
82
83
84Get Vnf Ip List
85 [arguments] ${vnf_id}
86
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}
95
96
97Check For Ns Instance To Configured
98 [arguments] ${ns_name}
99
100 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
romeromonser4edf7332020-04-02 15:54:38 +0200101 log ${stdout}
102 Should Be Equal As Integers ${rc} ${success_return_code}
103 Should Contain Any ${stdout} READY BROKEN
104
105Check For NS Instance For Failure
106 [Arguments] ${ns_name}
107
108 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
109 log ${stdout}
110 Should Be Equal As Integers ${rc} ${success_return_code}
111 Should Not Contain ${stdout} BROKEN
112
113Check For NS Instance To Be Deleted
114 [Arguments] ${ns}
115
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}
118
119Delete NS
120 [Documentation] Delete ns
121 [Arguments] ${ns}
122
123 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
124 log ${stdout}
125 Should Be Equal As Integers ${rc} ${success_return_code}
126
127 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 +0200128
129Execute NS Action
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}
136
137 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
138
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}",
143 END
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}
151 [Return] ${stdout}
152
153
154Execute 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.
158
159 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
160
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}
169 [Return] ${stdout}
170
171
172Get Operations List
173 [Arguments] ${ns_name}
174
175 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
176 log ${stdout}
177 log ${rc}
178 Should Be Equal As Integers ${rc} ${success_return_code}
179
180
181Check For NS Operation Completed
182 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
183
184 [Arguments] ${ns_operation_id}
185
186 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
187 log ${stdout}
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
190
191
192Get Ns Vnfr Ids
193 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
194
195 [Arguments] ${ns_id}
196
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}
200 [Return] @{vdur}
201
202
203Get Vnf Vdur Names
204 [Documentation] Return a list with the names of the VDU records of a VNF instance.
205
206 [Arguments] ${vnf_id}
207
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}
211 [Return] @{vdur}
212