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 | |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 15 | import copy |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 16 | |
Ken'ichi Ohmichi | 024cdae | 2014-03-24 08:05:59 +0900 | [diff] [blame] | 17 | from tempest.api_schema.compute import parameter_types |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 18 | from tempest.api_schema.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': { |
| 28 | # NOTE: Now the type of 'id' is uuid, but here allows |
| 29 | # 'integer' also because old OpenStack uses 'integer' |
| 30 | # as a server id. |
| 31 | 'id': {'type': ['integer', 'string']}, |
| 32 | 'os-security-groups:security_groups': {'type': 'array'}, |
Ken'ichi Ohmichi | 024cdae | 2014-03-24 08:05:59 +0900 | [diff] [blame] | 33 | 'links': parameter_types.links, |
Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 34 | 'admin_password': {'type': 'string'}, |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 35 | 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4, |
| 36 | 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6 |
Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 37 | }, |
| 38 | # NOTE: os-access-ips:access_ip_v4/v6 are API extension, |
| 39 | # and some environments return a response without these |
| 40 | # attributes. So they are not 'required'. |
| 41 | 'required': ['id', 'os-security-groups:security_groups', |
| 42 | 'links', 'admin_password'] |
| 43 | } |
| 44 | }, |
| 45 | 'required': ['server'] |
| 46 | } |
| 47 | } |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 48 | |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 49 | addresses_v3 = copy.deepcopy(parameter_types.addresses) |
| 50 | addresses_v3['patternProperties']['^[a-zA-Z0-9-_.]+$']['items'][ |
| 51 | 'properties'].update({ |
| 52 | 'type': {'type': 'string'}, |
| 53 | 'mac_addr': {'type': 'string'} |
| 54 | }) |
| 55 | addresses_v3['patternProperties']['^[a-zA-Z0-9-_.]+$']['items'][ |
| 56 | 'required'].extend( |
| 57 | ['type', 'mac_addr'] |
| 58 | ) |
| 59 | |
| 60 | update_server = copy.deepcopy(servers.base_update_server) |
| 61 | update_server['response_body']['properties']['server']['properties'].update({ |
| 62 | 'addresses': addresses_v3, |
| 63 | 'host_id': {'type': 'string'}, |
| 64 | 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4, |
| 65 | 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6 |
| 66 | }) |
| 67 | update_server['response_body']['properties']['server']['required'].append( |
| 68 | # NOTE: os-access-ips:access_ip_v4/v6 are API extension, |
| 69 | # and some environments return a response without these |
| 70 | # attributes. So they are not 'required'. |
| 71 | 'host_id' |
| 72 | ) |
| 73 | |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 74 | attach_detach_volume = { |
| 75 | 'status_code': [202] |
| 76 | } |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 77 | |
| 78 | set_get_server_metadata_item = copy.deepcopy(servers.set_server_metadata) |
Ghanshyam | 9541ad1 | 2014-05-07 16:38:43 +0900 | [diff] [blame] | 79 | |
| 80 | list_addresses_by_network = { |
| 81 | 'status_code': [200], |
| 82 | 'response_body': addresses_v3 |
| 83 | } |
Ghanshyam | 997c909 | 2014-04-03 19:00:20 +0900 | [diff] [blame] | 84 | |
| 85 | server_actions_change_password = copy.deepcopy( |
| 86 | servers.server_actions_delete_password) |
Ghanshyam | d847c58 | 2014-05-07 16:21:36 +0900 | [diff] [blame] | 87 | |
| 88 | list_addresses = { |
| 89 | 'status_code': [200], |
| 90 | 'response_body': { |
| 91 | 'type': 'object', |
| 92 | 'properties': { |
| 93 | 'addresses': addresses_v3 |
| 94 | }, |
| 95 | 'required': ['addresses'] |
| 96 | } |
| 97 | } |
Ghanshyam | e842106 | 2014-06-02 15:58:21 +0900 | [diff] [blame^] | 98 | |
| 99 | update_server_metadata = copy.deepcopy(servers.update_server_metadata) |
| 100 | # V3 API's response status_code is 201 |
| 101 | update_server_metadata['status_code'] = [201] |