Default to using neutron networks_client in get_tenant_network
Proxy apis to neutron like '/os-networks' are deprecated in microverion 2.36, and calling to them will get 404 error. So this is to use neutron networks_client as default in get_tenant_network. https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id33 Change-Id: I0496d2d0c3c9fe29d61124275c7f5cca78729bf2
This commit is contained in:
parent
96107397fe
commit
33289a2347
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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',
|
||||
|
@ -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']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user