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 4df471f96..c5745452c 100644 --- a/dcorch/cmd/api_proxy.py +++ b/dcorch/cmd/api_proxy.py @@ -46,6 +46,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 = [ @@ -69,14 +72,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