From 5d1c8c7092616c3e2192c0fc5314372dacd2be3b Mon Sep 17 00:00:00 2001 From: zhao er tao Date: Fri, 2 Feb 2018 23:40:37 +0800 Subject: [PATCH] deal with rspconfig in python --- .../lib/python/agent/xcatagent/openbmc.py | 1 - xCAT-server/lib/xcat/plugins/openbmc2.pm | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py index 82ec20b8f..4346cb6f6 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py @@ -696,7 +696,6 @@ class OpenBMCManager(base.BaseManager): else: DefaultSensorManager().get_sensor_info(runner, action) - def _get_full_path(self,file_path): if type(self.cwd) == 'unicode': dir_path = self.cwd diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index 584e801e9..a34626dbd 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -113,6 +113,10 @@ sub process_request { $callback = shift; my $noderange = $request->{node}; my $check = parse_node_info($noderange); + if (&refactor_args($request)) { + xCAT::MsgUtils->message("E", { data => ["Failed to refactor arguments"] }, $callback); + return; + } $callback->({ errorcode => [$check] }) if ($check); return unless(%node_info); my $pid = xCAT::OPENBMC::start_python_agent(); @@ -298,4 +302,32 @@ sub parse_node_info { return $rst; } +#------------------------------------------------------- + +=head3 refactor_args + + refractor args to be easily dealt by python client + +=cut + +#------------------------------------------------------- + +sub refactor_args { + my $request = shift; + my $command = $request->{command}->[0]; + my $extrargs = $request->{arg}; + if ($command eq "rspconfig") { + if ($extrargs->[0] eq "dump") { + $request->{arg}->[0] = "--dump"; + } else { + foreach my $arg (@$extrargs) { + if ($arg !~ /^-/) { + $arg = "--".$arg; + } + } + } + } + return 0; +} + 1;