mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-29 09:13:08 +00:00
Merge pull request #4815 from gurevichmark/openbmc_rflash_perl
Allow choosing individual openbmc commands to use Python
This commit is contained in:
commit
aba8b368ab
@ -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;
|
||||
|
@ -756,12 +756,24 @@ sub preprocess_request {
|
||||
}
|
||||
##############################################
|
||||
|
||||
if (xCAT::OPENBMC->is_openbmc_python($request->{environment})) {
|
||||
$request = {};
|
||||
return;
|
||||
}
|
||||
|
||||
$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 (without EXCEPT: prefix.
|
||||
# All other cases => return
|
||||
SWITCH: {
|
||||
if ($python_env eq "ALL") {$request = {}; return;}
|
||||
if ($python_env eq "NO") {last SWITCH;}
|
||||
if ($python_env !~ $command) {
|
||||
if ($python_env =~ /^EXCEPT:/) {$request = {}; return;}
|
||||
else {last SWITCH;}
|
||||
}
|
||||
if ($python_env =~ $command) {
|
||||
if ($python_env =~ /^EXCEPT:/) {last SWITCH;}
|
||||
else {$request = {}; return;}
|
||||
}
|
||||
}
|
||||
|
||||
if ($::XCATSITEVALS{xcatdebugmode}) { $xcatdebugmode = $::XCATSITEVALS{xcatdebugmode} }
|
||||
|
||||
@ -769,7 +781,6 @@ sub preprocess_request {
|
||||
process_debug_info("OpenBMC");
|
||||
}
|
||||
|
||||
my $command = $request->{command}->[0];
|
||||
my $noderange = $request->{node};
|
||||
my $extrargs = $request->{arg};
|
||||
my @exargs = ($request->{arg});
|
||||
|
@ -57,12 +57,25 @@ sub preprocess_request {
|
||||
my $request = shift;
|
||||
$callback = shift;
|
||||
|
||||
if (!xCAT::OPENBMC->is_openbmc_python($request->{environment})) {
|
||||
$request = {};
|
||||
return;
|
||||
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 (without EXCEPT: prefix).
|
||||
# All other cases => return
|
||||
|
||||
SWITCH: {
|
||||
if ($python_env eq "NO") {$request = {}; return;}
|
||||
if ($python_env eq "ALL") {last SWITCH;}
|
||||
if ($python_env !~ $command) {
|
||||
if ($python_env =~ /^EXCEPT:/) {last SWITCH}
|
||||
else {$request = {}; return;}
|
||||
}
|
||||
if ($python_env =~ $command) {
|
||||
if ($python_env =~ /^EXCEPT:/) {$request = {}; return;}
|
||||
else {last SWITCH;}
|
||||
}
|
||||
}
|
||||
|
||||
my $command = $request->{command}->[0];
|
||||
my $noderange = $request->{node};
|
||||
my $extrargs = $request->{arg};
|
||||
my @exargs = ($request->{arg});
|
||||
|
Loading…
x
Reference in New Issue
Block a user