blob: 1f1020d0a2ed7700c582379c0e801096da83cdd5 [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 ***
14${success_return_code} 0
15
16
17*** Keywords ***
18Get Server Flavor ID
19 [Arguments] ${server_id}
20
21 Should Not Be Empty ${server_id}
22 ${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}
garciaale0e696252020-09-24 18:04:27 +000024 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020025 [Return] ${stdout}
garciaale0e696252020-09-24 18:04:27 +000026
27
28Get Flavor Properties
29 [Arguments] ${flavor_id}
30
31 Should Not Be Empty ${flavor_id}
32 ${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}
garciaale0e696252020-09-24 18:04:27 +000034 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020035 [Return] ${stdout}
aguilard3422ec32021-06-30 12:28:46 +020036
37
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}
41
42 Should Not Be Empty ${ns_name}
43 ${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}
aguilard3422ec32021-06-30 12:28:46 +020045 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020046 @{servers} = Split String ${stdout}
47 ${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
50
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}
54
55 Should Not Be Empty ${volume_id}
56 ${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
61
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}
65
66 Should Not Be Empty ${field}
67 ${rc} ${stdout}= Run and Return RC and Output openstack quota show -c ${field} -f value
garciadeblas321726f2022-12-21 11:43:06 +010068 Log ${stdout}
aguilardceb1cb42022-02-24 10:54:14 +000069 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020070 [Return] ${stdout}
aguilardceb1cb42022-02-24 10:54:14 +000071
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}
aguilardbde67802022-03-18 14:15:17 +000076
77 Should Not Be Empty ${server_id}
78 Should Not Be Empty ${field}
79 ${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}
aguilardbde67802022-03-18 14:15:17 +000081 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020082 [Return] ${stdout}
aguilardbde67802022-03-18 14:15:17 +000083
84
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}
88
89 Should Not Be Empty ${server_group_name}
90 Should Not Be Empty ${server_id}
91 ${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}
Alexis Romerodd1b09d2022-03-16 06:51:43 +010093 Should Be Equal As Integers ${rc} ${success_return_code}
94 Should Contain ${stdout} ${server_id}
95
96
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}
100
101 Should Not Be Empty ${volume_match} ${index}
102 ${bootable}= Check If Volume Bootable ${volume_match}[${index}]
103 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]
108 ELSE
109 Set Suite Variable ${ordinary_vol_id} ${volume_match}[0]
110 END
111 END
112
113
114Get 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}
117
118 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
122 log ${volumes_attached}
123 ${stdout}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1
124 log ${stdout}
125 [Return] ${stdout}
126
127
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}
aguilardbde67802022-03-18 14:15:17 +0000131
132 Should Not Be Empty ${volume_id}
133 ${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}
aguilardbde67802022-03-18 14:15:17 +0000135 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200136 [Return] ${stdout}
aguilardbde67802022-03-18 14:15:17 +0000137
138
139Delete Volume
garciadeblasf4ebaa82022-06-23 13:33:26 +0200140 [Documentation] Delete a volume by its identifier
141 [Arguments] ${volume_id}
aguilardbde67802022-03-18 14:15:17 +0000142
143 Should Not Be Empty ${volume_id}
144 ${rc} ${stdout}= Run and Return RC and Output openstack volume delete ${volume_id}
garciadeblas321726f2022-12-21 11:43:06 +0100145 Log ${stdout}
aguilardbde67802022-03-18 14:15:17 +0000146 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200147 [Return] ${stdout}
aguilard845c2ea2022-04-08 09:36:03 +0000148
149
150Stop Server
garciadeblasf4ebaa82022-06-23 13:33:26 +0200151 [Documentation] Stop a server
152 [Arguments] ${server_id}
aguilard845c2ea2022-04-08 09:36:03 +0000153
154 Should Not Be Empty ${server_id}
155 ${rc} ${stdout}= Run and Return RC and Output openstack server stop ${server_id}
garciadeblas321726f2022-12-21 11:43:06 +0100156 Log ${stdout}
aguilard845c2ea2022-04-08 09:36:03 +0000157 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200158 [Return] ${stdout}
dhanasekaranc4da0672022-04-28 12:56:03 +0000159
aguilard8f18bfd2022-06-22 10:44:20 +0000160
dhanasekaranc4da0672022-04-28 12:56:03 +0000161Halt Server
garciadeblasf4ebaa82022-06-23 13:33:26 +0200162 [Documentation] Reset a server
163 [Arguments] ${server_id}
dhanasekaranc4da0672022-04-28 12:56:03 +0000164
165 Should Not Be Empty ${server_id}
166 ${rc} ${stdout}= Run and Return RC and Output openstack server set --state error ${server_id}
garciadeblas321726f2022-12-21 11:43:06 +0100167 Log ${stdout}
dhanasekaranc4da0672022-04-28 12:56:03 +0000168 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200169 [Return] ${stdout}
aguilard8f18bfd2022-06-22 10:44:20 +0000170
171
172Delete Server
173 [Documentation] Delete a server
174 [Arguments] ${server_id}
175
176 Should Not Be Empty ${server_id}
177 ${rc} ${stdout}= Run and Return RC and Output openstack server delete ${server_id}
garciadeblas321726f2022-12-21 11:43:06 +0100178 Log ${stdout}
aguilard8f18bfd2022-06-22 10:44:20 +0000179 Should Be Equal As Integers ${rc} ${success_return_code}
180 [Return] ${stdout}
181
182