diff --git a/bilean/common/context.py b/bilean/common/context.py index dae1a02..def3d50 100644 --- a/bilean/common/context.py +++ b/bilean/common/context.py @@ -109,7 +109,7 @@ class RequestContext(base_context.RequestContext): return cls(**values) -def get_service_context(**kwargs): +def get_service_context(set_project_id=False, **kwargs): '''An abstraction layer for getting service credential. There could be multiple cloud backends for bilean to use. This @@ -120,6 +120,9 @@ def get_service_context(**kwargs): ''' identity_service = driver_base.BileanDriver().identity service_creds = identity_service.get_service_credentials(**kwargs) + if set_project_id: + project = identity_service().conn.session.get_project_id() + service_creds.update(project=project) return RequestContext(**service_creds) diff --git a/bilean/drivers/base.py b/bilean/drivers/base.py index 4e0f35d..33112b7 100644 --- a/bilean/drivers/base.py +++ b/bilean/drivers/base.py @@ -17,6 +17,7 @@ from oslo_config import cfg from bilean.engine import environment CONF = cfg.CONF +CONF.import_opt('cloud_backend', 'bilean.common.config') class DriverBase(object): diff --git a/bilean/notification/endpoint.py b/bilean/notification/endpoint.py index b484b0c..ab2ab59 100644 --- a/bilean/notification/endpoint.py +++ b/bilean/notification/endpoint.py @@ -29,7 +29,7 @@ KEYSTONE_EVENTS = ['identity.project.created', class EventsNotificationEndpoint(object): def __init__(self): self.resource_converter = converter.setup_resources() - self.cnxt = context.get_admin_context() + self.cnxt = context.get_service_context(set_project_id=True) super(EventsNotificationEndpoint, self).__init__() def info(self, ctxt, publisher_id, event_type, payload, metadata):