2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 19:22:05 +00:00

1, Make the function header and comments more clear

This commit is contained in:
Bin Xu 2017-08-02 14:39:28 +08:00
parent 770d947c94
commit 0d85cd441b
4 changed files with 23 additions and 40 deletions

View File

@ -126,7 +126,8 @@ sub get_parallel_scope {
=head3 get_broadcast_scope_with_parallel
Convert a request object to an array of multiple requests according to the
splitted node range.
splitted node range. Also it replicates the requests to all required service
nodes or management node.
Arguments:
Reference of request
@ -155,7 +156,8 @@ sub get_broadcast_scope_with_parallel {
my @requests = (); # The request array will be return.
push @requests, @$reqs;
# get site.master from DB and dispatch to it as MN will not be in SN list.
# when this method is called on service node, it is required to broadcast to MN too.
# get site.master from DB in order to dispatch to MN ( MN will not be added in servicenode table)
if ( xCAT::Utils->isServiceNode() ) {
my @entries = xCAT::TableUtils->get_site_attribute("master");
my $master = $entries[0];
@ -184,8 +186,10 @@ sub get_broadcast_scope_with_parallel {
=head3 get_broadcast_disjoint_scope_with_parallel
Convert a request object to an array of multiple request objects according to the
service node management scope. (Work under disjoint mode)
Convert a request object to an array of multiple requests according to the
splitted node range. Also it replicates the requests to all required service
nodes or management node, but the request to a service node will only contains
the node range it manages.
Arguments:
Reference of request
@ -245,9 +249,6 @@ sub get_broadcast_disjoint_scope_with_parallel {
$reqs = get_parallel_scope($reqcopy);
push @requests, @$reqs;
#foreach (@$reqs) {
# push @requests, {%$_};
#}
} elsif ($handled4me == 0) {
my $reqcopy = {%$req};
$reqcopy->{'node'} = $sn_hash->{$xcatdest};

View File

@ -1,6 +1,6 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT_plugin::grub2;
#use Data::Dumper;
use Sys::Syslog;
use xCAT::Scope;
use xCAT::Utils;
@ -611,17 +611,13 @@ sub process_request {
my $str_node = join(" ", @nodes);
xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: nodes are $str_node") if ($str_node);
# return directly if no nodes in the same network
# Return directly if no nodes in the same network, need to report error on console if its managed nodes are not handled.
unless (@nodes) {
xCAT::MsgUtils->message("S", "xCAT: grub2 netboot: no valid nodes. Stop the operation on this server.");
# We need special hanlding to see if the plugin needs report error.
# - For MN, it is designed to handle all nodes, any error is required to be reqport. (All nodes are handled on MN if sharedtftp=1)
# - For SN, if disjointdhcps=1 AND sharedtftp=0, all nodes in the request are the nodes managed by this SN, so we need report error
# if disjointdhcps=1 AND sharedtftp=0, report error only if there are nodes are managed by me.
if (xCAT::Utils->isMN() != 1 && $request->{'_disparatetftp'}->[0] && $request->{'_disjointmode'}->[0] != 1) {
# If non-shared tftproot and non disjoint mode, need to figure out if no nodes here is a normal case.
if ($request->{'_disparatetftp'}->[0] && $request->{'_disjointmode'}->[0] != 1) {
# Find out which nodes are really mine only when not sharedtftp and not disjoint mode.
# For other case, all passing node range are required to be handled.
my %iphash = ();
# flag the IPs or names in iphash
foreach (@hostinfo) { $iphash{$_} = 1; }
@ -629,16 +625,14 @@ sub process_request {
# Get managed node list under current server
# The node will be under under 'site.master' if no 'noderes.servicenode' is defined
my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@rnodes, "xcat", "MN");
#my %managed = ();
my $req2manage = 0;
foreach (keys %$sn_hash) {
if (exists($iphash{$_})) {
#my $cur_xmaster = $_;
#foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
$req2manage = 1;
last;
}
}
# Okay, now report error as no nodes are handled.
if ($req2manage == 0) {
xCAT::MsgUtils->trace(0, "d", "grub2: No nodes are required to be managed on this server");
return;

View File

@ -501,17 +501,13 @@ sub process_request {
my $str_node = join(" ", @nodes);
xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: nodes are $str_node") if ($str_node);
# Return directly if no nodes in the same network
# Return directly if no nodes in the same network, need to report error on console if its managed nodes are not handled.
unless (@nodes) {
xCAT::MsgUtils->message("S", "xCAT: petitboot netboot: no valid nodes. Stop the operation on this server.");
# We need special hanlding to see if the plugin needs report error.
# - For MN, it is designed to handle all nodes, any error is required to be reqport. (All nodes are handled on MN if sharedtftp=1)
# - For SN, if disjointdhcps=1 AND sharedtftp=0, all nodes in the request are the nodes managed by this SN, so we need report error
# if disjointdhcps=1 AND sharedtftp=0, report error only if there are nodes are managed by me.
if (xCAT::Utils->isMN() != 1 && $request->{'_disparatetftp'}->[0] && $request->{'_disjointmode'}->[0] != 1) {
# If non-shared tftproot and non disjoint mode, need to figure out if no nodes here is a normal case.
if ($request->{'_disparatetftp'}->[0] && $request->{'_disjointmode'}->[0] != 1) {
# Find out which nodes are really mine only when not sharedtftp and not disjoint mode.
# For other case, all passing node range are required to be handled.
my %iphash = ();
# flag the IPs or names in iphash
foreach (@hostinfo) { $iphash{$_} = 1; }
@ -519,21 +515,19 @@ sub process_request {
# Get managed node list under current server
# The node will be under under 'site.master' if no 'noderes.servicenode' is defined
my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@rnodes, "xcat", "MN");
#my %managed = ();
my $req2manage = 0;
foreach (keys %$sn_hash) {
if (exists($iphash{$_})) {
#my $cur_xmaster = $_;
#foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
$req2manage = 1;
last;
}
}
if ($req2manage == 0) {
xCAT::MsgUtils->trace(0, "d", "petitboot: No nodes are required to be managed on this server");
#No nodes are required to be handled, quit without error.
return;
}
}
# Okay, now report error as no nodes are handled.
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate petitboot configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";

View File

@ -547,17 +547,13 @@ sub process_request {
my $str_node = join(" ", @nodes);
xCAT::MsgUtils->trace(0, "d", "xnba: nodes are $str_node") if ($str_node);
# return directly if no nodes in the same network
# Return directly if no nodes in the same network, need to report error on console if its managed nodes are not handled.
unless (@nodes) {
xCAT::MsgUtils->message("S", "xCAT: xnba netboot: no valid nodes. Stop the operation on this server.");
# We need special hanlding to see if the plugin needs report error.
# - For MN, it is designed to handle all nodes, any error is required to be reqport. (All nodes are handled on MN if sharedtftp=1)
# - For SN, if disjointdhcps=1 AND sharedtftp=0, all nodes in the request are the nodes managed by this SN, so we need report error
# if disjointdhcps=1 AND sharedtftp=0, report error only if there are nodes are managed by me.
if (xCAT::Utils->isMN() != 1 && $::XNBA_request->{'_disparatetftp'}->[0] && $::XNBA_request->{'_disjointmode'}->[0] != 1) {
# If non-shared tftproot and non disjoint mode, need to figure out if no nodes here is a normal case.
if ($::XNBA_request->{'_disparatetftp'}->[0] && $::XNBA_request->{'_disjointmode'}->[0] != 1) {
# Find out which nodes are really mine only when not sharedtftp and not disjoint mode.
# For other case, all passing node range are required to be handled.
my %iphash = ();
# flag the IPs or names in iphash
foreach (@hostinfo) { $iphash{$_} = 1; }
@ -565,21 +561,19 @@ sub process_request {
# Get managed node list under current server
# The node will be under under 'site.master' if no 'noderes.servicenode' is defined
my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@rnodes, "xcat", "MN");
#my %managed = ();
my $req2manage = 0;
foreach (keys %$sn_hash) {
if (exists($iphash{$_})) {
#my $cur_xmaster = $_;
#foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
$req2manage = 1;
last;
}
}
if ($req2manage == 0) {
xCAT::MsgUtils->trace(0, "d", "xnba: No nodes are required to be managed on this server");
#No nodes are required to be handled, quit without error.
return;
}
}
# Okay, now report error as no nodes are handled.
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate xnba configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";