Merge "Fix compatibility with oslo.context >= 4.0.0"

This commit is contained in:
Zuul 2022-03-18 16:38:22 +00:00 committed by Gerrit Code Review
commit 0263bf2dc5
3 changed files with 15 additions and 11 deletions

View File

@ -10,8 +10,10 @@
jobs:
- openstack-tox-pylint:
voting: false
- sahara-tests-scenario
- sahara-tests-scenario-v2
- sahara-tests-scenario:
voting: false
- sahara-tests-scenario-v2:
voting: false
- sahara-tests-tempest
- sahara-tests-tempest-v2
- openstack-tox-cover:
@ -23,8 +25,10 @@
gate:
queue: sahara
jobs:
- sahara-tests-scenario
- sahara-tests-scenario-v2
- sahara-tests-scenario:
voting: false
- sahara-tests-scenario-v2:
voting: false
- sahara-tests-tempest
- sahara-tests-tempest-v2
# - sahara-grenade

View File

@ -56,7 +56,7 @@ class Context(context.RequestContext):
super(Context, self).__init__(auth_token=auth_token,
user=user_id,
tenant=tenant_id,
project_id=tenant_id,
is_admin=is_admin,
resource_uuid=resource_uuid,
request_id=request_id,
@ -105,8 +105,8 @@ class Context(context.RequestContext):
return d
def is_auth_capable(self):
return (self.service_catalog and self.auth_token and self.tenant and
self.user_id)
return (self.service_catalog and self.auth_token and self.project_id
and self.user_id)
# NOTE(adrienverge): The Context class uses the 'user' and 'tenant'
# properties internally (inherited from oslo_context), but Sahara code
@ -121,11 +121,11 @@ class Context(context.RequestContext):
@property
def tenant_id(self):
return self.tenant
return self.project_id
@tenant_id.setter
def tenant_id(self, value):
self.tenant = value
self.project_id = value
def get_admin_context():

View File

@ -110,13 +110,13 @@ class TestPluginDataCRUD(base.SaharaWithDbTestCase):
self.assertIsNotNone(raised)
# not duplicated entry, other tenant
ctx.tenant = "tenant_2"
ctx.project_id = "tenant_2"
res = conductor.plugin_create(ctx, {'name': 'fake'})
conductor.plugin_create(ctx, {'name': 'guy'})
self.assertIsNotNone(res)
self.assertEqual(2, len(conductor.plugin_get_all(ctx)))
ctx.tenant = "tenant_1"
ctx.project_id = "tenant_1"
data = conductor.plugin_get(ctx, 'fake')
self.assertEqual('fake', data['name'])