Enable to set project_id when get service context
Change-Id: Id8a882e81cc8aba603dd8b9bc061566760f53a92
This commit is contained in:
parent
1e540840c3
commit
c31a3afcc4
@ -109,7 +109,7 @@ class RequestContext(base_context.RequestContext):
|
|||||||
return cls(**values)
|
return cls(**values)
|
||||||
|
|
||||||
|
|
||||||
def get_service_context(**kwargs):
|
def get_service_context(set_project_id=False, **kwargs):
|
||||||
'''An abstraction layer for getting service credential.
|
'''An abstraction layer for getting service credential.
|
||||||
|
|
||||||
There could be multiple cloud backends for bilean to use. This
|
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
|
identity_service = driver_base.BileanDriver().identity
|
||||||
service_creds = identity_service.get_service_credentials(**kwargs)
|
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)
|
return RequestContext(**service_creds)
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ from oslo_config import cfg
|
|||||||
from bilean.engine import environment
|
from bilean.engine import environment
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
CONF.import_opt('cloud_backend', 'bilean.common.config')
|
||||||
|
|
||||||
|
|
||||||
class DriverBase(object):
|
class DriverBase(object):
|
||||||
|
@ -29,7 +29,7 @@ KEYSTONE_EVENTS = ['identity.project.created',
|
|||||||
class EventsNotificationEndpoint(object):
|
class EventsNotificationEndpoint(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.resource_converter = converter.setup_resources()
|
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__()
|
super(EventsNotificationEndpoint, self).__init__()
|
||||||
|
|
||||||
def info(self, ctxt, publisher_id, event_type, payload, metadata):
|
def info(self, ctxt, publisher_id, event_type, payload, metadata):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user