diff --git a/xCAT-server/lib/perl/xCAT/OPENBMC.pm b/xCAT-server/lib/perl/xCAT/OPENBMC.pm index 64fd999d5..783a9e30e 100644 --- a/xCAT-server/lib/perl/xCAT/OPENBMC.pm +++ b/xCAT-server/lib/perl/xCAT/OPENBMC.pm @@ -201,7 +201,13 @@ sub wait_agent { sub is_openbmc_python { my $environment = shift; $environment = shift if (($environment) && ($environment =~ /OPENBMC/)); - # If XCAT_OPENBMC_PYTHON is YES, will run openbmc2.pm. If not, run openbmc.pm + # If XCAT_OPENBMC_PYTHON is YES, + # will return "ALL" and caller will run openbmc2.pm. + # If XCAT_OPENBMC_PYTHON is not set or is set to NO, return "NO" and caller + # will run openbmc.pm + # If XCAT_OPENBMC_PYTHON is a list of commands, return that list and caller + # will run openbmc2.pm if the command is on the list, caller will run + # openbmc.pm if command is not on the list if (ref($environment) eq 'ARRAY' and ref($environment->[0]->{XCAT_OPENBMC_PYTHON}) eq 'ARRAY') { $::OPENBMC_PYTHON = $environment->[0]->{XCAT_OPENBMC_PYTHON}->[0]; } elsif (ref($environment) eq 'ARRAY') { @@ -209,11 +215,19 @@ sub is_openbmc_python { } else { $::OPENBMC_PYTHON = $environment->{XCAT_OPENBMC_PYTHON}; } - if (defined($::OPENBMC_PYTHON) and $::OPENBMC_PYTHON eq "YES") { - return 1; + if (defined($::OPENBMC_PYTHON)) { + if ($::OPENBMC_PYTHON eq "YES") { + return "ALL"; + } + elsif ($::OPENBMC_PYTHON eq "NO") { + return "NO"; + } + else { + return $::OPENBMC_PYTHON; + } } - return 0; + return "NO"; } 1; diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 34d424f98..53fd31c9b 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -756,20 +756,23 @@ sub preprocess_request { } ############################################## - if (xCAT::OPENBMC->is_openbmc_python($request->{environment})) { + $callback = shift; + my $command = $request->{command}->[0]; + my $python_env = xCAT::OPENBMC->is_openbmc_python($request->{environment}); + # Process command in this module only if PYTHON env is not ALL or command is + # listed in the PYTHON env list. All other cases => return + if (($python_env eq "ALL") || + (($python_env ne "NO") && ($python_env =~ $command))) { $request = {}; return; } - $callback = shift; - if ($::XCATSITEVALS{xcatdebugmode}) { $xcatdebugmode = $::XCATSITEVALS{xcatdebugmode} } if ($xcatdebugmode) { process_debug_info("OpenBMC"); } - my $command = $request->{command}->[0]; my $noderange = $request->{node}; my $extrargs = $request->{arg}; my @exargs = ($request->{arg}); diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index 92ce69da9..69820a057 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -57,12 +57,16 @@ sub preprocess_request { my $request = shift; $callback = shift; - if (!xCAT::OPENBMC->is_openbmc_python($request->{environment})) { + my $command = $request->{command}->[0]; + my $python_env = xCAT::OPENBMC->is_openbmc_python($request->{environment}); + # Process command in this module only if PYTHON env is not NO or + # command is listed in the PYTHON env list. All other cases => return + if (($python_env eq "NO") || + (($python_env ne "ALL") && ($python_env !~ $command))) { $request = {}; return; } - my $command = $request->{command}->[0]; my $noderange = $request->{node}; my $extrargs = $request->{arg}; my @exargs = ($request->{arg});