| garciaale | 0e69625 | 2020-09-24 18:04:27 +0000 | [diff] [blame] | 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 |
| 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 *** |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 14 | ${success_return_code} 0 |
| garciaale | 0e69625 | 2020-09-24 18:04:27 +0000 | [diff] [blame] | 15 | |
| 16 | |
| 17 | *** Keywords *** |
| 18 | Get Server Flavor ID |
| 19 | [Arguments] ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 20 | |
| garciaale | 0e69625 | 2020-09-24 18:04:27 +0000 | [diff] [blame] | 21 | Should Not Be Empty ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 22 | ${rc} ${stdout}= Run and Return RC and Output openstack server show ${server_id} | grep flavor | awk 'NR>1{print $1}' RS='(' FS=')' |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 23 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 24 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 25 | [Return] ${stdout} |
| 26 | |
| garciaale | 0e69625 | 2020-09-24 18:04:27 +0000 | [diff] [blame] | 27 | |
| 28 | Get Flavor Properties |
| 29 | [Arguments] ${flavor_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 30 | |
| garciaale | 0e69625 | 2020-09-24 18:04:27 +0000 | [diff] [blame] | 31 | Should Not Be Empty ${flavor_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 32 | ${rc} ${stdout}= Run and Return RC and Output openstack flavor show ${flavor_id} | grep properties | awk -F '|' '{print $3}' |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 33 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 34 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 35 | [Return] ${stdout} |
| 36 | |
| aguilard | 3422ec3 | 2021-06-30 12:28:46 +0200 | [diff] [blame] | 37 | |
| 38 | Check NS Servers In VIM |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 39 | [Documentation] Check if the number of servers in Openstack by filtering by NS name is as expected. |
| aguilard | 3422ec3 | 2021-06-30 12:28:46 +0200 | [diff] [blame] | 40 | [Arguments] ${ns_name} ${number} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 41 | |
| aguilard | 3422ec3 | 2021-06-30 12:28:46 +0200 | [diff] [blame] | 42 | Should Not Be Empty ${ns_name} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 43 | ${rc} ${stdout}= Run and Return RC and Output openstack server list | grep ${ns_name} | awk '{print $4}' |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 44 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 45 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 46 | @{servers} = Split String ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 47 | ${n_servers}= Get Length ${servers} |
| aguilard | 3422ec3 | 2021-06-30 12:28:46 +0200 | [diff] [blame] | 48 | Should Be Equal As Integers ${number} ${n_servers} |
| aguilard | ceb1cb4 | 2022-02-24 10:54:14 +0000 | [diff] [blame] | 49 | |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 50 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 51 | Check If Volume Bootable |
| 52 | [Documentation] Check the volume properties and return whether it is bootable or not. |
| 53 | [Arguments] ${volume_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 54 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 55 | Should Not Be Empty ${volume_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 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 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 61 | |
| aguilard | ceb1cb4 | 2022-02-24 10:54:14 +0000 | [diff] [blame] | 62 | Get Project Quota |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 63 | [Documentation] Get a field (ram, cores, ports, etc.) from quota in current project. |
| aguilard | ceb1cb4 | 2022-02-24 10:54:14 +0000 | [diff] [blame] | 64 | [Arguments] ${field} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 65 | |
| aguilard | ceb1cb4 | 2022-02-24 10:54:14 +0000 | [diff] [blame] | 66 | Should Not Be Empty ${field} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 67 | ${rc} ${stdout}= Run and Return RC and Output openstack quota show -f yaml | yq '.[] | select(.Resource=="${field}") | .Limit' |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 68 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 69 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 70 | [Return] ${stdout} |
| 71 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 72 | |
| 73 | Get Server Property |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 74 | [Documentation] Get a field (flavor, image, volumes_attached, etc.) from a server. |
| 75 | [Arguments] ${server_id} ${field} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 76 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 77 | Should Not Be Empty ${server_id} |
| 78 | Should Not Be Empty ${field} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 79 | ${rc} ${stdout}= Run and Return RC and Output openstack server show ${server_id} -c ${field} -f value |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 80 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 81 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 82 | [Return] ${stdout} |
| 83 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 84 | |
| Alexis Romero | dd1b09d | 2022-03-16 06:51:43 +0100 | [diff] [blame] | 85 | Check 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} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 88 | |
| Alexis Romero | dd1b09d | 2022-03-16 06:51:43 +0100 | [diff] [blame] | 89 | Should Not Be Empty ${server_group_name} |
| 90 | Should Not Be Empty ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 91 | ${rc} ${stdout}= Run and Return RC and Output openstack server group show ${server_group_name} -c members -f value |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 92 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 93 | Should Be Equal As Integers ${rc} ${success_return_code} |
| Alexis Romero | dd1b09d | 2022-03-16 06:51:43 +0100 | [diff] [blame] | 94 | Should Contain ${stdout} ${server_id} |
| 95 | |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 96 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 97 | Set Volume Id |
| 98 | [Documentation] Sets the root volume ID and ordinary volume ID by checking bootable property of volumes |
| 99 | [Arguments] ${volume_match} ${index} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 100 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 101 | Should Not Be Empty ${volume_match} ${index} |
| 102 | ${bootable}= Check If Volume Bootable ${volume_match}[${index}] |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 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] |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 108 | ELSE |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 109 | Set Suite Variable ${ordinary_vol_id} ${volume_match}[0] |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 110 | END |
| 111 | END |
| 112 | |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 113 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 114 | Get 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} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 117 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 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 |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 122 | log ${volumes_attached} |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 123 | ${stdout}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1 |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 124 | log ${stdout} |
| 125 | [Return] ${stdout} |
| 126 | |
| Gulsum Atici | 8ceaee0 | 2022-12-09 16:38:22 +0300 | [diff] [blame] | 127 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 128 | Check If Volume Exists |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 129 | [Documentation] Checks if a volume id exists |
| 130 | [Arguments] ${volume_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 131 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 132 | Should Not Be Empty ${volume_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 133 | ${rc} ${stdout}= Run and Return RC and Output openstack volume list | grep ${volume_id} | wc -l |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 134 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 135 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 136 | [Return] ${stdout} |
| 137 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 138 | |
| 139 | Delete Volume |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 140 | [Documentation] Delete a volume by its identifier |
| 141 | [Arguments] ${volume_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 142 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 143 | Should Not Be Empty ${volume_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 144 | ${rc} ${stdout}= Run and Return RC and Output openstack volume delete ${volume_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 145 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 146 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 147 | [Return] ${stdout} |
| 148 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 149 | |
| Gabriel Cuba | 245b04f | 2023-05-09 12:37:29 -0500 | [diff] [blame] | 150 | Get Subnet |
| 151 | [Documentation] Get subnet information in JSON format |
| 152 | [Arguments] ${subnet_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 153 | |
| Gabriel Cuba | 245b04f | 2023-05-09 12:37:29 -0500 | [diff] [blame] | 154 | Should Not Be Empty ${subnet_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 155 | ${rc} ${stdout}= Run and Return RC and Output openstack subnet show ${subnet_id} -f json |
| Gabriel Cuba | 245b04f | 2023-05-09 12:37:29 -0500 | [diff] [blame] | 156 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 157 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 158 | [Return] ${stdout} |
| 159 | |
| Gabriel Cuba | 245b04f | 2023-05-09 12:37:29 -0500 | [diff] [blame] | 160 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 161 | Stop Server |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 162 | [Documentation] Stop a server |
| 163 | [Arguments] ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 164 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 165 | Should Not Be Empty ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 166 | ${rc} ${stdout}= Run and Return RC and Output openstack server stop ${server_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 167 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 168 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 169 | [Return] ${stdout} |
| 170 | |
| aguilard | 8f18bfd | 2022-06-22 10:44:20 +0000 | [diff] [blame] | 171 | |
| dhanasekaran | c4da067 | 2022-04-28 12:56:03 +0000 | [diff] [blame] | 172 | Halt Server |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 173 | [Documentation] Reset a server |
| 174 | [Arguments] ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 175 | |
| dhanasekaran | c4da067 | 2022-04-28 12:56:03 +0000 | [diff] [blame] | 176 | Should Not Be Empty ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 177 | ${rc} ${stdout}= Run and Return RC and Output openstack server set --state error ${server_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 178 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 179 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 180 | [Return] ${stdout} |
| 181 | |
| aguilard | 8f18bfd | 2022-06-22 10:44:20 +0000 | [diff] [blame] | 182 | |
| 183 | Delete Server |
| 184 | [Documentation] Delete a server |
| 185 | [Arguments] ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 186 | |
| aguilard | 8f18bfd | 2022-06-22 10:44:20 +0000 | [diff] [blame] | 187 | Should Not Be Empty ${server_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 188 | ${rc} ${stdout}= Run and Return RC and Output openstack server delete ${server_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 189 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 190 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 191 | [Return] ${stdout} |
| 192 | |
| aguilard | 8f18bfd | 2022-06-22 10:44:20 +0000 | [diff] [blame] | 193 | |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 194 | Create Flavor |
| 195 | [Documentation] Create a Flavor |
| 196 | [Arguments] ${flavor_name} ${cpu}=1 ${ram}=1024 ${disk}=10 |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 197 | |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 198 | Should Not Be Empty ${flavor_name} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 199 | ${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 Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 200 | Log ${flavor_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 201 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 202 | [Return] ${flavor_id} |
| 203 | |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 204 | |
| 205 | Delete Flavor |
| 206 | [Documentation] Delete a Flavor |
| 207 | [Arguments] ${flavor_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 208 | |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 209 | Should Not Be Empty ${flavor_id} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 210 | ${rc} ${stdout}= Run and Return RC and Output openstack flavor delete ${flavor_id} |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 211 | Log ${stdout} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame^] | 212 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 213 | [Return] ${stdout} |