keystone-api-proxy for containerized openstack services - service

This update enhanced keystone-api-proxy to take a sync_endpoint
parameter from its configuration file and enqueue job for dcorch with
that sync_endpoint type. If sync_endpoint doesn't present in its
configuration file, it will use the default endpoint type to enqueue
job.

Change-Id: I85698638cee2598955c4deb41a6b8033b0ace9fd
Story: 2004766
Task: 36156
Depends-On: https://review.opendev.org/#/c/682062/
Signed-off-by: Andy Ning <andy.ning@windriver.com>
This commit is contained in:
Andy Ning 2019-07-17 16:27:22 -04:00
parent 36702d225c
commit 95eac8c932
3 changed files with 27 additions and 3 deletions

View File

@ -55,6 +55,7 @@ class APIController(Middleware):
self._default_dispatcher = APIDispatcher(app)
self.rpc_client = rpc_client.EngineClient()
self.response_hander_map = {}
self.sync_endpoint = proxy_utils.get_sync_endpoint(CONF)
@staticmethod
def get_status_code(response):
@ -443,6 +444,8 @@ class IdentityAPIController(APIController):
self.response_hander_map = {
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):
if self.get_status_code(response) in self.OK_STATUS_CODE:
@ -534,7 +537,7 @@ class IdentityAPIController(APIController):
if resource_id:
try:
utils.enqueue_work(self.ctxt,
self.ENDPOINT_TYPE,
self.sync_endpoint,
resource_type,
resource_id,
operation_type,

View File

@ -64,6 +64,24 @@ def get_remote_host_port_options(cfg):
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):
result = urlparse(url)
return result.path.split('/')

View File

@ -44,6 +44,9 @@ proxy_opts = [
cfg.IntOpt('bind_port',
default=28774,
help='listen port for api proxy'),
cfg.StrOpt('sync_endpoint',
default=None,
help='The endpoint type for the enqueued sync work'),
]
proxy_cli_opts = [
@ -68,14 +71,14 @@ def main():
messaging.setup()
dcmanager_messaging.setup()
application = app.load_paste_app()
if CONF.type not in consts.ENDPOINT_TYPES_LIST:
LOG.error("Unsupported endpoint type: (%s)", CONF.type)
sys.exit(1)
CONF.register_opts(proxy_opts, CONF.type)
application = app.load_paste_app()
host, port = utils.get_host_port_options(CONF)
workers = CONF.api_workers