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
5 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 ${success_return_code} 0
19 [Arguments] ${server_id}
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=')'
24 Should Be Equal As Integers ${rc} ${success_return_code}
29 [Arguments] ${flavor_id}
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}'
34 Should Be Equal As Integers ${rc} ${success_return_code}
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}
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}'
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}
52 [Documentation] Get a field (ram, cores, ports, etc.) from quota in current project.
55 Should Not Be Empty ${field}
56 ${rc} ${stdout}= Run and Return RC and Output openstack quota show -c ${field} -f value
58 Should Be Equal As Integers ${rc} ${success_return_code}
63 [Documentation] Get a field (flavor, image, volumes_attached, etc.) from a server.
64 [Arguments] ${server_id} ${field}
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
70 Should Be Equal As Integers ${rc} ${success_return_code}
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}
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
82 Should Be Equal As Integers ${rc} ${success_return_code}
83 Should Contain ${stdout} ${server_id}
86 Check If Volume Exists
87 [Documentation] Checks if a volume id exists
88 [Arguments] ${volume_id}
90 Should Not Be Empty ${volume_id}
91 ${rc} ${stdout}= Run and Return RC and Output openstack volume list | grep ${volume_id} | wc -l
93 Should Be Equal As Integers ${rc} ${success_return_code}
98 [Documentation] Delete a volume by its identifier
99 [Arguments] ${volume_id}
101 Should Not Be Empty ${volume_id}
102 ${rc} ${stdout}= Run and Return RC and Output openstack volume delete ${volume_id}
104 Should Be Equal As Integers ${rc} ${success_return_code}
109 [Documentation] Stop a server
110 [Arguments] ${server_id}
112 Should Not Be Empty ${server_id}
113 ${rc} ${stdout}= Run and Return RC and Output openstack server stop ${server_id}
115 Should Be Equal As Integers ${rc} ${success_return_code}
120 [Documentation] Reset a server
121 [Arguments] ${server_id}
123 Should Not Be Empty ${server_id}
124 ${rc} ${stdout}= Run and Return RC and Output openstack server set --state error ${server_id}
126 Should Be Equal As Integers ${rc} ${success_return_code}
131 [Documentation] Delete a server
132 [Arguments] ${server_id}
134 Should Not Be Empty ${server_id}
135 ${rc} ${stdout}= Run and Return RC and Output openstack server delete ${server_id}
137 Should Be Equal As Integers ${rc} ${success_return_code}