diff --git a/_cmd.py b/_cmd.py index 041c31a4..98c10ddf 100644 --- a/_cmd.py +++ b/_cmd.py @@ -1948,7 +1948,8 @@ def lock_mode(self): return LockMode.NO_LOCK def _do_command(self, obd): - return obd.obdiag_offline_func("gather_scene_list", self.opts) + # return obd.obdiag_offline_func("gather_scene_list", self.opts) + return obd.obdiag_offline_workflow("gather_scene_list") class ObdiagGatherSceneRunCommand(ObdCommand): @@ -2024,7 +2025,8 @@ def init(self, cmd, args): def _do_command(self, obd): offline_args_sign = '--files' if self.args and (offline_args_sign in self.args): - return obd.obdiag_offline_func("analyze_%s" % self.name, self.opts) + # return obd.obdiag_offline_func("analyze_%s" % self.name, self.opts) + return obd.obdiag_offline_workflow("analyze_%s" % self.name) if self.cmds: return obd.obdiag_online_func(self.cmds[0], "analyze_%s" % self.name, self.opts) else: @@ -2117,7 +2119,8 @@ def lock_mode(self): return LockMode.NO_LOCK def _do_command(self, obd): - return obd.obdiag_offline_func("rca_list", self.opts) + # return obd.obdiag_offline_func("rca_list", self.opts) + return obd.obdiag_offline_workflow("rca_list") class ObdiagRcaRunCommand(ObdCommand): @@ -2155,7 +2158,8 @@ def init(self, cmd, args): return self def _do_command(self, obd): - return obd.obdiag_offline_func("update_scene", self.opts) + # return obd.obdiag_offline_func("update_scene", self.opts) + return obd.obdiag_offline_workflow("update_scene") class ToolListCommand(ObdCommand): diff --git a/core.py b/core.py index 680019e8..e30ec87e 100644 --- a/core.py +++ b/core.py @@ -5006,6 +5006,26 @@ def obdiag_offline_func(self, fuction_type, opts): else: self._call_stdio('error', err.EC_OBDIAG_FUCYION_FAILED.format(fuction=fuction_type)) return False + + def obdiag_offline_workflow(self, workflow_name): + obdiag_config = Values() + setattr(obdiag_config, 'depends', []) + deploy_config = DeployConfig('', config_parser_manager=object()) + deploy_config.components = {'oceanbase-diagnostic-tool': obdiag_config} + tool_name = COMP_OCEANBASE_DIAGNOSTIC_TOOL + pkg = self.mirror_manager.get_best_pkg(name=tool_name) + if not pkg: + self._call_stdio('critical', '%s package not found' % tool_name) + return False + repository = self.repository_manager.create_instance_repository(pkg.name, pkg.version, pkg.md5) + deployed = self.obdiag_deploy(workflow_name) + tool = self.tool_manager.get_tool_config_by_name(tool_name) + if deployed and tool: + workflows = self.get_workflows(workflow_name, [repository]) + return self.run_workflow(workflows, deploy_config, [repository]) + else: + self._call_stdio('error', err.EC_OBDIAG_FUCYION_FAILED.format(fuction=workflow_name)) + return False def obdiag_deploy(self, fuction_type): component_name = COMP_OCEANBASE_DIAGNOSTIC_TOOL diff --git a/workflows/oceanbase-diagnostic-tool/2.5.0/analyze_log.py b/workflows/oceanbase-diagnostic-tool/2.5.0/analyze_log.py new file mode 100644 index 00000000..810aa8a2 --- /dev/null +++ b/workflows/oceanbase-diagnostic-tool/2.5.0/analyze_log.py @@ -0,0 +1,28 @@ +# coding: utf-8 +# OceanBase Deploy. +# Copyright (C) 2021 OceanBase +# +# This file is part of OceanBase Deploy. +# +# OceanBase Deploy is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OceanBase Deploy is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OceanBase Deploy. If not, see . + + +from __future__ import absolute_import, division, print_function + +import const + + +def analyze_log(plugin_context, workflow, *args, **kwargs): + workflow.add_with_component(const.STAGE_FIRST, 'oceanbase-diagnostic-tool', 'analyze_log') + plugin_context.return_true() diff --git a/workflows/oceanbase-diagnostic-tool/2.5.0/gather_scene_list.py b/workflows/oceanbase-diagnostic-tool/2.5.0/gather_scene_list.py new file mode 100644 index 00000000..b7e94142 --- /dev/null +++ b/workflows/oceanbase-diagnostic-tool/2.5.0/gather_scene_list.py @@ -0,0 +1,28 @@ +# coding: utf-8 +# OceanBase Deploy. +# Copyright (C) 2021 OceanBase +# +# This file is part of OceanBase Deploy. +# +# OceanBase Deploy is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OceanBase Deploy is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OceanBase Deploy. If not, see . + + +from __future__ import absolute_import, division, print_function + +import const + + +def gather_scene_list(plugin_context, workflow, *args, **kwargs): + workflow.add_with_component(const.STAGE_FIRST, 'oceanbase-diagnostic-tool', 'gather_scene_list') + plugin_context.return_true() diff --git a/workflows/oceanbase-diagnostic-tool/2.5.0/rca_list.py b/workflows/oceanbase-diagnostic-tool/2.5.0/rca_list.py new file mode 100644 index 00000000..f4aad438 --- /dev/null +++ b/workflows/oceanbase-diagnostic-tool/2.5.0/rca_list.py @@ -0,0 +1,28 @@ +# coding: utf-8 +# OceanBase Deploy. +# Copyright (C) 2021 OceanBase +# +# This file is part of OceanBase Deploy. +# +# OceanBase Deploy is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OceanBase Deploy is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OceanBase Deploy. If not, see . + + +from __future__ import absolute_import, division, print_function + +import const + + +def rca_list(plugin_context, workflow, *args, **kwargs): + workflow.add_with_component(const.STAGE_FIRST, 'oceanbase-diagnostic-tool', 'rca_list') + plugin_context.return_true() diff --git a/workflows/oceanbase-diagnostic-tool/2.5.0/update_scene.py b/workflows/oceanbase-diagnostic-tool/2.5.0/update_scene.py new file mode 100644 index 00000000..56423bbc --- /dev/null +++ b/workflows/oceanbase-diagnostic-tool/2.5.0/update_scene.py @@ -0,0 +1,28 @@ +# coding: utf-8 +# OceanBase Deploy. +# Copyright (C) 2021 OceanBase +# +# This file is part of OceanBase Deploy. +# +# OceanBase Deploy is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OceanBase Deploy is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OceanBase Deploy. If not, see . + + +from __future__ import absolute_import, division, print_function + +import const + + +def update_scene(plugin_context, workflow, *args, **kwargs): + workflow.add_with_component(const.STAGE_FIRST, 'oceanbase-diagnostic-tool', 'update_scene') + plugin_context.return_true()