Browse Source

Merge "Allow creating subnet without a gateway"

tags/0.1.0
Zuul 1 year ago
parent
commit
1d90adb9c7

+ 6
- 3
neutron_tempest_plugin/api/base.py View File

@@ -284,7 +284,7 @@ class BaseNetworkTest(test.BaseTestCase):
284 284
         return network
285 285
 
286 286
     @classmethod
287
-    def create_subnet(cls, network, gateway=None, cidr=None, mask_bits=None,
287
+    def create_subnet(cls, network, gateway='', cidr=None, mask_bits=None,
288 288
                       ip_version=None, client=None, **kwargs):
289 289
         """Wrapper utility that returns a test subnet.
290 290
 
@@ -298,6 +298,7 @@ class BaseNetworkTest(test.BaseTestCase):
298 298
         It can be a str or a netaddr.IPAddress
299 299
         If gateway is not given, then it will use default address for
300 300
         given subnet CIDR, like "192.168.0.1" for "192.168.0.0/24" CIDR
301
+        if gateway is given as None then no gateway will be assigned
301 302
 
302 303
         :param cidr: CIDR of the subnet to create
303 304
         It can be either None, a str or a netaddr.IPNetwork instance
@@ -335,17 +336,19 @@ class BaseNetworkTest(test.BaseTestCase):
335 336
                         "Gateway IP version doesn't match IP version")
336 337
             else:
337 338
                 ip_version = gateway_ip.version
339
+        else:
340
+            ip_version = ip_version or cls._ip_version
338 341
 
339 342
         for subnet_cidr in cls.get_subnet_cidrs(
340 343
                 ip_version=ip_version, cidr=cidr, mask_bits=mask_bits):
341 344
             if cls.try_reserve_subnet_cidr(subnet_cidr):
342
-                gateway_ip = gateway or str(subnet_cidr.ip + 1)
345
+                if gateway is not None:
346
+                    kwargs['gateway_ip'] = str(gateway or (subnet_cidr.ip + 1))
343 347
                 try:
344 348
                     body = client.create_subnet(
345 349
                         network_id=network['id'],
346 350
                         cidr=str(subnet_cidr),
347 351
                         ip_version=subnet_cidr.version,
348
-                        gateway_ip=str(gateway_ip),
349 352
                         **kwargs)
350 353
                     break
351 354
                 except lib_exc.BadRequest as e:

+ 1
- 1
neutron_tempest_plugin/scenario/test_trunk.py View File

@@ -230,7 +230,7 @@ class TrunkTest(base.BaseTempestTestCase):
230 230
         vlan_tag = 10
231 231
 
232 232
         vlan_network = self.create_network()
233
-        self.create_subnet(vlan_network)
233
+        self.create_subnet(vlan_network, gateway=None)
234 234
 
235 235
         servers = [
236 236
             self._create_server_with_port_and_subport(vlan_network, vlan_tag)

Loading…
Cancel
Save