diff --git a/tempest/lib/common/fixed_network.py b/tempest/lib/common/fixed_network.py index e2054a4d16..875a79d5f9 100644 --- a/tempest/lib/common/fixed_network.py +++ b/tempest/lib/common/fixed_network.py @@ -38,7 +38,12 @@ def get_network_from_name(name, compute_networks_client): raise exceptions.InvalidTestResource(type='network', name=name) networks = compute_networks_client.list_networks()['networks'] - networks = [n for n in networks if n['label'] == name] + # NOTE(zhufl) compute networks_client uses 'label' as network name field, + # while neutron networks_client uses 'name' as network name field. + try: + networks = [n for n in networks if n['label'] == name] + except KeyError: + networks = [n for n in networks if n['name'] == name] # Check that a network exists, else raise an InvalidConfigurationException if len(networks) == 1: diff --git a/tempest/lib/common/preprov_creds.py b/tempest/lib/common/preprov_creds.py index 83db513a96..fcdeb17523 100644 --- a/tempest/lib/common/preprov_creds.py +++ b/tempest/lib/common/preprov_creds.py @@ -344,11 +344,11 @@ class PreProvisionedCredentialProvider(cred_provider.CredentialProvider): net_creds = cred_provider.TestResources(credential) net_clients = clients.ServiceClients(credentials=credential, identity_uri=self.identity_uri) - compute_network_client = net_clients.compute.NetworksClient() + networks_client = net_clients.network.NetworksClient() net_name = self.hash_dict['networks'].get(hash, None) try: network = fixed_network.get_network_from_name( - net_name, compute_network_client) + net_name, networks_client) except lib_exc.InvalidTestResource: network = {} net_creds.set_resources(network=network) diff --git a/tempest/test.py b/tempest/test.py index 9da85d5fc4..27e01650f4 100644 --- a/tempest/test.py +++ b/tempest/test.py @@ -836,7 +836,7 @@ class BaseTestCase(testtools.testcase.WithAttributes, manager = cls.get_client_manager() # Make sure cred_provider exists and get a network client - networks_client = manager.compute_networks_client + networks_client = manager.networks_client cred_provider = cls._get_credentials_provider() # In case of nova network, isolated tenants are not able to list the # network configured in fixed_network_name, even if they can use it diff --git a/tempest/tests/lib/common/test_preprov_creds.py b/tempest/tests/lib/common/test_preprov_creds.py index 9b10159789..25df2a7c4f 100644 --- a/tempest/tests/lib/common/test_preprov_creds.py +++ b/tempest/tests/lib/common/test_preprov_creds.py @@ -339,7 +339,7 @@ class TestPreProvisionedCredentials(base.TestCase): return_value=test_accounts)) test_accounts_class = preprov_creds.PreProvisionedCredentialProvider( **self.fixed_params) - with mock.patch('tempest.lib.services.compute.networks_client.' + with mock.patch('tempest.lib.services.network.networks_client.' 'NetworksClient.list_networks', return_value={'networks': [{'name': 'network-2', 'id': 'fake-id', diff --git a/tempest/tests/test_base_test.py b/tempest/tests/test_base_test.py index 011bc9bebc..2b5a947003 100644 --- a/tempest/tests/test_base_test.py +++ b/tempest/tests/test_base_test.py @@ -41,7 +41,7 @@ class TestBaseTestCase(base.TestCase): def test_get_tenant_network(self, mock_gtn, mock_gprov, mock_gcm): net_client = mock.Mock() mock_prov = mock.Mock() - mock_gcm.return_value.compute_networks_client = net_client + mock_gcm.return_value.networks_client = net_client mock_gprov.return_value = mock_prov test.BaseTestCase.get_tenant_network() @@ -85,7 +85,7 @@ class TestBaseTestCase(base.TestCase): mock_gcm): net_client = mock.Mock() mock_prov = mock.Mock() - mock_gcm.return_value.compute_networks_client = net_client + mock_gcm.return_value.networks_client = net_client mock_gprov.return_value = mock_prov test.BaseTestCase.get_tenant_network(credentials_type='alt') @@ -102,7 +102,7 @@ class TestBaseTestCase(base.TestCase): mock_gcm): net_client = mock.Mock() mock_prov = mock.Mock() - mock_gcm.return_value.compute_networks_client = net_client + mock_gcm.return_value.networks_client = net_client mock_gprov.return_value = mock_prov creds = ['foo_type', 'role1']