blob: b654cfd504d0ff163c1d1baa54e5b81acfca291d [file] [log] [blame]
garciaale0e696252020-09-24 18:04:27 +00001# 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 ***
garciadeblas23ff8f92023-12-11 16:26:40 +010014${success_return_code} 0
garciaale0e696252020-09-24 18:04:27 +000015
16
17*** Keywords ***
18Get Server Flavor ID
19 [Arguments] ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +010020
garciaale0e696252020-09-24 18:04:27 +000021 Should Not Be Empty ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +010022 ${rc} ${stdout}= Run and Return RC and Output openstack server show ${server_id} | grep flavor | awk 'NR>1{print $1}' RS='(' FS=')'
garciadeblas321726f2022-12-21 11:43:06 +010023 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +010024 Should Be Equal As Integers ${rc} ${success_return_code}
25 [Return] ${stdout}
26
garciaale0e696252020-09-24 18:04:27 +000027
28Get Flavor Properties
29 [Arguments] ${flavor_id}
garciadeblas23ff8f92023-12-11 16:26:40 +010030
garciaale0e696252020-09-24 18:04:27 +000031 Should Not Be Empty ${flavor_id}
garciadeblas23ff8f92023-12-11 16:26:40 +010032 ${rc} ${stdout}= Run and Return RC and Output openstack flavor show ${flavor_id} | grep properties | awk -F '|' '{print $3}'
garciadeblas321726f2022-12-21 11:43:06 +010033 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +010034 Should Be Equal As Integers ${rc} ${success_return_code}
35 [Return] ${stdout}
36
aguilard3422ec32021-06-30 12:28:46 +020037
38Check NS Servers In VIM
garciadeblasf4ebaa82022-06-23 13:33:26 +020039 [Documentation] Check if the number of servers in Openstack by filtering by NS name is as expected.
aguilard3422ec32021-06-30 12:28:46 +020040 [Arguments] ${ns_name} ${number}
garciadeblas23ff8f92023-12-11 16:26:40 +010041
aguilard3422ec32021-06-30 12:28:46 +020042 Should Not Be Empty ${ns_name}
garciadeblas23ff8f92023-12-11 16:26:40 +010043 ${rc} ${stdout}= Run and Return RC and Output openstack server list | grep ${ns_name} | awk '{print $4}'
garciadeblas321726f2022-12-21 11:43:06 +010044 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +010045 Should Be Equal As Integers ${rc} ${success_return_code}
46 @{servers} = Split String ${stdout}
garciadeblasf4ebaa82022-06-23 13:33:26 +020047 ${n_servers}= Get Length ${servers}
aguilard3422ec32021-06-30 12:28:46 +020048 Should Be Equal As Integers ${number} ${n_servers}
aguilardceb1cb42022-02-24 10:54:14 +000049
garciadeblas23ff8f92023-12-11 16:26:40 +010050
Gulsum Atici8ceaee02022-12-09 16:38:22 +030051Check If Volume Bootable
52 [Documentation] Check the volume properties and return whether it is bootable or not.
53 [Arguments] ${volume_id}
garciadeblas23ff8f92023-12-11 16:26:40 +010054
Gulsum Atici8ceaee02022-12-09 16:38:22 +030055 Should Not Be Empty ${volume_id}
garciadeblas23ff8f92023-12-11 16:26:40 +010056 ${rc} ${stdout}= Run and Return RC and Output openstack volume show ${volume_id} | grep bootable | awk '{print $4}'
57 log ${stdout}
58 Should Be Equal As Integers ${rc} ${success_return_code}
59 [Return] ${stdout}
60
Gulsum Atici8ceaee02022-12-09 16:38:22 +030061
aguilardceb1cb42022-02-24 10:54:14 +000062Get Project Quota
garciadeblasf4ebaa82022-06-23 13:33:26 +020063 [Documentation] Get a field (ram, cores, ports, etc.) from quota in current project.
aguilardceb1cb42022-02-24 10:54:14 +000064 [Arguments] ${field}
garciadeblas23ff8f92023-12-11 16:26:40 +010065
aguilardceb1cb42022-02-24 10:54:14 +000066 Should Not Be Empty ${field}
garciadeblas23ff8f92023-12-11 16:26:40 +010067 ${rc} ${stdout}= Run and Return RC and Output openstack quota show -f yaml | yq '.[] | select(.Resource=="${field}") | .Limit'
garciadeblas321726f2022-12-21 11:43:06 +010068 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +010069 Should Be Equal As Integers ${rc} ${success_return_code}
70 [Return] ${stdout}
71
aguilardbde67802022-03-18 14:15:17 +000072
73Get Server Property
garciadeblasf4ebaa82022-06-23 13:33:26 +020074 [Documentation] Get a field (flavor, image, volumes_attached, etc.) from a server.
75 [Arguments] ${server_id} ${field}
garciadeblas23ff8f92023-12-11 16:26:40 +010076
aguilardbde67802022-03-18 14:15:17 +000077 Should Not Be Empty ${server_id}
78 Should Not Be Empty ${field}
garciadeblas23ff8f92023-12-11 16:26:40 +010079 ${rc} ${stdout}= Run and Return RC and Output openstack server show ${server_id} -c ${field} -f value
garciadeblas321726f2022-12-21 11:43:06 +010080 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +010081 Should Be Equal As Integers ${rc} ${success_return_code}
82 [Return] ${stdout}
83
aguilardbde67802022-03-18 14:15:17 +000084
Alexis Romerodd1b09d2022-03-16 06:51:43 +010085Check VM In Server Group
86 [Documentation] Check if a given server is included in an Openstack server group
87 [Arguments] ${server_id} ${server_group_name}
garciadeblas23ff8f92023-12-11 16:26:40 +010088
Alexis Romerodd1b09d2022-03-16 06:51:43 +010089 Should Not Be Empty ${server_group_name}
90 Should Not Be Empty ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +010091 ${rc} ${stdout}= Run and Return RC and Output openstack server group show ${server_group_name} -c members -f value
garciadeblas321726f2022-12-21 11:43:06 +010092 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +010093 Should Be Equal As Integers ${rc} ${success_return_code}
Alexis Romerodd1b09d2022-03-16 06:51:43 +010094 Should Contain ${stdout} ${server_id}
95
garciadeblas23ff8f92023-12-11 16:26:40 +010096
Gulsum Atici8ceaee02022-12-09 16:38:22 +030097Set Volume Id
98 [Documentation] Sets the root volume ID and ordinary volume ID by checking bootable property of volumes
99 [Arguments] ${volume_match} ${index}
garciadeblas23ff8f92023-12-11 16:26:40 +0100100
Gulsum Atici8ceaee02022-12-09 16:38:22 +0300101 Should Not Be Empty ${volume_match} ${index}
102 ${bootable}= Check If Volume Bootable ${volume_match}[${index}]
garciadeblas23ff8f92023-12-11 16:26:40 +0100103 Set Suite Variable ${bootable}
104 IF '${bootable}'=='true'
105 Set Suite Variable ${root_vol_id} ${volume_match}[${index}]
106 IF ${index}==0
107 Set Suite Variable ${ordinary_vol_id} ${volume_match}[1]
Gulsum Atici8ceaee02022-12-09 16:38:22 +0300108 ELSE
garciadeblas23ff8f92023-12-11 16:26:40 +0100109 Set Suite Variable ${ordinary_vol_id} ${volume_match}[0]
Gulsum Atici8ceaee02022-12-09 16:38:22 +0300110 END
111 END
112
garciadeblas23ff8f92023-12-11 16:26:40 +0100113
Gulsum Atici8ceaee02022-12-09 16:38:22 +0300114Get Persistent Volumes Attached To Vm
115 [Documentation] Sets the root volume ID and ordinary volume ID by checking bootable property of volumes
116 [Arguments] ${ns_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100117
Gulsum Atici8ceaee02022-12-09 16:38:22 +0300118 Variable Should Exist ${ns_id} msg=NS is not available
119 ${vnfs_list}= Get Ns Vnf List ${ns_id}
120 ${vim_id}= Get VNF VIM ID ${vnfs_list}[0]
121 ${volumes_attached}= Get Server Property ${vim_id} volumes_attached
garciadeblas23ff8f92023-12-11 16:26:40 +0100122 log ${volumes_attached}
Gulsum Atici8ceaee02022-12-09 16:38:22 +0300123 ${stdout}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1
garciadeblas23ff8f92023-12-11 16:26:40 +0100124 log ${stdout}
125 [Return] ${stdout}
126
Gulsum Atici8ceaee02022-12-09 16:38:22 +0300127
aguilardbde67802022-03-18 14:15:17 +0000128Check If Volume Exists
garciadeblasf4ebaa82022-06-23 13:33:26 +0200129 [Documentation] Checks if a volume id exists
130 [Arguments] ${volume_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100131
aguilardbde67802022-03-18 14:15:17 +0000132 Should Not Be Empty ${volume_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100133 ${rc} ${stdout}= Run and Return RC and Output openstack volume list | grep ${volume_id} | wc -l
garciadeblas321726f2022-12-21 11:43:06 +0100134 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +0100135 Should Be Equal As Integers ${rc} ${success_return_code}
136 [Return] ${stdout}
137
aguilardbde67802022-03-18 14:15:17 +0000138
139Delete Volume
garciadeblasf4ebaa82022-06-23 13:33:26 +0200140 [Documentation] Delete a volume by its identifier
141 [Arguments] ${volume_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100142
aguilardbde67802022-03-18 14:15:17 +0000143 Should Not Be Empty ${volume_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100144 ${rc} ${stdout}= Run and Return RC and Output openstack volume delete ${volume_id}
garciadeblas321726f2022-12-21 11:43:06 +0100145 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +0100146 Should Be Equal As Integers ${rc} ${success_return_code}
147 [Return] ${stdout}
148
aguilard845c2ea2022-04-08 09:36:03 +0000149
Gabriel Cuba245b04f2023-05-09 12:37:29 -0500150Get Subnet
151 [Documentation] Get subnet information in JSON format
152 [Arguments] ${subnet_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100153
Gabriel Cuba245b04f2023-05-09 12:37:29 -0500154 Should Not Be Empty ${subnet_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100155 ${rc} ${stdout}= Run and Return RC and Output openstack subnet show ${subnet_id} -f json
Gabriel Cuba245b04f2023-05-09 12:37:29 -0500156 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +0100157 Should Be Equal As Integers ${rc} ${success_return_code}
158 [Return] ${stdout}
159
Gabriel Cuba245b04f2023-05-09 12:37:29 -0500160
aguilard845c2ea2022-04-08 09:36:03 +0000161Stop Server
garciadeblasf4ebaa82022-06-23 13:33:26 +0200162 [Documentation] Stop a server
163 [Arguments] ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100164
aguilard845c2ea2022-04-08 09:36:03 +0000165 Should Not Be Empty ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100166 ${rc} ${stdout}= Run and Return RC and Output openstack server stop ${server_id}
garciadeblas321726f2022-12-21 11:43:06 +0100167 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +0100168 Should Be Equal As Integers ${rc} ${success_return_code}
169 [Return] ${stdout}
170
aguilard8f18bfd2022-06-22 10:44:20 +0000171
dhanasekaranc4da0672022-04-28 12:56:03 +0000172Halt Server
garciadeblasf4ebaa82022-06-23 13:33:26 +0200173 [Documentation] Reset a server
174 [Arguments] ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100175
dhanasekaranc4da0672022-04-28 12:56:03 +0000176 Should Not Be Empty ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100177 ${rc} ${stdout}= Run and Return RC and Output openstack server set --state error ${server_id}
garciadeblas321726f2022-12-21 11:43:06 +0100178 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +0100179 Should Be Equal As Integers ${rc} ${success_return_code}
180 [Return] ${stdout}
181
aguilard8f18bfd2022-06-22 10:44:20 +0000182
183Delete Server
184 [Documentation] Delete a server
185 [Arguments] ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100186
aguilard8f18bfd2022-06-22 10:44:20 +0000187 Should Not Be Empty ${server_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100188 ${rc} ${stdout}= Run and Return RC and Output openstack server delete ${server_id}
garciadeblas321726f2022-12-21 11:43:06 +0100189 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +0100190 Should Be Equal As Integers ${rc} ${success_return_code}
191 [Return] ${stdout}
192
aguilard8f18bfd2022-06-22 10:44:20 +0000193
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500194Create Flavor
195 [Documentation] Create a Flavor
196 [Arguments] ${flavor_name} ${cpu}=1 ${ram}=1024 ${disk}=10
garciadeblas23ff8f92023-12-11 16:26:40 +0100197
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500198 Should Not Be Empty ${flavor_name}
garciadeblas23ff8f92023-12-11 16:26:40 +0100199 ${rc} ${flavor_id}= Run and Return RC and Output openstack flavor create ${flavor_name} --ram ${ram} --disk ${disk} --vcpus ${cpu} -c id -f value
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500200 Log ${flavor_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100201 Should Be Equal As Integers ${rc} ${success_return_code}
202 [Return] ${flavor_id}
203
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500204
205Delete Flavor
206 [Documentation] Delete a Flavor
207 [Arguments] ${flavor_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100208
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500209 Should Not Be Empty ${flavor_id}
garciadeblas23ff8f92023-12-11 16:26:40 +0100210 ${rc} ${stdout}= Run and Return RC and Output openstack flavor delete ${flavor_id}
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500211 Log ${stdout}
garciadeblas23ff8f92023-12-11 16:26:40 +0100212 Should Be Equal As Integers ${rc} ${success_return_code}
213 [Return] ${stdout}