Skip to content

Commit

Permalink
fix offline context
Browse files Browse the repository at this point in the history
  • Loading branch information
Teingi committed May 11, 2024
1 parent e908474 commit a993be3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
30 changes: 25 additions & 5 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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':
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit a993be3

Please sign in to comment.