Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add workflow for obdiag #211

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions _cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 20 additions & 0 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions workflows/oceanbase-diagnostic-tool/2.5.0/analyze_log.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.


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()
28 changes: 28 additions & 0 deletions workflows/oceanbase-diagnostic-tool/2.5.0/gather_scene_list.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.


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()
28 changes: 28 additions & 0 deletions workflows/oceanbase-diagnostic-tool/2.5.0/rca_list.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.


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()
28 changes: 28 additions & 0 deletions workflows/oceanbase-diagnostic-tool/2.5.0/update_scene.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.


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()