Merge "keystone-api-proxy for containerized openstack services - service"
This commit is contained in:
commit
b020fc86c8
@ -55,6 +55,7 @@ class APIController(Middleware):
|
|||||||
self._default_dispatcher = APIDispatcher(app)
|
self._default_dispatcher = APIDispatcher(app)
|
||||||
self.rpc_client = rpc_client.EngineClient()
|
self.rpc_client = rpc_client.EngineClient()
|
||||||
self.response_hander_map = {}
|
self.response_hander_map = {}
|
||||||
|
self.sync_endpoint = proxy_utils.get_sync_endpoint(CONF)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_status_code(response):
|
def get_status_code(response):
|
||||||
@ -443,6 +444,8 @@ class IdentityAPIController(APIController):
|
|||||||
self.response_hander_map = {
|
self.response_hander_map = {
|
||||||
self.ENDPOINT_TYPE: self._process_response
|
self.ENDPOINT_TYPE: self._process_response
|
||||||
}
|
}
|
||||||
|
if self.sync_endpoint is None:
|
||||||
|
self.sync_endpoint = self.ENDPOINT_TYPE
|
||||||
|
|
||||||
def _process_response(self, environ, request_body, response):
|
def _process_response(self, environ, request_body, response):
|
||||||
if self.get_status_code(response) in self.OK_STATUS_CODE:
|
if self.get_status_code(response) in self.OK_STATUS_CODE:
|
||||||
@ -534,7 +537,7 @@ class IdentityAPIController(APIController):
|
|||||||
if resource_id:
|
if resource_id:
|
||||||
try:
|
try:
|
||||||
utils.enqueue_work(self.ctxt,
|
utils.enqueue_work(self.ctxt,
|
||||||
self.ENDPOINT_TYPE,
|
self.sync_endpoint,
|
||||||
resource_type,
|
resource_type,
|
||||||
resource_id,
|
resource_id,
|
||||||
operation_type,
|
operation_type,
|
||||||
|
@ -64,6 +64,24 @@ def get_remote_host_port_options(cfg):
|
|||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
|
def get_sync_endpoint(cfg):
|
||||||
|
if cfg.type == consts.ENDPOINT_TYPE_COMPUTE:
|
||||||
|
return cfg.compute.sync_endpoint
|
||||||
|
elif cfg.type == consts.ENDPOINT_TYPE_PLATFORM:
|
||||||
|
return cfg.platform.sync_endpoint
|
||||||
|
elif cfg.type == consts.ENDPOINT_TYPE_NETWORK:
|
||||||
|
return cfg.network.sync_endpoint
|
||||||
|
elif cfg.type == consts.ENDPOINT_TYPE_PATCHING:
|
||||||
|
return cfg.patching.sync_endpoint
|
||||||
|
elif cfg.type == consts.ENDPOINT_TYPE_VOLUME:
|
||||||
|
return cfg.volume.sync_endpoint
|
||||||
|
elif cfg.type == consts.ENDPOINT_TYPE_IDENTITY:
|
||||||
|
return cfg.identity.sync_endpoint
|
||||||
|
else:
|
||||||
|
LOG.error("Type: %s is undefined! Ignoring", cfg.type)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_url_path_components(url):
|
def get_url_path_components(url):
|
||||||
result = urlparse(url)
|
result = urlparse(url)
|
||||||
return result.path.split('/')
|
return result.path.split('/')
|
||||||
|
@ -46,6 +46,9 @@ proxy_opts = [
|
|||||||
cfg.IntOpt('bind_port',
|
cfg.IntOpt('bind_port',
|
||||||
default=28774,
|
default=28774,
|
||||||
help='listen port for api proxy'),
|
help='listen port for api proxy'),
|
||||||
|
cfg.StrOpt('sync_endpoint',
|
||||||
|
default=None,
|
||||||
|
help='The endpoint type for the enqueued sync work'),
|
||||||
]
|
]
|
||||||
|
|
||||||
proxy_cli_opts = [
|
proxy_cli_opts = [
|
||||||
@ -69,14 +72,14 @@ def main():
|
|||||||
messaging.setup()
|
messaging.setup()
|
||||||
dcmanager_messaging.setup()
|
dcmanager_messaging.setup()
|
||||||
|
|
||||||
application = app.load_paste_app()
|
|
||||||
|
|
||||||
if CONF.type not in consts.ENDPOINT_TYPES_LIST:
|
if CONF.type not in consts.ENDPOINT_TYPES_LIST:
|
||||||
LOG.error("Unsupported endpoint type: (%s)", CONF.type)
|
LOG.error("Unsupported endpoint type: (%s)", CONF.type)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
CONF.register_opts(proxy_opts, CONF.type)
|
CONF.register_opts(proxy_opts, CONF.type)
|
||||||
|
|
||||||
|
application = app.load_paste_app()
|
||||||
|
|
||||||
host, port = utils.get_host_port_options(CONF)
|
host, port = utils.get_host_port_options(CONF)
|
||||||
workers = CONF.api_workers
|
workers = CONF.api_workers
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user