Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1 | # Copyright 2015 Hewlett-Packard Development Company, L.P. |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 16 | from tempest.common import utils |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 17 | from tempest.lib.common.utils import data_utils |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 18 | from tempest.lib import decorators |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 19 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 20 | from neutron_tempest_plugin.api import base |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 21 | |
| 22 | SUBNETPOOL_NAME = 'smoke-subnetpool' |
| 23 | SUBNET_NAME = 'smoke-subnet' |
| 24 | |
| 25 | |
| 26 | class SubnetPoolsTestBase(base.BaseAdminNetworkTest): |
| 27 | |
| 28 | @classmethod |
| 29 | def resource_setup(cls): |
| 30 | super(SubnetPoolsTestBase, cls).resource_setup() |
| 31 | min_prefixlen = '29' |
| 32 | prefixes = [u'10.11.12.0/24'] |
| 33 | cls._subnetpool_data = {'prefixes': prefixes, |
| 34 | 'min_prefixlen': min_prefixlen} |
| 35 | |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 36 | @classmethod |
| 37 | def _create_subnetpool(cls, is_admin=False, **kwargs): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 38 | if 'name' not in kwargs: |
| 39 | name = data_utils.rand_name(SUBNETPOOL_NAME) |
| 40 | else: |
| 41 | name = kwargs.pop('name') |
| 42 | |
| 43 | if 'prefixes' not in kwargs: |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 44 | kwargs['prefixes'] = cls._subnetpool_data['prefixes'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 45 | |
| 46 | if 'min_prefixlen' not in kwargs: |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 47 | kwargs['min_prefixlen'] = cls._subnetpool_data['min_prefixlen'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 48 | |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 49 | return cls.create_subnetpool(name=name, is_admin=is_admin, **kwargs) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 50 | |
| 51 | |
| 52 | class SubnetPoolsTest(SubnetPoolsTestBase): |
| 53 | |
| 54 | min_prefixlen = '28' |
Lucas Alvares Gomes | 7ff60d8 | 2018-04-09 16:28:49 +0100 | [diff] [blame] | 55 | max_prefixlen = '30' |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 56 | _ip_version = 4 |
Lucas Alvares Gomes | 7ff60d8 | 2018-04-09 16:28:49 +0100 | [diff] [blame] | 57 | subnet_cidr = u'10.11.12.0/29' |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 58 | new_prefix = u'10.11.15.0/24' |
| 59 | larger_prefix = u'10.11.0.0/16' |
| 60 | |
Brian Haley | ae328b9 | 2018-10-09 19:51:54 -0400 | [diff] [blame] | 61 | """Test Subnet Pools |
| 62 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 63 | Tests the following operations in the Neutron API using the REST client for |
| 64 | Neutron: |
| 65 | |
| 66 | create a subnetpool for a tenant |
| 67 | list tenant's subnetpools |
| 68 | show a tenant subnetpool details |
| 69 | subnetpool update |
| 70 | delete a subnetpool |
| 71 | |
| 72 | All subnetpool tests are run once with ipv4 and once with ipv6. |
| 73 | |
| 74 | v2.0 of the Neutron API is assumed. |
| 75 | |
| 76 | """ |
| 77 | |
| 78 | def _new_subnetpool_attributes(self): |
| 79 | new_name = data_utils.rand_name(SUBNETPOOL_NAME) |
| 80 | return {'name': new_name, 'min_prefixlen': self.min_prefixlen, |
| 81 | 'max_prefixlen': self.max_prefixlen} |
| 82 | |
| 83 | def _check_equality_updated_subnetpool(self, expected_values, |
| 84 | updated_pool): |
| 85 | self.assertEqual(expected_values['name'], |
| 86 | updated_pool['name']) |
| 87 | self.assertEqual(expected_values['min_prefixlen'], |
| 88 | updated_pool['min_prefixlen']) |
| 89 | self.assertEqual(expected_values['max_prefixlen'], |
| 90 | updated_pool['max_prefixlen']) |
| 91 | # expected_values may not contains all subnetpool values |
| 92 | if 'prefixes' in expected_values: |
| 93 | self.assertEqual(expected_values['prefixes'], |
| 94 | updated_pool['prefixes']) |
| 95 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 96 | @decorators.idempotent_id('6e1781ec-b45b-4042-aebe-f485c022996e') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 97 | def test_create_list_subnetpool(self): |
| 98 | created_subnetpool = self._create_subnetpool() |
| 99 | body = self.client.list_subnetpools() |
| 100 | subnetpools = body['subnetpools'] |
| 101 | self.assertIn(created_subnetpool['id'], |
| 102 | [sp['id'] for sp in subnetpools], |
| 103 | "Created subnetpool id should be in the list") |
| 104 | self.assertIn(created_subnetpool['name'], |
| 105 | [sp['name'] for sp in subnetpools], |
| 106 | "Created subnetpool name should be in the list") |
| 107 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 108 | @decorators.idempotent_id('c72c1c0c-2193-4aca-ddd4-b1442640bbbb') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 109 | @utils.requires_ext(extension="standard-attr-description", |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 110 | service="network") |
| 111 | def test_create_update_subnetpool_description(self): |
| 112 | body = self._create_subnetpool(description='d1') |
| 113 | self.assertEqual('d1', body['description']) |
| 114 | sub_id = body['id'] |
Nguyen Phuong An | c486b97 | 2016-08-29 18:15:30 +0700 | [diff] [blame] | 115 | subnet_pools = [x for x in |
| 116 | self.client.list_subnetpools()['subnetpools'] if x['id'] == sub_id] |
| 117 | body = subnet_pools[0] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 118 | self.assertEqual('d1', body['description']) |
| 119 | body = self.client.update_subnetpool(sub_id, description='d2') |
| 120 | self.assertEqual('d2', body['subnetpool']['description']) |
Nguyen Phuong An | c486b97 | 2016-08-29 18:15:30 +0700 | [diff] [blame] | 121 | subnet_pools = [x for x in |
| 122 | self.client.list_subnetpools()['subnetpools'] if x['id'] == sub_id] |
| 123 | body = subnet_pools[0] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 124 | self.assertEqual('d2', body['description']) |
| 125 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 126 | @decorators.idempotent_id('741d08c2-1e3f-42be-99c7-0ea93c5b728c') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 127 | def test_get_subnetpool(self): |
| 128 | created_subnetpool = self._create_subnetpool() |
| 129 | prefixlen = self._subnetpool_data['min_prefixlen'] |
| 130 | body = self.client.show_subnetpool(created_subnetpool['id']) |
| 131 | subnetpool = body['subnetpool'] |
| 132 | self.assertEqual(created_subnetpool['name'], subnetpool['name']) |
| 133 | self.assertEqual(created_subnetpool['id'], subnetpool['id']) |
| 134 | self.assertEqual(prefixlen, subnetpool['min_prefixlen']) |
| 135 | self.assertEqual(prefixlen, subnetpool['default_prefixlen']) |
| 136 | self.assertFalse(subnetpool['shared']) |
| 137 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 138 | @decorators.idempotent_id('5bf9f1e2-efc8-4195-acf3-d12b2bd68dd3') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 139 | @utils.requires_ext(extension="project-id", service="network") |
Henry Gessau | fa6c78d | 2016-10-09 19:56:09 -0400 | [diff] [blame] | 140 | def test_show_subnetpool_has_project_id(self): |
| 141 | subnetpool = self._create_subnetpool() |
| 142 | body = self.client.show_subnetpool(subnetpool['id']) |
| 143 | show_subnetpool = body['subnetpool'] |
| 144 | self.assertIn('project_id', show_subnetpool) |
| 145 | self.assertIn('tenant_id', show_subnetpool) |
| 146 | self.assertEqual(self.client.tenant_id, show_subnetpool['project_id']) |
| 147 | self.assertEqual(self.client.tenant_id, show_subnetpool['tenant_id']) |
| 148 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 149 | @decorators.idempotent_id('764f1b93-1c4a-4513-9e7b-6c2fc5e9270c') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 150 | def test_tenant_update_subnetpool(self): |
| 151 | created_subnetpool = self._create_subnetpool() |
| 152 | pool_id = created_subnetpool['id'] |
| 153 | subnetpool_data = self._new_subnetpool_attributes() |
| 154 | self.client.update_subnetpool(created_subnetpool['id'], |
| 155 | **subnetpool_data) |
| 156 | |
| 157 | body = self.client.show_subnetpool(pool_id) |
| 158 | subnetpool = body['subnetpool'] |
| 159 | self._check_equality_updated_subnetpool(subnetpool_data, |
| 160 | subnetpool) |
| 161 | self.assertFalse(subnetpool['shared']) |
| 162 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 163 | @decorators.idempotent_id('4b496082-c992-4319-90be-d4a7ce646290') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 164 | def test_update_subnetpool_prefixes_append(self): |
| 165 | # We can append new prefixes to subnetpool |
| 166 | create_subnetpool = self._create_subnetpool() |
| 167 | pool_id = create_subnetpool['id'] |
| 168 | old_prefixes = self._subnetpool_data['prefixes'] |
| 169 | new_prefixes = old_prefixes[:] |
| 170 | new_prefixes.append(self.new_prefix) |
| 171 | subnetpool_data = {'prefixes': new_prefixes} |
| 172 | self.client.update_subnetpool(pool_id, **subnetpool_data) |
| 173 | body = self.client.show_subnetpool(pool_id) |
| 174 | prefixes = body['subnetpool']['prefixes'] |
| 175 | self.assertIn(self.new_prefix, prefixes) |
| 176 | self.assertIn(old_prefixes[0], prefixes) |
| 177 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 178 | @decorators.idempotent_id('2cae5d6a-9d32-42d8-8067-f13970ae13bb') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 179 | def test_update_subnetpool_prefixes_extend(self): |
| 180 | # We can extend current subnetpool prefixes |
| 181 | created_subnetpool = self._create_subnetpool() |
| 182 | pool_id = created_subnetpool['id'] |
| 183 | old_prefixes = self._subnetpool_data['prefixes'] |
| 184 | subnetpool_data = {'prefixes': [self.larger_prefix]} |
| 185 | self.client.update_subnetpool(pool_id, **subnetpool_data) |
| 186 | body = self.client.show_subnetpool(pool_id) |
| 187 | prefixes = body['subnetpool']['prefixes'] |
| 188 | self.assertIn(self.larger_prefix, prefixes) |
| 189 | self.assertNotIn(old_prefixes[0], prefixes) |
| 190 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 191 | @decorators.idempotent_id('d70c6c35-913b-4f24-909f-14cd0d29b2d2') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 192 | def test_admin_create_shared_subnetpool(self): |
| 193 | created_subnetpool = self._create_subnetpool(is_admin=True, |
| 194 | shared=True) |
| 195 | pool_id = created_subnetpool['id'] |
| 196 | # Shared subnetpool can be retrieved by tenant user. |
| 197 | body = self.client.show_subnetpool(pool_id) |
| 198 | subnetpool = body['subnetpool'] |
| 199 | self.assertEqual(created_subnetpool['name'], subnetpool['name']) |
| 200 | self.assertTrue(subnetpool['shared']) |
| 201 | |
| 202 | def _create_subnet_from_pool(self, subnet_values=None, pool_values=None): |
| 203 | if pool_values is None: |
| 204 | pool_values = {} |
| 205 | |
| 206 | created_subnetpool = self._create_subnetpool(**pool_values) |
| 207 | pool_id = created_subnetpool['id'] |
| 208 | subnet_name = data_utils.rand_name(SUBNETPOOL_NAME) |
| 209 | network = self.create_network() |
| 210 | subnet_kwargs = {'name': subnet_name, |
| 211 | 'subnetpool_id': pool_id} |
| 212 | if subnet_values: |
| 213 | subnet_kwargs.update(subnet_values) |
| 214 | # not creating the subnet using the base.create_subnet because |
| 215 | # that function needs to be enhanced to support subnet_create when |
| 216 | # prefixlen and subnetpool_id is specified. |
| 217 | body = self.client.create_subnet( |
| 218 | network_id=network['id'], |
| 219 | ip_version=self._ip_version, |
| 220 | **subnet_kwargs) |
| 221 | subnet = body['subnet'] |
| 222 | return pool_id, subnet |
| 223 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 224 | @decorators.idempotent_id('1362ed7d-3089-42eb-b3a5-d6cb8398ee77') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 225 | def test_create_subnet_from_pool_with_prefixlen(self): |
| 226 | subnet_values = {"prefixlen": self.max_prefixlen} |
| 227 | pool_id, subnet = self._create_subnet_from_pool( |
| 228 | subnet_values=subnet_values) |
| 229 | cidr = str(subnet['cidr']) |
| 230 | self.assertEqual(pool_id, subnet['subnetpool_id']) |
| 231 | self.assertTrue(cidr.endswith(str(self.max_prefixlen))) |
| 232 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 233 | @decorators.idempotent_id('86b86189-9789-4582-9c3b-7e2bfe5735ee') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 234 | def test_create_subnet_from_pool_with_subnet_cidr(self): |
| 235 | subnet_values = {"cidr": self.subnet_cidr} |
| 236 | pool_id, subnet = self._create_subnet_from_pool( |
| 237 | subnet_values=subnet_values) |
| 238 | cidr = str(subnet['cidr']) |
| 239 | self.assertEqual(pool_id, subnet['subnetpool_id']) |
| 240 | self.assertEqual(cidr, self.subnet_cidr) |
| 241 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 242 | @decorators.idempotent_id('83f76e3a-9c40-40c2-a015-b7c5242178d8') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 243 | def test_create_subnet_from_pool_with_default_prefixlen(self): |
| 244 | # If neither cidr nor prefixlen is specified, |
| 245 | # subnet will use subnetpool default_prefixlen for cidr. |
| 246 | pool_id, subnet = self._create_subnet_from_pool() |
| 247 | cidr = str(subnet['cidr']) |
| 248 | self.assertEqual(pool_id, subnet['subnetpool_id']) |
| 249 | prefixlen = self._subnetpool_data['min_prefixlen'] |
| 250 | self.assertTrue(cidr.endswith(str(prefixlen))) |
| 251 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 252 | @decorators.idempotent_id('a64af292-ec52-4bde-b654-a6984acaf477') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 253 | def test_create_subnet_from_pool_with_quota(self): |
| 254 | pool_values = {'default_quota': 4} |
| 255 | subnet_values = {"prefixlen": self.max_prefixlen} |
| 256 | pool_id, subnet = self._create_subnet_from_pool( |
| 257 | subnet_values=subnet_values, pool_values=pool_values) |
| 258 | cidr = str(subnet['cidr']) |
| 259 | self.assertEqual(pool_id, subnet['subnetpool_id']) |
| 260 | self.assertTrue(cidr.endswith(str(self.max_prefixlen))) |
| 261 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 262 | @decorators.idempotent_id('49b44c64-1619-4b29-b527-ffc3c3115dc4') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 263 | @utils.requires_ext(extension='address-scope', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 264 | def test_create_subnetpool_associate_address_scope(self): |
| 265 | address_scope = self.create_address_scope( |
| 266 | name=data_utils.rand_name('smoke-address-scope'), |
| 267 | ip_version=self._ip_version) |
| 268 | created_subnetpool = self._create_subnetpool( |
| 269 | address_scope_id=address_scope['id']) |
| 270 | body = self.client.show_subnetpool(created_subnetpool['id']) |
| 271 | self.assertEqual(address_scope['id'], |
| 272 | body['subnetpool']['address_scope_id']) |
| 273 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 274 | @decorators.idempotent_id('910b6393-db24-4f6f-87dc-b36892ad6c8c') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 275 | @utils.requires_ext(extension='address-scope', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 276 | def test_update_subnetpool_associate_address_scope(self): |
| 277 | address_scope = self.create_address_scope( |
| 278 | name=data_utils.rand_name('smoke-address-scope'), |
| 279 | ip_version=self._ip_version) |
| 280 | created_subnetpool = self._create_subnetpool() |
| 281 | pool_id = created_subnetpool['id'] |
| 282 | body = self.client.show_subnetpool(pool_id) |
| 283 | self.assertIsNone(body['subnetpool']['address_scope_id']) |
| 284 | self.client.update_subnetpool(pool_id, |
| 285 | address_scope_id=address_scope['id']) |
| 286 | body = self.client.show_subnetpool(pool_id) |
| 287 | self.assertEqual(address_scope['id'], |
| 288 | body['subnetpool']['address_scope_id']) |
| 289 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 290 | @decorators.idempotent_id('18302e80-46a3-4563-82ac-ccd1dd57f652') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 291 | @utils.requires_ext(extension='address-scope', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 292 | def test_update_subnetpool_associate_another_address_scope(self): |
| 293 | address_scope = self.create_address_scope( |
| 294 | name=data_utils.rand_name('smoke-address-scope'), |
| 295 | ip_version=self._ip_version) |
| 296 | another_address_scope = self.create_address_scope( |
| 297 | name=data_utils.rand_name('smoke-address-scope'), |
| 298 | ip_version=self._ip_version) |
| 299 | created_subnetpool = self._create_subnetpool( |
| 300 | address_scope_id=address_scope['id']) |
| 301 | pool_id = created_subnetpool['id'] |
| 302 | body = self.client.show_subnetpool(pool_id) |
| 303 | self.assertEqual(address_scope['id'], |
| 304 | body['subnetpool']['address_scope_id']) |
| 305 | self.client.update_subnetpool( |
| 306 | pool_id, address_scope_id=another_address_scope['id']) |
| 307 | body = self.client.show_subnetpool(pool_id) |
| 308 | self.assertEqual(another_address_scope['id'], |
| 309 | body['subnetpool']['address_scope_id']) |
| 310 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 311 | @decorators.idempotent_id('f8970048-e41b-42d6-934b-a1297b07706a') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 312 | @utils.requires_ext(extension='address-scope', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 313 | def test_update_subnetpool_disassociate_address_scope(self): |
| 314 | address_scope = self.create_address_scope( |
| 315 | name=data_utils.rand_name('smoke-address-scope'), |
| 316 | ip_version=self._ip_version) |
| 317 | created_subnetpool = self._create_subnetpool( |
| 318 | address_scope_id=address_scope['id']) |
| 319 | pool_id = created_subnetpool['id'] |
| 320 | body = self.client.show_subnetpool(pool_id) |
| 321 | self.assertEqual(address_scope['id'], |
| 322 | body['subnetpool']['address_scope_id']) |
| 323 | self.client.update_subnetpool(pool_id, |
| 324 | address_scope_id=None) |
| 325 | body = self.client.show_subnetpool(pool_id) |
| 326 | self.assertIsNone(body['subnetpool']['address_scope_id']) |
| 327 | |
Dongcan Ye | 2bc62bb | 2017-05-26 10:48:40 +0800 | [diff] [blame] | 328 | @decorators.idempotent_id('4c6963c2-f54c-4347-b288-75d18421c4c4') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 329 | @utils.requires_ext(extension='default-subnetpools', service='network') |
Dongcan Ye | 2bc62bb | 2017-05-26 10:48:40 +0800 | [diff] [blame] | 330 | def test_tenant_create_non_default_subnetpool(self): |
Brian Haley | ae328b9 | 2018-10-09 19:51:54 -0400 | [diff] [blame] | 331 | """Test creates a subnetpool, the "is_default" attribute is False.""" |
Dongcan Ye | 2bc62bb | 2017-05-26 10:48:40 +0800 | [diff] [blame] | 332 | created_subnetpool = self._create_subnetpool() |
| 333 | self.assertFalse(created_subnetpool['is_default']) |
| 334 | |
| 335 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 336 | class SubnetPoolsTestV6(SubnetPoolsTest): |
| 337 | |
| 338 | min_prefixlen = '48' |
| 339 | max_prefixlen = '64' |
| 340 | _ip_version = 6 |
| 341 | subnet_cidr = '2001:db8:3::/64' |
| 342 | new_prefix = u'2001:db8:5::/64' |
| 343 | larger_prefix = u'2001:db8::/32' |
| 344 | |
| 345 | @classmethod |
| 346 | def resource_setup(cls): |
| 347 | super(SubnetPoolsTestV6, cls).resource_setup() |
| 348 | min_prefixlen = '64' |
| 349 | prefixes = [u'2001:db8:3::/48'] |
| 350 | cls._subnetpool_data = {'min_prefixlen': min_prefixlen, |
| 351 | 'prefixes': prefixes} |
| 352 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 353 | @decorators.idempotent_id('f62d73dc-cf6f-4879-b94b-dab53982bf3b') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 354 | def test_create_dual_stack_subnets_from_subnetpools(self): |
| 355 | pool_id_v6, subnet_v6 = self._create_subnet_from_pool() |
| 356 | pool_values_v4 = {'prefixes': ['192.168.0.0/16'], |
| 357 | 'min_prefixlen': 21, |
| 358 | 'max_prefixlen': 32} |
| 359 | create_v4_subnetpool = self._create_subnetpool(**pool_values_v4) |
| 360 | pool_id_v4 = create_v4_subnetpool['id'] |
| 361 | subnet_v4 = self.client.create_subnet( |
| 362 | network_id=subnet_v6['network_id'], ip_version=4, |
| 363 | subnetpool_id=pool_id_v4)['subnet'] |
| 364 | self.assertEqual(subnet_v4['network_id'], subnet_v6['network_id']) |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 365 | |
| 366 | |
| 367 | class SubnetPoolsSearchCriteriaTest(base.BaseSearchCriteriaTest, |
| 368 | SubnetPoolsTestBase): |
| 369 | |
| 370 | resource = 'subnetpool' |
| 371 | |
Ihar Hrachyshka | a9035b6 | 2016-06-13 11:21:38 +0200 | [diff] [blame] | 372 | list_kwargs = {'shared': False} |
| 373 | |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 374 | @classmethod |
| 375 | def resource_setup(cls): |
| 376 | super(SubnetPoolsSearchCriteriaTest, cls).resource_setup() |
| 377 | for name in cls.resource_names: |
| 378 | cls._create_subnetpool(name=name) |
| 379 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 380 | @decorators.idempotent_id('6e3f842e-6bfb-49cb-82d3-0026be4e8e04') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 381 | def test_list_sorts_asc(self): |
| 382 | self._test_list_sorts_asc() |
| 383 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 384 | @decorators.idempotent_id('f336859b-b868-438c-a6fc-2c06374115f2') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 385 | def test_list_sorts_desc(self): |
| 386 | self._test_list_sorts_desc() |
| 387 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 388 | @decorators.idempotent_id('1291fae7-c196-4372-ad59-ce7988518f7b') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 389 | def test_list_pagination(self): |
| 390 | self._test_list_pagination() |
| 391 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 392 | @decorators.idempotent_id('ddb20d14-1952-49b4-a17e-231cc2239a52') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 393 | def test_list_pagination_with_marker(self): |
| 394 | self._test_list_pagination_with_marker() |
| 395 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 396 | @decorators.idempotent_id('b3bd9665-2769-4a43-b50c-31b1add12891') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 397 | def test_list_pagination_with_href_links(self): |
| 398 | self._test_list_pagination_with_href_links() |
| 399 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 400 | @decorators.idempotent_id('1ec1f325-43b0-406e-96ce-20539e38a61d') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 401 | def test_list_pagination_page_reverse_asc(self): |
| 402 | self._test_list_pagination_page_reverse_asc() |
| 403 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 404 | @decorators.idempotent_id('f43a293e-4aaa-48f4-aeaf-de63a676357c') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 405 | def test_list_pagination_page_reverse_desc(self): |
| 406 | self._test_list_pagination_page_reverse_desc() |
| 407 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 408 | @decorators.idempotent_id('73511385-839c-4829-8ac1-b5ad992126c4') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 409 | def test_list_pagination_page_reverse_with_href_links(self): |
| 410 | self._test_list_pagination_page_reverse_with_href_links() |
| 411 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 412 | @decorators.idempotent_id('82a13efc-c18f-4249-b8ec-cec7cf26fbd6') |
Ihar Hrachyshka | eace174 | 2016-06-08 15:07:35 +0200 | [diff] [blame] | 413 | def test_list_no_pagination_limit_0(self): |
| 414 | self._test_list_no_pagination_limit_0() |
Victor Morales | 1be97b4 | 2016-09-05 08:50:06 -0500 | [diff] [blame] | 415 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 416 | @decorators.idempotent_id('27feb3f8-40f4-4e50-8cd2-7d0096a98682') |
Victor Morales | 1be97b4 | 2016-09-05 08:50:06 -0500 | [diff] [blame] | 417 | def test_list_validation_filters(self): |
Hongbin Lu | 54f5592 | 2018-07-12 19:05:39 +0000 | [diff] [blame] | 418 | self._test_list_validation_filters(self.list_kwargs) |
| 419 | self._test_list_validation_filters({ |
| 420 | 'unknown_filter': 'value'}, filter_is_valid=False) |