blob: ebee6976980b1c365f5687a7410802f26a72c29a [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
Marc Koderer6fbd74f2014-08-04 09:38:19 +020017from tempest.api_schema.response.compute import parameter_types
18from tempest.api_schema.response.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 'OS-DCF:diskConfig': {'type': 'string'}
32 },
ghanshyamfbc45c72015-02-24 11:18:00 +090033 # NOTE: OS-DCF:diskConfig & security_groups are API extension,
34 # and some environments return a response without these
35 # attributes.So they are not 'required'.
36 'required': ['id', 'links']
Ken'ichi Ohmichi02604582014-03-14 16:23:41 +090037 }
38 },
39 'required': ['server']
40 }
41}
Ghanshyam08ce58d2014-04-04 14:51:14 +090042
Ghanshyam7f989102014-07-29 14:23:26 +090043create_server_with_admin_pass = copy.deepcopy(create_server)
44create_server_with_admin_pass['response_body']['properties']['server'][
45 'properties'].update({'adminPass': {'type': 'string'}})
46create_server_with_admin_pass['response_body']['properties']['server'][
47 'required'].append('adminPass')
48
Ken'ichi Ohmichi21e4fc72014-05-08 16:46:23 +090049update_server = copy.deepcopy(servers.base_update_get_server)
Ken'ichi Ohmichi29cd5122014-04-28 11:04:52 +090050update_server['response_body']['properties']['server']['properties'].update({
51 'hostId': {'type': 'string'},
52 'OS-DCF:diskConfig': {'type': 'string'},
53 'accessIPv4': parameter_types.access_ip_v4,
54 'accessIPv6': parameter_types.access_ip_v6
55})
56update_server['response_body']['properties']['server']['required'].append(
57 # NOTE: OS-DCF:diskConfig and accessIPv4/v6 are API
58 # extensions, and some environments return a response
59 # without these attributes. So they are not 'required'.
60 'hostId'
61)
62
Ken'ichi Ohmichi21e4fc72014-05-08 16:46:23 +090063get_server = copy.deepcopy(servers.base_update_get_server)
64get_server['response_body']['properties']['server']['properties'].update({
65 'key_name': {'type': ['string', 'null']},
66 'hostId': {'type': 'string'},
ghanshyamfbc45c72015-02-24 11:18:00 +090067 'security_groups': {'type': 'array'},
Ken'ichi Ohmichi21e4fc72014-05-08 16:46:23 +090068
69 # NOTE: Non-admin users also can see "OS-SRV-USG" and "OS-EXT-AZ"
70 # attributes.
71 'OS-SRV-USG:launched_at': {'type': ['string', 'null']},
72 'OS-SRV-USG:terminated_at': {'type': ['string', 'null']},
73 'OS-EXT-AZ:availability_zone': {'type': 'string'},
74
75 # NOTE: Admin users only can see "OS-EXT-STS" and "OS-EXT-SRV-ATTR"
76 # attributes.
77 'OS-EXT-STS:task_state': {'type': ['string', 'null']},
78 'OS-EXT-STS:vm_state': {'type': 'string'},
79 'OS-EXT-STS:power_state': {'type': 'integer'},
80 'OS-EXT-SRV-ATTR:host': {'type': ['string', 'null']},
81 'OS-EXT-SRV-ATTR:instance_name': {'type': 'string'},
82 'OS-EXT-SRV-ATTR:hypervisor_hostname': {'type': ['string', 'null']},
83 'os-extended-volumes:volumes_attached': {'type': 'array'},
84 'OS-DCF:diskConfig': {'type': 'string'},
85 'accessIPv4': parameter_types.access_ip_v4,
86 'accessIPv6': parameter_types.access_ip_v6,
87 'config_drive': {'type': 'string'}
88})
89get_server['response_body']['properties']['server']['required'].append(
90 # NOTE: OS-SRV-USG, OS-EXT-AZ, OS-EXT-STS, OS-EXT-SRV-ATTR,
91 # os-extended-volumes, OS-DCF and accessIPv4/v6 are API
92 # extension, and some environments return a response without
93 # these attributes. So they are not 'required'.
94 'hostId'
95)
ghanshyam69ebee22015-02-24 19:28:00 +090096# NOTE(gmann): Update OS-EXT-IPS:type and OS-EXT-IPS-MAC:mac_addr
97# attributes in server address. Those are API extension,
98# and some environments return a response without
99# these attributes. So they are not 'required'.
100get_server['response_body']['properties']['server']['properties'][
101 'addresses']['patternProperties']['^[a-zA-Z0-9-_.]+$']['items'][
102 'properties'].update({
103 'OS-EXT-IPS:type': {'type': 'string'},
104 'OS-EXT-IPS-MAC:mac_addr': parameter_types.mac_address})
Ken'ichi Ohmichi21e4fc72014-05-08 16:46:23 +0900105
Ghanshyam08ce58d2014-04-04 14:51:14 +0900106list_virtual_interfaces = {
107 'status_code': [200],
108 'response_body': {
109 'type': 'object',
110 'properties': {
111 'virtual_interfaces': {
112 'type': 'array',
113 'items': {
114 'type': 'object',
115 'properties': {
116 'id': {'type': 'string'},
117 'mac_address': parameter_types.mac_address,
118 'OS-EXT-VIF-NET:net_id': {'type': 'string'}
119 },
120 # 'OS-EXT-VIF-NET:net_id' is API extension So it is
121 # not defined as 'required'
122 'required': ['id', 'mac_address']
123 }
124 }
125 },
126 'required': ['virtual_interfaces']
127 }
128}
Ghanshyam385c4e72014-03-27 11:42:25 +0900129
Ghanshyam5c2a5582014-04-14 17:16:57 +0900130common_attach_volume_info = {
131 'type': 'object',
132 'properties': {
133 'id': {'type': 'string'},
134 'device': {'type': 'string'},
135 'volumeId': {'type': 'string'},
136 'serverId': {'type': ['integer', 'string']}
137 },
138 'required': ['id', 'device', 'volumeId', 'serverId']
139}
140
Ghanshyam385c4e72014-03-27 11:42:25 +0900141attach_volume = {
142 'status_code': [200],
143 'response_body': {
144 'type': 'object',
145 'properties': {
Ghanshyam5c2a5582014-04-14 17:16:57 +0900146 'volumeAttachment': common_attach_volume_info
Ghanshyam385c4e72014-03-27 11:42:25 +0900147 },
148 'required': ['volumeAttachment']
149 }
150}
151
152detach_volume = {
153 'status_code': [202]
154}
Ghanshyameaaa6a42014-04-25 18:38:21 +0900155
Ghanshyam5c2a5582014-04-14 17:16:57 +0900156get_volume_attachment = copy.deepcopy(attach_volume)
157get_volume_attachment['response_body']['properties'][
158 'volumeAttachment']['properties'].update({'serverId': {'type': 'string'}})
159
160list_volume_attachments = {
161 'status_code': [200],
162 'response_body': {
163 'type': 'object',
164 'properties': {
165 'volumeAttachments': {
166 'type': 'array',
167 'items': common_attach_volume_info
168 }
169 },
170 'required': ['volumeAttachments']
171 }
172}
173list_volume_attachments['response_body']['properties'][
174 'volumeAttachments']['items']['properties'].update(
175 {'serverId': {'type': 'string'}})
176
Ghanshyameaaa6a42014-04-25 18:38:21 +0900177set_get_server_metadata_item = {
178 'status_code': [200],
179 'response_body': {
180 'type': 'object',
181 'properties': {
182 'meta': {
183 'type': 'object',
184 'patternProperties': {
185 '^.+$': {'type': 'string'}
186 }
187 }
188 },
189 'required': ['meta']
190 }
191}
Ghanshyam9541ad12014-05-07 16:38:43 +0900192
193list_addresses_by_network = {
194 'status_code': [200],
195 'response_body': parameter_types.addresses
196}
Ghanshyam997c9092014-04-03 19:00:20 +0900197
198server_actions_confirm_resize = copy.deepcopy(
199 servers.server_actions_delete_password)
Ghanshyamd847c582014-05-07 16:21:36 +0900200
201list_addresses = {
202 'status_code': [200],
203 'response_body': {
204 'type': 'object',
205 'properties': {
206 'addresses': parameter_types.addresses
207 },
208 'required': ['addresses']
209 }
210}
Ghanshyamf81f9fa2014-05-23 13:38:56 +0900211
212common_server_group = {
213 'type': 'object',
214 'properties': {
215 'id': {'type': 'string'},
216 'name': {'type': 'string'},
217 'policies': {
218 'type': 'array',
219 'items': {'type': 'string'}
220 },
221 # 'members' attribute contains the array of instance's UUID of
222 # instances present in server group
223 'members': {
224 'type': 'array',
225 'items': {'type': 'string'}
226 },
227 'metadata': {'type': 'object'}
228 },
229 'required': ['id', 'name', 'policies', 'members', 'metadata']
230}
231
232create_get_server_group = {
233 'status_code': [200],
234 'response_body': {
235 'type': 'object',
236 'properties': {
237 'server_group': common_server_group
238 },
239 'required': ['server_group']
240 }
241}
242
243delete_server_group = {
244 'status_code': [204]
245}
Ghanshyam29966092014-04-07 17:27:41 +0900246
Ghanshyam438ed3b2014-06-18 17:25:41 +0900247list_server_groups = {
248 'status_code': [200],
249 'response_body': {
250 'type': 'object',
251 'properties': {
252 'server_groups': {
253 'type': 'array',
254 'items': common_server_group
255 }
256 },
257 'required': ['server_groups']
258 }
259}
260
Ghanshyam29966092014-04-07 17:27:41 +0900261instance_actions_object = copy.deepcopy(servers.common_instance_actions)
262instance_actions_object[
263 'properties'].update({'instance_uuid': {'type': 'string'}})
264instance_actions_object['required'].extend(['instance_uuid'])
265
266list_instance_actions = {
267 'status_code': [200],
268 'response_body': {
269 'type': 'object',
270 'properties': {
271 'instanceActions': {
272 'type': 'array',
273 'items': instance_actions_object
274 }
275 },
276 'required': ['instanceActions']
277 }
278}
Ghanshyam51744862014-06-13 12:56:24 +0900279
Ghanshyam4b41dfd2014-07-17 13:40:38 +0900280get_instance_actions_object = copy.deepcopy(servers.common_get_instance_action)
281get_instance_actions_object[
282 'properties'].update({'instance_uuid': {'type': 'string'}})
283get_instance_actions_object['required'].extend(['instance_uuid'])
284
285get_instance_action = {
286 'status_code': [200],
287 'response_body': {
288 'type': 'object',
289 'properties': {
290 'instanceAction': get_instance_actions_object
291 },
292 'required': ['instanceAction']
293 }
294}
295
Ghanshyam51744862014-06-13 12:56:24 +0900296list_servers_detail = copy.deepcopy(servers.base_list_servers_detail)
297list_servers_detail['response_body']['properties']['servers']['items'][
298 'properties'].update({
ghanshyam07c44882015-02-25 12:55:40 +0900299 'key_name': {'type': ['string', 'null']},
Ghanshyam51744862014-06-13 12:56:24 +0900300 'hostId': {'type': 'string'},
301 'OS-DCF:diskConfig': {'type': 'string'},
ghanshyamfbc45c72015-02-24 11:18:00 +0900302 'security_groups': {'type': 'array'},
ghanshyam07c44882015-02-25 12:55:40 +0900303
304 # NOTE: Non-admin users also can see "OS-SRV-USG" and "OS-EXT-AZ"
305 # attributes.
306 'OS-SRV-USG:launched_at': {'type': ['string', 'null']},
307 'OS-SRV-USG:terminated_at': {'type': ['string', 'null']},
308 'OS-EXT-AZ:availability_zone': {'type': 'string'},
309
310 # NOTE: Admin users only can see "OS-EXT-STS" and "OS-EXT-SRV-ATTR"
311 # attributes.
312 'OS-EXT-STS:task_state': {'type': ['string', 'null']},
313 'OS-EXT-STS:vm_state': {'type': 'string'},
314 'OS-EXT-STS:power_state': {'type': 'integer'},
315 'OS-EXT-SRV-ATTR:host': {'type': ['string', 'null']},
316 'OS-EXT-SRV-ATTR:instance_name': {'type': 'string'},
317 'OS-EXT-SRV-ATTR:hypervisor_hostname': {'type': ['string', 'null']},
318 'os-extended-volumes:volumes_attached': {'type': 'array'},
Ghanshyam51744862014-06-13 12:56:24 +0900319 'accessIPv4': parameter_types.access_ip_v4,
ghanshyam07c44882015-02-25 12:55:40 +0900320 'accessIPv6': parameter_types.access_ip_v6,
321 'config_drive': {'type': 'string'}
Ghanshyam51744862014-06-13 12:56:24 +0900322 })
ghanshyam07c44882015-02-25 12:55:40 +0900323# NOTE(GMann): OS-SRV-USG, OS-EXT-AZ, OS-EXT-STS, OS-EXT-SRV-ATTR,
324# os-extended-volumes, OS-DCF and accessIPv4/v6 are API
325# extensions, and some environments return a response without
326# these attributes. So they are not 'required'.
Ghanshyam51744862014-06-13 12:56:24 +0900327list_servers_detail['response_body']['properties']['servers']['items'][
328 'required'].append('hostId')
ghanshyam69ebee22015-02-24 19:28:00 +0900329# NOTE(gmann): Update OS-EXT-IPS:type and OS-EXT-IPS-MAC:mac_addr
330# attributes in server address. Those are API extension,
331# and some environments return a response without
332# these attributes. So they are not 'required'.
333list_servers_detail['response_body']['properties']['servers']['items'][
334 'properties']['addresses']['patternProperties']['^[a-zA-Z0-9-_.]+$'][
335 'items']['properties'].update({
336 'OS-EXT-IPS:type': {'type': 'string'},
337 'OS-EXT-IPS-MAC:mac_addr': parameter_types.mac_address})
ghanshyamc3df6a92015-02-25 17:24:09 +0900338# Defining 'servers_links' attributes for V2 server schema
339list_servers_detail['response_body'][
340 'properties'].update({'servers_links': parameter_types.links})
341# NOTE(gmann): servers_links attribute is not necessary to be
342# present always So it is not 'required'.
Ghanshyam9c2e50d2014-07-22 21:32:05 +0900343
344rebuild_server = copy.deepcopy(update_server)
345rebuild_server['status_code'] = [202]
Ghanshyam9c2e50d2014-07-22 21:32:05 +0900346
347rebuild_server_with_admin_pass = copy.deepcopy(rebuild_server)
348rebuild_server_with_admin_pass['response_body']['properties']['server'][
349 'properties'].update({'adminPass': {'type': 'string'}})
350rebuild_server_with_admin_pass['response_body']['properties']['server'][
351 'required'].append('adminPass')
Ghanshyam88457912014-07-25 16:02:12 +0900352
353rescue_server = {
354 'status_code': [200],
355 'response_body': {
356 'type': 'object',
357 'properties': {
358 'adminPass': {'type': 'string'}
359 },
360 'required': ['adminPass']
361 }
362}