blob: 405ebe759993f287badc5c6629017cc002709171 [file] [log] [blame]
Ken'ichi Ohmichi02604582014-03-14 16:23:41 +09001# Copyright 2014 NEC Corporation. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Ken'ichi Ohmichi29cd5122014-04-28 11:04:52 +090015import copy
16
Ken'ichi Ohmichi024cdae2014-03-24 08:05:59 +090017from tempest.api_schema.compute import parameter_types
Ken'ichi Ohmichi29cd5122014-04-28 11:04:52 +090018from tempest.api_schema.compute import servers
Ken'ichi Ohmichi024cdae2014-03-24 08:05:59 +090019
Ken'ichi Ohmichi02604582014-03-14 16:23:41 +090020create_server = {
21 'status_code': [202],
22 'response_body': {
23 'type': 'object',
24 'properties': {
25 'server': {
26 'type': 'object',
27 'properties': {
Ghanshyamc5b842d2014-06-10 17:06:05 +090028 'id': {'type': 'string'},
Ken'ichi Ohmichi02604582014-03-14 16:23:41 +090029 'security_groups': {'type': 'array'},
Ken'ichi Ohmichi024cdae2014-03-24 08:05:59 +090030 'links': parameter_types.links,
Ken'ichi Ohmichi02604582014-03-14 16:23:41 +090031 'adminPass': {'type': 'string'},
32 'OS-DCF:diskConfig': {'type': 'string'}
33 },
34 # NOTE: OS-DCF:diskConfig is API extension, and some
35 # environments return a response without the attribute.
36 # So it is not 'required'.
JordanP551140c2014-04-02 11:16:09 +020037 # NOTE: adminPass is not required because it can be deactivated
38 # with nova API flag enable_instance_password=False
39 'required': ['id', 'security_groups', 'links']
Ken'ichi Ohmichi02604582014-03-14 16:23:41 +090040 }
41 },
42 'required': ['server']
43 }
44}
Ghanshyam08ce58d2014-04-04 14:51:14 +090045
Ken'ichi Ohmichi21e4fc72014-05-08 16:46:23 +090046update_server = copy.deepcopy(servers.base_update_get_server)
Ken'ichi Ohmichi29cd5122014-04-28 11:04:52 +090047update_server['response_body']['properties']['server']['properties'].update({
48 'hostId': {'type': 'string'},
49 'OS-DCF:diskConfig': {'type': 'string'},
50 'accessIPv4': parameter_types.access_ip_v4,
51 'accessIPv6': parameter_types.access_ip_v6
52})
53update_server['response_body']['properties']['server']['required'].append(
54 # NOTE: OS-DCF:diskConfig and accessIPv4/v6 are API
55 # extensions, and some environments return a response
56 # without these attributes. So they are not 'required'.
57 'hostId'
58)
59
Ken'ichi Ohmichi21e4fc72014-05-08 16:46:23 +090060get_server = copy.deepcopy(servers.base_update_get_server)
61get_server['response_body']['properties']['server']['properties'].update({
62 'key_name': {'type': ['string', 'null']},
63 'hostId': {'type': 'string'},
64
65 # NOTE: Non-admin users also can see "OS-SRV-USG" and "OS-EXT-AZ"
66 # attributes.
67 'OS-SRV-USG:launched_at': {'type': ['string', 'null']},
68 'OS-SRV-USG:terminated_at': {'type': ['string', 'null']},
69 'OS-EXT-AZ:availability_zone': {'type': 'string'},
70
71 # NOTE: Admin users only can see "OS-EXT-STS" and "OS-EXT-SRV-ATTR"
72 # attributes.
73 'OS-EXT-STS:task_state': {'type': ['string', 'null']},
74 'OS-EXT-STS:vm_state': {'type': 'string'},
75 'OS-EXT-STS:power_state': {'type': 'integer'},
76 'OS-EXT-SRV-ATTR:host': {'type': ['string', 'null']},
77 'OS-EXT-SRV-ATTR:instance_name': {'type': 'string'},
78 'OS-EXT-SRV-ATTR:hypervisor_hostname': {'type': ['string', 'null']},
79 'os-extended-volumes:volumes_attached': {'type': 'array'},
80 'OS-DCF:diskConfig': {'type': 'string'},
81 'accessIPv4': parameter_types.access_ip_v4,
82 'accessIPv6': parameter_types.access_ip_v6,
83 'config_drive': {'type': 'string'}
84})
85get_server['response_body']['properties']['server']['required'].append(
86 # NOTE: OS-SRV-USG, OS-EXT-AZ, OS-EXT-STS, OS-EXT-SRV-ATTR,
87 # os-extended-volumes, OS-DCF and accessIPv4/v6 are API
88 # extension, and some environments return a response without
89 # these attributes. So they are not 'required'.
90 'hostId'
91)
92
Ghanshyam08ce58d2014-04-04 14:51:14 +090093list_virtual_interfaces = {
94 'status_code': [200],
95 'response_body': {
96 'type': 'object',
97 'properties': {
98 'virtual_interfaces': {
99 'type': 'array',
100 'items': {
101 'type': 'object',
102 'properties': {
103 'id': {'type': 'string'},
104 'mac_address': parameter_types.mac_address,
105 'OS-EXT-VIF-NET:net_id': {'type': 'string'}
106 },
107 # 'OS-EXT-VIF-NET:net_id' is API extension So it is
108 # not defined as 'required'
109 'required': ['id', 'mac_address']
110 }
111 }
112 },
113 'required': ['virtual_interfaces']
114 }
115}
Ghanshyam385c4e72014-03-27 11:42:25 +0900116
117attach_volume = {
118 'status_code': [200],
119 'response_body': {
120 'type': 'object',
121 'properties': {
122 'volumeAttachment': {
123 'type': 'object',
124 'properties': {
125 'id': {'type': 'string'},
126 'device': {'type': 'string'},
127 'volumeId': {'type': 'string'},
128 'serverId': {'type': ['integer', 'string']}
129 },
130 'required': ['id', 'device', 'volumeId', 'serverId']
131 }
132 },
133 'required': ['volumeAttachment']
134 }
135}
136
137detach_volume = {
138 'status_code': [202]
139}
Ghanshyameaaa6a42014-04-25 18:38:21 +0900140
141set_get_server_metadata_item = {
142 'status_code': [200],
143 'response_body': {
144 'type': 'object',
145 'properties': {
146 'meta': {
147 'type': 'object',
148 'patternProperties': {
149 '^.+$': {'type': 'string'}
150 }
151 }
152 },
153 'required': ['meta']
154 }
155}
Ghanshyam9541ad12014-05-07 16:38:43 +0900156
157list_addresses_by_network = {
158 'status_code': [200],
159 'response_body': parameter_types.addresses
160}
Ghanshyam997c9092014-04-03 19:00:20 +0900161
162server_actions_confirm_resize = copy.deepcopy(
163 servers.server_actions_delete_password)
Ghanshyamd847c582014-05-07 16:21:36 +0900164
165list_addresses = {
166 'status_code': [200],
167 'response_body': {
168 'type': 'object',
169 'properties': {
170 'addresses': parameter_types.addresses
171 },
172 'required': ['addresses']
173 }
174}
Ghanshyamf81f9fa2014-05-23 13:38:56 +0900175
176common_server_group = {
177 'type': 'object',
178 'properties': {
179 'id': {'type': 'string'},
180 'name': {'type': 'string'},
181 'policies': {
182 'type': 'array',
183 'items': {'type': 'string'}
184 },
185 # 'members' attribute contains the array of instance's UUID of
186 # instances present in server group
187 'members': {
188 'type': 'array',
189 'items': {'type': 'string'}
190 },
191 'metadata': {'type': 'object'}
192 },
193 'required': ['id', 'name', 'policies', 'members', 'metadata']
194}
195
196create_get_server_group = {
197 'status_code': [200],
198 'response_body': {
199 'type': 'object',
200 'properties': {
201 'server_group': common_server_group
202 },
203 'required': ['server_group']
204 }
205}
206
207delete_server_group = {
208 'status_code': [204]
209}
Ghanshyam29966092014-04-07 17:27:41 +0900210
Ghanshyam438ed3b2014-06-18 17:25:41 +0900211list_server_groups = {
212 'status_code': [200],
213 'response_body': {
214 'type': 'object',
215 'properties': {
216 'server_groups': {
217 'type': 'array',
218 'items': common_server_group
219 }
220 },
221 'required': ['server_groups']
222 }
223}
224
Ghanshyam29966092014-04-07 17:27:41 +0900225instance_actions_object = copy.deepcopy(servers.common_instance_actions)
226instance_actions_object[
227 'properties'].update({'instance_uuid': {'type': 'string'}})
228instance_actions_object['required'].extend(['instance_uuid'])
229
230list_instance_actions = {
231 'status_code': [200],
232 'response_body': {
233 'type': 'object',
234 'properties': {
235 'instanceActions': {
236 'type': 'array',
237 'items': instance_actions_object
238 }
239 },
240 'required': ['instanceActions']
241 }
242}
Ghanshyam51744862014-06-13 12:56:24 +0900243
Ghanshyam4b41dfd2014-07-17 13:40:38 +0900244get_instance_actions_object = copy.deepcopy(servers.common_get_instance_action)
245get_instance_actions_object[
246 'properties'].update({'instance_uuid': {'type': 'string'}})
247get_instance_actions_object['required'].extend(['instance_uuid'])
248
249get_instance_action = {
250 'status_code': [200],
251 'response_body': {
252 'type': 'object',
253 'properties': {
254 'instanceAction': get_instance_actions_object
255 },
256 'required': ['instanceAction']
257 }
258}
259
Ghanshyam51744862014-06-13 12:56:24 +0900260list_servers_detail = copy.deepcopy(servers.base_list_servers_detail)
261list_servers_detail['response_body']['properties']['servers']['items'][
262 'properties'].update({
263 'hostId': {'type': 'string'},
264 'OS-DCF:diskConfig': {'type': 'string'},
265 'accessIPv4': parameter_types.access_ip_v4,
266 'accessIPv6': parameter_types.access_ip_v6
267 })
268# NOTE(GMann): OS-DCF:diskConfig and accessIPv4/v6 are API
269# extensions, and some environments return a response
270# without these attributes. So they are not 'required'.
271list_servers_detail['response_body']['properties']['servers']['items'][
272 'required'].append('hostId')
Ghanshyam9c2e50d2014-07-22 21:32:05 +0900273
274rebuild_server = copy.deepcopy(update_server)
275rebuild_server['status_code'] = [202]
276del rebuild_server['response_body']['properties']['server'][
277 'properties']['OS-DCF:diskConfig']
278
279rebuild_server_with_admin_pass = copy.deepcopy(rebuild_server)
280rebuild_server_with_admin_pass['response_body']['properties']['server'][
281 'properties'].update({'adminPass': {'type': 'string'}})
282rebuild_server_with_admin_pass['response_body']['properties']['server'][
283 'required'].append('adminPass')
Ghanshyam88457912014-07-25 16:02:12 +0900284
285rescue_server = {
286 'status_code': [200],
287 'response_body': {
288 'type': 'object',
289 'properties': {
290 'adminPass': {'type': 'string'}
291 },
292 'required': ['adminPass']
293 }
294}