2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-12 17:30:19 +00:00

Allow choosing individual openbmc commands to use Python

This commit is contained in:
Mark Gurevich
2018-02-08 15:25:56 -05:00
parent 6f6fbbd16e
commit 7722c15b18
3 changed files with 31 additions and 10 deletions

View File

@ -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;

View File

@ -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});

View File

@ -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});