mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 11:42:05 +00:00
modify the pattern for xcat.discovery.xxx from MTMS to mac address
This commit is contained in:
parent
31a7b8bf03
commit
e80517eb6e
@ -25,8 +25,26 @@ sub process_request {
|
||||
$cb->($rsp);
|
||||
return;
|
||||
}
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Get a discover request");
|
||||
my $client_ip = $req->{'_xcat_clientip'};
|
||||
my $arptable;
|
||||
if ( -x "/usr/sbin/arp") {
|
||||
$arptable = `/usr/sbin/arp -n`;
|
||||
}
|
||||
else{
|
||||
$arptable = `/sbin/arp -n`;
|
||||
}
|
||||
my @arpents = split /\n/,$arptable;
|
||||
my $mac = "$req->{mtm}->[0]*$req->{serial}->[0]";
|
||||
foreach (@arpents) {
|
||||
if (m/^($client_ip)\s+\S+\s+(\S+)\s/) {
|
||||
$mac=$2;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($mac) Get a discover request");
|
||||
$req->{discoverymethod}->[0] = 'undef';
|
||||
$req->{_xcat_clientmac}->[0] = $mac;
|
||||
xCAT::DiscoveryUtils->update_discovery_data($req);
|
||||
return;
|
||||
}
|
||||
|
@ -4375,7 +4375,7 @@ sub process_request {
|
||||
return;
|
||||
}
|
||||
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Processing discovery request");
|
||||
my $mptab = xCAT::Table->new("mp");
|
||||
unless ($mptab) { return 2; }
|
||||
my @bladents = $mptab->getAllNodeAttribs([qw(node)]);
|
||||
@ -4454,7 +4454,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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node");
|
||||
return 1; #failure
|
||||
}
|
||||
if ($request->{mtm} and $request->{mtm} =~ /^(\w{4})/) {
|
||||
@ -4470,7 +4470,7 @@ 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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Find node $node for the discovery request");
|
||||
#my %request = (
|
||||
# command => ['makedhcp'],
|
||||
# node => [$macmap{$mac}]
|
||||
|
@ -689,7 +689,7 @@ sub process_request {
|
||||
# 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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Processing discovery request");
|
||||
my $mptab = xCAT::Table->new("mp");
|
||||
unless ($mptab) { return 2; }
|
||||
my @bladents = $mptab->getAllNodeAttribs([qw(node)]);
|
||||
@ -733,7 +733,7 @@ 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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node");
|
||||
return 1; #failure
|
||||
}
|
||||
# The discovered command will update mac table, no need to update here
|
||||
@ -745,7 +745,7 @@ sub process_request {
|
||||
# node => [$macmap{$mac}]
|
||||
# );
|
||||
#$doreq->(\%request);
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$macmap{$mac} for the discovery request");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Find node:$macmap{$mac} for the discovery request");
|
||||
my $req={%$request};
|
||||
$req->{command}=['discovered'];
|
||||
$req->{noderange} = [$macmap{$mac}];
|
||||
|
@ -63,7 +63,7 @@ sub findme {
|
||||
}
|
||||
|
||||
# do the sequential discovery
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Processing discovery request");
|
||||
|
||||
# Get the parameters for the sequential discovery
|
||||
my %param;
|
||||
@ -76,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", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: virtual machines is not supported");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Error: virtual machines is not supported");
|
||||
return;
|
||||
}
|
||||
my $arptable;
|
||||
@ -96,7 +96,7 @@ sub findme {
|
||||
}
|
||||
|
||||
unless ($mac) {
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find mac of the $ip");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Error: Could not find mac of the $ip");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ sub findme {
|
||||
|
||||
# call the discovered command to update the discovery request to a node
|
||||
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$node for the discovery request");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Find node:$node for the discovery request");
|
||||
$request->{discoverymethod} = ['sequential'];
|
||||
my $req = {%$request};
|
||||
$req->{command}=['discovered'];
|
||||
@ -386,7 +386,7 @@ sub findme {
|
||||
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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -277,8 +277,8 @@ sub process_request {
|
||||
# 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'};
|
||||
$mac = $req->{_xcat_clientmac}->[0];
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($mac) Processing discovery request");
|
||||
if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') {
|
||||
#Don't attempt switch discovery of a VM Guest
|
||||
#TODO: in this case, we could/should find the host system
|
||||
@ -288,20 +288,6 @@ sub process_request {
|
||||
#discovery working. Food for thought.
|
||||
return;
|
||||
}
|
||||
my $arptable;
|
||||
if ( -x "/usr/sbin/arp") {
|
||||
$arptable = `/usr/sbin/arp -n`;
|
||||
}
|
||||
else{
|
||||
$arptable = `/sbin/arp -n`;
|
||||
}
|
||||
my @arpents = split /\n/,$arptable;
|
||||
foreach (@arpents) {
|
||||
if (m/^($ip)\s+\S+\s+(\S+)\s/) {
|
||||
$mac=$2;
|
||||
last;
|
||||
}
|
||||
}
|
||||
my $firstpass=1;
|
||||
if ($mac) {
|
||||
$node = $macmap->find_mac($mac,$req->{cacheonly}->[0]);
|
||||
@ -327,7 +313,7 @@ sub process_request {
|
||||
}
|
||||
|
||||
if ($node) {
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Find node:$node for the discovery request");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[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});
|
||||
@ -346,7 +332,7 @@ sub process_request {
|
||||
%{$request}=();#Clear req structure, it's done..
|
||||
undef $mactab;
|
||||
} else {
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Error: Could not find any node");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Error: Could not find any node");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ sub findme {
|
||||
}
|
||||
my @attr_array = ();
|
||||
my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0];
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Processing discovery request");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Processing discovery request");
|
||||
my $tmp_nodes = $::XCATVPDHASH{$mtms};
|
||||
my @nodes = ();
|
||||
my $bmc_node;
|
||||
@ -35,14 +35,14 @@ sub findme {
|
||||
}
|
||||
my $nodenum = $#nodes;
|
||||
if ($nodenum < 0) {
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Error: Could not find any node");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) 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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Error: More than one node were found");
|
||||
return;
|
||||
}
|
||||
{
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Find node:$nodes[0] for the discovery request");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Find node:$nodes[0] for the discovery request");
|
||||
$request->{discoverymethod}->[0] = 'mtms';
|
||||
my $req = {%$request};
|
||||
$req->{command} = ['discovered'];
|
||||
|
@ -17,15 +17,15 @@ sub process_request {
|
||||
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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Finish to process the discovery request");
|
||||
if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0]) or ($req->{discoverymethod}->[0] eq 'undef')) {
|
||||
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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[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");
|
||||
xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Successfully processed by $req->{discoverymethod}->[0] method");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user