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 | |
Ken'ichi Ohmichi | 024cdae | 2014-03-24 08:05:59 +0900 | [diff] [blame] | 17 | from tempest.api_schema.compute import parameter_types |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +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 | '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 | 'adminPass': {'type': 'string'}, |
| 32 | 'OS-DCF:diskConfig': {'type': 'string'} |
| 33 | }, |
| 34 | # NOTE: OS-DCF:diskConfig is API extension, and some |
| 35 | # environments return a response without the attribute. |
| 36 | # So it is not 'required'. |
JordanP | 551140c | 2014-04-02 11:16:09 +0200 | [diff] [blame] | 37 | # NOTE: adminPass is not required because it can be deactivated |
| 38 | # with nova API flag enable_instance_password=False |
| 39 | 'required': ['id', 'security_groups', 'links'] |
Ken'ichi Ohmichi | 0260458 | 2014-03-14 16:23:41 +0900 | [diff] [blame] | 40 | } |
| 41 | }, |
| 42 | 'required': ['server'] |
| 43 | } |
| 44 | } |
Ghanshyam | 08ce58d | 2014-04-04 14:51:14 +0900 | [diff] [blame] | 45 | |
Ken'ichi Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 46 | update_server = copy.deepcopy(servers.base_update_get_server) |
Ken'ichi Ohmichi | 29cd512 | 2014-04-28 11:04:52 +0900 | [diff] [blame] | 47 | update_server['response_body']['properties']['server']['properties'].update({ |
| 48 | 'hostId': {'type': 'string'}, |
| 49 | 'OS-DCF:diskConfig': {'type': 'string'}, |
| 50 | 'accessIPv4': parameter_types.access_ip_v4, |
| 51 | 'accessIPv6': parameter_types.access_ip_v6 |
| 52 | }) |
| 53 | update_server['response_body']['properties']['server']['required'].append( |
| 54 | # NOTE: OS-DCF:diskConfig and accessIPv4/v6 are API |
| 55 | # extensions, and some environments return a response |
| 56 | # without these attributes. So they are not 'required'. |
| 57 | 'hostId' |
| 58 | ) |
| 59 | |
Ken'ichi Ohmichi | 21e4fc7 | 2014-05-08 16:46:23 +0900 | [diff] [blame] | 60 | get_server = copy.deepcopy(servers.base_update_get_server) |
| 61 | get_server['response_body']['properties']['server']['properties'].update({ |
| 62 | 'key_name': {'type': ['string', 'null']}, |
| 63 | 'hostId': {'type': 'string'}, |
| 64 | |
| 65 | # NOTE: Non-admin users also can see "OS-SRV-USG" and "OS-EXT-AZ" |
| 66 | # attributes. |
| 67 | 'OS-SRV-USG:launched_at': {'type': ['string', 'null']}, |
| 68 | 'OS-SRV-USG:terminated_at': {'type': ['string', 'null']}, |
| 69 | 'OS-EXT-AZ:availability_zone': {'type': 'string'}, |
| 70 | |
| 71 | # NOTE: Admin users only can see "OS-EXT-STS" and "OS-EXT-SRV-ATTR" |
| 72 | # attributes. |
| 73 | 'OS-EXT-STS:task_state': {'type': ['string', 'null']}, |
| 74 | 'OS-EXT-STS:vm_state': {'type': 'string'}, |
| 75 | 'OS-EXT-STS:power_state': {'type': 'integer'}, |
| 76 | 'OS-EXT-SRV-ATTR:host': {'type': ['string', 'null']}, |
| 77 | 'OS-EXT-SRV-ATTR:instance_name': {'type': 'string'}, |
| 78 | 'OS-EXT-SRV-ATTR:hypervisor_hostname': {'type': ['string', 'null']}, |
| 79 | 'os-extended-volumes:volumes_attached': {'type': 'array'}, |
| 80 | 'OS-DCF:diskConfig': {'type': 'string'}, |
| 81 | 'accessIPv4': parameter_types.access_ip_v4, |
| 82 | 'accessIPv6': parameter_types.access_ip_v6, |
| 83 | 'config_drive': {'type': 'string'} |
| 84 | }) |
| 85 | get_server['response_body']['properties']['server']['required'].append( |
| 86 | # NOTE: OS-SRV-USG, OS-EXT-AZ, OS-EXT-STS, OS-EXT-SRV-ATTR, |
| 87 | # os-extended-volumes, OS-DCF and accessIPv4/v6 are API |
| 88 | # extension, and some environments return a response without |
| 89 | # these attributes. So they are not 'required'. |
| 90 | 'hostId' |
| 91 | ) |
| 92 | |
Ghanshyam | 08ce58d | 2014-04-04 14:51:14 +0900 | [diff] [blame] | 93 | list_virtual_interfaces = { |
| 94 | 'status_code': [200], |
| 95 | 'response_body': { |
| 96 | 'type': 'object', |
| 97 | 'properties': { |
| 98 | 'virtual_interfaces': { |
| 99 | 'type': 'array', |
| 100 | 'items': { |
| 101 | 'type': 'object', |
| 102 | 'properties': { |
| 103 | 'id': {'type': 'string'}, |
| 104 | 'mac_address': parameter_types.mac_address, |
| 105 | 'OS-EXT-VIF-NET:net_id': {'type': 'string'} |
| 106 | }, |
| 107 | # 'OS-EXT-VIF-NET:net_id' is API extension So it is |
| 108 | # not defined as 'required' |
| 109 | 'required': ['id', 'mac_address'] |
| 110 | } |
| 111 | } |
| 112 | }, |
| 113 | 'required': ['virtual_interfaces'] |
| 114 | } |
| 115 | } |
Ghanshyam | 385c4e7 | 2014-03-27 11:42:25 +0900 | [diff] [blame] | 116 | |
| 117 | attach_volume = { |
| 118 | 'status_code': [200], |
| 119 | 'response_body': { |
| 120 | 'type': 'object', |
| 121 | 'properties': { |
| 122 | 'volumeAttachment': { |
| 123 | 'type': 'object', |
| 124 | 'properties': { |
| 125 | 'id': {'type': 'string'}, |
| 126 | 'device': {'type': 'string'}, |
| 127 | 'volumeId': {'type': 'string'}, |
| 128 | 'serverId': {'type': ['integer', 'string']} |
| 129 | }, |
| 130 | 'required': ['id', 'device', 'volumeId', 'serverId'] |
| 131 | } |
| 132 | }, |
| 133 | 'required': ['volumeAttachment'] |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | detach_volume = { |
| 138 | 'status_code': [202] |
| 139 | } |
Ghanshyam | eaaa6a4 | 2014-04-25 18:38:21 +0900 | [diff] [blame] | 140 | |
| 141 | set_get_server_metadata_item = { |
| 142 | 'status_code': [200], |
| 143 | 'response_body': { |
| 144 | 'type': 'object', |
| 145 | 'properties': { |
| 146 | 'meta': { |
| 147 | 'type': 'object', |
| 148 | 'patternProperties': { |
| 149 | '^.+$': {'type': 'string'} |
| 150 | } |
| 151 | } |
| 152 | }, |
| 153 | 'required': ['meta'] |
| 154 | } |
| 155 | } |
Ghanshyam | 9541ad1 | 2014-05-07 16:38:43 +0900 | [diff] [blame] | 156 | |
| 157 | list_addresses_by_network = { |
| 158 | 'status_code': [200], |
| 159 | 'response_body': parameter_types.addresses |
| 160 | } |
Ghanshyam | 997c909 | 2014-04-03 19:00:20 +0900 | [diff] [blame] | 161 | |
| 162 | server_actions_confirm_resize = copy.deepcopy( |
| 163 | servers.server_actions_delete_password) |
Ghanshyam | d847c58 | 2014-05-07 16:21:36 +0900 | [diff] [blame] | 164 | |
| 165 | list_addresses = { |
| 166 | 'status_code': [200], |
| 167 | 'response_body': { |
| 168 | 'type': 'object', |
| 169 | 'properties': { |
| 170 | 'addresses': parameter_types.addresses |
| 171 | }, |
| 172 | 'required': ['addresses'] |
| 173 | } |
| 174 | } |
Ghanshyam | f81f9fa | 2014-05-23 13:38:56 +0900 | [diff] [blame] | 175 | |
| 176 | common_server_group = { |
| 177 | 'type': 'object', |
| 178 | 'properties': { |
| 179 | 'id': {'type': 'string'}, |
| 180 | 'name': {'type': 'string'}, |
| 181 | 'policies': { |
| 182 | 'type': 'array', |
| 183 | 'items': {'type': 'string'} |
| 184 | }, |
| 185 | # 'members' attribute contains the array of instance's UUID of |
| 186 | # instances present in server group |
| 187 | 'members': { |
| 188 | 'type': 'array', |
| 189 | 'items': {'type': 'string'} |
| 190 | }, |
| 191 | 'metadata': {'type': 'object'} |
| 192 | }, |
| 193 | 'required': ['id', 'name', 'policies', 'members', 'metadata'] |
| 194 | } |
| 195 | |
| 196 | create_get_server_group = { |
| 197 | 'status_code': [200], |
| 198 | 'response_body': { |
| 199 | 'type': 'object', |
| 200 | 'properties': { |
| 201 | 'server_group': common_server_group |
| 202 | }, |
| 203 | 'required': ['server_group'] |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | delete_server_group = { |
| 208 | 'status_code': [204] |
| 209 | } |
Ghanshyam | 2996609 | 2014-04-07 17:27:41 +0900 | [diff] [blame] | 210 | |
Ghanshyam | 438ed3b | 2014-06-18 17:25:41 +0900 | [diff] [blame] | 211 | list_server_groups = { |
| 212 | 'status_code': [200], |
| 213 | 'response_body': { |
| 214 | 'type': 'object', |
| 215 | 'properties': { |
| 216 | 'server_groups': { |
| 217 | 'type': 'array', |
| 218 | 'items': common_server_group |
| 219 | } |
| 220 | }, |
| 221 | 'required': ['server_groups'] |
| 222 | } |
| 223 | } |
| 224 | |
Ghanshyam | 2996609 | 2014-04-07 17:27:41 +0900 | [diff] [blame] | 225 | instance_actions_object = copy.deepcopy(servers.common_instance_actions) |
| 226 | instance_actions_object[ |
| 227 | 'properties'].update({'instance_uuid': {'type': 'string'}}) |
| 228 | instance_actions_object['required'].extend(['instance_uuid']) |
| 229 | |
| 230 | list_instance_actions = { |
| 231 | 'status_code': [200], |
| 232 | 'response_body': { |
| 233 | 'type': 'object', |
| 234 | 'properties': { |
| 235 | 'instanceActions': { |
| 236 | 'type': 'array', |
| 237 | 'items': instance_actions_object |
| 238 | } |
| 239 | }, |
| 240 | 'required': ['instanceActions'] |
| 241 | } |
| 242 | } |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 243 | |
Ghanshyam | 4b41dfd | 2014-07-17 13:40:38 +0900 | [diff] [blame] | 244 | get_instance_actions_object = copy.deepcopy(servers.common_get_instance_action) |
| 245 | get_instance_actions_object[ |
| 246 | 'properties'].update({'instance_uuid': {'type': 'string'}}) |
| 247 | get_instance_actions_object['required'].extend(['instance_uuid']) |
| 248 | |
| 249 | get_instance_action = { |
| 250 | 'status_code': [200], |
| 251 | 'response_body': { |
| 252 | 'type': 'object', |
| 253 | 'properties': { |
| 254 | 'instanceAction': get_instance_actions_object |
| 255 | }, |
| 256 | 'required': ['instanceAction'] |
| 257 | } |
| 258 | } |
| 259 | |
Ghanshyam | 5174486 | 2014-06-13 12:56:24 +0900 | [diff] [blame] | 260 | list_servers_detail = copy.deepcopy(servers.base_list_servers_detail) |
| 261 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 262 | 'properties'].update({ |
| 263 | 'hostId': {'type': 'string'}, |
| 264 | 'OS-DCF:diskConfig': {'type': 'string'}, |
| 265 | 'accessIPv4': parameter_types.access_ip_v4, |
| 266 | 'accessIPv6': parameter_types.access_ip_v6 |
| 267 | }) |
| 268 | # NOTE(GMann): OS-DCF:diskConfig and accessIPv4/v6 are API |
| 269 | # extensions, and some environments return a response |
| 270 | # without these attributes. So they are not 'required'. |
| 271 | list_servers_detail['response_body']['properties']['servers']['items'][ |
| 272 | 'required'].append('hostId') |
Ghanshyam | 9c2e50d | 2014-07-22 21:32:05 +0900 | [diff] [blame] | 273 | |
| 274 | rebuild_server = copy.deepcopy(update_server) |
| 275 | rebuild_server['status_code'] = [202] |
| 276 | del rebuild_server['response_body']['properties']['server'][ |
| 277 | 'properties']['OS-DCF:diskConfig'] |
| 278 | |
| 279 | rebuild_server_with_admin_pass = copy.deepcopy(rebuild_server) |
| 280 | rebuild_server_with_admin_pass['response_body']['properties']['server'][ |
| 281 | 'properties'].update({'adminPass': {'type': 'string'}}) |
| 282 | rebuild_server_with_admin_pass['response_body']['properties']['server'][ |
| 283 | 'required'].append('adminPass') |
Ghanshyam | 8845791 | 2014-07-25 16:02:12 +0900 | [diff] [blame^] | 284 | |
| 285 | rescue_server = { |
| 286 | 'status_code': [200], |
| 287 | 'response_body': { |
| 288 | 'type': 'object', |
| 289 | 'properties': { |
| 290 | 'adminPass': {'type': 'string'} |
| 291 | }, |
| 292 | 'required': ['adminPass'] |
| 293 | } |
| 294 | } |