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 | ) |
| 96 | |
Ghanshyam | 08ce58d | 2014-04-04 14:51:14 +0900 | [diff] [blame] | 97 | list_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 | } |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 120 | |
Ghanshyam | 5c2a558 | 2014-04-14 17:16:57 +0900 | [diff] [blame] | 121 | common_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 | |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 132 | attach_volume = { |
| 133 | 'status_code': [200], |
| 134 | 'response_body': { |
| 135 | 'type': 'object', |
| 136 | 'properties': { |
Ghanshyam | 5c2a558 | 2014-04-14 17:16:57 +0900 | [diff] [blame] | 137 | 'volumeAttachment': common_attach_volume_info |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 138 | }, |
| 139 | 'required': ['volumeAttachment'] |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | detach_volume = { |
| 144 | 'status_code': [202] |
| 145 | } |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 146 | |
Ghanshyam | 5c2a558 | 2014-04-14 17:16:57 +0900 | [diff] [blame] | 147 | get_volume_attachment = copy.deepcopy(attach_volume) |
| 148 | get_volume_attachment['response_body']['properties'][ |
| 149 | 'volumeAttachment']['properties'].update({'serverId': {'type': 'string'}}) |
| 150 | |
| 151 | list_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 | } |
| 164 | list_volume_attachments['response_body']['properties'][ |
| 165 | 'volumeAttachments']['items']['properties'].update( |
| 166 | {'serverId': {'type': 'string'}}) |
| 167 | |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 168 | set_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 | } |
Ghanshyam | 9541ad1 | 2014-05-07 16:38:43 +0900 | [diff] [blame] | 183 | |
| 184 | list_addresses_by_network = { |
| 185 | 'status_code': [200], |
| 186 | 'response_body': parameter_types.addresses |
| 187 | } |
Ghanshyam | 997c909 | 2014-04-03 19:00:20 +0900 | [diff] [blame] | 188 | |
| 189 | server_actions_confirm_resize = copy.deepcopy( |
| 190 | servers.server_actions_delete_password) |
Ghanshyam | d847c58 | 2014-05-07 16:21:36 +0900 | [diff] [blame] | 191 | |
| 192 | list_addresses = { |
| 193 | 'status_code': [200], |
| 194 | 'response_body': { |
| 195 | 'type': 'object', |
| 196 | 'properties': { |
| 197 | 'addresses': parameter_types.addresses |
| 198 | }, |
| 199 | 'required': ['addresses'] |
| 200 | } |
| 201 | } |
Ghanshyam | f81f9fa | 2014-05-23 13:38:56 +0900 | [diff] [blame] | 202 | |
| 203 | common_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 | |
| 223 | create_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 | |
| 234 | delete_server_group = { |
| 235 | 'status_code': [204] |
| 236 | } |
Ghanshyam | 2996609 | 2014-04-07 17:27:41 +0900 | [diff] [blame] | 237 | |
Ghanshyam | 438ed3b | 2014-06-18 17:25:41 +0900 | [diff] [blame] | 238 | list_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 | |
Ghanshyam | 2996609 | 2014-04-07 17:27:41 +0900 | [diff] [blame] | 252 | instance_actions_object = copy.deepcopy(servers.common_instance_actions) |
| 253 | instance_actions_object[ |
| 254 | 'properties'].update({'instance_uuid': {'type': 'string'}}) |
| 255 | instance_actions_object['required'].extend(['instance_uuid']) |
| 256 | |
| 257 | list_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 | } |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 270 | |
Ghanshyam | 4b41dfd | 2014-07-17 13:40:38 +0900 | [diff] [blame] | 271 | get_instance_actions_object = copy.deepcopy(servers.common_get_instance_action) |
| 272 | get_instance_actions_object[ |
| 273 | 'properties'].update({'instance_uuid': {'type': 'string'}}) |
| 274 | get_instance_actions_object['required'].extend(['instance_uuid']) |
| 275 | |
| 276 | get_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 | |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 287 | list_servers_detail = copy.deepcopy(servers.base_list_servers_detail) |
| 288 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 289 | 'properties'].update({ |
| 290 | 'hostId': {'type': 'string'}, |
| 291 | 'OS-DCF:diskConfig': {'type': 'string'}, |
ghanshyam | fbc45c7 | 2015-02-24 11:18:00 +0900 | [diff] [blame] | 292 | 'security_groups': {'type': 'array'}, |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 293 | 'accessIPv4': parameter_types.access_ip_v4, |
| 294 | 'accessIPv6': parameter_types.access_ip_v6 |
| 295 | }) |
ghanshyam | fbc45c7 | 2015-02-24 11:18:00 +0900 | [diff] [blame] | 296 | # NOTE(GMann): OS-DCF:diskConfig, security_groups and accessIPv4/v6 are API |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 297 | # extensions, and some environments return a response |
| 298 | # without these attributes. So they are not 'required'. |
| 299 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 300 | 'required'].append('hostId') |
Ghanshyam | 9c2e50d | 2014-07-22 21:32:05 +0900 | [diff] [blame] | 301 | |
| 302 | rebuild_server = copy.deepcopy(update_server) |
| 303 | rebuild_server['status_code'] = [202] |
| 304 | del rebuild_server['response_body']['properties']['server'][ |
| 305 | 'properties']['OS-DCF:diskConfig'] |
| 306 | |
| 307 | rebuild_server_with_admin_pass = copy.deepcopy(rebuild_server) |
| 308 | rebuild_server_with_admin_pass['response_body']['properties']['server'][ |
| 309 | 'properties'].update({'adminPass': {'type': 'string'}}) |
| 310 | rebuild_server_with_admin_pass['response_body']['properties']['server'][ |
| 311 | 'required'].append('adminPass') |
Ghanshyam | 8845791 | 2014-07-25 16:02:12 +0900 | [diff] [blame] | 312 | |
| 313 | rescue_server = { |
| 314 | 'status_code': [200], |
| 315 | 'response_body': { |
| 316 | 'type': 'object', |
| 317 | 'properties': { |
| 318 | 'adminPass': {'type': 'string'} |
| 319 | }, |
| 320 | 'required': ['adminPass'] |
| 321 | } |
| 322 | } |