Skip to content

Commit 75eefdb

Browse files
committed
Return both project_id when validating auto allocate network
When neutron API is called to check requirements for the auto_allocate topology, it needs to return not only 'tenant_id' field but also 'project_id' as that is required for the policy enforcement. Without this 'project_id' field requirements check was failing for member and reader users as they got 404 from the Neutron API. And the reason why Neutron was returning 404 was that it wasn't passing policy enforcement due to missing project_id field in the 'target' object. Closes-bug: #2066369 Change-Id: Idf96a82bc6c8cb0b47dfde3baba94b42a8a8beba (cherry picked from commit dfc01be)
1 parent 0fe6b7c commit 75eefdb

File tree

2 files changed

+7
-2
lines changed
  • neutron

2 files changed

+7
-2
lines changed

neutron/services/auto_allocate/db.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ def _check_requirements(self, context, tenant_id):
194194
except n_exc.NotFound:
195195
raise exceptions.AutoAllocationFailure(
196196
reason=_("No default subnetpools defined"))
197-
return {'id': 'dry-run=pass', 'tenant_id': tenant_id}
197+
return {'id': 'dry-run=pass',
198+
'tenant_id': tenant_id,
199+
'project_id': tenant_id}
198200

199201
def _validate(self, context, tenant_id):
200202
"""Validate and return the tenant to be associated to the topology."""

neutron/tests/unit/services/auto_allocate/test_db.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ def test__check_requirements_happy_path_for_kevin(self):
351351
mock.patch.object(
352352
self.mixin, '_get_supported_subnetpools'):
353353
result = self.mixin._check_requirements(self.ctx, 'foo_tenant')
354-
expected = {'id': 'dry-run=pass', 'tenant_id': 'foo_tenant'}
354+
expected = {
355+
'id': 'dry-run=pass',
356+
'tenant_id': 'foo_tenant',
357+
'project_id': 'foo_tenant'}
355358
self.assertEqual(expected, result)
356359

357360
def test__cleanup_handles_failures(self):

0 commit comments

Comments
 (0)