Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 1 | # 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 Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 15 | import copy |
| 16 | |
Marc Koderer | 6fbd74f | 2014-08-04 09:38:19 +0200 | [diff] [blame] | 17 | from tempest.api_schema.response.compute import parameter_types |
| 18 | from tempest.api_schema.response.compute import servers |
Ken'ichi Ohmichi | 024cdae | 2014-03-24 08:05:59 +0900 | [diff] [blame] | 19 | |
Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 20 | create_server = { |
| 21 | 'status_code': [202], |
| 22 | 'response_body': { |
| 23 | 'type': 'object', |
| 24 | 'properties': { |
| 25 | 'server': { |
| 26 | 'type': 'object', |
| 27 | 'properties': { |
Ghanshyam | c5b842d | 2014-06-10 17:06:05 +0900 | [diff] [blame] | 28 | 'id': {'type': 'string'}, |
Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 29 | 'security_groups': {'type': 'array'}, |
Ken'ichi Ohmichi | 024cdae | 2014-03-24 08:05:59 +0900 | [diff] [blame] | 30 | 'links': parameter_types.links, |
Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 31 | 'OS-DCF:diskConfig': {'type': 'string'} |
| 32 | }, |
ghanshyam | fbc45c7 | 2015-02-24 11:18:00 +0900 | [diff] [blame] | 33 | # 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 Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 37 | } |
| 38 | }, |
| 39 | 'required': ['server'] |
| 40 | } |
| 41 | } |
Ghanshyam | 08ce58d | 2014-04-04 14:51:14 +0900 | [diff] [blame] | 42 | |
Ghanshyam | 7f98910 | 2014-07-29 14:23:26 +0900 | [diff] [blame] | 43 | create_server_with_admin_pass = copy.deepcopy(create_server) |
| 44 | create_server_with_admin_pass['response_body']['properties']['server'][ |
| 45 | 'properties'].update({'adminPass': {'type': 'string'}}) |
| 46 | create_server_with_admin_pass['response_body']['properties']['server'][ |
| 47 | 'required'].append('adminPass') |
| 48 | |
Ken'ichi Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 49 | update_server = copy.deepcopy(servers.base_update_get_server) |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 50 | update_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 | }) |
| 56 | update_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 Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 63 | get_server = copy.deepcopy(servers.base_update_get_server) |
| 64 | get_server['response_body']['properties']['server']['properties'].update({ |
| 65 | 'key_name': {'type': ['string', 'null']}, |
| 66 | 'hostId': {'type': 'string'}, |
ghanshyam | fbc45c7 | 2015-02-24 11:18:00 +0900 | [diff] [blame] | 67 | 'security_groups': {'type': 'array'}, |
Ken'ichi Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 68 | |
| 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 | }) |
| 89 | get_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 | ) |
ghanshyam | 69ebee2 | 2015-02-24 19:28:00 +0900 | [diff] [blame] | 96 | # 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'. |
| 100 | get_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 Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 105 | |
Ghanshyam | 08ce58d | 2014-04-04 14:51:14 +0900 | [diff] [blame] | 106 | list_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 | } |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 129 | |
Ghanshyam | 5c2a558 | 2014-04-14 17:16:57 +0900 | [diff] [blame] | 130 | common_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 | |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 141 | attach_volume = { |
| 142 | 'status_code': [200], |
| 143 | 'response_body': { |
| 144 | 'type': 'object', |
| 145 | 'properties': { |
Ghanshyam | 5c2a558 | 2014-04-14 17:16:57 +0900 | [diff] [blame] | 146 | 'volumeAttachment': common_attach_volume_info |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 147 | }, |
| 148 | 'required': ['volumeAttachment'] |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | detach_volume = { |
| 153 | 'status_code': [202] |
| 154 | } |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 155 | |
Ghanshyam | 5c2a558 | 2014-04-14 17:16:57 +0900 | [diff] [blame] | 156 | get_volume_attachment = copy.deepcopy(attach_volume) |
| 157 | get_volume_attachment['response_body']['properties'][ |
| 158 | 'volumeAttachment']['properties'].update({'serverId': {'type': 'string'}}) |
| 159 | |
| 160 | list_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 | } |
| 173 | list_volume_attachments['response_body']['properties'][ |
| 174 | 'volumeAttachments']['items']['properties'].update( |
| 175 | {'serverId': {'type': 'string'}}) |
| 176 | |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 177 | set_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 | } |
Ghanshyam | 9541ad1 | 2014-05-07 16:38:43 +0900 | [diff] [blame] | 192 | |
| 193 | list_addresses_by_network = { |
| 194 | 'status_code': [200], |
| 195 | 'response_body': parameter_types.addresses |
| 196 | } |
Ghanshyam | 997c909 | 2014-04-03 19:00:20 +0900 | [diff] [blame] | 197 | |
| 198 | server_actions_confirm_resize = copy.deepcopy( |
| 199 | servers.server_actions_delete_password) |
Ghanshyam | d847c58 | 2014-05-07 16:21:36 +0900 | [diff] [blame] | 200 | |
| 201 | list_addresses = { |
| 202 | 'status_code': [200], |
| 203 | 'response_body': { |
| 204 | 'type': 'object', |
| 205 | 'properties': { |
| 206 | 'addresses': parameter_types.addresses |
| 207 | }, |
| 208 | 'required': ['addresses'] |
| 209 | } |
| 210 | } |
Ghanshyam | f81f9fa | 2014-05-23 13:38:56 +0900 | [diff] [blame] | 211 | |
| 212 | common_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 | |
| 232 | create_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 | |
| 243 | delete_server_group = { |
| 244 | 'status_code': [204] |
| 245 | } |
Ghanshyam | 2996609 | 2014-04-07 17:27:41 +0900 | [diff] [blame] | 246 | |
Ghanshyam | 438ed3b | 2014-06-18 17:25:41 +0900 | [diff] [blame] | 247 | list_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 | |
Ghanshyam | 2996609 | 2014-04-07 17:27:41 +0900 | [diff] [blame] | 261 | instance_actions_object = copy.deepcopy(servers.common_instance_actions) |
| 262 | instance_actions_object[ |
| 263 | 'properties'].update({'instance_uuid': {'type': 'string'}}) |
| 264 | instance_actions_object['required'].extend(['instance_uuid']) |
| 265 | |
| 266 | list_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 | } |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 279 | |
Ghanshyam | 4b41dfd | 2014-07-17 13:40:38 +0900 | [diff] [blame] | 280 | get_instance_actions_object = copy.deepcopy(servers.common_get_instance_action) |
| 281 | get_instance_actions_object[ |
| 282 | 'properties'].update({'instance_uuid': {'type': 'string'}}) |
| 283 | get_instance_actions_object['required'].extend(['instance_uuid']) |
| 284 | |
| 285 | get_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 | |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 296 | list_servers_detail = copy.deepcopy(servers.base_list_servers_detail) |
| 297 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 298 | 'properties'].update({ |
ghanshyam | 07c4488 | 2015-02-25 12:55:40 +0900 | [diff] [blame] | 299 | 'key_name': {'type': ['string', 'null']}, |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 300 | 'hostId': {'type': 'string'}, |
| 301 | 'OS-DCF:diskConfig': {'type': 'string'}, |
ghanshyam | fbc45c7 | 2015-02-24 11:18:00 +0900 | [diff] [blame] | 302 | 'security_groups': {'type': 'array'}, |
ghanshyam | 07c4488 | 2015-02-25 12:55:40 +0900 | [diff] [blame] | 303 | |
| 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'}, |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 319 | 'accessIPv4': parameter_types.access_ip_v4, |
ghanshyam | 07c4488 | 2015-02-25 12:55:40 +0900 | [diff] [blame] | 320 | 'accessIPv6': parameter_types.access_ip_v6, |
| 321 | 'config_drive': {'type': 'string'} |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 322 | }) |
ghanshyam | 07c4488 | 2015-02-25 12:55:40 +0900 | [diff] [blame] | 323 | # 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'. |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 327 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 328 | 'required'].append('hostId') |
ghanshyam | 69ebee2 | 2015-02-24 19:28:00 +0900 | [diff] [blame] | 329 | # 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'. |
| 333 | list_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}) |
ghanshyam | c3df6a9 | 2015-02-25 17:24:09 +0900 | [diff] [blame] | 338 | # Defining 'servers_links' attributes for V2 server schema |
| 339 | list_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'. |
Ghanshyam | 9c2e50d | 2014-07-22 21:32:05 +0900 | [diff] [blame] | 343 | |
| 344 | rebuild_server = copy.deepcopy(update_server) |
| 345 | rebuild_server['status_code'] = [202] |
Ghanshyam | 9c2e50d | 2014-07-22 21:32:05 +0900 | [diff] [blame] | 346 | |
| 347 | rebuild_server_with_admin_pass = copy.deepcopy(rebuild_server) |
| 348 | rebuild_server_with_admin_pass['response_body']['properties']['server'][ |
| 349 | 'properties'].update({'adminPass': {'type': 'string'}}) |
| 350 | rebuild_server_with_admin_pass['response_body']['properties']['server'][ |
| 351 | 'required'].append('adminPass') |
Ghanshyam | 8845791 | 2014-07-25 16:02:12 +0900 | [diff] [blame] | 352 | |
| 353 | rescue_server = { |
| 354 | 'status_code': [200], |
| 355 | 'response_body': { |
| 356 | 'type': 'object', |
| 357 | 'properties': { |
| 358 | 'adminPass': {'type': 'string'} |
| 359 | }, |
| 360 | 'required': ['adminPass'] |
| 361 | } |
| 362 | } |