From 230a4dbb79d3a4c3e9a1542f736955896cb6cb06 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Mon, 8 May 2017 10:13:59 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20issue=20#2794,=20Nodeset=20fails=20to=20g?= =?UTF-8?q?enerate=20/tftpboot=20config=20files=20if=20=E2=80=A6=20(#2982)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix issue #2794, Nodeset fails to generate /tftpboot config files if ip attribute is not set - Report error when the node cannot be handled by its xcatmaster/servicenode (sharedtftp=0) * - using determinehostname to get the current server name, it will reduce the time when many service nodes. --- xCAT-server/lib/xcat/plugins/grub2.pm | 22 ++++++++++++++++++++- xCAT-server/lib/xcat/plugins/petitboot.pm | 22 ++++++++++++++++++++- xCAT-server/lib/xcat/plugins/xnba.pm | 24 ++++++++++++++++++++++- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 25446d0e1..5593dcdee 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -513,11 +513,31 @@ sub process_request { #if not shared tftpdir, then filter, 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", "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; } + foreach (@rnodes) { if (xCAT::NetworkUtils->nodeonmynet($_)) { push @nodes, $_; } else { - xCAT::MsgUtils->message("S", "$_: grub2 netboot: stop configuration because of none sharedtftp and not on same network with its xcatmaster."); + 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{$_} ) ) { + # report error when it is under my control but I cannot handle it. + my $rsp; + $rsp->{data}->[0] = $msg; + xCAT::MsgUtils->message("E", $rsp, $callback); + } else { + xCAT::MsgUtils->message("S", $msg); + } } } } else { diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index f99b41c92..ffa3b7842 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -404,11 +404,31 @@ sub process_request { #if not shared tftpdir, then filter, 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", "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; } + foreach (@rnodes) { if (xCAT::NetworkUtils->nodeonmynet($_)) { push @nodes, $_; } else { - xCAT::MsgUtils->message("S", "$_: petitboot netboot: stop configuration because of none sharedtftp and not on same network with its xcatmaster."); + 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{$_} ) ) { + # report error when it is under my control but I cannot handle it. + my $rsp; + $rsp->{data}->[0] = $msg; + xCAT::MsgUtils->message("E", $rsp, $callback); + } else { + xCAT::MsgUtils->message("S", $msg); + } } } } else { diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index fc485dd4e..eba36892d 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -449,11 +449,33 @@ sub process_request { #if not shared, then help sync up 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 foreach (@rnodes) { if (xCAT::NetworkUtils->nodeonmynet($_)) { push @nodes, $_; } else { - xCAT::MsgUtils->message("S", "$_: xnba netboot: stop configuration because of none sharedtftp and not on same network with its xcatmaster."); + 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{$_} ) ) { + # report error when it is under my control but I cannot handle it. + my $rsp; + $rsp->{data}->[0] = $msg; + xCAT::MsgUtils->message("E", $rsp, $::XNBA_callback); + } else { + xCAT::MsgUtils->message("S", $msg); + } + } } } else {