Merge "Stop running CONF getattr during import"
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index dd888a6..8720985 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -53,8 +53,6 @@
# Default to ipv4.
_ip_version = 4
- _tenant_network_cidr = CONF.network.tenant_network_cidr
- _tenant_network_mask_bits = CONF.network.tenant_network_mask_bits
@classmethod
def setUpClass(cls):
@@ -147,8 +145,12 @@
def create_subnet(cls, network):
"""Wrapper utility that returns a test subnet."""
# The cidr and mask_bits depend on the ip version.
- cidr = netaddr.IPNetwork(cls._tenant_network_cidr)
- mask_bits = cls._tenant_network_mask_bits
+ if cls._ip_version == 4:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
+ elif cls._ip_version == 6:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+ mask_bits = CONF.network.tenant_network_v6_mask_bits
# Find a cidr that is not in use yet and create a subnet with it
body = None
failure = None
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index aba2c8e..654552d 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -85,8 +85,12 @@
updated_net = body['network']
self.assertEqual(updated_net['name'], new_name)
# Find a cidr that is not in use yet and create a subnet with it
- cidr = netaddr.IPNetwork(self._tenant_network_cidr)
- mask_bits = self._tenant_network_mask_bits
+ if self._ip_version == 4:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
+ elif self._ip_version == 6:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+ mask_bits = CONF.network.tenant_network_v6_mask_bits
for subnet_cidr in cidr.subnet(mask_bits):
try:
resp, body = self.client.create_subnet(
@@ -464,8 +468,6 @@
class NetworksIpV6TestJSON(NetworksTestJSON):
_ip_version = 6
- _tenant_network_cidr = CONF.network.tenant_network_v6_cidr
- _tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
@classmethod
def setUpClass(cls):