blob: 0132350da08a0e737724fa1a74d922f883a06f98 [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)
96
Ghanshyam08ce58d2014-04-04 14:51:14 +090097list_virtual_interfaces = {
98 'status_code': [200],
99 'response_body': {
100 'type': 'object',
101 'properties': {
102 'virtual_interfaces': {
103 'type': 'array',
104 'items': {
105 'type': 'object',
106 'properties': {
107 'id': {'type': 'string'},
108 'mac_address': parameter_types.mac_address,
109 'OS-EXT-VIF-NET:net_id': {'type': 'string'}
110 },
111 # 'OS-EXT-VIF-NET:net_id' is API extension So it is
112 # not defined as 'required'
113 'required': ['id', 'mac_address']
114 }
115 }
116 },
117 'required': ['virtual_interfaces']
118 }
119}
Ghanshyam385c4e72014-03-27 11:42:25 +0900120
Ghanshyam5c2a5582014-04-14 17:16:57 +0900121common_attach_volume_info = {
122 'type': 'object',
123 'properties': {
124 'id': {'type': 'string'},
125 'device': {'type': 'string'},
126 'volumeId': {'type': 'string'},
127 'serverId': {'type': ['integer', 'string']}
128 },
129 'required': ['id', 'device', 'volumeId', 'serverId']
130}
131
Ghanshyam385c4e72014-03-27 11:42:25 +0900132attach_volume = {
133 'status_code': [200],
134 'response_body': {
135 'type': 'object',
136 'properties': {
Ghanshyam5c2a5582014-04-14 17:16:57 +0900137 'volumeAttachment': common_attach_volume_info
Ghanshyam385c4e72014-03-27 11:42:25 +0900138 },
139 'required': ['volumeAttachment']
140 }
141}
142
143detach_volume = {
144 'status_code': [202]
145}
Ghanshyameaaa6a42014-04-25 18:38:21 +0900146
Ghanshyam5c2a5582014-04-14 17:16:57 +0900147get_volume_attachment = copy.deepcopy(attach_volume)
148get_volume_attachment['response_body']['properties'][
149 'volumeAttachment']['properties'].update({'serverId': {'type': 'string'}})
150
151list_volume_attachments = {
152 'status_code': [200],
153 'response_body': {
154 'type': 'object',
155 'properties': {
156 'volumeAttachments': {
157 'type': 'array',
158 'items': common_attach_volume_info
159 }
160 },
161 'required': ['volumeAttachments']
162 }
163}
164list_volume_attachments['response_body']['properties'][
165 'volumeAttachments']['items']['properties'].update(
166 {'serverId': {'type': 'string'}})
167
Ghanshyameaaa6a42014-04-25 18:38:21 +0900168set_get_server_metadata_item = {
169 'status_code': [200],
170 'response_body': {
171 'type': 'object',
172 'properties': {
173 'meta': {
174 'type': 'object',
175 'patternProperties': {
176 '^.+$': {'type': 'string'}
177 }
178 }
179 },
180 'required': ['meta']
181 }
182}
Ghanshyam9541ad12014-05-07 16:38:43 +0900183
184list_addresses_by_network = {
185 'status_code': [200],
186 'response_body': parameter_types.addresses
187}
Ghanshyam997c9092014-04-03 19:00:20 +0900188
189server_actions_confirm_resize = copy.deepcopy(
190 servers.server_actions_delete_password)
Ghanshyamd847c582014-05-07 16:21:36 +0900191
192list_addresses = {
193 'status_code': [200],
194 'response_body': {
195 'type': 'object',
196 'properties': {
197 'addresses': parameter_types.addresses
198 },
199 'required': ['addresses']
200 }
201}
Ghanshyamf81f9fa2014-05-23 13:38:56 +0900202
203common_server_group = {
204 'type': 'object',
205 'properties': {
206 'id': {'type': 'string'},
207 'name': {'type': 'string'},
208 'policies': {
209 'type': 'array',
210 'items': {'type': 'string'}
211 },
212 # 'members' attribute contains the array of instance's UUID of
213 # instances present in server group
214 'members': {
215 'type': 'array',
216 'items': {'type': 'string'}
217 },
218 'metadata': {'type': 'object'}
219 },
220 'required': ['id', 'name', 'policies', 'members', 'metadata']
221}
222
223create_get_server_group = {
224 'status_code': [200],
225 'response_body': {
226 'type': 'object',
227 'properties': {
228 'server_group': common_server_group
229 },
230 'required': ['server_group']
231 }
232}
233
234delete_server_group = {
235 'status_code': [204]
236}
Ghanshyam29966092014-04-07 17:27:41 +0900237
Ghanshyam438ed3b2014-06-18 17:25:41 +0900238list_server_groups = {
239 'status_code': [200],
240 'response_body': {
241 'type': 'object',
242 'properties': {
243 'server_groups': {
244 'type': 'array',
245 'items': common_server_group
246 }
247 },
248 'required': ['server_groups']
249 }
250}
251
Ghanshyam29966092014-04-07 17:27:41 +0900252instance_actions_object = copy.deepcopy(servers.common_instance_actions)
253instance_actions_object[
254 'properties'].update({'instance_uuid': {'type': 'string'}})
255instance_actions_object['required'].extend(['instance_uuid'])
256
257list_instance_actions = {
258 'status_code': [200],
259 'response_body': {
260 'type': 'object',
261 'properties': {
262 'instanceActions': {
263 'type': 'array',
264 'items': instance_actions_object
265 }
266 },
267 'required': ['instanceActions']
268 }
269}
Ghanshyam51744862014-06-13 12:56:24 +0900270
Ghanshyam4b41dfd2014-07-17 13:40:38 +0900271get_instance_actions_object = copy.deepcopy(servers.common_get_instance_action)
272get_instance_actions_object[
273 'properties'].update({'instance_uuid': {'type': 'string'}})
274get_instance_actions_object['required'].extend(['instance_uuid'])
275
276get_instance_action = {
277 'status_code': [200],
278 'response_body': {
279 'type': 'object',
280 'properties': {
281 'instanceAction': get_instance_actions_object
282 },
283 'required': ['instanceAction']
284 }
285}
286
Ghanshyam51744862014-06-13 12:56:24 +0900287list_servers_detail = copy.deepcopy(servers.base_list_servers_detail)
288list_servers_detail['response_body']['properties']['servers']['items'][
289 'properties'].update({
290 'hostId': {'type': 'string'},
291 'OS-DCF:diskConfig': {'type': 'string'},
ghanshyamfbc45c72015-02-24 11:18:00 +0900292 'security_groups': {'type': 'array'},
Ghanshyam51744862014-06-13 12:56:24 +0900293 'accessIPv4': parameter_types.access_ip_v4,
294 'accessIPv6': parameter_types.access_ip_v6
295 })
ghanshyamfbc45c72015-02-24 11:18:00 +0900296# NOTE(GMann): OS-DCF:diskConfig, security_groups and accessIPv4/v6 are API
Ghanshyam51744862014-06-13 12:56:24 +0900297# extensions, and some environments return a response
298# without these attributes. So they are not 'required'.
299list_servers_detail['response_body']['properties']['servers']['items'][
300 'required'].append('hostId')
Ghanshyam9c2e50d2014-07-22 21:32:05 +0900301
302rebuild_server = copy.deepcopy(update_server)
303rebuild_server['status_code'] = [202]
304del rebuild_server['response_body']['properties']['server'][
305 'properties']['OS-DCF:diskConfig']
306
307rebuild_server_with_admin_pass = copy.deepcopy(rebuild_server)
308rebuild_server_with_admin_pass['response_body']['properties']['server'][
309 'properties'].update({'adminPass': {'type': 'string'}})
310rebuild_server_with_admin_pass['response_body']['properties']['server'][
311 'required'].append('adminPass')
Ghanshyam88457912014-07-25 16:02:12 +0900312
313rescue_server = {
314 'status_code': [200],
315 'response_body': {
316 'type': 'object',
317 'properties': {
318 'adminPass': {'type': 'string'}
319 },
320 'required': ['adminPass']
321 }
322}