diff --git a/neutron/policy.py b/neutron/policy.py index 34091f8be39..1d9362f6d59 100644 --- a/neutron/policy.py +++ b/neutron/policy.py @@ -420,7 +420,7 @@ class FieldCheck(policy.Check): {'field': self.field, 'target_dict': target_dict}) return project_id = target_dict.get('project_id') - ctx = (context.Context(tenant_id=project_id) if project_id + ctx = (context.Context(project_id=project_id) if project_id else context.get_admin_context()) plugin = directory.get_plugin() network = plugin.get_network(ctx, target_network_id) diff --git a/neutron/tests/common/test_db_base_plugin_v2.py b/neutron/tests/common/test_db_base_plugin_v2.py index e68e76930fa..255ef8dfff0 100644 --- a/neutron/tests/common/test_db_base_plugin_v2.py +++ b/neutron/tests/common/test_db_base_plugin_v2.py @@ -1338,7 +1338,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase): def test_get_ports_count(self): with self.port(), self.port(), self.port(), self.port() as p: tenid = p['port']['tenant_id'] - ctx = context.Context(user_id=None, tenant_id=tenid, + ctx = context.Context(user_id=None, project_id=tenid, is_admin=False) pl = directory.get_plugin() count = pl.get_ports_count(ctx, filters={'tenant_id': [tenid]}) @@ -3369,7 +3369,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): def test_create_subnet_with_network_different_tenant(self): with self.network(shared=False, tenant_id='tenant1') as network: ctx = context.Context(user_id='non_admin', - tenant_id='tenant2', + project_id='tenant2', is_admin=False) data = {'subnet': {'network_id': network['network']['id'], 'cidr': '10.0.2.0/24', @@ -5364,7 +5364,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): gateway_ip='10.0.2.1', cidr='10.0.2.0/24'): project_id = network['network']['project_id'] - ctx = context.Context(user_id=None, tenant_id=project_id, + ctx = context.Context(user_id=None, project_id=project_id, is_admin=False) pl = directory.get_plugin() count = pl.get_subnets_count( @@ -5385,7 +5385,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self.subnet(network=network, gateway_ip='10.0.2.1', cidr='10.0.2.0/24'): - ctx = context.Context(user_id=None, tenant_id=project_id, + ctx = context.Context(user_id=None, project_id=project_id, is_admin=True) pl = directory.get_plugin() count = pl.get_subnets_count( @@ -5409,7 +5409,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): gateway_ip='10.0.2.1', cidr='10.0.2.0/24'): project_id = network['network']['project_id'] - ctx = context.Context(user_id=None, tenant_id=project_id, + ctx = context.Context(user_id=None, project_id=project_id, is_admin=False) pl = directory.get_plugin() count = pl.get_subnets_count(ctx, diff --git a/neutron/tests/functional/common/test_utils.py b/neutron/tests/functional/common/test_utils.py index 1a43cb38f85..c367271e1ee 100644 --- a/neutron/tests/functional/common/test_utils.py +++ b/neutron/tests/functional/common/test_utils.py @@ -39,7 +39,7 @@ class TestIsSessionActive(testlib_api.SqlTestCase, super().setUp() def test_is_session_active(self): - context = n_context.Context(user_id=None, tenant_id=None, + context = n_context.Context(user_id=None, project_id=None, is_admin=True, overwrite=False) self.assertFalse(db_api.is_session_active(context.session)) with db_api.CONTEXT_WRITER.using(context): diff --git a/neutron/tests/functional/db/test_ipam.py b/neutron/tests/functional/db/test_ipam.py index cdc08bf8c45..1de16f5663a 100644 --- a/neutron/tests/functional/db/test_ipam.py +++ b/neutron/tests/functional/db/test_ipam.py @@ -44,7 +44,7 @@ class IpamTestCase(testlib_api.SqlTestCase, testlib_api.MySQLTestCaseMixin): self.setup_coreplugin(DB_PLUGIN_KLASS) self.plugin = base_plugin.NeutronDbPluginV2() self.cxt = context.Context(user_id=None, - tenant_id=None, + project_id=None, is_admin=True, overwrite=False) self.tenant_id = uuidutils.generate_uuid() diff --git a/neutron/tests/functional/db/test_network.py b/neutron/tests/functional/db/test_network.py index 2c0814038a0..4840d5840b7 100644 --- a/neutron/tests/functional/db/test_network.py +++ b/neutron/tests/functional/db/test_network.py @@ -41,7 +41,7 @@ class NetworkRBACTestCase(testlib_api.SqlTestCase): l3_dvrscheduler_db, '_notify_l3_agent_new_port').start() self.plugin_l3 = l3_router_plugin.L3RouterPlugin() self.ctx = context.Context(user_id=None, - tenant_id=None, + project_id=None, is_admin=True, overwrite=False) self.project_1 = uuidutils.generate_uuid() @@ -140,11 +140,11 @@ class NetworkRBACTestCase(testlib_api.SqlTestCase): action=constants.ACCESS_SHARED) ctx_1 = context.Context(user_id=None, - tenant_id=self.project_1, + project_id=self.project_1, is_admin=False, overwrite=False) ctx_2 = context.Context(user_id=None, - tenant_id=self.project_2, + project_id=self.project_2, is_admin=False, overwrite=False) diff --git a/neutron/tests/functional/objects/plugins/ml2/test_base.py b/neutron/tests/functional/objects/plugins/ml2/test_base.py index 1a8e11cb95e..0fdfe5a50ca 100644 --- a/neutron/tests/functional/objects/plugins/ml2/test_base.py +++ b/neutron/tests/functional/objects/plugins/ml2/test_base.py @@ -32,7 +32,7 @@ class SegmentAllocation(testlib_api.SqlTestCase, self.skipTest('No allocation class defined') super().setUp() self.context = context.Context(user_id='usier_id', - tenant_id='tenant_id') + project_id='tenant_id') self.segid_field = ( self.segment_allocation_class.get_segmentation_id().name) self.is_vlan = ('physical_network' in diff --git a/neutron/tests/functional/objects/test_quota.py b/neutron/tests/functional/objects/test_quota.py index a9d0b417a01..e116a034d0b 100644 --- a/neutron/tests/functional/objects/test_quota.py +++ b/neutron/tests/functional/objects/test_quota.py @@ -28,7 +28,7 @@ class TestReservationSql(testlib_api.SqlTestCase, testlib_api.MySQLTestCaseMixin): def setUp(self): super().setUp() - self.context = context.Context(user_id=None, tenant_id=None, + self.context = context.Context(user_id=None, project_id=None, is_admin=True, overwrite=False) def _create_test_reservation(self, exp): diff --git a/neutron/tests/unit/db/quota/test_driver.py b/neutron/tests/unit/db/quota/test_driver.py index 4edd8e46897..d3f0f7c3cc7 100644 --- a/neutron/tests/unit/db/quota/test_driver.py +++ b/neutron/tests/unit/db/quota/test_driver.py @@ -126,20 +126,20 @@ class TestDbQuotaDriver(testlib_api.SqlTestCase, def test_get_default_quotas(self): defaults = {RESOURCE: TestResource(RESOURCE, 4)} - user_ctx = context.Context(user_id=PROJECT, tenant_id=PROJECT) + user_ctx = context.Context(user_id=PROJECT, project_id=PROJECT) self.plugin.update_quota_limit(self.context, PROJECT, RESOURCE, 2) quotas = self.plugin.get_default_quotas(user_ctx, defaults, PROJECT) self.assertEqual(4, quotas[RESOURCE]) def test_get_project_quotas(self): - user_ctx = context.Context(user_id=PROJECT, tenant_id=PROJECT) + user_ctx = context.Context(user_id=PROJECT, project_id=PROJECT) self.plugin.update_quota_limit(self.context, PROJECT, RESOURCE, 2) quotas = self.plugin.get_project_quotas(user_ctx, {}, PROJECT) self.assertEqual(2, quotas[RESOURCE]) def test_get_project_quotas_different_project(self): user_ctx = context.Context(user_id=PROJECT, - tenant_id='another_project') + project_id='another_project') self.plugin.update_quota_limit(self.context, PROJECT, RESOURCE, 2) # It is appropriate to use assertFalse here as the expected return # value is an empty dict (the defaults passed in the statement below diff --git a/neutron/tests/unit/db/quota/test_driver_nolock.py b/neutron/tests/unit/db/quota/test_driver_nolock.py index 50ffc5b1802..1098900c177 100644 --- a/neutron/tests/unit/db/quota/test_driver_nolock.py +++ b/neutron/tests/unit/db/quota/test_driver_nolock.py @@ -78,7 +78,7 @@ class TestDbQuotaDriverNoLock(test_driver.TestDbQuotaDriver): def test_get_detailed_project_quotas_resource(self): user_ctx = context.Context(user_id=self.project_1, - tenant_id=self.project_1) + project_id=self.project_1) tracked_resource = quota_resource.TrackedResource( 'network', models_v2.Network, 'quota_network') res = {'network': tracked_resource} @@ -108,7 +108,7 @@ class TestDbQuotaDriverNoLock(test_driver.TestDbQuotaDriver): resources = self._create_tracked_resources() for project_id in self.projects: user_ctx = context.Context(user_id=project_id, - tenant_id=project_id) + project_id=project_id) self.plugin.update_quota_limit( user_ctx, project_id, 'network', 101) self.plugin.update_quota_limit(user_ctx, project_id, 'subnet', 102) @@ -134,7 +134,7 @@ class TestDbQuotaDriverNoLock(test_driver.TestDbQuotaDriver): 'port': {'limit': 103, 'used': 1, 'reserved': 0}} for project_id in self.projects: user_ctx = context.Context(user_id=project_id, - tenant_id=project_id) + project_id=project_id) returned = self.plugin.get_detailed_project_quotas( user_ctx, resources, project_id) self.assertEqual(reference, returned) diff --git a/neutron/tests/unit/db/test_securitygroups_db.py b/neutron/tests/unit/db/test_securitygroups_db.py index ca595f8dd36..104b034bb24 100644 --- a/neutron/tests/unit/db/test_securitygroups_db.py +++ b/neutron/tests/unit/db/test_securitygroups_db.py @@ -564,10 +564,10 @@ class SecurityGroupDbMixinTestCase(testlib_api.SqlTestCase): def _create_environment(self): self.sg = copy.deepcopy(FAKE_SECGROUP) - self.user_ctx = context.Context(user_id='user1', tenant_id='tenant_1', - is_admin=False, overwrite=False) - self.admin_ctx = context.Context(user_id='user2', tenant_id='tenant_2', - is_admin=True, overwrite=False) + self.user_ctx = context.Context(user_id='user1', + project_id='tenant_1', is_admin=False, overwrite=False) + self.admin_ctx = context.Context(user_id='user2', + project_id='tenant_2', is_admin=True, overwrite=False) self.sg_user = self.mixin.create_security_group( self.user_ctx, {'security_group': {'name': 'name', 'tenant_id': 'tenant_1', diff --git a/neutron/tests/unit/objects/test_rbac.py b/neutron/tests/unit/objects/test_rbac.py index 125572ef8a5..8d59bfeca43 100644 --- a/neutron/tests/unit/objects/test_rbac.py +++ b/neutron/tests/unit/objects/test_rbac.py @@ -64,7 +64,7 @@ class TestRBACObjectMixin: for idx in range(3): project = 'project_%s' % idx - ctx_no_admin = context.Context(user_id='user', tenant_id=project, + ctx_no_admin = context.Context(user_id='user', project_id=project, is_admin=False) objects = self._parent_class.get_objects(ctx_no_admin) self.assertEqual([_obj_shared.id], [_obj.id for _obj in objects]) diff --git a/requirements.txt b/requirements.txt index b73e31ede11..4a54a021e3e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ requests>=2.32.3 # Apache-2.0 Jinja2>=2.10 # BSD License (3 clause) keystonemiddleware>=5.1.0 # Apache-2.0 netaddr>=0.7.18 # BSD -neutron-lib>=3.16.0 # Apache-2.0 +neutron-lib>=3.17.0 # Apache-2.0 python-neutronclient>=7.8.0 # Apache-2.0 tenacity>=6.0.0 # Apache-2.0 SQLAlchemy>=1.4.23 # MIT