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

Fix #3088, introduce 'disjointnetboot' site attribute to make nodeset

request will only be handled for managed nodes on SN.
This commit is contained in:
Bin Xu 2017-07-14 13:50:58 +08:00
parent b5da727853
commit 47b92c193f
5 changed files with 140 additions and 46 deletions

View File

@ -298,6 +298,10 @@ site Attributes:
If value is set to a hostname, the directory in tftpdir
will be mounted from that hostname on the SN
disjointnetboot: Only avaialbe when sharedtftp is set to 0/no. If set to '1', a service node
handles the netboot (petitboot/grub2/xnba) config file only for the nodes it manages.
The default value is '0'. '0' means handle all the nodes in the same subnet.
sharedinstall: Indicates if a shared file system will be used for installation
resources. Possible values are: 'no', 'sns', or 'all'. 'no'
means a shared file system is not being used. 'sns' means a

View File

@ -1171,6 +1171,9 @@ passed as argument rather than by table value',
" in tftpdir is mounted on all on Service Nodes. Default is 1/yes.\n" .
" If value is set to a hostname, the directory in tftpdir\n" .
" will be mounted from that hostname on the SN\n\n" .
" disjointnetboot: Only available when sharedtftp is set to 0/no. If set to '1', a service node\n" .
" handles the netboot (petitboot/grub2/xnba) config file only for the nodes it manages.\n" .
" The default value is '0'. '0' means handle all the nodes in the same subnet.\n\n" .
" sharedinstall: Indicates if a shared file system will be used for installation\n" .
" resources. Possible values are: 'no', 'sns', or 'all'. 'no' \n" .
" means a shared file system is not being used. 'sns' means a\n" .

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 Data::Dumper;
use Sys::Syslog;
use xCAT::Scope;
use xCAT::Utils;
@ -123,12 +123,10 @@ sub setstate {
# We are in the service node pools, print error if no facing ip.
if (xCAT::InstUtils->is_me($sn)) {
my @myself = xCAT::NetworkUtils->determinehostname();
my $myname = $myself[ (scalar @myself) - 1 ];
$::callback->(
{
error => [
"$myname: $ipfnd[1] on service node $sn"
"$::myxcatname: $ipfnd[1] on service node $sn"
],
errorcode => [1]
}
@ -140,7 +138,7 @@ sub setstate {
$::callback->(
{
error => [
"$myname: $ipfnd[1]"
"$::myxcatname: $ipfnd[1]"
],
errorcode => [1]
}
@ -486,6 +484,7 @@ sub preprocess_request {
return xCAT::Scope->get_broadcast_scope_with_parallel($req);
}
}
# Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs.
return xCAT::Scope->get_parallel_scope($req);
}
@ -528,27 +527,56 @@ sub process_request {
return;
}
#if not shared tftpdir, then filter, otherwise, set up everything
my @hostinfo = xCAT::NetworkUtils->determinehostname();
$::myxcatname = $hostinfo[(scalar @hostinfo) - 1];
xCAT::MsgUtils->trace(0, "d", "grub2: running on $::myxcatname");
my @unmanagednodes = ();
#if not shared tftpdir, then broadcast, otherwise, set up everything
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
@nodes = ();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $cur_xmaster = pop @hostinfo;
xCAT::MsgUtils->trace(0, "d", "grub2: running on $cur_xmaster");
# Get current server managed node list
my %iphash = ();
# flag the IPs or names in iphash
foreach (@hostinfo) { $iphash{$_} = 1; }
#print Dumper(\%iphash);
my $mynodeonly = 0;
my @entries = xCAT::TableUtils->get_site_attribute("disjointnetboot");
my $t_entry = $entries[0];
if (defined($t_entry)) {
$mynodeonly = $t_entry;
}
xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: disjointnetboot=$mynodeonly");
# 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 = {};
foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
#print Dumper($sn_hash);
my %managed = ();
foreach (keys %$sn_hash) {
if (exists($iphash{$_})) {
my $cur_xmaster = $_;
foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
last;
}
}
foreach (@rnodes) {
# For MN, the scope is all CN, for SN, the scope is the nodes it managed if disjointnetboot is set.
my $req2manage = exists($managed{$_}) || xCAT::Utils->isMN();
if ($mynodeonly == 1 && $req2manage != 1) {
push @unmanagednodes, $_;
next;
}
# Only handle its boot configuration files if the node in same subnet
if (xCAT::NetworkUtils->nodeonmynet($_)) {
push @nodes, $_;
} else {
my $msg = "grub2 configuration file was not created for node [$_] because sharedtftp attribute is not set and the node is not on same network as this xcatmaster";
if ( $cur_xmaster ) {
$msg .= ": $cur_xmaster";
}
if ( exists( $managed{$_} ) ) {
$msg .= ": $::myxcatname" if ( $::myxcatname );
if ($req2manage == 1) {
# report error when it is under my control but I cannot handle it.
my $rsp;
$rsp->{data}->[0] = $msg;
@ -619,7 +647,7 @@ sub process_request {
bootparams => \%bphash
}, \&pass_along);
if ($errored) {
xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: Failed in processing setdestiny. Processing will not continue.");
xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: Failed in processing setdestiny. Processing will not continue.");
return;
}
}

View File

@ -1,6 +1,7 @@
# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT_plugin::petitboot;
#use Data::Dumper;
use File::Path;
use Getopt::Long;
use xCAT::Table;
@ -125,12 +126,10 @@ sub setstate {
# We are in the service node pools, print error if no facing ip.
if (xCAT::InstUtils->is_me($sn)) {
my @myself = xCAT::NetworkUtils->determinehostname();
my $myname = $myself[ (scalar @myself) - 1 ];
$::callback->(
{
error => [
"$myname: $ipfnd[1] on service node $sn"
"$::myxcatname: $ipfnd[1] on service node $sn"
],
errorcode => [1]
}
@ -142,7 +141,7 @@ sub setstate {
$::callback->(
{
error => [
"$myname: $ipfnd[1]"
"$::myxcatname: $ipfnd[1]"
],
errorcode => [1]
}
@ -363,6 +362,7 @@ sub preprocess_request {
return xCAT::Scope->get_broadcast_scope_with_parallel($req);
}
}
# Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs.
return xCAT::Scope->get_parallel_scope($req);
}
@ -408,27 +408,57 @@ sub process_request {
return;
}
#if not shared tftpdir, then filter, otherwise, set up everything
my @hostinfo = xCAT::NetworkUtils->determinehostname();
$::myxcatname = $hostinfo[(scalar @hostinfo) - 1];
xCAT::MsgUtils->trace(0, "d", "petitboot: running on $::myxcatname");
my @unmanagednodes = ();
#if not shared tftpdir, then broadcast, otherwise, set up everything
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
@nodes = ();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $cur_xmaster = pop @hostinfo;
xCAT::MsgUtils->trace(0, "d", "petitboot: running on $cur_xmaster");
# Get current server managed node list
my %iphash = ();
# flag the IPs or names in iphash
foreach (@hostinfo) { $iphash{$_} = 1; }
#print Dumper(\%iphash);
my $mynodeonly = 0;
my @entries = xCAT::TableUtils->get_site_attribute("disjointnetboot");
my $t_entry = $entries[0];
if (defined($t_entry)) {
$mynodeonly = $t_entry;
}
xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: disjointnetboot=$mynodeonly");
# 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 = {};
foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
#print Dumper($sn_hash);
my %managed = ();
foreach (keys %$sn_hash) {
if (exists($iphash{$_})) {
my $cur_xmaster = $_;
foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
last;
}
}
foreach (@rnodes) {
# For MN, the scope is all CN, for SN, the scope is the nodes it managed if disjointnetboot is set.
my $req2manage = exists($managed{$_}) || xCAT::Utils->isMN();
if ($mynodeonly == 1 && $req2manage != 1) {
push @unmanagednodes, $_;
next;
}
# Only handle its boot configuration files if the node in same subnet
if (xCAT::NetworkUtils->nodeonmynet($_)) {
push @nodes, $_;
} else {
my $msg = "petitboot configuration file was not created for node [$_] because sharedtftp attribute is not set and the node is not on same network as this xcatmaster";
if ( $cur_xmaster ) {
$msg .= ": $cur_xmaster";
}
if ( exists( $managed{$_} ) ) {
$msg .= ": $::myxcatname" if ( $::myxcatname );
if ($req2manage == 1) {
# report error when it is under my control but I cannot handle it.
my $rsp;
$rsp->{data}->[0] = $msg;

View File

@ -411,6 +411,7 @@ sub preprocess_request {
return xCAT::Scope->get_broadcast_scope_with_parallel($req);
}
}
# Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs.
return xCAT::Scope->get_parallel_scope($req);
}
@ -450,28 +451,56 @@ sub process_request {
return;
}
#if not shared, then help sync up
my @hostinfo = xCAT::NetworkUtils->determinehostname();
$::myxcatname = $hostinfo[(scalar @hostinfo) - 1];
xCAT::MsgUtils->trace(0, "d", "xnba: running on $::myxcatname");
my @unmanagednodes = ();
#if not shared tftpdir, then broadcast, otherwise, set up everything
if ($::XNBA_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
@nodes = ();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $cur_xmaster = pop @hostinfo;
xCAT::MsgUtils->trace(0, "d", "xnba: running on $cur_xmaster");
# Get current server managed node list
my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@rnodes, "xcat", "MN");
my %managed = {};
foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
# Whatever the node managed by this xcatmaster explicitly, if the node in same subnet, we need to handle its boot configuration files
my %iphash = ();
# flag the IPs or names in iphash
foreach (@hostinfo) { $iphash{$_} = 1; }
#print Dumper(\%iphash);
my $mynodeonly = 0;
my @entries = xCAT::TableUtils->get_site_attribute("disjointnetboot");
my $t_entry = $entries[0];
if (defined($t_entry)) {
$mynodeonly = $t_entry;
}
xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: disjointnetboot=$mynodeonly");
# 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");
#print Dumper($sn_hash);
my %managed = ();
foreach (keys %$sn_hash) {
if (exists($iphash{$_})) {
my $cur_xmaster = $_;
foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; }
last;
}
}
foreach (@rnodes) {
# For MN, the scope is all CN, for SN, the scope is the nodes it managed if disjointnetboot is set.
my $req2manage = exists($managed{$_}) || xCAT::Utils->isMN();
if ($mynodeonly == 1 && $req2manage != 1) {
push @unmanagednodes, $_;
next;
}
# Only handle its boot configuration files if the node in same subnet
if (xCAT::NetworkUtils->nodeonmynet($_)) {
push @nodes, $_;
} else {
my $msg = "xnba configuration file was not created for node [$_] because sharedtftp attribute is not set and the node is not on same network as this xcatmaster";
if ( $cur_xmaster ) {
$msg .= ": $cur_xmaster";
}
if ( exists( $managed{$_} ) ) {
$msg .= ": $::myxcatname" if ( $::myxcatname );
if ($req2manage == 1) {
# report error when it is under my control but I cannot handle it.
my $rsp;
$rsp->{data}->[0] = $msg;