Remove any reference to "tenant_id" in network

Change-Id: I43789e243581aa176c11d6a85691f36acfa55b27
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
This commit is contained in:
Rodolfo Alonso Hernandez 2020-02-15 13:24:28 +00:00
parent 257f3b009f
commit c1449d4ff2
15 changed files with 116 additions and 69 deletions

View File

@ -0,0 +1,6 @@
---
features:
- |
[`blueprint blueprint adopt-oslo-versioned-objects-for-db <https://blueprints.launchpad.net/neutron/+spec/adopt-oslo-versioned-objects-for-db>`_]
Any reference to "tenant_id" in Network objects is replaced with
"project_id".

View File

@ -93,7 +93,7 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
# Creates a floating IP # Creates a floating IP
body = self.admin_floating_ips_client.create_floatingip( body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id, floating_network_id=self.ext_net_id,
tenant_id=self.network['tenant_id'], project_id=self.network['project_id'],
port_id=self.port['id']) port_id=self.port['id'])
created_floating_ip = body['floatingip'] created_floating_ip = body['floatingip']
self.addCleanup( self.addCleanup(
@ -101,7 +101,7 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
self.floating_ips_client.delete_floatingip, self.floating_ips_client.delete_floatingip,
created_floating_ip['id']) created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id']) self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id']) self.assertIsNotNone(created_floating_ip['project_id'])
self.assertIsNotNone(created_floating_ip['floating_ip_address']) self.assertIsNotNone(created_floating_ip['floating_ip_address'])
self.assertEqual(created_floating_ip['port_id'], self.port['id']) self.assertEqual(created_floating_ip['port_id'], self.port['id'])
self.assertEqual(created_floating_ip['floating_network_id'], self.assertEqual(created_floating_ip['floating_network_id'],
@ -116,8 +116,8 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id']) self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
self.assertEqual(shown_floating_ip['floating_network_id'], self.assertEqual(shown_floating_ip['floating_network_id'],
self.ext_net_id) self.ext_net_id)
self.assertEqual(shown_floating_ip['tenant_id'], self.assertEqual(shown_floating_ip['project_id'],
self.network['tenant_id']) self.network['project_id'])
self.assertEqual(shown_floating_ip['floating_ip_address'], self.assertEqual(shown_floating_ip['floating_ip_address'],
created_floating_ip['floating_ip_address']) created_floating_ip['floating_ip_address'])
self.assertEqual(shown_floating_ip['port_id'], self.port['id']) self.assertEqual(shown_floating_ip['port_id'], self.port['id'])

View File

@ -121,7 +121,7 @@ class MeteringTestJSON(base.BaseAdminNetworkTest):
metering_label = body['metering_label'] metering_label = body['metering_label']
self.assertEqual(self.metering_label['id'], metering_label['id']) self.assertEqual(self.metering_label['id'], metering_label['id'])
self.assertEqual(self.metering_label['tenant_id'], self.assertEqual(self.metering_label['tenant_id'],
metering_label['tenant_id']) metering_label['project_id'])
self.assertEqual(self.metering_label['name'], metering_label['name']) self.assertEqual(self.metering_label['name'], metering_label['name'])
self.assertEqual(self.metering_label['description'], self.assertEqual(self.metering_label['description'],
metering_label['description']) metering_label['description'])

View File

@ -58,12 +58,12 @@ class QuotasNegativeTest(base.BaseAdminNetworkTest):
# Create two networks # Create two networks
n1 = self.admin_networks_client.create_network( n1 = self.admin_networks_client.create_network(
tenant_id=self.project['id']) project_id=self.project['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_networks_client.delete_network, self.admin_networks_client.delete_network,
n1['network']['id']) n1['network']['id'])
n2 = self.admin_networks_client.create_network( n2 = self.admin_networks_client.create_network(
tenant_id=self.project['id']) project_id=self.project['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_networks_client.delete_network, self.admin_networks_client.delete_network,
n2['network']['id']) n2['network']['id'])
@ -73,7 +73,7 @@ class QuotasNegativeTest(base.BaseAdminNetworkTest):
lib_exc.Conflict, lib_exc.Conflict,
r"Quota exceeded for resources: \['network'\].*"): r"Quota exceeded for resources: \['network'\].*"):
n3 = self.admin_networks_client.create_network( n3 = self.admin_networks_client.create_network(
tenant_id=self.project['id']) project_id=self.project['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_networks_client.delete_network, self.admin_networks_client.delete_network,
n3['network']['id']) n3['network']['id'])

View File

@ -67,7 +67,7 @@ class QuotasTest(base.BaseAdminNetworkTest):
non_default_quotas = self.admin_quotas_client.list_quotas() non_default_quotas = self.admin_quotas_client.list_quotas()
found = False found = False
for qs in non_default_quotas['quotas']: for qs in non_default_quotas['quotas']:
if qs['tenant_id'] == project_id: if qs['project_id'] == project_id:
found = True found = True
self.assertTrue(found) self.assertTrue(found)
@ -81,7 +81,7 @@ class QuotasTest(base.BaseAdminNetworkTest):
self.admin_quotas_client.reset_quotas(project_id) self.admin_quotas_client.reset_quotas(project_id)
non_default_quotas = self.admin_quotas_client.list_quotas() non_default_quotas = self.admin_quotas_client.list_quotas()
for q in non_default_quotas['quotas']: for q in non_default_quotas['quotas']:
self.assertNotEqual(project_id, q['tenant_id']) self.assertNotEqual(project_id, q['project_id'])
quota_set = self.admin_quotas_client.show_quotas(project_id)['quota'] quota_set = self.admin_quotas_client.show_quotas(project_id)['quota']
default_quotas = self.admin_quotas_client.show_default_quotas( default_quotas = self.admin_quotas_client.show_default_quotas(
project_id)['quota'] project_id)['quota']

View File

@ -63,11 +63,11 @@ class RoutersAdminTest(base.BaseAdminNetworkTest):
name = data_utils.rand_name('router-') name = data_utils.rand_name('router-')
create_body = self.admin_routers_client.create_router( create_body = self.admin_routers_client.create_router(
name=name, tenant_id=project_id) name=name, project_id=project_id)
self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_routers_client.delete_router, self.admin_routers_client.delete_router,
create_body['router']['id']) create_body['router']['id'])
self.assertEqual(project_id, create_body['router']['tenant_id']) self.assertEqual(project_id, create_body['router']['project_id'])
@decorators.idempotent_id('847257cc-6afd-4154-b8fb-af49f5670ce8') @decorators.idempotent_id('847257cc-6afd-4154-b8fb-af49f5670ce8')
@utils.requires_ext(extension='ext-gw-mode', service='network') @utils.requires_ext(extension='ext-gw-mode', service='network')

View File

@ -106,14 +106,14 @@ class RoutersTestDVR(base.BaseAdminNetworkTest):
attribute will be set to True attribute will be set to True
""" """
name = data_utils.rand_name('router') name = data_utils.rand_name('router')
tenant_id = self.routers_client.tenant_id project_id = self.routers_client.project_id
# router needs to be in admin state down in order to be upgraded to DVR # router needs to be in admin state down in order to be upgraded to DVR
# l3ha routers are not upgradable to dvr, make it explicitly non ha # l3ha routers are not upgradable to dvr, make it explicitly non ha
router = self.admin_routers_client.create_router(name=name, router = self.admin_routers_client.create_router(name=name,
distributed=False, distributed=False,
admin_state_up=False, admin_state_up=False,
ha=False, ha=False,
tenant_id=tenant_id) project_id=project_id)
router_id = router['router']['id'] router_id = router['router']['id']
self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_routers_client.delete_router, router_id) self.admin_routers_client.delete_router, router_id)

View File

@ -83,7 +83,7 @@ class FloatingIPTestJSON(base.BaseNetworkTest):
self.floating_ips_client.delete_floatingip, self.floating_ips_client.delete_floatingip,
created_floating_ip['id']) created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id']) self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id']) self.assertIsNotNone(created_floating_ip['project_id'])
self.assertIsNotNone(created_floating_ip['floating_ip_address']) self.assertIsNotNone(created_floating_ip['floating_ip_address'])
self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id']) self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id'])
self.assertEqual(created_floating_ip['floating_network_id'], self.assertEqual(created_floating_ip['floating_network_id'],
@ -97,8 +97,8 @@ class FloatingIPTestJSON(base.BaseNetworkTest):
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id']) self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
self.assertEqual(shown_floating_ip['floating_network_id'], self.assertEqual(shown_floating_ip['floating_network_id'],
self.ext_net_id) self.ext_net_id)
self.assertEqual(shown_floating_ip['tenant_id'], self.assertEqual(shown_floating_ip['project_id'],
created_floating_ip['tenant_id']) created_floating_ip['project_id'])
self.assertEqual(shown_floating_ip['floating_ip_address'], self.assertEqual(shown_floating_ip['floating_ip_address'],
created_floating_ip['floating_ip_address']) created_floating_ip['floating_ip_address'])
self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id']) self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])

View File

@ -192,9 +192,9 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
port_list = self.ports_client.list_ports(fixed_ips=fixed_ips) port_list = self.ports_client.list_ports(fixed_ips=fixed_ips)
# Check that we got the desired port # Check that we got the desired port
ports = port_list['ports'] ports = port_list['ports']
tenant_ids = set([port['tenant_id'] for port in ports]) project_ids = set([port['project_id'] for port in ports])
self.assertEqual(len(tenant_ids), 1, self.assertEqual(len(project_ids), 1,
'Ports from multiple tenants are in the list resp') 'Ports from multiple projects are in the list resp')
port_ids = [port['id'] for port in ports] port_ids = [port['id'] for port in ports]
fixed_ips = [port['fixed_ips'] for port in ports] fixed_ips = [port['fixed_ips'] for port in ports]
port_net_ids = [port['network_id'] for port in ports] port_net_ids = [port['network_id'] for port in ports]

View File

@ -21,6 +21,7 @@ import time
import jsonschema import jsonschema
from oslo_log import log as logging from oslo_log import log as logging
from oslo_log import versionutils
from oslo_serialization import jsonutils as json from oslo_serialization import jsonutils as json
import six import six
from six.moves import urllib from six.moves import urllib
@ -176,6 +177,15 @@ class RestClient(object):
""" """
return self.auth_provider.credentials.tenant_name return self.auth_provider.credentials.tenant_name
@property
def project_id(self):
"""The project id being used for requests
:rtype: string
:return: The project id being used for requests
"""
return self.auth_provider.credentials.tenant_id
@property @property
def tenant_id(self): def tenant_id(self):
"""The tenant/project id being used for requests """The tenant/project id being used for requests
@ -183,7 +193,12 @@ class RestClient(object):
:rtype: string :rtype: string
:return: The tenant/project id being used for requests :return: The tenant/project id being used for requests
""" """
return self.auth_provider.credentials.tenant_id # NOTE(ralonsoh): this property should be deprecated, reference
# blueprint adopt-oslo-versioned-objects-for-db.
versionutils.report_deprecated_feature(
self.LOG, '"tenant_id" property is deprecated for removal, use '
'"project_id" instead')
return self.project_id
@property @property
def password(self): def password(self):

View File

@ -12,11 +12,33 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import functools
from tempest.lib.services.network import base from tempest.lib.services.network import base
def _warning_deprecate_tenant_id(func):
@functools.wraps(func)
def inner(*args, **kwargs):
_self = args[0]
# check length of arg to know whether 'tenant_id' is passed as
# positional arg or kwargs.
if len(args) < 2:
if 'tenant_id' in kwargs:
_self.LOG.warning(
'positional arg name "tenant_id" is deprecated, for '
'removal, please start using "project_id" instead')
elif 'project_id' in kwargs:
# fallback to deprecated name till deprecation phase.
kwargs['tenant_id'] = kwargs.pop('project_id')
return func(*args, **kwargs)
return inner
class QuotasClient(base.BaseNetworkClient): class QuotasClient(base.BaseNetworkClient):
@_warning_deprecate_tenant_id
def update_quotas(self, tenant_id, **kwargs): def update_quotas(self, tenant_id, **kwargs):
"""Update quota for a project. """Update quota for a project.
@ -28,12 +50,14 @@ class QuotasClient(base.BaseNetworkClient):
uri = '/quotas/%s' % tenant_id uri = '/quotas/%s' % tenant_id
return self.update_resource(uri, put_body) return self.update_resource(uri, put_body)
@_warning_deprecate_tenant_id
def reset_quotas(self, tenant_id): # noqa def reset_quotas(self, tenant_id): # noqa
# NOTE: This noqa is for passing T111 check and we cannot rename # NOTE: This noqa is for passing T111 check and we cannot rename
# to keep backwards compatibility. # to keep backwards compatibility.
uri = '/quotas/%s' % tenant_id uri = '/quotas/%s' % tenant_id
return self.delete_resource(uri) return self.delete_resource(uri)
@_warning_deprecate_tenant_id
def show_quotas(self, tenant_id, **fields): def show_quotas(self, tenant_id, **fields):
"""Show quota for a project. """Show quota for a project.
@ -54,11 +78,13 @@ class QuotasClient(base.BaseNetworkClient):
uri = '/quotas' uri = '/quotas'
return self.list_resources(uri, **filters) return self.list_resources(uri, **filters)
@_warning_deprecate_tenant_id
def show_default_quotas(self, tenant_id): def show_default_quotas(self, tenant_id):
"""List default quotas for a project.""" """List default quotas for a project."""
uri = '/quotas/%s/default' % tenant_id uri = '/quotas/%s/default' % tenant_id
return self.show_resource(uri) return self.show_resource(uri)
@_warning_deprecate_tenant_id
def show_quota_details(self, tenant_id): def show_quota_details(self, tenant_id):
"""Show quota details for a project.""" """Show quota details for a project."""
uri = '/quotas/%s/details.json' % tenant_id uri = '/quotas/%s/details.json' % tenant_id

View File

@ -868,15 +868,15 @@ class NetworkScenarioTest(ScenarioTest):
raise cls.skipException('Neutron not available') raise cls.skipException('Neutron not available')
def _create_network(self, networks_client=None, def _create_network(self, networks_client=None,
tenant_id=None, project_id=None,
namestart='network-smoke-', namestart='network-smoke-',
port_security_enabled=True, **net_dict): port_security_enabled=True, **net_dict):
if not networks_client: if not networks_client:
networks_client = self.networks_client networks_client = self.networks_client
if not tenant_id: if not project_id:
tenant_id = networks_client.tenant_id project_id = networks_client.project_id
name = data_utils.rand_name(namestart) name = data_utils.rand_name(namestart)
network_kwargs = dict(name=name, tenant_id=tenant_id) network_kwargs = dict(name=name, project_id=project_id)
if net_dict: if net_dict:
network_kwargs.update(net_dict) network_kwargs.update(net_dict)
# Neutron disables port security by default so we have to check the # Neutron disables port security by default so we have to check the
@ -901,14 +901,14 @@ class NetworkScenarioTest(ScenarioTest):
if not subnets_client: if not subnets_client:
subnets_client = self.subnets_client subnets_client = self.subnets_client
def cidr_in_use(cidr, tenant_id): def cidr_in_use(cidr, project_id):
"""Check cidr existence """Check cidr existence
:returns: True if subnet with cidr already exist in tenant :returns: True if subnet with cidr already exist in tenant
False else False else
""" """
cidr_in_use = self.os_admin.subnets_client.list_subnets( cidr_in_use = self.os_admin.subnets_client.list_subnets(
tenant_id=tenant_id, cidr=cidr)['subnets'] project_id=project_id, cidr=cidr)['subnets']
return len(cidr_in_use) != 0 return len(cidr_in_use) != 0
ip_version = kwargs.pop('ip_version', 4) ip_version = kwargs.pop('ip_version', 4)
@ -927,13 +927,13 @@ class NetworkScenarioTest(ScenarioTest):
# blocks until an unallocated block is found. # blocks until an unallocated block is found.
for subnet_cidr in tenant_cidr.subnet(num_bits): for subnet_cidr in tenant_cidr.subnet(num_bits):
str_cidr = str(subnet_cidr) str_cidr = str(subnet_cidr)
if cidr_in_use(str_cidr, tenant_id=network['tenant_id']): if cidr_in_use(str_cidr, project_id=network['project_id']):
continue continue
subnet = dict( subnet = dict(
name=data_utils.rand_name(namestart), name=data_utils.rand_name(namestart),
network_id=network['id'], network_id=network['id'],
tenant_id=network['tenant_id'], project_id=network['project_id'],
cidr=str_cidr, cidr=str_cidr,
ip_version=ip_version, ip_version=ip_version,
**kwargs **kwargs
@ -1015,7 +1015,7 @@ class NetworkScenarioTest(ScenarioTest):
kwargs = { kwargs = {
'floating_network_id': external_network_id, 'floating_network_id': external_network_id,
'port_id': port_id, 'port_id': port_id,
'tenant_id': thing['tenant_id'], 'tenant_id': thing.get('project_id') or thing['tenant_id'],
'fixed_ip_address': ip4, 'fixed_ip_address': ip4,
} }
if CONF.network.subnet_id: if CONF.network.subnet_id:
@ -1122,18 +1122,18 @@ class NetworkScenarioTest(ScenarioTest):
self.fail(msg) self.fail(msg)
def _create_security_group(self, security_group_rules_client=None, def _create_security_group(self, security_group_rules_client=None,
tenant_id=None, project_id=None,
namestart='secgroup-smoke', namestart='secgroup-smoke',
security_groups_client=None): security_groups_client=None):
if security_group_rules_client is None: if security_group_rules_client is None:
security_group_rules_client = self.security_group_rules_client security_group_rules_client = self.security_group_rules_client
if security_groups_client is None: if security_groups_client is None:
security_groups_client = self.security_groups_client security_groups_client = self.security_groups_client
if tenant_id is None: if project_id is None:
tenant_id = security_groups_client.tenant_id project_id = security_groups_client.project_id
secgroup = self._create_empty_security_group( secgroup = self._create_empty_security_group(
namestart=namestart, client=security_groups_client, namestart=namestart, client=security_groups_client,
tenant_id=tenant_id) project_id=project_id)
# Add rules to the security group # Add rules to the security group
rules = self._create_loginable_secgroup_rule( rules = self._create_loginable_secgroup_rule(
@ -1141,11 +1141,11 @@ class NetworkScenarioTest(ScenarioTest):
secgroup=secgroup, secgroup=secgroup,
security_groups_client=security_groups_client) security_groups_client=security_groups_client)
for rule in rules: for rule in rules:
self.assertEqual(tenant_id, rule['tenant_id']) self.assertEqual(project_id, rule['project_id'])
self.assertEqual(secgroup['id'], rule['security_group_id']) self.assertEqual(secgroup['id'], rule['security_group_id'])
return secgroup return secgroup
def _create_empty_security_group(self, client=None, tenant_id=None, def _create_empty_security_group(self, client=None, project_id=None,
namestart='secgroup-smoke'): namestart='secgroup-smoke'):
"""Create a security group without rules. """Create a security group without rules.
@ -1153,23 +1153,23 @@ class NetworkScenarioTest(ScenarioTest):
- IPv4 egress to any - IPv4 egress to any
- IPv6 egress to any - IPv6 egress to any
:param tenant_id: secgroup will be created in this tenant :param project_id: secgroup will be created in this project
:returns: the created security group :returns: the created security group
""" """
if client is None: if client is None:
client = self.security_groups_client client = self.security_groups_client
if not tenant_id: if not project_id:
tenant_id = client.tenant_id project_id = client.project_id
sg_name = data_utils.rand_name(namestart) sg_name = data_utils.rand_name(namestart)
sg_desc = sg_name + " description" sg_desc = sg_name + " description"
sg_dict = dict(name=sg_name, sg_dict = dict(name=sg_name,
description=sg_desc) description=sg_desc)
sg_dict['tenant_id'] = tenant_id sg_dict['project_id'] = project_id
result = client.create_security_group(**sg_dict) result = client.create_security_group(**sg_dict)
secgroup = result['security_group'] secgroup = result['security_group']
self.assertEqual(secgroup['name'], sg_name) self.assertEqual(secgroup['name'], sg_name)
self.assertEqual(tenant_id, secgroup['tenant_id']) self.assertEqual(project_id, secgroup['project_id'])
self.assertEqual(secgroup['description'], sg_desc) self.assertEqual(secgroup['description'], sg_desc)
self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.addCleanup(test_utils.call_and_ignore_notfound_exc,
@ -1178,15 +1178,15 @@ class NetworkScenarioTest(ScenarioTest):
def _create_security_group_rule(self, secgroup=None, def _create_security_group_rule(self, secgroup=None,
sec_group_rules_client=None, sec_group_rules_client=None,
tenant_id=None, project_id=None,
security_groups_client=None, **kwargs): security_groups_client=None, **kwargs):
"""Create a rule from a dictionary of rule parameters. """Create a rule from a dictionary of rule parameters.
Create a rule in a secgroup. if secgroup not defined will search for Create a rule in a secgroup. if secgroup not defined will search for
default secgroup in tenant_id. default secgroup in project_id.
:param secgroup: the security group. :param secgroup: the security group.
:param tenant_id: if secgroup not passed -- the tenant in which to :param project_id: if secgroup not passed -- the tenant in which to
search for default secgroup search for default secgroup
:param kwargs: a dictionary containing rule parameters: :param kwargs: a dictionary containing rule parameters:
for example, to allow incoming ssh: for example, to allow incoming ssh:
@ -1201,18 +1201,18 @@ class NetworkScenarioTest(ScenarioTest):
sec_group_rules_client = self.security_group_rules_client sec_group_rules_client = self.security_group_rules_client
if security_groups_client is None: if security_groups_client is None:
security_groups_client = self.security_groups_client security_groups_client = self.security_groups_client
if not tenant_id: if not project_id:
tenant_id = security_groups_client.tenant_id project_id = security_groups_client.project_id
if secgroup is None: if secgroup is None:
# Get default secgroup for tenant_id # Get default secgroup for project_id
default_secgroups = security_groups_client.list_security_groups( default_secgroups = security_groups_client.list_security_groups(
name='default', tenant_id=tenant_id)['security_groups'] name='default', project_id=project_id)['security_groups']
msg = "No default security group for tenant %s." % (tenant_id) msg = "No default security group for project %s." % (project_id)
self.assertNotEmpty(default_secgroups, msg) self.assertNotEmpty(default_secgroups, msg)
secgroup = default_secgroups[0] secgroup = default_secgroups[0]
ruleset = dict(security_group_id=secgroup['id'], ruleset = dict(security_group_id=secgroup['id'],
tenant_id=secgroup['tenant_id']) project_id=secgroup['project_id'])
ruleset.update(kwargs) ruleset.update(kwargs)
sg_rule = sec_group_rules_client.create_security_group_rule(**ruleset) sg_rule = sec_group_rules_client.create_security_group_rule(**ruleset)
@ -1278,7 +1278,7 @@ class NetworkScenarioTest(ScenarioTest):
return rules return rules
def _get_router(self, client=None, tenant_id=None): def _get_router(self, client=None, project_id=None):
"""Retrieve a router for the given tenant id. """Retrieve a router for the given tenant id.
If a public router has been configured, it will be returned. If a public router has been configured, it will be returned.
@ -1289,8 +1289,8 @@ class NetworkScenarioTest(ScenarioTest):
""" """
if not client: if not client:
client = self.routers_client client = self.routers_client
if not tenant_id: if not project_id:
tenant_id = client.tenant_id project_id = client.project_id
router_id = CONF.network.public_router_id router_id = CONF.network.public_router_id
network_id = CONF.network.public_network_id network_id = CONF.network.public_network_id
if router_id: if router_id:
@ -1300,7 +1300,7 @@ class NetworkScenarioTest(ScenarioTest):
router = client.create_router( router = client.create_router(
name=data_utils.rand_name(self.__class__.__name__ + '-router'), name=data_utils.rand_name(self.__class__.__name__ + '-router'),
admin_state_up=True, admin_state_up=True,
tenant_id=tenant_id, project_id=project_id,
external_gateway_info=dict(network_id=network_id))['router'] external_gateway_info=dict(network_id=network_id))['router']
self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.addCleanup(test_utils.call_and_ignore_notfound_exc,
client.delete_router, router['id']) client.delete_router, router['id'])
@ -1311,14 +1311,14 @@ class NetworkScenarioTest(ScenarioTest):
def create_networks(self, networks_client=None, def create_networks(self, networks_client=None,
routers_client=None, subnets_client=None, routers_client=None, subnets_client=None,
tenant_id=None, dns_nameservers=None, project_id=None, dns_nameservers=None,
port_security_enabled=True, **net_dict): port_security_enabled=True, **net_dict):
"""Create a network with a subnet connected to a router. """Create a network with a subnet connected to a router.
The baremetal driver is a special case since all nodes are The baremetal driver is a special case since all nodes are
on the same shared network. on the same shared network.
:param tenant_id: id of tenant to create resources in. :param project_id: id of project to create resources in.
:param dns_nameservers: list of dns servers to send to subnet. :param dns_nameservers: list of dns servers to send to subnet.
:param port_security_enabled: whether or not port_security is enabled :param port_security_enabled: whether or not port_security is enabled
:param net_dict: a dict containing experimental network information in :param net_dict: a dict containing experimental network information in
@ -1343,11 +1343,11 @@ class NetworkScenarioTest(ScenarioTest):
else: else:
network = self._create_network( network = self._create_network(
networks_client=networks_client, networks_client=networks_client,
tenant_id=tenant_id, project_id=project_id,
port_security_enabled=port_security_enabled, port_security_enabled=port_security_enabled,
**net_dict) **net_dict)
router = self._get_router(client=routers_client, router = self._get_router(client=routers_client,
tenant_id=tenant_id) project_id=project_id)
subnet_kwargs = dict(network=network, subnet_kwargs = dict(network=network,
subnets_client=subnets_client) subnets_client=subnets_client)
# use explicit check because empty list is a valid option # use explicit check because empty list is a valid option

View File

@ -321,7 +321,7 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
internal_ips = ( internal_ips = (
p['fixed_ips'][0]['ip_address'] for p in p['fixed_ips'][0]['ip_address'] for p in
self.os_admin.ports_client.list_ports( self.os_admin.ports_client.list_ports(
tenant_id=server['tenant_id'], project_id=server['tenant_id'],
network_id=network['id'])['ports'] network_id=network['id'])['ports']
if p['device_owner'].startswith('network') or if p['device_owner'].startswith('network') or
p['device_owner'].startswith('compute') p['device_owner'].startswith('compute')

View File

@ -176,7 +176,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
cls.primary_tenant = cls.TenantProperties(cls.os_primary) cls.primary_tenant = cls.TenantProperties(cls.os_primary)
cls.alt_tenant = cls.TenantProperties(cls.os_alt) cls.alt_tenant = cls.TenantProperties(cls.os_alt)
for tenant in [cls.primary_tenant, cls.alt_tenant]: for tenant in [cls.primary_tenant, cls.alt_tenant]:
cls.tenants[tenant.creds.tenant_id] = tenant cls.tenants[tenant.creds.project_id] = tenant
cls.floating_ip_access = not CONF.network.public_router_id cls.floating_ip_access = not CONF.network.public_router_id
@ -199,14 +199,14 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
def _create_tenant_security_groups(self, tenant): def _create_tenant_security_groups(self, tenant):
access_sg = self._create_empty_security_group( access_sg = self._create_empty_security_group(
namestart='secgroup_access-', namestart='secgroup_access-',
tenant_id=tenant.creds.tenant_id, project_id=tenant.creds.project_id,
client=tenant.manager.security_groups_client client=tenant.manager.security_groups_client
) )
# don't use default secgroup since it allows in-project traffic # don't use default secgroup since it allows in-project traffic
def_sg = self._create_empty_security_group( def_sg = self._create_empty_security_group(
namestart='secgroup_general-', namestart='secgroup_general-',
tenant_id=tenant.creds.tenant_id, project_id=tenant.creds.project_id,
client=tenant.manager.security_groups_client client=tenant.manager.security_groups_client
) )
tenant.security_groups.update(access=access_sg, default=def_sg) tenant.security_groups.update(access=access_sg, default=def_sg)
@ -536,7 +536,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
# Create empty security group and add icmp rule in it # Create empty security group and add icmp rule in it
new_sg = self._create_empty_security_group( new_sg = self._create_empty_security_group(
namestart='secgroup_new-', namestart='secgroup_new-',
tenant_id=new_tenant.creds.tenant_id, project_id=new_tenant.creds.project_id,
client=new_tenant.manager.security_groups_client) client=new_tenant.manager.security_groups_client)
icmp_rule = dict( icmp_rule = dict(
protocol='icmp', protocol='icmp',

View File

@ -52,7 +52,7 @@ class TestQuotasClient(base.BaseServiceTest):
} }
} }
FAKE_QUOTA_TENANT_ID = "bab7d5c60cd041a0a36f7c4b6e1dd978" FAKE_QUOTA_PROJECT_ID = "bab7d5c60cd041a0a36f7c4b6e1dd978"
FAKE_QUOTA_DETAILS = { FAKE_QUOTA_DETAILS = {
"quota": { "quota": {
@ -115,7 +115,7 @@ class TestQuotasClient(base.BaseServiceTest):
self.FAKE_PROJECT_QUOTAS, self.FAKE_PROJECT_QUOTAS,
bytes_body, bytes_body,
200, 200,
tenant_id=self.FAKE_QUOTA_TENANT_ID) project_id=self.FAKE_QUOTA_PROJECT_ID)
def _test_show_default_quotas(self, bytes_body=False): def _test_show_default_quotas(self, bytes_body=False):
self.check_service_client_function( self.check_service_client_function(
@ -124,7 +124,7 @@ class TestQuotasClient(base.BaseServiceTest):
self.FAKE_PROJECT_QUOTAS, self.FAKE_PROJECT_QUOTAS,
bytes_body, bytes_body,
200, 200,
tenant_id=self.FAKE_QUOTA_TENANT_ID) project_id=self.FAKE_QUOTA_PROJECT_ID)
def _test_update_quotas(self, bytes_body=False): def _test_update_quotas(self, bytes_body=False):
self.check_service_client_function( self.check_service_client_function(
@ -133,7 +133,7 @@ class TestQuotasClient(base.BaseServiceTest):
self.FAKE_PROJECT_QUOTAS, self.FAKE_PROJECT_QUOTAS,
bytes_body, bytes_body,
200, 200,
tenant_id=self.FAKE_QUOTA_TENANT_ID) project_id=self.FAKE_QUOTA_PROJECT_ID)
def _test_show_quota_details(self, bytes_body=False): def _test_show_quota_details(self, bytes_body=False):
self.check_service_client_function( self.check_service_client_function(
@ -142,7 +142,7 @@ class TestQuotasClient(base.BaseServiceTest):
self.FAKE_QUOTA_DETAILS, self.FAKE_QUOTA_DETAILS,
bytes_body, bytes_body,
200, 200,
tenant_id=self.FAKE_QUOTA_TENANT_ID) project_id=self.FAKE_QUOTA_PROJECT_ID)
def test_reset_quotas(self): def test_reset_quotas(self):
self.check_service_client_function( self.check_service_client_function(
@ -150,7 +150,7 @@ class TestQuotasClient(base.BaseServiceTest):
"tempest.lib.common.rest_client.RestClient.delete", "tempest.lib.common.rest_client.RestClient.delete",
{}, {},
status=204, status=204,
tenant_id=self.FAKE_QUOTA_TENANT_ID) project_id=self.FAKE_QUOTA_PROJECT_ID)
def test_list_quotas_with_str_body(self): def test_list_quotas_with_str_body(self):
self._test_list_quotas() self._test_list_quotas()