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}
51 Check If Volume Bootable
52 [Documentation] Check the volume properties and return whether it is bootable or not.
53 [Arguments] ${volume_id}
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}'
58 Should Be Equal As Integers ${rc} ${success_return_code}
63 [Documentation] Get a field (ram, cores, ports, etc.) from quota in current project.
66 Should Not Be Empty ${field}
67 ${rc} ${stdout}= Run and Return RC and Output openstack quota show -c ${field} -f value
69 Should Be Equal As Integers ${rc} ${success_return_code}
74 [Documentation] Get a field (flavor, image, volumes_attached, etc.) from a server.
75 [Arguments] ${server_id} ${field}
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
81 Should Be Equal As Integers ${rc} ${success_return_code}
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}
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
93 Should Be Equal As Integers ${rc} ${success_return_code}
94 Should Contain ${stdout} ${server_id}
98 [Documentation] Sets the root volume ID and ordinary volume ID by checking bootable property of volumes
99 [Arguments] ${volume_match} ${index}
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}]
107 Set Suite Variable ${ordinary_vol_id} ${volume_match}[1]
109 Set Suite Variable ${ordinary_vol_id} ${volume_match}[0]
114 Get Persistent Volumes Attached To Vm
115 [Documentation] Sets the root volume ID and ordinary volume ID by checking bootable property of volumes
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
128 Check If Volume Exists
129 [Documentation] Checks if a volume id exists
130 [Arguments] ${volume_id}
132 Should Not Be Empty ${volume_id}
133 ${rc} ${stdout}= Run and Return RC and Output openstack volume list | grep ${volume_id} | wc -l
135 Should Be Equal As Integers ${rc} ${success_return_code}
140 [Documentation] Delete a volume by its identifier
141 [Arguments] ${volume_id}
143 Should Not Be Empty ${volume_id}
144 ${rc} ${stdout}= Run and Return RC and Output openstack volume delete ${volume_id}
146 Should Be Equal As Integers ${rc} ${success_return_code}
151 [Documentation] Stop a server
152 [Arguments] ${server_id}
154 Should Not Be Empty ${server_id}
155 ${rc} ${stdout}= Run and Return RC and Output openstack server stop ${server_id}
157 Should Be Equal As Integers ${rc} ${success_return_code}
162 [Documentation] Reset a server
163 [Arguments] ${server_id}
165 Should Not Be Empty ${server_id}
166 ${rc} ${stdout}= Run and Return RC and Output openstack server set --state error ${server_id}
168 Should Be Equal As Integers ${rc} ${success_return_code}
173 [Documentation] Delete a server
174 [Arguments] ${server_id}
176 Should Not Be Empty ${server_id}
177 ${rc} ${stdout}= Run and Return RC and Output openstack server delete ${server_id}
179 Should Be Equal As Integers ${rc} ${success_return_code}