Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions _cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def _process_long_opt(self, rargs, values):
value = rargs[0]
OptionParser._process_long_opt(self, rargs, values)
except BadOptionError as e:
if self.prog.split()[-1] == "obdiag":
return
if self.allow_undefine:
key = e.opt_str
value = value[len(key)+1:]
Expand All @@ -138,6 +140,8 @@ def _process_short_opts(self, rargs, values):
value = rargs[0]
OptionParser._process_short_opts(self, rargs, values)
except BadOptionError as e:
if self.prog.split()[-1] == "obdiag":
return
if self.allow_undefine:
key = e.opt_str
value = value[len(key)+1:]
Expand Down
4 changes: 2 additions & 2 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4775,7 +4775,7 @@ def obdiag_func(self, args, deploy_name):
self._call_stdio('error', err.EC_OBDIAG_NOT_CONTAIN_DEPEND_COMPONENT.format(components=allow_components))
return False
cluster_config = deploy_config.components[component_name]
deploy_config.components = {tool_name: cluster_config}
deploy_config.components[tool_name] = cluster_config

workflow_name='diag'
pkg = self.mirror_manager.get_best_pkg(name=tool_name)
Expand All @@ -4790,7 +4790,7 @@ def obdiag_func(self, args, deploy_name):
workflows = self.get_workflows(workflow_name, [repository])
return self.run_workflow(workflows, deploy_config.components, [repository], **{const.COMP_OCEANBASE_DIAGNOSTIC_TOOL: {"full_cmd": args, "deploy_config": deploy_config}})
else:
self._call_stdio('error', err.EC_OBDIAG_FUNCTION_FAILED.format(function=workflow_name))
self._call_stdio('error', err.EC_OBDIAG_NOT_FOUND.format())
return False

def obdiag_deploy(self, fuction_type):
Expand Down
25 changes: 24 additions & 1 deletion plugins/oceanbase-diagnostic-tool/1.0/diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from __future__ import absolute_import, division, print_function
from ssh import LocalClient
import _errno as err
import re


def diag(plugin_context, *args, **kwargs):
Expand All @@ -31,4 +32,26 @@ def local_execute_command(command, env=None, timeout=None):
if not ret:
stdio.error(err.EC_OBDIAG_NOT_FOUND.format())
return plugin_context.return_false()
stdio.print(ret.stdout)

fixed_output= ""
if kwargs["full_cmd"][-1] == "list":
command_to_replace = kwargs["full_cmd"][0]
pattern = rf'(\s*)obdiag\s+{re.escape(command_to_replace)}(\s|$)'
replacement = rf'\1obd obdiag {command_to_replace}\2'
fixed_output = re.sub(
pattern,
replacement,
ret.stdout,
flags=re.MULTILINE | re.IGNORECASE
)
fixed_output = re.sub(
r'Usage: /.*?/obdiag',
'Usage: obd obdiag',
fixed_output
)
fixed_output = re.sub(
r'(<command>)(\s+\[options\])',
r'\1 <deploy name>\2',
fixed_output
)
stdio.print(fixed_output)
7 changes: 7 additions & 0 deletions plugins/oceanbase-diagnostic-tool/3.2.0/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def get_obdiag_config():
nodeItem["ssh_password"] = parse_empty(user_config.password)
nodeItem["private_key"] = parse_empty(user_config.key_file)
server_config = obproxy.get_server_conf(server)
obproxy_config["obproxy_port"] = server_config.get("listen_port")
nodeItem["home_path"] = server_config.get("home_path")
obproxy_nodes.append(nodeItem)
obproxy_config["servers"] = {"nodes": obproxy_nodes, "global": {}}
Expand Down Expand Up @@ -98,6 +99,12 @@ def get_obdiag_config():
obcluster_config["servers"] = {"nodes": observer_nodes, "global": {}}
if len(obproxy_nodes) > 0:
config={"obcluster": obcluster_config, "obproxy": obproxy_config}
if obproxy_config["obproxy_port"] == None:
obcluster_config["db_port"] = 2883
obcluster_config["db_host"] = obproxy_config["servers"]["nodes"][0]["ip"]
else:
obcluster_config["db_port"] = obproxy_config["obproxy_port"]
obcluster_config["db_host"] = obproxy_config["servers"]["nodes"][0]["ip"]
else:
config={"obcluster": obcluster_config}
return config
Expand Down
Loading