Convert network api tests to use global CONF object
This commit takes all the uses of config in the network api tests
and converts them to use the global CONF object.
Partially implements bp config-cleanup
Change-Id: I4fc99d44073598513653cd87fd73a82a0b0093da
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 0085cd6..1c2c4b0 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -17,10 +17,13 @@
from tempest import clients
from tempest.common.utils import data_utils
+from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
+CONF = config.CONF
+
LOG = logging.getLogger(__name__)
@@ -52,8 +55,7 @@
cls.set_network_resources()
super(BaseNetworkTest, cls).setUpClass()
os = clients.Manager(interface=cls._interface)
- cls.network_cfg = os.config.network
- if not cls.config.service_available.neutron:
+ if not CONF.service_available.neutron:
raise cls.skipException("Neutron support is required")
cls.client = os.network_client
cls.networks = []
@@ -123,8 +125,8 @@
@classmethod
def create_subnet(cls, network, ip_version=4):
"""Wrapper utility that returns a test subnet."""
- cidr = netaddr.IPNetwork(cls.network_cfg.tenant_network_cidr)
- mask_bits = cls.network_cfg.tenant_network_mask_bits
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
# Find a cidr that is not in use yet and create a subnet with it
body = None
failure = None
@@ -260,9 +262,9 @@
@classmethod
def setUpClass(cls):
super(BaseAdminNetworkTest, cls).setUpClass()
- admin_username = cls.config.compute_admin.username
- admin_password = cls.config.compute_admin.password
- admin_tenant = cls.config.compute_admin.tenant_name
+ admin_username = CONF.compute_admin.username
+ admin_password = CONF.compute_admin.password
+ admin_tenant = CONF.compute_admin.tenant_name
if not (admin_username and admin_password and admin_tenant):
msg = ("Missing Administrative Network API credentials "
"in configuration.")
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index a7c1bd2..69367ab 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -15,8 +15,11 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class FloatingIPTestJSON(base.BaseNetworkTest):
_interface = 'json'
@@ -43,7 +46,7 @@
@classmethod
def setUpClass(cls):
super(FloatingIPTestJSON, cls).setUpClass()
- cls.ext_net_id = cls.config.network.public_network_id
+ cls.ext_net_id = CONF.network.public_network_id
# Create network, subnet, router and add interface
cls.network = cls.create_network()
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index b1f4608..3aa765c 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -17,9 +17,12 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
+from tempest import config
from tempest import exceptions
from tempest.test import attr
+CONF = config.CONF
+
class NetworksTestJSON(base.BaseNetworkTest):
_interface = 'json'
@@ -76,8 +79,8 @@
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.network_cfg.tenant_network_cidr)
- mask_bits = self.network_cfg.tenant_network_mask_bits
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
for subnet_cidr in cidr.subnet(mask_bits):
try:
resp, body = self.client.create_subnet(
@@ -321,8 +324,8 @@
@attr(type='smoke')
def test_bulk_create_delete_subnet(self):
# Creates 2 subnets in one request
- cidr = netaddr.IPNetwork(self.network_cfg.tenant_network_cidr)
- mask_bits = self.network_cfg.tenant_network_mask_bits
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
cidrs = []
for subnet_cidr in cidr.subnet(mask_bits):
cidrs.append(subnet_cidr)
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 426273c..5a673cc 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -17,8 +17,11 @@
from tempest.api.network import base_routers as base
from tempest.common.utils import data_utils
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class RoutersTest(base.BaseRouterTest):
_interface = 'json'
@@ -35,14 +38,14 @@
name = data_utils.rand_name('router-')
resp, create_body = self.client.create_router(
name, external_gateway_info={
- "network_id": self.network_cfg.public_network_id},
+ "network_id": CONF.network.public_network_id},
admin_state_up=False)
self.assertEqual('201', resp['status'])
self.addCleanup(self._delete_router, create_body['router']['id'])
self.assertEqual(create_body['router']['name'], name)
self.assertEqual(
create_body['router']['external_gateway_info']['network_id'],
- self.network_cfg.public_network_id)
+ CONF.network.public_network_id)
self.assertEqual(create_body['router']['admin_state_up'], False)
# Show details of the created router
resp, show_body = self.client.show_router(
@@ -51,7 +54,7 @@
self.assertEqual(show_body['router']['name'], name)
self.assertEqual(
show_body['router']['external_gateway_info']['network_id'],
- self.network_cfg.public_network_id)
+ CONF.network.public_network_id)
self.assertEqual(show_body['router']['admin_state_up'], False)
# List routers and verify if created router is there in response
resp, list_body = self.client.list_routers()
@@ -123,14 +126,14 @@
def _verify_gateway_port(self, router_id):
resp, list_body = self.admin_client.list_ports(
- network_id=self.network_cfg.public_network_id,
+ network_id=CONF.network.public_network_id,
device_id=router_id)
self.assertEqual(len(list_body['ports']), 1)
gw_port = list_body['ports'][0]
fixed_ips = gw_port['fixed_ips']
self.assertEqual(len(fixed_ips), 1)
resp, public_net_body = self.admin_client.show_network(
- self.network_cfg.public_network_id)
+ CONF.network.public_network_id)
public_subnet_id = public_net_body['network']['subnets'][0]
self.assertEqual(fixed_ips[0]['subnet_id'], public_subnet_id)
@@ -140,13 +143,13 @@
self.client.update_router(
router['id'],
external_gateway_info={
- 'network_id': self.network_cfg.public_network_id})
+ 'network_id': CONF.network.public_network_id})
# Verify operation - router
resp, show_body = self.client.show_router(router['id'])
self.assertEqual('200', resp['status'])
self._verify_router_gateway(
router['id'],
- {'network_id': self.network_cfg.public_network_id})
+ {'network_id': CONF.network.public_network_id})
self._verify_gateway_port(router['id'])
@test.attr(type='smoke')
@@ -155,11 +158,11 @@
self.admin_client.update_router_with_snat_gw_info(
router['id'],
external_gateway_info={
- 'network_id': self.network_cfg.public_network_id,
+ 'network_id': CONF.network.public_network_id,
'enable_snat': True})
self._verify_router_gateway(
router['id'],
- {'network_id': self.network_cfg.public_network_id,
+ {'network_id': CONF.network.public_network_id,
'enable_snat': True})
self._verify_gateway_port(router['id'])
@@ -169,11 +172,11 @@
self.admin_client.update_router_with_snat_gw_info(
router['id'],
external_gateway_info={
- 'network_id': self.network_cfg.public_network_id,
+ 'network_id': CONF.network.public_network_id,
'enable_snat': False})
self._verify_router_gateway(
router['id'],
- {'network_id': self.network_cfg.public_network_id,
+ {'network_id': CONF.network.public_network_id,
'enable_snat': False})
self._verify_gateway_port(router['id'])
@@ -181,12 +184,12 @@
def test_update_router_unset_gateway(self):
router = self.create_router(
data_utils.rand_name('router-'),
- external_network_id=self.network_cfg.public_network_id)
+ external_network_id=CONF.network.public_network_id)
self.client.update_router(router['id'], external_gateway_info={})
self._verify_router_gateway(router['id'])
# No gateway port expected
resp, list_body = self.admin_client.list_ports(
- network_id=self.network_cfg.public_network_id,
+ network_id=CONF.network.public_network_id,
device_id=router['id'])
self.assertFalse(list_body['ports'])
@@ -194,15 +197,15 @@
def test_update_router_reset_gateway_without_snat(self):
router = self.create_router(
data_utils.rand_name('router-'),
- external_network_id=self.network_cfg.public_network_id)
+ external_network_id=CONF.network.public_network_id)
self.admin_client.update_router_with_snat_gw_info(
router['id'],
external_gateway_info={
- 'network_id': self.network_cfg.public_network_id,
+ 'network_id': CONF.network.public_network_id,
'enable_snat': False})
self._verify_router_gateway(
router['id'],
- {'network_id': self.network_cfg.public_network_id,
+ {'network_id': CONF.network.public_network_id,
'enable_snat': False})
self._verify_gateway_port(router['id'])
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 089f9ef..64b8a41 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -15,8 +15,11 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class VPNaaSJSON(base.BaseNetworkTest):
_interface = 'json'
@@ -43,7 +46,7 @@
cls.subnet = cls.create_subnet(cls.network)
cls.router = cls.create_router(
data_utils.rand_name("router-"),
- external_network_id=cls.network_cfg.public_network_id)
+ external_network_id=CONF.network.public_network_id)
cls.create_router_interface(cls.router['id'], cls.subnet['id'])
cls.vpnservice = cls.create_vpnservice(cls.subnet['id'],
cls.router['id'])