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': { |
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 | 'os-security-groups: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 | 'admin_password': {'type': 'string'}, |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 32 | 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4, |
| 33 | 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6 |
Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 34 | }, |
| 35 | # NOTE: os-access-ips:access_ip_v4/v6 are API extension, |
| 36 | # and some environments return a response without these |
| 37 | # attributes. So they are not 'required'. |
| 38 | 'required': ['id', 'os-security-groups:security_groups', |
| 39 | 'links', 'admin_password'] |
| 40 | } |
| 41 | }, |
| 42 | 'required': ['server'] |
| 43 | } |
| 44 | } |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 45 | |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 46 | addresses_v3 = copy.deepcopy(parameter_types.addresses) |
| 47 | addresses_v3['patternProperties']['^[a-zA-Z0-9-_.]+$']['items'][ |
| 48 | 'properties'].update({ |
| 49 | 'type': {'type': 'string'}, |
| 50 | 'mac_addr': {'type': 'string'} |
| 51 | }) |
| 52 | addresses_v3['patternProperties']['^[a-zA-Z0-9-_.]+$']['items'][ |
| 53 | 'required'].extend( |
| 54 | ['type', 'mac_addr'] |
| 55 | ) |
| 56 | |
Ken'ichi Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 57 | update_server = copy.deepcopy(servers.base_update_get_server) |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 58 | update_server['response_body']['properties']['server']['properties'].update({ |
| 59 | 'addresses': addresses_v3, |
| 60 | 'host_id': {'type': 'string'}, |
| 61 | 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4, |
| 62 | 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6 |
| 63 | }) |
| 64 | update_server['response_body']['properties']['server']['required'].append( |
| 65 | # NOTE: os-access-ips:access_ip_v4/v6 are API extension, |
| 66 | # and some environments return a response without these |
| 67 | # attributes. So they are not 'required'. |
| 68 | 'host_id' |
| 69 | ) |
| 70 | |
Ken'ichi Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 71 | get_server = copy.deepcopy(servers.base_update_get_server) |
| 72 | get_server['response_body']['properties']['server']['properties'].update({ |
| 73 | 'key_name': {'type': ['string', 'null']}, |
| 74 | 'host_id': {'type': 'string'}, |
| 75 | |
| 76 | # NOTE: Non-admin users also can see "os-server-usage" and |
| 77 | # "os-extended-availability-zone" attributes. |
| 78 | 'os-server-usage:launched_at': {'type': ['string', 'null']}, |
| 79 | 'os-server-usage:terminated_at': {'type': ['string', 'null']}, |
| 80 | 'os-extended-availability-zone:availability_zone': {'type': 'string'}, |
| 81 | |
| 82 | # NOTE: Admin users only can see "os-extended-status" and |
| 83 | # "os-extended-server-attributes" attributes. |
| 84 | 'os-extended-status:task_state': {'type': ['string', 'null']}, |
| 85 | 'os-extended-status:vm_state': {'type': 'string'}, |
| 86 | 'os-extended-status:power_state': {'type': 'integer'}, |
| 87 | 'os-extended-status:locked_by': {'type': ['string', 'null']}, |
| 88 | 'os-extended-server-attributes:host': {'type': ['string', 'null']}, |
| 89 | 'os-extended-server-attributes:instance_name': {'type': 'string'}, |
| 90 | 'os-extended-server-attributes:hypervisor_hostname': { |
| 91 | 'type': ['string', 'null'] |
| 92 | }, |
| 93 | 'os-extended-volumes:volumes_attached': {'type': 'array'}, |
| 94 | 'os-pci:pci_devices': {'type': 'array'}, |
| 95 | 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4, |
| 96 | 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6, |
| 97 | 'os-config-drive:config_drive': {'type': 'string'} |
| 98 | }) |
| 99 | get_server['response_body']['properties']['server']['required'].append( |
| 100 | # NOTE: os-server-usage, os-extended-availability-zone, |
| 101 | # os-extended-status, os-extended-server-attributes, |
| 102 | # os-extended-volumes, os-pci, os-access-ips and |
| 103 | # os-config-driveare API extension, and some environments |
| 104 | # return a response without these attributes. So they are not 'required'. |
| 105 | 'host_id' |
| 106 | ) |
| 107 | |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 108 | attach_detach_volume = { |
| 109 | 'status_code': [202] |
| 110 | } |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 111 | |
| 112 | set_get_server_metadata_item = copy.deepcopy(servers.set_server_metadata) |
Ghanshyam | 9541ad1 | 2014-05-07 16:38:43 +0900 | [diff] [blame] | 113 | |
| 114 | list_addresses_by_network = { |
| 115 | 'status_code': [200], |
| 116 | 'response_body': addresses_v3 |
| 117 | } |
Ghanshyam | 997c909 | 2014-04-03 19:00:20 +0900 | [diff] [blame] | 118 | |
| 119 | server_actions_change_password = copy.deepcopy( |
| 120 | servers.server_actions_delete_password) |
Ghanshyam | d847c58 | 2014-05-07 16:21:36 +0900 | [diff] [blame] | 121 | |
| 122 | list_addresses = { |
| 123 | 'status_code': [200], |
| 124 | 'response_body': { |
| 125 | 'type': 'object', |
| 126 | 'properties': { |
| 127 | 'addresses': addresses_v3 |
| 128 | }, |
| 129 | 'required': ['addresses'] |
| 130 | } |
| 131 | } |
Ghanshyam | e842106 | 2014-06-02 15:58:21 +0900 | [diff] [blame] | 132 | |
| 133 | update_server_metadata = copy.deepcopy(servers.update_server_metadata) |
| 134 | # V3 API's response status_code is 201 |
| 135 | update_server_metadata['status_code'] = [201] |
Ghanshyam | 2996609 | 2014-04-07 17:27:41 +0900 | [diff] [blame] | 136 | |
| 137 | server_actions_object = copy.deepcopy(servers.common_instance_actions) |
| 138 | server_actions_object['properties'].update({'server_uuid': {'type': 'string'}}) |
| 139 | server_actions_object['required'].extend(['server_uuid']) |
| 140 | |
| 141 | list_server_actions = { |
| 142 | 'status_code': [200], |
| 143 | 'response_body': { |
| 144 | 'type': 'object', |
| 145 | 'properties': { |
| 146 | 'server_actions': { |
| 147 | 'type': 'array', |
| 148 | 'items': server_actions_object |
| 149 | } |
| 150 | }, |
| 151 | 'required': ['server_actions'] |
| 152 | } |
| 153 | } |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 154 | |
Ghanshyam | 4b41dfd | 2014-07-17 13:40:38 +0900 | [diff] [blame] | 155 | get_server_actions_object = copy.deepcopy(servers.common_get_instance_action) |
| 156 | get_server_actions_object[ |
| 157 | 'properties'].update({'server_uuid': {'type': 'string'}}) |
| 158 | get_server_actions_object['required'].extend(['server_uuid']) |
| 159 | |
| 160 | get_server_action = { |
| 161 | 'status_code': [200], |
| 162 | 'response_body': { |
| 163 | 'type': 'object', |
| 164 | 'properties': { |
| 165 | 'server_action': get_server_actions_object |
| 166 | }, |
| 167 | 'required': ['server_action'] |
| 168 | } |
| 169 | } |
| 170 | |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 171 | list_servers_detail = copy.deepcopy(servers.base_list_servers_detail) |
| 172 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 173 | 'properties'].update({ |
| 174 | 'addresses': addresses_v3, |
| 175 | 'host_id': {'type': 'string'}, |
| 176 | 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4, |
| 177 | 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6 |
| 178 | }) |
| 179 | # NOTE(GMann): os-access-ips:access_ip_v4/v6 are API extension, |
| 180 | # and some environments return a response without these |
| 181 | # attributes. So they are not 'required'. |
| 182 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 183 | 'required'].append('host_id') |