Skip to content

Commit

Permalink
Using opts to pass input_parameters options
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaodong-ji committed Aug 9, 2024
1 parent cf7dfdd commit 9bb329d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions context.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def return_false(self, *args, **kwargs):

class HandlerContext(object):

def __init__(self, handler_name=None, namespace=None, namespaces=None, cluster_config=None, obproxy_config=None, ocp_config=None, inner_config=None, cmd=None, options=None, stdio=None, rca_scene_parameters=None):
def __init__(self, handler_name=None, namespace=None, namespaces=None, cluster_config=None, obproxy_config=None, ocp_config=None, inner_config=None, cmd=None, options=None, stdio=None):
self.namespace = HandlerContextNamespace(namespace)
self.namespaces = namespaces
self.handler_name = handler_name
Expand All @@ -113,7 +113,6 @@ def __init__(self, handler_name=None, namespace=None, namespaces=None, cluster_c
self.cmds = cmd
self.options = options
self.stdio = stdio
self.rca_scene_parameters = rca_scene_parameters
self._return = HandlerReturn()

def get_return(self, handler_name=None, spacename=None):
Expand Down
4 changes: 1 addition & 3 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

class ObdiagHome(object):

def __init__(self, stdio=None, config_path=os.path.expanduser('~/.obdiag/config.yml'), inner_config_change_map=None, scene_input_param_map=None):
def __init__(self, stdio=None, config_path=os.path.expanduser('~/.obdiag/config.yml'), inner_config_change_map=None):
self._optimize_manager = None
self.stdio = None
self._stdio_func = None
Expand All @@ -71,7 +71,6 @@ def __init__(self, stdio=None, config_path=os.path.expanduser('~/.obdiag/config.
self.namespaces = {}
self.set_stdio(stdio)
self.context = None
self.rca_scene_parameters = scene_input_param_map
self.inner_config_manager = InnerConfigManager(stdio=stdio, inner_config_change_map=inner_config_change_map)
if self.inner_config_manager.config.get("obdiag") is not None and self.inner_config_manager.config.get("obdiag").get("basic") is not None and self.inner_config_manager.config.get("obdiag").get("basic").get("print_type") is not None:
stdio.set_err_stream(self.inner_config_manager.config.get("obdiag").get("logger").get("error_stream"))
Expand Down Expand Up @@ -129,7 +128,6 @@ def set_context(self, handler_name, namespace, config):
options=self.options,
stdio=self.stdio,
inner_config=self.inner_config_manager.config,
rca_scene_parameters=self.rca_scene_parameters,
)
telemetry.set_cluster_conn(config.get_ob_cluster_config)

Expand Down
3 changes: 2 additions & 1 deletion diag_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def do_command(self):
else:
ROOT_IO.error('The option you provided with -c: {0} is a non-existent configuration file path.'.format(custom_config))
return
obdiag = ObdiagHome(stdio=ROOT_IO, config_path=config_path, inner_config_change_map=self.inner_config_change_map, scene_input_param_map=self.scene_input_param_map)
obdiag = ObdiagHome(stdio=ROOT_IO, config_path=config_path, inner_config_change_map=self.inner_config_change_map)
obdiag.set_options(self.opts)
obdiag.set_cmds(self.cmds)
ret = self._do_command(obdiag)
Expand Down Expand Up @@ -930,6 +930,7 @@ def init(self, cmd, args):
return self

def _do_command(self, obdiag):
Util.set_option(self.opts, 'input_parameters', self.scene_input_param_map)
return obdiag.rca_run(self.opts)


Expand Down
2 changes: 1 addition & 1 deletion handler/rca/rca_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, context):
# init input parameters
self.report = None
self.tasks = None
self.context.set_variable("input_parameters", self.context.rca_scene_parameters)
self.context.set_variable("input_parameters", Util.get_option(self.options, "input_parameters"))
self.store_dir = Util.get_option(self.options, "store_dir", "./rca/")
self.context.set_variable("store_dir", self.store_dir)
self.stdio.verbose(
Expand Down

0 comments on commit 9bb329d

Please sign in to comment.