diff --git a/cmd.py b/cmd.py index d3935ac8..2a225da8 100644 --- a/cmd.py +++ b/cmd.py @@ -526,7 +526,7 @@ def init(self, cmd, args): return self def _do_command(self, obdiag): - return obdiag.gather_function('gather_obproxy_log', self.opts) + return obdiag.gather_obproxy_log(self.opts) class ObdiagGatherSceneListCommand(ObdiagOriginCommand): diff --git a/core.py b/core.py index fec2e00c..d1c87404 100644 --- a/core.py +++ b/core.py @@ -117,6 +117,19 @@ def set_context(self, handler_name, namespace, config): ) telemetry.set_cluster_conn(config.get_ob_cluster_config) + def set_context_skip_cluster_conn(self, handler_name, namespace, config): + self.context = HandlerContext( + handler_name=handler_name, + namespace=namespace, + cluster_config=config.get_ob_cluster_config, + obproxy_config=config.get_obproxy_config, + ocp_config=config.get_ocp_config, + cmd=self.cmds, + options=self.options, + stdio=self.stdio, + inner_config=self.inner_config_manager.config + ) + def set_offline_context(self, handler_name, namespace): self.context = HandlerContext( handler_name=handler_name, @@ -211,9 +224,6 @@ def gather_function(self, function_type, opt): self.context.set_variable('gather_obadmin_mode', 'slog') handler = GatherObAdminHandler(self.context) return handler.handle() - elif function_type == 'gather_obproxy_log': - handler = GatherObProxyLogHandler(self.context) - return handler.handle() elif function_type == 'gather_obstack': handler = GatherObstack2Handler(self.context) return handler.handle() @@ -248,6 +258,16 @@ def gather_function(self, function_type, opt): self._call_stdio('error', 'Not support gather function: {0}'.format(function_type)) return False + def gather_obproxy_log(self, opt): + config = self.config_manager + if not config: + self._call_stdio('error', 'No such custum config') + return False + else: + self.set_context_skip_cluster_conn('gather_obproxy_log', 'gather', config) + handler = GatherObProxyLogHandler(self.context) + return handler.handle() + def gather_scenes_list(self, opt): self.set_offline_context('gather_scenes_list', 'gather') handler = GatherScenesListHandler(self.context) @@ -265,7 +285,7 @@ def analyze_fuction(self, function_type, opt): handler = AnalyzeLogHandler(self.context) handler.handle() elif function_type == 'analyze_log_offline': - self.set_offline_context(function_type, 'analyze', config) + self.set_offline_context(function_type, 'analyze') handler = AnalyzeLogHandler(self.context) handler.handle() elif function_type == 'analyze_flt_trace': @@ -348,7 +368,7 @@ def update(self, opts): return False else: self.stdio.print("update start ...") - self.set_offline_context('update', 'update', config) + self.set_offline_context('update', 'update') handler = UpdateHandler(self.context) handler.execute()