From 95eac8c932f934f3ab849a43f551c824e3af6771 Mon Sep 17 00:00:00 2001 From: Andy Ning Date: Wed, 17 Jul 2019 16:27:22 -0400 Subject: [PATCH] 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 --- dcorch/api/proxy/apps/controller.py | 5 ++++- dcorch/api/proxy/common/utils.py | 18 ++++++++++++++++++ dcorch/cmd/api_proxy.py | 7 +++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/dcorch/api/proxy/apps/controller.py b/dcorch/api/proxy/apps/controller.py index b5770049d..aa0f1f2ca 100644 --- a/dcorch/api/proxy/apps/controller.py +++ b/dcorch/api/proxy/apps/controller.py @@ -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, diff --git a/dcorch/api/proxy/common/utils.py b/dcorch/api/proxy/common/utils.py index 33c267728..dbd969213 100644 --- a/dcorch/api/proxy/common/utils.py +++ b/dcorch/api/proxy/common/utils.py @@ -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('/') diff --git a/dcorch/cmd/api_proxy.py b/dcorch/cmd/api_proxy.py index 74229a0dd..e9f22f125 100644 --- a/dcorch/cmd/api_proxy.py +++ b/dcorch/cmd/api_proxy.py @@ -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