diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 831bae20a..b3ab69236 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -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); } diff --git a/xCAT-genesis-scripts/bin/dodiscovery b/xCAT-genesis-scripts/bin/dodiscovery index 3d5e3c522..5148e1dab 100755 --- a/xCAT-genesis-scripts/bin/dodiscovery +++ b/xCAT-genesis-scripts/bin/dodiscovery @@ -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 '' > /tmp/discopacket echo "findme" >> /tmp/discopacket +echo "1" >> /tmp/discopacket echo "$ARCH" >> /tmp/discopacket if [ "$IAMAVM" = 1 ]; then echo "virtual" >> /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 "" >> /tmp/discopacket done +if [ "$UUID" == "unknown" ]; then + UUID=`echo $MTM-$SERIAL-$MAC_OF_FIRST_UP_NIC | tr /A-Z/ /a-z/` + echo "$UUID" >> /tmp/discopacket +fi echo "$PUBKEY" >> /tmp/discopacket #this is not secure to use by itself, switch sourced pubkey for security echo "" >> /tmp/discopacket echo "" >> /tmp/discopacket diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 9c7c3ba52..afd458a39 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -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 #################################### diff --git a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm new file mode 100644 index 000000000..13ae57055 --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm @@ -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; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index b34da65aa..ea413ff69 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -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; } diff --git a/xCAT-server/lib/xcat/plugins/fsp.pm b/xCAT-server/lib/xcat/plugins/fsp.pm index 9726685b6..53708d120 100644 --- a/xCAT-server/lib/xcat/plugins/fsp.pm +++ b/xCAT-server/lib/xcat/plugins/fsp.pm @@ -32,7 +32,6 @@ sub handled_commands { rscan => 'nodehm:mgt', getfspcon => 'nodehm:cons', getmulcon => 'fsp', - findme => 'fsp', }; } diff --git a/xCAT-server/lib/xcat/plugins/hpblade.pm b/xCAT-server/lib/xcat/plugins/hpblade.pm index 156de8071..6328f8b95 100755 --- a/xCAT-server/lib/xcat/plugins/hpblade.pm +++ b/xCAT-server/lib/xcat/plugins/hpblade.pm @@ -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; } diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index 2f52069b2..058d0401a 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -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]}); } diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 69067866a..242216f82 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -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. diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index dad597b05..87d1d5281 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -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; } diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 1ae78f71a..12024e6d1 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -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"); } } } diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm new file mode 100644 index 000000000..53e5cc29d --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -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; diff --git a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm new file mode 100644 index 000000000..643b178c8 --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm @@ -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; diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index d891dcd64..ab6abd7c1 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -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"); }