2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-08-18 09:10:23 +00:00

Merge pull request #1389 from zet809/refine_hdwrdiscovery_progress

refine hardware discovery framework, put mtms based hardware discover…
This commit is contained in:
Xiaopeng Wang
2016-06-27 17:36:58 +08:00
committed by GitHub
14 changed files with 247 additions and 120 deletions

View File

@@ -4442,9 +4442,9 @@ sub cleanup_for_powerLE_hardware_discovery {
}
my $subreq = shift;
my $host_node = $request->{node}->[0];
my $pbmc_node = undef;
if (defined($request->{pbmc_node}) and defined($request->{pbmc_node}->[0])) {
$pbmc_node = $request->{pbmc_node}->[0];
my $bmc_node = undef;
if (defined($request->{bmc_node}) and defined($request->{bmc_node}->[0])) {
$bmc_node = $request->{bmc_node}->[0];
}
my $ipmitab = xCAT::Table->new("ipmi");
@@ -4457,31 +4457,31 @@ sub cleanup_for_powerLE_hardware_discovery {
my $new_bmc_ip = $ipmihash->{$host_node}->[0]->{bmc};
my $new_bmc_username = $ipmihash->{$host_node}->[0]->{username};
my $new_bmc_password = $ipmihash->{$host_node}->[0]->{password};
if (!defined($pbmc_node)) {
if (!defined($bmc_node)) {
xCAT::MsgUtils->message("S", "Discover info: configure static BMC ip:$new_bmc_ip for host_node:$host_node.");
`rspconfig $host_node ip=$new_bmc_ip`;
return;
}
xCAT::MsgUtils->message("S", "Discovery info: configure password for pbmc_node:$pbmc_node.");
xCAT::MsgUtils->message("S", "Discovery info: configure password for bmc_node:$bmc_node.");
if (defined($new_bmc_username) and $new_bmc_username ne '') {
if ($new_bmc_username eq "ADMIN" or $new_bmc_username eq 'USERID') {
# ADMIN is username for OpenPOWER server, it is not allowed to modify at present
# USERID is username for IBM system x server, just modify password
`rspconfig $pbmc_node userid=2 password=$new_bmc_password`;
`rspconfig $bmc_node userid=2 password=$new_bmc_password`;
} else {
# For other username, we'd better create new user for them
`rspconfig $pbmc_node userid=3 username=$new_bmc_username password=$new_bmc_password`;
`rspconfig $bmc_node userid=3 username=$new_bmc_username password=$new_bmc_password`;
}
} else {
`rspconfig $pbmc_node password=$new_bmc_password`;
`rspconfig $bmc_node password=$new_bmc_password`;
}
# the rspconfig doesn't update node definition, need to modify manually for modifying bmc ip address
`chdef $pbmc_node bmcusername=$new_bmc_username bmcpassword=$new_bmc_password`;
`chdef $bmc_node bmcusername=$new_bmc_username bmcpassword=$new_bmc_password`;
#if ($new_bmc_password) {
# xCAT::Utils->runxcmd(
# {
# command => ["rspconfig"],
# node => ["$pbmc_node"],
# node => ["$bmc_node"],
# arg => [ "password=$new_bmc_password" ],
# },
# $subreq, 0,1);
@@ -4491,13 +4491,13 @@ sub cleanup_for_powerLE_hardware_discovery {
# }
#}
xCAT::MsgUtils->message("S", "Discover info: configure ip:$new_bmc_ip for pbmc_node:$pbmc_node.");
`rspconfig $pbmc_node ip=$new_bmc_ip`;
xCAT::MsgUtils->message("S", "Discover info: configure ip:$new_bmc_ip for bmc_node:$bmc_node.");
`rspconfig $bmc_node ip=$new_bmc_ip`;
#if($new_bmc_ip) {
# xCAT::Utils->runxcmd(
# {
# command => ["rspconfig"],
# node => ["$pbmc_node"],
# node => ["$bmc_node"],
# arg => [ "ip=$new_bmc_ip" ],
# },
# $subreq, 0,1);
@@ -4506,12 +4506,12 @@ sub cleanup_for_powerLE_hardware_discovery {
# return;
# }
#}
xCAT::MsgUtils->message("S", "Discovery info: remove pbmc_node:$pbmc_node.");
`rmdef $pbmc_node`;
xCAT::MsgUtils->message("S", "Discovery info: remove bmc_node:$bmc_node.");
`rmdef $bmc_node`;
#xCAT::Utils->runxcmd(
# {
# command => ["rmdef"],
# node => ["$pbmc_node"],
# node => ["$bmc_node"],
# },
# $subreq, 0,1);
}

View File

@@ -91,7 +91,9 @@ elif [ -r /proc/device-tree/model ]; then #POWER
done
CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
SERIAL=`cat /proc/device-tree/system-id -vT | sed -e 's/^.*,//' | sed -e 's/^[\t ]*//'| sed -e 's/[\t ]*\^@//'`
UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /proc/sys/kernel/random/uuid`
# For POWER servers, the /proc/sys/kernel/random/uuid is changing for each query, so use mtms + mac of first up nic as the UUID
#UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /proc/sys/kernel/random/uuid`
UUID=unknown
fi
#CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l`
@@ -115,6 +117,7 @@ DISKSIZE=`cat /proc/partitions |grep -e "sd.\>" |awk -F' ' '{printf "%s:%.0fGB\n
logger -t $log_label -p local4.info "Beginning echo infomation to discovery packet file..."
echo '<xcatrequest>' > /tmp/discopacket
echo "<command>findme</command>" >> /tmp/discopacket
echo "<sequential>1</sequential>" >> /tmp/discopacket
echo "<arch>$ARCH</arch>" >> /tmp/discopacket
if [ "$IAMAVM" = 1 ]; then
echo "<nodetype>virtual</nodetype>" >> /tmp/discopacket
@@ -166,6 +169,7 @@ if [ -f "/usr/sbin/dmidecode" ]; then
fi
done
fi
MAC_OF_FIRST_UP_NIC=unknown
#TODO: downed nics, also examine /sys/bus/pci/*/ for more network class devices that might not have driver suppert
for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v usb0`; do
FIRMDESC=""
@@ -174,6 +178,9 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v
PCI_SLOT=`grep PCI_SLOT_NAME /sys/class/net/$dev/device/uevent|awk -F= '{print $2}'`
ADDRESS=`ip address show dev $dev|grep "inet "|grep global|awk '{print $2}'`
MAC=`ip link show dev $dev|grep ether|awk '{print $2}'| tr /a-f/ /A-F/`
if [ "$MAC_OF_FIRST_UP_NIC" == "unknown" ]; then
MAC_OF_FIRST_UP_NIC=`echo $MAC | sed -e s/://g`
fi
if [[ ! -z "$PCI_SLOT" && -f "/usr/sbin/dmidecode" ]]; then
SLOTNAME=`dmidecode -t 9|egrep '(Designation|Address)'|grep -B1 $PCI_SLOT|grep Designation|sed -e 's/.*Designation:[ ]*//'`
if [ -z "$SLOTNAME" ]; then #check for on board device
@@ -234,6 +241,10 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v
echo "</nic>" >> /tmp/discopacket
done
if [ "$UUID" == "unknown" ]; then
UUID=`echo $MTM-$SERIAL-$MAC_OF_FIRST_UP_NIC | tr /A-Z/ /a-z/`
echo "<uuid>$UUID</uuid>" >> /tmp/discopacket
fi
echo "<xcatpubkey>$PUBKEY</xcatpubkey>" >> /tmp/discopacket #this is not secure to use by itself, switch sourced pubkey for security
echo "<sha512sig>" >> /tmp/discopacket
echo "</sha512sig>" >> /tmp/discopacket

View File

@@ -2135,44 +2135,7 @@ sub parse_args
}
sub findme {
my $request = shift;
my $callback = shift;
my $subreq = shift;
if (!defined $request->{'mtm'} or !defined $request->{'serial'}) {
xCAT::MsgUtils->message("S", "Discovery Error: 'mtm' or 'serial' not found.");
return;
}
my @attr_array = ();
my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0];
my $tmp_nodes = $::XCATVPDHASH{$mtms};
my @nodes = ();
my $pbmc_node;
foreach (@$tmp_nodes) {
if ($::XCATMPHASH{$_}) {
$pbmc_node = $_;
} else {
push @nodes, $_;
}
}
my $nodenum = $#nodes;
if ($nodenum < 0) {
xCAT::MsgUtils->message("S", "Discovery Error: Could not find any node.");
return;
} elsif ($nodenum > 0) {
xCAT::MsgUtils->message("S", "Discovery Error: More than one node were found.");
return;
}
{
my $req = {%$request};
$req->{command} = ['discovered'];
$req->{noderange} = [$nodes[0]];
$req->{pbmc_node} = [$pbmc_node];
$req->{discoverymethod} = ['mtms'];
$subreq->($req);
%{$req} = ();
}
}
##########################################################################
# Process request from xCat daemon
@@ -2188,15 +2151,6 @@ sub process_request {
# Get hwtype
####################################
$package =~ s/xCAT_plugin:://;
####################################
# Deal with findme request
####################################
if ($req->{command}->[0] eq 'findme') {
# Need to support both ppc64 and ppc64le, maybe also x86_64. Will be move out later.
&findme($req, $callback, $subreq);
return;
}
####################################
# Build hash to pass around
####################################

View File

@@ -0,0 +1,35 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# The first module to deal with hardware discovery request, write the request into "discoverydata" table only
package xCAT_plugin::aaadiscovery;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
use xCAT::DiscoveryUtils;
sub handled_commands {
return {
findme => 'aaadiscovery',
};
}
sub process_request {
my $req = shift;
my $cb = shift;
my $doreq = shift;
if ($req->{command}->[0] eq 'findme') {
if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) {
my $rsp = {};
$rsp->{error}->[0] = "The findme request had been processed by ".$req->{discoverymethod}->[0] ." module";
$cb->($rsp);
return;
}
xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Get a discover request");
$req->{discoverymethod}->[0] = 'undef';
xCAT::DiscoveryUtils->update_discovery_data($req);
return;
}
}
1;

View File

@@ -4359,6 +4359,12 @@ sub process_request {
}
}
if ($request->{command}->[0] eq "findme") {
if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) {
# The findme request had been processed by other module, just return
return;
}
xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request");
my $mptab = xCAT::Table->new("mp");
unless ($mptab) { return 2; }
my @bladents = $mptab->getAllNodeAttribs([qw(node)]);
@@ -4437,6 +4443,7 @@ sub process_request {
}
}
unless ($node) {
xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node");
return 1; #failure
}
if ($request->{mtm} and $request->{mtm} =~ /^(\w{4})/) {
@@ -4452,16 +4459,18 @@ sub process_request {
undef $mactab;
}
xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node $node for the discovery request");
#my %request = (
# command => ['makedhcp'],
# node => [$macmap{$mac}]
# );
#$doreq->(\%request);
$request->{command}=['discovered'];
$request->{noderange} = [$node];
$request->{discoverymethod} = ['blade'];
$doreq->($request);
%{$request}=(); #Clear request. it is done
my $req = {%$request};
$req->{noderange} = [$node];
$req->{discoverymethod} = ['blade'];
$doreq->($req);
%{$req}=(); #Clear request. it is done
return 0;
}

View File

@@ -32,7 +32,6 @@ sub handled_commands {
rscan => 'nodehm:mgt',
getfspcon => 'nodehm:cons',
getmulcon => 'fsp',
findme => 'fsp',
};
}

View File

@@ -685,6 +685,11 @@ sub process_request {
}
}
if ($request->{command}->[0] eq "findme") {
if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) {
# The findme request had been processed by other module, just return
return;
}
xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request");
my $mptab = xCAT::Table->new("mp");
unless ($mptab) { return 2; }
my @bladents = $mptab->getAllNodeAttribs([qw(node)]);
@@ -728,21 +733,25 @@ sub process_request {
}
}
unless ($macmap{$mac}) {
xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node");
return 1; #failure
}
my $mactab = xCAT::Table->new('mac',-create=>1);
$mactab->setNodeAttribs($macmap{$mac},{mac=>$mac});
$mactab->close();
# The discovered command will update mac table, no need to update here
#my $mactab = xCAT::Table->new('mac',-create=>1);
#$mactab->setNodeAttribs($macmap{$mac},{mac=>$mac});
#$mactab->close();
#my %request = (
# command => ['makedhcp'],
# node => [$macmap{$mac}]
# );
#$doreq->(\%request);
$request->{command}=['discovered'];
$request->{noderange} = [$macmap{$mac}];
$doreq->($request);
%{$request}=(); #Clear request. it is done
undef $mactab;
xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$macmap{$mac} for the discovery request");
my $req={%$request};
$req->{command}=['discovered'];
$req->{noderange} = [$macmap{$mac}];
$doreq->($req);
%{$req}=(); #Clear request. it is done
#undef $mactab;
return 0;
}

View File

@@ -373,8 +373,8 @@ sub process_request {
}
if (defined($request->{bmcinband})) {
syslog("local4|info", "The attribute bmcinband is specified, just remove the temp BMC node if there is");
if (defined($request->{pbmc_node}) and defined($request->{pbmc_node}->[0])) {
my $bmc_node = $request->{pbmc_node}->[0];
if (defined($request->{bmc_node}) and defined($request->{bmc_node}->[0])) {
my $bmc_node = $request->{bmc_node}->[0];
syslog("local4|info", "Find BMC $bmc_node, so remove it");
$doreq->({ command => ['rmdef'], arg => [$bmc_node]});
}

View File

@@ -1816,6 +1816,10 @@ Usage:
#-------------------------------------------------------
sub findme{
if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) {
# The findme request had been processed by other module, just return
return;
}
# re-initalize the global variable
%args_dict = ();
# Read DB to confirm the discover is started.

View File

@@ -50,22 +50,20 @@ sub findme {
my $request = shift;
my $callback = shift;
my $subreq = shift;
my @SEQdiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover");
my @PCMdiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover");
if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) {
# The findme request had been processed by other module, just return
return;
}
unless ($SEQdiscover[0]) {
if ($PCMdiscover[0]) {
#profile disocvery is running, then just return to make profile discovery to handle it
return;
}
# update the discoverydata table to have an undefined node
$request->{discoverymethod}->[0] = 'undef';
xCAT::DiscoveryUtils->update_discovery_data($request);
return;
}
# do the sequential discovery
xCAT::MsgUtils->message("S", "Sequential Discovery: Processing");
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request");
# Get the parameters for the sequential discovery
my %param;
@@ -78,7 +76,7 @@ sub findme {
my $mac;
my $ip = $request->{'_xcat_clientip'};
if (defined $request->{nodetype} and $request->{nodetype}->[0] eq 'virtual') {
xCAT::MsgUtils->message("S", "Sequential discovery does not support virtual machines, exiting...");
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: virtual machines is not supported");
return;
}
my $arptable;
@@ -98,7 +96,7 @@ sub findme {
}
unless ($mac) {
xCAT::MsgUtils->message("S", "Discovery Error: Could not find the mac of the $ip.");
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find mac of the $ip");
return;
}
@@ -130,13 +128,13 @@ sub findme {
$node = $allnodes[0];
}
}
my $pbmc_node = undef;
my $bmc_node = undef;
if ($request->{'mtm'}->[0] and $request->{'serial'}->[0]) {
my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0];
my $tmp_nodes = $::XCATVPDHASH{$mtms};
foreach (@$tmp_nodes) {
if ($::XCATMPHASH{$_}) {
$pbmc_node = $_;
$bmc_node = $_;
}
}
}
@@ -375,19 +373,20 @@ sub findme {
# call the discovered command to update the discovery request to a node
$request->{command}=['discovered'];
$request->{noderange} = [$node];
if ($pbmc_node) {
$request->{pbmc_node} = [$pbmc_node];
}
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$node for the discovery request");
$request->{discoverymethod} = ['sequential'];
$request->{updateswitch} = ['yes'];
$subreq->($request);
%{$request}=();#Clear req structure, it's done..
my $req = {%$request};
$req->{command}=['discovered'];
$req->{noderange} = [$node];
$request->{bmc_node} = [$bmc_node];
$req->{updateswitch} = ['yes'];
$subreq->($req);
%{$req}=();#Clear req structure, it's done..
undef $mactab;
} else {
nodediscoverstop($callback, undef, "node names");
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node");
return;
}

View File

@@ -268,6 +268,11 @@ sub process_request {
}
return;
} elsif ($req->{command}->[0] eq 'findme') {
if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) {
# The findme request had been processed by other module, just return
return;
}
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Processing discovery request");
my $ip = $req->{'_xcat_clientip'};
if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') {
#Don't attempt switch discovery of a VM Guest
@@ -305,37 +310,38 @@ sub process_request {
if ($node) { last; }
}
}
my $pbmc_node = undef;
my $bmc_node = undef;
if ($req->{'mtm'}->[0] and $req->{'serial'}->[0]) {
my $mtms = $req->{'mtm'}->[0]."*".$req->{'serial'}->[0];
my $tmp_nodes = $::XCATVPDHASH{$mtms};
foreach (@$tmp_nodes) {
if ($::XCATMPHASH{$_}) {
$pbmc_node = $_;
$bmc_node = $_;
}
}
}
if ($node) {
my $mactab = xCAT::Table->new('mac',-create=>1);
$mactab->setNodeAttribs($node,{mac=>$mac});
$mactab->close();
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Find node:$node for the discovery request");
# No need to write mac table here, 'discovered' command will write
# my $mactab = xCAT::Table->new('mac',-create=>1);
# $mactab->setNodeAttribs($node,{mac=>$mac});
# $mactab->close();
#my %request = (
# command => ['makedhcp'],
# node => [$node]
#);
#$doreq->(\%request);
$req->{command}=['discovered'];
$req->{noderange} = [$node];
if ($pbmc_node) {
$req->{pbmc_node} = [$pbmc_node];
}
$req->{discoverymethod} = ['switch'];
$doreq->($req);
%{$req}=();#Clear req structure, it's done..
$req->{discoverymethod}->[0] = 'switch';
my $request = {%$req};
$request->{command}=['discovered'];
$request->{noderange} = [$node];
$request->{bmc_node} = [$bmc_node];
$doreq->($request);
%{$request}=();#Clear req structure, it's done..
undef $mactab;
} else {
#Shouldn't complain, might be blade, but how to log total failures?
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Error: Could not find any node");
}
}
}

View File

@@ -0,0 +1,68 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# Used to deal with MTMS(machine-type/model and serial) based hardware discovery
package xCAT_plugin::typemtms;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
sub handled_commands {
return {
findme => 'typemtms',
};
}
sub findme {
my $request = shift;
my $callback = shift;
my $subreq = shift;
if (!defined $request->{'mtm'} or !defined $request->{'serial'}) {
xCAT::MsgUtils->message("S", "Discovery Error: 'mtm' or 'serial' not found.");
return;
}
my @attr_array = ();
my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0];
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Processing discovery request");
my $tmp_nodes = $::XCATVPDHASH{$mtms};
my @nodes = ();
my $bmc_node;
foreach (@$tmp_nodes) {
if ($::XCATMPHASH{$_}) {
$bmc_node = $_;
} else {
push @nodes, $_;
}
}
my $nodenum = $#nodes;
if ($nodenum < 0) {
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Error: Could not find any node");
return;
} elsif ($nodenum > 0) {
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Error: More than one node were found");
return;
}
{
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Find node:$nodes[0] for the discovery request");
$request->{discoverymethod}->[0] = 'mtms';
my $req = {%$request};
$req->{command} = ['discovered'];
$req->{noderange} = [$nodes[0]];
$req->{bmc_node} = [$bmc_node];
$subreq->($req);
%{$req} = ();
}
}
sub process_request {
my $req = shift;
my $cb = shift;
my $doreq = shift;
if ($req->{command}->[0] eq 'findme') {
if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) {
# The findme request had been processed by other module, just return
return;
}
&findme($req, $callback, $doreq);
return;
}
}
1;

View File

@@ -0,0 +1,32 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# The last module to deal with hardware discovery request, write information that which module can deal with this request or no module can deal with it at all
package xCAT_plugin::zzzdiscovery;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
sub handled_commands {
return {
findme => 'zzzdiscovery',
};
}
sub process_request {
my $req = shift;
my $cb = shift;
my $doreq = shift;
if ($req->{command}->[0] eq 'findme') {
xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Finish to process the discovery request");
if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0])) {
my $rsp = {};
$rsp->{error}->[0] = "The discovery request can not be processed";
$cb->($rsp);
xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Failed to be processed");
return;
}
xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Successfully processed by $req->{discoverymethod}->[0] method");
return;
}
}
1;

View File

@@ -625,12 +625,13 @@ sub do_discovery_process {
$req->{'_xcat_clientport'}=$sport;
if (defined($cmd_handlers{"findme"}) and xCAT::NetworkUtils->nodeonmynet($clientip)) { # only discover from ips that appear to be on a managed network
xCAT::MsgUtils->message("S","xcatd: Processing discovery request from ".$req->{'_xcat_clientip'});
$req->{cacheonly}->[0] = 1;
# Using cacheonly will cause the discovery processing running 2 times, cacheonly seems useless for switch.pm, so remove it
#$req->{cacheonly}->[0] = 1;
#plugin_command($req,undef,\&build_response);
#if ($req->{cacheonly}->[0]) {
#delete $req->{cacheonly};
plugin_command($req,undef,\&build_response);
if ($req->{cacheonly}->[0]) {
delete $req->{cacheonly};
plugin_command($req,undef,\&build_response);
}
#}
} else {
xCAT::MsgUtils->message("S","xcatd: Skipping discovery from ".$client." because we either have no discovery plugins or the client address does not match an IP network that xCAT is managing");
}