| 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 *** |
| 14 | ${success_return_code} 0 |
| 15 | |
| 16 | |
| 17 | *** Keywords *** |
| 18 | Get 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=')' |
| 23 | log ${stdout} |
| 24 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 25 | [Return] ${stdout} |
| 26 | |
| 27 | |
| 28 | Get 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}' |
| 33 | log ${stdout} |
| 34 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 35 | [Return] ${stdout} |
| aguilard | 3422ec3 | 2021-06-30 12:28:46 +0200 | [diff] [blame] | 36 | |
| 37 | |
| 38 | Check NS Servers In VIM |
| 39 | [Documentation] Check if the number of servers in Openstack by filtering by NS name is as expected. |
| 40 | [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}' |
| 44 | log ${stdout} |
| 45 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 46 | @{servers} = Split String ${stdout} |
| 47 | ${n_servers}= Get Length ${servers} |
| 48 | Should Be Equal As Integers ${number} ${n_servers} |
| aguilard | ceb1cb4 | 2022-02-24 10:54:14 +0000 | [diff] [blame] | 49 | |
| 50 | |
| 51 | Get Project Quota |
| 52 | [Documentation] Get a field (ram, cores, ports, etc.) from quota in current project. |
| 53 | [Arguments] ${field} |
| 54 | |
| 55 | Should Not Be Empty ${field} |
| 56 | ${rc} ${stdout}= Run and Return RC and Output openstack quota show -c ${field} -f value |
| 57 | log ${stdout} |
| 58 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 59 | [Return] ${stdout} |
| 60 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 61 | |
| 62 | Get Server Property |
| 63 | [Documentation] Get a field (flavor, image, volumes_attached, etc.) from a server. |
| 64 | [Arguments] ${server_id} ${field} |
| 65 | |
| 66 | Should Not Be Empty ${server_id} |
| 67 | Should Not Be Empty ${field} |
| 68 | ${rc} ${stdout}= Run and Return RC and Output openstack server show ${server_id} -c ${field} -f value |
| 69 | log ${stdout} |
| 70 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 71 | [Return] ${stdout} |
| 72 | |
| 73 | |
| Alexis Romero | dd1b09d | 2022-03-16 06:51:43 +0100 | [diff] [blame] | 74 | Check VM In Server Group |
| 75 | [Documentation] Check if a given server is included in an Openstack server group |
| 76 | [Arguments] ${server_id} ${server_group_name} |
| 77 | |
| 78 | Should Not Be Empty ${server_group_name} |
| 79 | Should Not Be Empty ${server_id} |
| 80 | ${rc} ${stdout}= Run and Return RC and Output openstack server group show ${server_group_name} -c members -f value |
| 81 | log ${stdout} |
| 82 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 83 | Should Contain ${stdout} ${server_id} |
| 84 | |
| 85 | |
| aguilard | bde6780 | 2022-03-18 14:15:17 +0000 | [diff] [blame] | 86 | Check If Volume Exists |
| 87 | [Documentation] Checks if a volume id exists |
| 88 | [Arguments] ${volume_id} |
| 89 | |
| 90 | Should Not Be Empty ${volume_id} |
| 91 | ${rc} ${stdout}= Run and Return RC and Output openstack volume list | grep ${volume_id} | wc -l |
| 92 | log ${stdout} |
| 93 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 94 | [Return] ${stdout} |
| 95 | |
| 96 | |
| 97 | Delete Volume |
| 98 | [Documentation] Delete a volume by its identifier |
| 99 | [Arguments] ${volume_id} |
| 100 | |
| 101 | Should Not Be Empty ${volume_id} |
| 102 | ${rc} ${stdout}= Run and Return RC and Output openstack volume delete ${volume_id} |
| 103 | log ${stdout} |
| 104 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 105 | [Return] ${stdout} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 106 | |
| 107 | |
| 108 | Stop Server |
| 109 | [Documentation] Stop a server |
| 110 | [Arguments] ${server_id} |
| 111 | |
| 112 | Should Not Be Empty ${server_id} |
| 113 | ${rc} ${stdout}= Run and Return RC and Output openstack server stop ${server_id} |
| 114 | log ${stdout} |
| 115 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 116 | [Return] ${stdout} |
| dhanasekaran | c4da067 | 2022-04-28 12:56:03 +0000 | [diff] [blame^] | 117 | |
| 118 | Halt Server |
| 119 | [Documentation] Reset a server |
| 120 | [Arguments] ${server_id} |
| 121 | |
| 122 | Should Not Be Empty ${server_id} |
| 123 | ${rc} ${stdout}= Run and Return RC and Output openstack server set --state error ${server_id} |
| 124 | log ${stdout} |
| 125 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 126 | [Return] ${stdout} |