From 47b92c193f28fe3cffb6ab13c25640d77684f40f Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Fri, 14 Jul 2017 13:50:58 +0800 Subject: [PATCH 01/35] Fix #3088, introduce 'disjointnetboot' site attribute to make nodeset request will only be handled for managed nodes on SN. --- .../admin-guides/references/man5/site.5.rst | 4 ++ perl-xCAT/xCAT/Schema.pm | 3 + xCAT-server/lib/xcat/plugins/grub2.pm | 62 ++++++++++++++----- xCAT-server/lib/xcat/plugins/petitboot.pm | 60 +++++++++++++----- xCAT-server/lib/xcat/plugins/xnba.pm | 57 ++++++++++++----- 5 files changed, 140 insertions(+), 46 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/site.5.rst b/docs/source/guides/admin-guides/references/man5/site.5.rst index 9e48d38c2..39a8fdc5b 100644 --- a/docs/source/guides/admin-guides/references/man5/site.5.rst +++ b/docs/source/guides/admin-guides/references/man5/site.5.rst @@ -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 diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index a19207611..b5badda23 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -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" . diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index f6600d22c..5d4fa8dd8 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -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; } } diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 04f7bcdf7..1b2248423 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -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; diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index dd8fe9d1c..773b75065 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -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; From 9b2f597ec2d6118174707344f899a84817803c6c Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Mon, 17 Jul 2017 14:44:34 +0800 Subject: [PATCH 02/35] Polish the code according to the review comments --- xCAT-server/lib/xcat/plugins/grub2.pm | 49 +++++++++++++++-------- xCAT-server/lib/xcat/plugins/petitboot.pm | 48 ++++++++++++++-------- xCAT-server/lib/xcat/plugins/xnba.pm | 48 ++++++++++++++-------- 3 files changed, 97 insertions(+), 48 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 5d4fa8dd8..f2a0b0958 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -528,7 +528,7 @@ sub process_request { } my @hostinfo = xCAT::NetworkUtils->determinehostname(); - $::myxcatname = $hostinfo[(scalar @hostinfo) - 1]; + $::myxcatname = $hostinfo[-1]; xCAT::MsgUtils->trace(0, "d", "grub2: running on $::myxcatname"); my @unmanagednodes = (); @@ -562,28 +562,45 @@ sub process_request { } } + my $notsamenet_nodes_err = ''; + my $notsamenet_nodes_warn = ''; + 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) { + my $req2manage = exists($managed{$_}); + if ($req2manage) { push @unmanagednodes, $_; - next; + # quick pass through if disjoint is set. + next if ( $mynodeonly == 1 && xCAT::Utils->isMN() != 1 ); } + # 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"; - $msg .= ": $::myxcatname" if ( $::myxcatname ); + } elsif ( $req2manage ) { + # report error when it is under my control but I cannot handle it. + $notsamenet_nodes_err .= " $_"; + } + else { + $notsamenet_nodes_warn .= " $_"; + } + } - if ($req2manage == 1) { - # 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); - } + if ( $mynodeonly == 1 && scalar (@unmanagednodes) > 0 && xCAT::Utils->isMN() != 1) { + my $str_umnodes = join(" ", @unmanagednodes); + xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: unmanaged nodes are $str_umnodes"); + } + + if ( $notsamenet_nodes_err || $notsamenet_nodes_warn ) { + my $msg = "grub2 configuration file was not created "; + $msg .= "on $::myxcatname " if ( $::myxcatname ); + $msg .= "for below nodes because sharedtftp attribute is not set and the nodes are not on same network as this xcatmaster: "; + xCAT::MsgUtils->message("S", $msg . $notsamenet_nodes_warn . $notsamenet_nodes_err); + # For managed children, need to report error + if ( $notsamenet_nodes_err ) { + my $rsp; + $rsp->{data}->[0] = $msg . $notsamenet_nodes_err; + xCAT::MsgUtils->message("E", $rsp, $callback); } } } else { @@ -592,7 +609,7 @@ sub process_request { #>>>>>>>used for trace log>>>>>>> my $str_node = join(" ", @nodes); - xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: nodes are $str_node"); + xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: nodes are $str_node") if ($str_node); # return directly if no nodes in the same network unless (@nodes) { diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 1b2248423..23493336f 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -409,7 +409,7 @@ sub process_request { } my @hostinfo = xCAT::NetworkUtils->determinehostname(); - $::myxcatname = $hostinfo[(scalar @hostinfo) - 1]; + $::myxcatname = $hostinfo[-1]; xCAT::MsgUtils->trace(0, "d", "petitboot: running on $::myxcatname"); my @unmanagednodes = (); @@ -443,29 +443,45 @@ sub process_request { } } + my $notsamenet_nodes_err = ''; + my $notsamenet_nodes_warn = ''; + 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) { + my $req2manage = exists($managed{$_}); + if ($req2manage) { push @unmanagednodes, $_; - next; + # quick pass through if disjoint is set. + next if ( $mynodeonly == 1 && xCAT::Utils->isMN() != 1 ); } # 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"; - $msg .= ": $::myxcatname" if ( $::myxcatname ); + } elsif ( $req2manage ) { + # report error when it is under my control but I cannot handle it. + $notsamenet_nodes_err .= " $_"; + } + else { + $notsamenet_nodes_warn .= " $_"; + } + } - if ($req2manage == 1) { - # 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); - } + if ( $mynodeonly == 1 && scalar (@unmanagednodes) > 0 && xCAT::Utils->isMN() != 1) { + my $str_umnodes = join(" ", @unmanagednodes); + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: unmanaged nodes are $str_umnodes"); + } + + if ( $notsamenet_nodes_err || $notsamenet_nodes_warn ) { + my $msg = "petitboot configuration file was not created "; + $msg .= "on $::myxcatname " if ( $::myxcatname ); + $msg .= "for below nodes because sharedtftp attribute is not set and the nodes are not on same network as this xcatmaster: "; + xCAT::MsgUtils->message("S", $msg . $notsamenet_nodes_warn . $notsamenet_nodes_err); + # For managed children, need to report error + if ( $notsamenet_nodes_err ) { + my $rsp; + $rsp->{data}->[0] = $msg . $notsamenet_nodes_err; + xCAT::MsgUtils->message("E", $rsp, $callback); } } } else { @@ -474,7 +490,7 @@ sub process_request { #>>>>>>>used for trace log>>>>>>> my $str_node = join(" ", @nodes); - xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: nodes are $str_node"); + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: nodes are $str_node") if ($str_node); # return directly if no nodes in the same network unless (@nodes) { diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 773b75065..52b459ce2 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -452,7 +452,7 @@ sub process_request { } my @hostinfo = xCAT::NetworkUtils->determinehostname(); - $::myxcatname = $hostinfo[(scalar @hostinfo) - 1]; + $::myxcatname = $hostinfo[-1]; xCAT::MsgUtils->trace(0, "d", "xnba: running on $::myxcatname"); my @unmanagednodes = (); @@ -486,29 +486,45 @@ sub process_request { } } + my $notsamenet_nodes_err = ''; + my $notsamenet_nodes_warn = ''; + 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) { + my $req2manage = exists($managed{$_}); + if ($req2manage) { push @unmanagednodes, $_; - next; + # quick pass through if disjoint is set. + next if ( $mynodeonly == 1 && xCAT::Utils->isMN() != 1 ); } + # 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"; - $msg .= ": $::myxcatname" if ( $::myxcatname ); + } elsif ( $req2manage ) { + # report error when it is under my control but I cannot handle it. + $notsamenet_nodes_err .= " $_"; + } + else { + $notsamenet_nodes_warn .= " $_"; + } + } - if ($req2manage == 1) { - # 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); - } + if ( $mynodeonly == 1 && scalar (@unmanagednodes) > 0 && xCAT::Utils->isMN() != 1) { + my $str_umnodes = join(" ", @unmanagednodes); + xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: unmanaged nodes are $str_umnodes"); + } + if ( $notsamenet_nodes_err || $notsamenet_nodes_warn ) { + my $msg = "xnba configuration file was not created "; + $msg .= "on $::myxcatname " if ( $::myxcatname ); + $msg .= "for below nodes because sharedtftp attribute is not set and the nodes are not on same network as this xcatmaster: "; + xCAT::MsgUtils->message("S", $msg . $notsamenet_nodes_warn . $notsamenet_nodes_err); + # For managed children, need to report error + if ( $notsamenet_nodes_err ) { + my $rsp; + $rsp->{data}->[0] = $msg . $notsamenet_nodes_err; + xCAT::MsgUtils->message("E", $rsp, $::XNBA_callback); } } } else { @@ -517,7 +533,7 @@ sub process_request { #>>>>>>>used for trace log>>>>>>> my $str_node = join(" ", @nodes); - xCAT::MsgUtils->trace(0, "d", "xnba: nodes are $str_node"); + xCAT::MsgUtils->trace(0, "d", "xnba: nodes are $str_node") if ($str_node); # return directly if no nodes in the same network unless (@nodes) { From 9dd5c3e986e41f1b5afa05dd2a80e399c4fc8e4b Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Mon, 17 Jul 2017 19:49:39 +0800 Subject: [PATCH 03/35] Fix typo --- xCAT-server/lib/xcat/plugins/grub2.pm | 4 ++-- xCAT-server/lib/xcat/plugins/petitboot.pm | 4 ++-- xCAT-server/lib/xcat/plugins/xnba.pm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index f2a0b0958..cbe35783f 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -626,8 +626,8 @@ sub process_request { #now run the begin part of the prescripts unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { $errored = 0; - if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children - xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: the call is distrubuted to the service node already, so only need to handles my own children"); + if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handle my own children + xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: the call is distrubuted to the service node already, so only need to handle my own children"); xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: issue runbeginpre request"); $sub_req->({ command => ['runbeginpre'], node => \@nodes, diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 23493336f..7b9487da3 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -507,8 +507,8 @@ sub process_request { #now run the begin part of the prescripts unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { $errored = 0; - if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children - xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: the call is distrubuted to the service node already, so only need to handles my own children"); + if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handle my own children + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: the call is distrubuted to the service node already, so only need to handle my own children"); xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue runbeginpre request"); $sub_req->({ command => ['runbeginpre'], node => \@nodes, diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 52b459ce2..6464a70c3 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -700,7 +700,7 @@ sub process_request { #now run the end part of the prescripts unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') $errored = 0; - if ($::XNBA_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children + if ($::XNBA_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handle my own children xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue runendpre request"); $sub_req->({ command => ['runendpre'], node => \@nodes, From 53d3b1bcedb077242ff4f2fb3a6c21ec5c5e2076 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Mon, 24 Jul 2017 13:32:40 +0800 Subject: [PATCH 04/35] 1, use 'disjointdhcps' for nodeset disjoint mode 2, handle 'disjoint' in preprocess method, to make sure that no request will be sent to SN which does not manage the nodes. 3, refine 'stat' to make sure it could query unmanaged nodes on-demand. --- .../admin-guides/references/man5/site.5.rst | 9 +- .../references/man8/nodeset.8.rst | 4 +- perl-xCAT/xCAT/NetworkUtils.pm | 55 +++- perl-xCAT/xCAT/Schema.pm | 8 +- perl-xCAT/xCAT/Scope.pm | 69 +++- perl-xCAT/xCAT/Usage.pm | 2 +- xCAT-client/pods/man8/nodeset.8.pod | 4 +- xCAT-server/lib/xcat/plugins/grub2.pm | 252 +++++++------- xCAT-server/lib/xcat/plugins/petitboot.pm | 310 ++++++++++-------- xCAT-server/lib/xcat/plugins/xnba.pm | 250 +++++++------- 10 files changed, 574 insertions(+), 389 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/site.5.rst b/docs/source/guides/admin-guides/references/man5/site.5.rst index 39a8fdc5b..7fb2bf6cc 100644 --- a/docs/source/guides/admin-guides/references/man5/site.5.rst +++ b/docs/source/guides/admin-guides/references/man5/site.5.rst @@ -110,8 +110,9 @@ site Attributes: dhcplease: The lease time for the dhcp client. The default value is 43200. disjointdhcps: If set to '1', the .leases file on a service node only contains - the nodes it manages. The default value is '0'. - '0' value means include all the nodes in the subnet. + the nodes it manages. And when 'sharedtftp' is disabled, nodeset handles + boot loader configuration on a service node only for the nodes it manages. + The default value is '0'. It means include all the nodes in the subnet. pruneservices: Whether to enable service pruning when noderm is run (i.e. removing DHCP entries when noderm is executed) @@ -298,10 +299,6 @@ 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 diff --git a/docs/source/guides/admin-guides/references/man8/nodeset.8.rst b/docs/source/guides/admin-guides/references/man8/nodeset.8.rst index 35edfcd45..50d12e87c 100644 --- a/docs/source/guides/admin-guides/references/man8/nodeset.8.rst +++ b/docs/source/guides/admin-guides/references/man8/nodeset.8.rst @@ -19,7 +19,7 @@ Name **************** -\ **nodeset**\ \ *noderange*\ [\ **boot**\ | \ **stat**\ | \ **offline**\ | \ **runcmd=bmcsetup**\ | \ **osimage**\ [=\ *imagename*\ ] | \ **shell**\ | \ **shutdown**\ ] +\ **nodeset**\ \ *noderange*\ [\ **boot**\ | \ **stat**\ [\ **-a**\ ]| \ **offline**\ | \ **runcmd=bmcsetup**\ | \ **osimage**\ [=\ *imagename*\ ] | \ **shell**\ | \ **shutdown**\ ] \ **nodeset**\ \ *noderange*\ \ **osimage**\ [=\ *imagename*\ ] [\ **-**\ **-noupdateinitrd**\ ] [\ **-**\ **-ignorekernelchk**\ ] @@ -101,7 +101,7 @@ A user can supply their own scripts to be run on the mn or on the service node ( \ **stat**\ - Display the current boot loader config file description for the nodes requested + Display the current boot loader config file description for the nodes requested. When \ **disjointdhcps**\ is set, using \ **-a**\ to display them on all available service nodes. diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index d54bf253b..9b65054a2 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -1645,10 +1645,14 @@ sub getNodeIPaddress { require xCAT::Table; my $nodetocheck = shift; - my $port = shift; - my $nodeip; + if ($nodetocheck eq 'xCAT::NetworkUtils') { #was called with -> syntax + $nodetocheck = shift; + } - $nodeip = xCAT::NetworkUtils->getipaddr($nodetocheck); + # Quick return if pass in an IP + return $nodetocheck if (xCAT::NetworkUtils->isIpaddr($nodetocheck)); + + my $nodeip = xCAT::NetworkUtils->getipaddr($nodetocheck); if (!$nodeip) { my $hoststab = xCAT::Table->new('hosts'); @@ -1666,6 +1670,51 @@ sub getNodeIPaddress } +#------------------------------------------------------------------------------- + +=head3 checkNodeIPaddress + Arguments: + Node name only one at a time + Returns: a hash object contains IP or Error + Globals: + none + Example: my $ipresult = xCAT::NetworkUtils::checkNodeIPaddress($nodetocheck); + +=cut + +#------------------------------------------------------------------------------- + +sub checkNodeIPaddress +{ + require xCAT::Table; + my $nodetocheck = shift; + if ($nodetocheck eq 'xCAT::NetworkUtils') { #was called with -> syntax + $nodetocheck = shift; + } + my $ret; + + my $nodeip; + my $hoststab = xCAT::Table->new('hosts'); + my $ent = $hoststab->getNodeAttribs($nodetocheck, ['ip']); + if ($ent->{'ip'}) { + $nodeip = $ent->{'ip'}; + } + + # Get the IP from DNS + my $dnsip = xCAT::NetworkUtils->getipaddr($nodetocheck); + if (!$dnsip) + { + $ret->{'error'} = "The $nodetocheck can not be resolved."; + $ret->{'ip'} = $nodeip if ($nodeip); + } elsif (!$nodeip) { + $ret->{'ip'} = $dnsip; + } else { + $ret->{'ip'} = $nodeip; + $ret->{'error'} = "Defined IP address of $nodetocheck is inconsistent with DNS." if ($nodeip ne $dnsip); + } + return $ret; +} + #------------------------------------------------------------------------------- diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index b5badda23..67a220457 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1029,8 +1029,9 @@ passed as argument rather than by table value', " dhcpsetup: If set to 'n', it will skip the dhcp setup process in the nodeset cmd.\n\n" . " dhcplease: The lease time for the dhcp client. The default value is 43200.\n\n" . " disjointdhcps: If set to '1', the .leases file on a service node only contains\n" . -" the nodes it manages. The default value is '0'.\n" . -" '0' value means include all the nodes in the subnet.\n\n" . +" the nodes it manages. And when 'sharedtftp' is disabled, nodeset handles\n" . +" boot loader configuration on a service node only for the nodes it manages.\n" . +" The default value is '0'. It means include all the nodes in the subnet.\n\n" . " pruneservices: Whether to enable service pruning when noderm is run (i.e.\n" . " removing DHCP entries when noderm is executed)\n\n" . " managedaddressmode: The mode of networking configuration during node provision.\n" . @@ -1171,9 +1172,6 @@ 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" . diff --git a/perl-xCAT/xCAT/Scope.pm b/perl-xCAT/xCAT/Scope.pm index a7aaf2588..e58d1a279 100644 --- a/perl-xCAT/xCAT/Scope.pm +++ b/perl-xCAT/xCAT/Scope.pm @@ -1,5 +1,6 @@ package xCAT::Scope; +#use Data::Dumper; use xCAT::Utils; use xCAT::Table; use xCAT::ServiceNodeUtils qw(getSNList); @@ -129,12 +130,12 @@ sub get_parallel_scope { Arguments: Reference of request - Callback: TODO, Optional, the Callback will be used to filter the nodes + SN list: Array of target service nodes Returns: An array of requests Error: none Example: - my $reqs = xCAT::Scope->get_broadcast_scope($request); + my $reqs = xCAT::Scope->get_broadcast_scope_with_parallel($request, \@snlist); =cut #----------------------------------------------------------------------------- @@ -146,18 +147,19 @@ sub get_broadcast_scope_with_parallel { #Exit if the packet has been preprocessed in its history if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } + my $snlist = shift; #Handle the one for current management/service node my $reqs = get_parallel_scope($req); my @requests = @$reqs; #Broadcast the request to other management/service nodes - foreach (xCAT::ServiceNodeUtils->getSNList()) { - if (xCAT::NetworkUtils->thishostisnot($_)) { - my $xcatdest = $_; + foreach (@$snlist) { + my $xcatdest = $_; + if (xCAT::NetworkUtils->thishostisnot($xcatdest)) { my $reqcopy = {%$req}; - $reqcopy->{'_xcatdest'} = $_; + $reqcopy->{'_xcatdest'} = $xcatdest; $reqcopy->{_xcatpreprocessed}->[0] = 1; - #Apply callback to filter the node range in future. + $reqs = get_parallel_scope($reqcopy); foreach (@$reqs) { push @requests, {%$_}; @@ -167,6 +169,59 @@ sub get_broadcast_scope_with_parallel { return \@requests; } +#----------------------------------------------------------------------------- + +=head3 get_broadcast_disjoint_scope_with_parallel + + Convert a request object to an array of multiple requests according to the + splitted node range. (Work under disjoint mode) + + Arguments: + Reference of request + SN hash: Hash of target service nodes => Managed CNs + Returns: An array of requests + Error: + none + Example: + my $reqs = xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($request, \@snhash); +=cut + +#----------------------------------------------------------------------------- +sub get_broadcast_disjoint_scope_with_parallel { + my $req = shift; + if ($req =~ /xCAT::Scope/) { + $req = shift; + } + #Exit if the packet has been preprocessed in its history + if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } + + my $sn_hash = shift; + my @reqs = (); + #Handle the one for current management/service node + if ( xCAT::Utils->isMN() ) { + $reqs = get_parallel_scope($req); + } + my @requests = @$reqs; + + #Broadcast the request to other management/service nodes + foreach (keys %$sn_hash) { + my $xcatdest = $_; + if (xCAT::NetworkUtils->thishostisnot($xcatdest)) { + my $reqcopy = {%$req}; + $reqcopy->{'_xcatdest'} = $xcatdest; + $reqcopy->{'node'} = $sn_hash->{$xcatdest}; + $reqcopy->{_xcatpreprocessed}->[0] = 1; + + $reqs = get_parallel_scope($reqcopy); + foreach (@$reqs) { + push @requests, {%$_}; + } + } + } + #print Dumper(\@requests); + return \@requests; +} + sub get_broadcast_scope { my $req = shift; diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 4ca8093c0..1377d56ce 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -481,7 +481,7 @@ Options: "Usage: Common: nodeset [-h|--help|-v|--version] - nodeset [shell|boot|runcmd=bmcsetup|osimage[=]|offline|shutdown|stat]", + nodeset [shell|boot|runcmd=bmcsetup|osimage[=]|offline|shutdown|stat [-a]]", "rmflexnode" => "Usage: rmflexnode [-h|--help|-v|--version] diff --git a/xCAT-client/pods/man8/nodeset.8.pod b/xCAT-client/pods/man8/nodeset.8.pod index 15618d46d..2fd8bc957 100644 --- a/xCAT-client/pods/man8/nodeset.8.pod +++ b/xCAT-client/pods/man8/nodeset.8.pod @@ -4,7 +4,7 @@ B - set the boot state for a noderange =head1 B -B I [B | B | B | B | B[=I] | B | B] +B I [B | B [B<-a>]| B | B | B[=I] | B | B] B I B[=I] [B<--noupdateinitrd>] [B<--ignorekernelchk>] @@ -68,7 +68,7 @@ If you would like to run a task after deployment, you can define that task with =item B -Display the current boot loader config file description for the nodes requested +Display the current boot loader config file description for the nodes requested. When B is set, using B<-a> to display them on all available service nodes. =item B diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index cbe35783f..4820f4307 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -174,9 +174,9 @@ sub setstate { $kern->{kcmdline} .= " " . $cmdhashref->{volatile}; } - my $pcfg; - unless (-d "$tftpdir/boot/grub2") { - mkpath("$tftpdir/boot/grub2"); + my $bootloader_root = "$tftpdir/boot/grub2"; + unless (-d "$bootloader_root") { + mkpath("$bootloader_root"); } my $nodemac; my %client_nethash = xCAT::DBobjUtils->getNetwkInfo([$node]); @@ -184,9 +184,10 @@ sub setstate { my $cref = $chainhash{$node}->[0]; #$chaintab->getNodeAttribs($node,['currstate']); # remove the old boot configuration files and create a new one, but only if not offline directive - system("find $tftpdir/boot/grub2/ -inum \$(stat --printf \%i $tftpdir/boot/grub2/$node 2>/dev/null) -exec rm -f {} \\; 2>/dev/null"); + system("find $bootloader_root/ -inum \$(stat --printf \%i $bootloader_root/$node 2>/dev/null) -exec rm -f {} \\; 2>/dev/null"); + my $pcfg; if ($cref and $cref->{currstate} ne "offline") { - open($pcfg, '>', $tftpdir . "/boot/grub2/" . $node); + open($pcfg, '>', "$bootloader_root/" . $node); print $pcfg "#" . $cref->{currstate} . "\n"; if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) { @@ -292,11 +293,6 @@ sub setstate { print $pcfg "}"; close($pcfg); } - my $inetn = xCAT::NetworkUtils->getipaddr($node); - unless ($inetn) { - syslog("local1|err", "xCAT unable to resolve IP for $node in grub2 plugin"); - return; - } } else { close($pcfg); } @@ -332,9 +328,9 @@ sub setstate { my $pname = "grub.cfg-" . sprintf("%02X%02X%02X%02X", @ipa); # remove the old boot configuration file and copy (link) a new one, but only if not offline directive - unlink($tftpdir . "/boot/grub2/" . $pname); + unlink("$bootloader_root/" . $pname); if ($cref and $cref->{currstate} ne "offline") { - link($tftpdir . "/boot/grub2/" . $node, $tftpdir . "/boot/grub2/" . $pname); + link("$bootloader_root/" . $node, "$bootloader_root/" . $pname); } } @@ -357,9 +353,9 @@ sub setstate { my $pname = "grub.cfg-01-" . $tmp; # remove the old boot configuration file and copy (link) a new one, but only if not offline directive - unlink($tftpdir . "/boot/grub2/" . $pname); + unlink("$bootloader_root/" . $pname); if ($cref and $cref->{currstate} ne "offline") { - link($tftpdir . "/boot/grub2/" . $node, $tftpdir . "/boot/grub2/" . $pname); + link("$bootloader_root/" . $node, "$bootloader_root/" . $pname); } } return; @@ -400,12 +396,14 @@ sub preprocess_request { #use Getopt::Long; my $HELP; + my $ALLFLAG; my $VERSION; my $VERBOSE; Getopt::Long::Configure("bundling"); Getopt::Long::Configure("pass_through"); if (!GetOptions('h|?|help' => \$HELP, 'v|version' => \$VERSION, + 'a' =>\$ALLFLAG, 'V' => \$VERBOSE #>>>>>>>used for trace log>>>>>>> )) { if ($usage{$command}) { @@ -467,12 +465,12 @@ sub preprocess_request { xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN); unless (($args[0] eq 'stat') or ($args[0] eq 'enact')) { if ((@SN > 0) && (@CN > 0)) { # there are both SN and CN - my $rsp; - $rsp->{data}->[0] = + my %rsp; + $rsp{errorcode}->[0] = 1; + $rsp{error}->[0] = "Nodeset was run with a noderange containing both service nodes and compute nodes. This is not valid. You must submit with either compute nodes in the noderange or service nodes. \n"; - xCAT::MsgUtils->message("E", $rsp, $callback1); + $callback1->(\%rsp); return; - } } @@ -480,8 +478,28 @@ sub preprocess_request { if ($req->{inittime}->[0]) { return [$req]; } - if (@CN > 0) { # if compute nodes broadcast to all servicenodes - return xCAT::Scope->get_broadcast_scope_with_parallel($req); + if (@CN > 0) { # if compute nodes only, then broadcast to servic enodes + + my @sn = xCAT::ServiceNodeUtils->getSNList(); + unless ( @sn > 0 ) { + return xCAT::Scope->get_parallel_scope($req) + } + + my $mynodeonly = 0; + my @entries = xCAT::TableUtils->get_site_attribute("disjointdhcps"); + my $t_entry = $entries[0]; + if (defined($t_entry)) { + $mynodeonly = $t_entry; + } + $req->{'_disjointmode'} = [$mynodeonly]; + xCAT::MsgUtils->trace(0, "d", "grub2: disjointdhcps=$mynodeonly"); + + if ($mynodeonly == 0 || $ALLFLAG) { # broadcast to all service nodes + return xCAT::Scope->get_broadcast_scope_with_parallel($req, \@sn); + } + + my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@CN, "xcat", "MN"); + return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash); } } # Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs. @@ -495,19 +513,16 @@ sub process_request { $sub_req = shift; my $command = $request->{command}->[0]; %breaknetbootnodes = (); - %normalnodes = (); + %normalnodes = (); # It will be fill-up by method: setstate. my @args; - my @nodes; - my @rnodes; - #>>>>>>>used for trace log start>>>>>>> my %opt; my $verbose_on_off = 0; - if (ref($::XNBA_request->{arg})) { - @args = @{ $::XNBA_request->{arg} }; + if (ref($request->{arg})) { + @args = @{ $request->{arg} }; } else { - @args = ($::XNBA_request->{arg}); + @args = ($request->{arg}); } @ARGV = @args; GetOptions('V' => \$opt{V}); @@ -515,6 +530,10 @@ sub process_request { #>>>>>>>used for trace log end>>>>>>> + my @hostinfo = xCAT::NetworkUtils->determinehostname(); + $::myxcatname = $hostinfo[-1]; + xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: running on $::myxcatname"); + my @rnodes; if (ref($request->{node})) { @rnodes = @{ $request->{node} }; } else { @@ -527,104 +546,101 @@ sub process_request { return; } - my @hostinfo = xCAT::NetworkUtils->determinehostname(); - $::myxcatname = $hostinfo[-1]; - xCAT::MsgUtils->trace(0, "d", "grub2: running on $::myxcatname"); + if ($args[0] eq 'stat') { + my $noderestab = xCAT::Table->new('noderes'); #in order to detect per-node tftp directories + my %nrhash = %{ $noderestab->getNodesAttribs(\@rnodes, [qw(tftpdir)]) }; + foreach my $node (@rnodes) { + my %response; + my $tftpdir; + if ($nrhash{$node}->[0] and $nrhash{$node}->[0]->{tftpdir}) { + $tftpdir = $nrhash{$node}->[0]->{tftpdir}; + } else { + $tftpdir = $globaltftpdir; + } + $response{node}->[0]->{name}->[0] = $node; + $response{node}->[0]->{data}->[0] = getstate($node, $tftpdir); + $callback->(\%response); + } + return; + } - my @unmanagednodes = (); - #if not shared tftpdir, then broadcast, otherwise, set up everything + my @nodes = (); + # Filter those nodes which have bad DNS: not resolvable or inconsistent IP + my %failurenodes = (); + my %preparednodes = (); + foreach (@rnodes) { + my $ipret = xCAT::NetworkUtils->checkNodeIPaddress($_); + my $errormsg = $ipret->{'error'}; + my $nodeip = $ipret->{'ip'}; + if ($errormsg) {# Add the node to failure set + xCAT::MsgUtils->trace(0, "E", "grub2: IP address of $_ is $nodeip. $errormsg"); + unless ($nodeip) { + $failurenodes{$_} = 1; + } + } + if ($nodeip) { + $preparednodes{$_} = $nodeip; + } + } + + #if not shared tftpdir, then filter, otherwise, set up everything if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command - @nodes = (); - - 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"); - #print Dumper($sn_hash); - my %managed = (); - foreach (keys %$sn_hash) { - if (exists($iphash{$_})) { - my $cur_xmaster = $_; - foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; } - last; - } - } - - my $notsamenet_nodes_err = ''; - my $notsamenet_nodes_warn = ''; - - 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{$_}); - if ($req2manage) { - push @unmanagednodes, $_; - # quick pass through if disjoint is set. - next if ( $mynodeonly == 1 && xCAT::Utils->isMN() != 1 ); - } - + # Filter those nodes not in the same subnet, and print error message in log file. + foreach (keys %preparednodes) { # Only handle its boot configuration files if the node in same subnet - if (xCAT::NetworkUtils->nodeonmynet($_)) { + if (xCAT::NetworkUtils->nodeonmynet($preparednodes{$_})) { push @nodes, $_; - } elsif ( $req2manage ) { - # report error when it is under my control but I cannot handle it. - $notsamenet_nodes_err .= " $_"; - } - else { - $notsamenet_nodes_warn .= " $_"; - } - } - - if ( $mynodeonly == 1 && scalar (@unmanagednodes) > 0 && xCAT::Utils->isMN() != 1) { - my $str_umnodes = join(" ", @unmanagednodes); - xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: unmanaged nodes are $str_umnodes"); - } - - if ( $notsamenet_nodes_err || $notsamenet_nodes_warn ) { - my $msg = "grub2 configuration file was not created "; - $msg .= "on $::myxcatname " if ( $::myxcatname ); - $msg .= "for below nodes because sharedtftp attribute is not set and the nodes are not on same network as this xcatmaster: "; - xCAT::MsgUtils->message("S", $msg . $notsamenet_nodes_warn . $notsamenet_nodes_err); - # For managed children, need to report error - if ( $notsamenet_nodes_err ) { - my $rsp; - $rsp->{data}->[0] = $msg . $notsamenet_nodes_err; - xCAT::MsgUtils->message("E", $rsp, $callback); + } else { + xCAT::MsgUtils->trace(0, "W", "grub2: configuration file was not created for [$_] because the node is not on the same network as this server"); + delete $preparednodes{$_}; } } } else { - @nodes = @rnodes; + @nodes = keys %preparednodes; } - #>>>>>>>used for trace log>>>>>>> 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 unless (@nodes) { xCAT::MsgUtils->message("S", "xCAT: grub2 netboot: no valid nodes. Stop the operation on this server."); + + # It must be an error if my managed nodes are not handled. + if (xCAT::Utils->isMN() != 1 && $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; } + + # 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", "grub2: No nodes are required to be managed on this server"); + return; + } + } + my $rsp; + $rsp->{errorcode}->[0] = 1; + $rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n"; + $callback->($rsp); return; } - if (ref($request->{arg})) { - @args = @{ $request->{arg} }; - } else { - @args = ($request->{arg}); - } - #now run the begin part of the prescripts - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + unless ($args[0] eq '') { # or $args[0] eq 'enact') { $errored = 0; if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handle my own children xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: the call is distrubuted to the service node already, so only need to handle my own children"); @@ -654,7 +670,7 @@ sub process_request { if (!$inittime) { $inittime = 0; } my %bphash; - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + unless ($args[0] eq '') { # or $args[0] eq 'enact') { $errored = 0; xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: issue setdestiny request"); $sub_req->({ command => ['setdestiny'], @@ -669,6 +685,7 @@ sub process_request { } } + xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: starting to handle configuration..."); my $chaintab = xCAT::Table->new('chain', -create => 1); my $chainhash = $chaintab->getNodesAttribs(\@nodes, ['currstate']); my $noderestab = xCAT::Table->new('noderes', -create => 1); @@ -694,10 +711,7 @@ sub process_request { $tftpdir = $globaltftpdir; } $response{node}->[0]->{name}->[0] = $_; - if ($args[0] eq 'stat') { - $response{node}->[0]->{data}->[0] = getstate($_, $tftpdir); - $callback->(\%response); - } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate + if ($args[0]) { # Send it on to the destiny plugin, then setstate my $ent = $typehash->{$_}->[0]; my $osimgname = $ent->{'provmethod'}; my $linuximghash = undef; @@ -713,11 +727,11 @@ sub process_request { } } } # end of foreach node + xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: Finish to handle configurations"); my @normalnodeset = keys %normalnodes; my @breaknetboot = keys %breaknetbootnodes; - #print "grub2 :inittime=$inittime; normalnodeset=@normalnodeset; breaknetboot=@breaknetboot\n"; my %osimagenodehash; for my $nn (@normalnodeset) { @@ -738,7 +752,7 @@ sub process_request { } #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time - unless (($args[0] eq 'stat') || ($inittime) || ($args[0] eq 'offline')) { + unless (($inittime) || ($args[0] eq 'offline')) { foreach my $osimage (keys %osimagenodehash) { #TOTO check the existence of grub2 executable files for corresponding arch @@ -838,7 +852,7 @@ sub process_request { } #now run the end part of the prescripts - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') + unless ($args[0] eq '') { # or $args[0] eq 'enact') $errored = 0; if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children xCAT::MsgUtils->trace($verbose_on_off, "d", "grub2: issue runendpre request"); @@ -859,6 +873,16 @@ sub process_request { return; } } + + # Return error codes if there are failed nodes + if (%failurenodes) { + my $rsp; + $rsp->{errorcode}->[0] = 1; + $rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n"; + $callback->($rsp); + return; + } + } #---------------------------------------------------------------------------- diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 7b9487da3..89c02fd3b 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -79,7 +79,7 @@ sub setstate { =pod - This function will manipulate the yaboot structure to match what the noderes/chain tables indicate the node should be booting. + This function will manipulate the petitboot structure to match what the noderes/chain tables indicate the node should be booting. =cut @@ -169,18 +169,19 @@ sub setstate { } } - my $pcfg; - unless (-d "$tftpdir/petitboot") { - mkpath("$tftpdir/petitboot"); + my $bootloader_root = "$tftpdir/petitboot"; + unless (-d "$bootloader_root") { + mkpath("$bootloader_root"); } my $nodemac; my $cref = $chainhash{$node}->[0]; #$chaintab->getNodeAttribs($node,['currstate']); + my $pcfg; # remove the old boot configuration file and create a new one, but only if not offline directive - unlink($tftpdir . "/petitboot/" . $node); + unlink("$bootloader_root/" . $node); if ($cref and $cref->{currstate} ne "offline") { - open($pcfg, '>', $tftpdir . "/petitboot/" . $node); + open($pcfg, '>', "$bootloader_root/" . $node); print $pcfg "#" . $cref->{currstate} . "\n"; } $normalnodes{$node} = 1; #Assume a normal netboot (well, normal dhcp, @@ -216,18 +217,13 @@ sub setstate { print $pcfg "\tappend \"" . $kern->{kcmdline} . "\"\n"; } close($pcfg); - my $inetn = xCAT::NetworkUtils->getipaddr($node); - unless ($inetn) { - syslog("local1|err", "xCAT unable to resolve IP for $node in petitboot plugin"); - return; - } } else { #TODO: actually, should possibly default to xCAT image? #print $pcfg "bye\n"; close($pcfg); } my $ip = xCAT::NetworkUtils->getipaddr($node); unless ($ip) { - syslog("local1|err", "xCAT unable to resolve IP in petitboot plugin"); + syslog("local1|err", "xCAT unable to resolve IP for $node in petitboot plugin"); return; } @@ -236,9 +232,9 @@ sub setstate { $pname = uc($pname); # remove the old boot configuration file and copy (link) a new one, but only if not offline directive - unlink($tftpdir . "/" . $pname); + unlink("$tftpdir/" . $pname); if ($cref and $cref->{currstate} ne "offline") { - link($tftpdir . "/petitboot/" . $node, $tftpdir . "/" . $pname); + link("$bootloader_root/" . $node, "$tftpdir/" . $pname); } return; } @@ -282,12 +278,14 @@ sub preprocess_request { #use Getopt::Long; my $HELP; + my $ALLFLAG; my $VERSION; my $VERBOSE; Getopt::Long::Configure("bundling"); Getopt::Long::Configure("pass_through"); if (!GetOptions('h|?|help' => \$HELP, 'v|version' => \$VERSION, + 'a' =>\$ALLFLAG, 'V' => \$VERBOSE #>>>>>>>used for trace log>>>>>>> )) { if ($usage{$command}) { @@ -333,6 +331,13 @@ sub preprocess_request { return; } + if ($ARGV[0] ne "stat" && $ALLFLAG) { + my %rsp; + $rsp{error}->[0] = "'-a' could only be used with 'stat' subcommand."; + $rsp{errorcode}->[0] = 1; + $callback1->(\%rsp); + return; + } #Assume shared tftp directory for boring people, but for cool people, help sync up tftpdirectory contents when #if they specify no sharedtftp in site table @@ -345,21 +350,43 @@ sub preprocess_request { my @SN; my @CN; xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN); - if ((@SN > 0) && (@CN > 0)) { # there are both SN and CN - my $rsp; - $rsp->{data}->[0] = -"Nodeset was run with a noderange containing both service nodes and compute nodes. This is not valid. You must submit with either compute nodes in the noderange or service nodes. \n"; - xCAT::MsgUtils->message("E", $rsp, $callback1); - return; - + unless (($args[0] eq 'stat') or ($args[0] eq 'enact')) { + if ((@SN > 0) && (@CN > 0)) { # there are both SN and CN + my %rsp; + $rsp{errorcode}->[0] = 1; + $rsp{error}->[0] = + "Nodeset was run with a noderange containing both service nodes and compute nodes. This is not valid. You must submit with either compute nodes in the noderange or service nodes. \n"; + $callback1->(\%rsp); + return; + } } $req->{'_disparatetftp'} = [1]; if ($req->{inittime}->[0]) { return [$req]; } - if (@CN > 0) { # if compute nodes broadcast to all servicenodes - return xCAT::Scope->get_broadcast_scope_with_parallel($req); + if (@CN > 0) { # if compute nodes only, then broadcast to servic enodes + + my @sn = xCAT::ServiceNodeUtils->getSNList(); + unless ( @sn > 0 ) { + return xCAT::Scope->get_parallel_scope($req) + } + + my $mynodeonly = 0; + my @entries = xCAT::TableUtils->get_site_attribute("disjointdhcps"); + my $t_entry = $entries[0]; + if (defined($t_entry)) { + $mynodeonly = $t_entry; + } + $req->{'_disjointmode'} = [$mynodeonly]; + xCAT::MsgUtils->trace(0, "d", "petitboot: disjointdhcps=$mynodeonly"); + + if ($mynodeonly == 0 || $ALLFLAG) { # broadcast to all service nodes + return xCAT::Scope->get_broadcast_scope_with_parallel($req, \@sn); + } + + my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@CN, "xcat", "MN"); + return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash); } } # Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs. @@ -374,16 +401,16 @@ sub process_request { $sub_req = shift; my $command = $request->{command}->[0]; %breaknetbootnodes = (); - %normalnodes = (); + %normalnodes = (); # It will be fill-up by method: setstate. #>>>>>>>used for trace log start>>>>>>> my @args = (); my %opt; my $verbose_on_off = 0; - if (ref($::request->{arg})) { - @args = @{ $::request->{arg} }; + if (ref($request->{arg})) { + @args = @{ $request->{arg} }; } else { - @args = ($::request->{arg}); + @args = ($request->{arg}); } @ARGV = @args; GetOptions('V' => \$opt{V}); @@ -394,7 +421,9 @@ sub process_request { if ($::XCATSITEVALS{"httpmethod"}) { $httpmethod = $::XCATSITEVALS{"httpmethod"}; } if ($::XCATSITEVALS{"httpport"}) { $httpport = $::XCATSITEVALS{"httpport"}; } - my @nodes; + my @hostinfo = xCAT::NetworkUtils->determinehostname(); + $::myxcatname = $hostinfo[-1]; + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: running on $::myxcatname"); my @rnodes; if (ref($request->{node})) { @rnodes = @{ $request->{node} }; @@ -408,104 +437,101 @@ sub process_request { return; } - my @hostinfo = xCAT::NetworkUtils->determinehostname(); - $::myxcatname = $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 %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"); - #print Dumper($sn_hash); - my %managed = (); - foreach (keys %$sn_hash) { - if (exists($iphash{$_})) { - my $cur_xmaster = $_; - foreach (@{ $sn_hash->{$cur_xmaster} }) { $managed{$_} = 1; } - last; + if ($args[0] eq 'stat') { + my $noderestab = xCAT::Table->new('noderes'); #in order to detect per-node tftp directories + my %nrhash = %{ $noderestab->getNodesAttribs(\@rnodes, [qw(tftpdir)]) }; + foreach my $node (@rnodes) { + my %response; + my $tftpdir; + if ($nrhash{$node}->[0] and $nrhash{$node}->[0]->{tftpdir}) { + $tftpdir = $nrhash{$node}->[0]->{tftpdir}; + } else { + $tftpdir = $globaltftpdir; } + $response{node}->[0]->{name}->[0] = $node; + $response{node}->[0]->{data}->[0] = getstate($node, $tftpdir); + $callback->(\%response); } - - my $notsamenet_nodes_err = ''; - my $notsamenet_nodes_warn = ''; - - 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{$_}); - if ($req2manage) { - push @unmanagednodes, $_; - # quick pass through if disjoint is set. - next if ( $mynodeonly == 1 && xCAT::Utils->isMN() != 1 ); - } - - # Only handle its boot configuration files if the node in same subnet - if (xCAT::NetworkUtils->nodeonmynet($_)) { - push @nodes, $_; - } elsif ( $req2manage ) { - # report error when it is under my control but I cannot handle it. - $notsamenet_nodes_err .= " $_"; - } - else { - $notsamenet_nodes_warn .= " $_"; - } - } - - if ( $mynodeonly == 1 && scalar (@unmanagednodes) > 0 && xCAT::Utils->isMN() != 1) { - my $str_umnodes = join(" ", @unmanagednodes); - xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: unmanaged nodes are $str_umnodes"); - } - - if ( $notsamenet_nodes_err || $notsamenet_nodes_warn ) { - my $msg = "petitboot configuration file was not created "; - $msg .= "on $::myxcatname " if ( $::myxcatname ); - $msg .= "for below nodes because sharedtftp attribute is not set and the nodes are not on same network as this xcatmaster: "; - xCAT::MsgUtils->message("S", $msg . $notsamenet_nodes_warn . $notsamenet_nodes_err); - # For managed children, need to report error - if ( $notsamenet_nodes_err ) { - my $rsp; - $rsp->{data}->[0] = $msg . $notsamenet_nodes_err; - xCAT::MsgUtils->message("E", $rsp, $callback); - } - } - } else { - @nodes = @rnodes; - } - - #>>>>>>>used for trace log>>>>>>> - 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 - unless (@nodes) { - xCAT::MsgUtils->message("S", "xCAT: petitboot netboot: no valid nodes. Stop the operation on this server."); return; } - if (ref($request->{arg})) { - @args = @{ $request->{arg} }; + my @nodes = (); + # Filter those nodes which have bad DNS: not resolvable or inconsistent IP + my %failurenodes = (); + my %preparednodes = (); + foreach (@rnodes) { + my $ipret = xCAT::NetworkUtils->checkNodeIPaddress($_); + my $errormsg = $ipret->{'error'}; + my $nodeip = $ipret->{'ip'}; + if ($errormsg) {# Add the node to failure set + xCAT::MsgUtils->trace(0, "E", "petitboot: IP address of $_ is $nodeip. $errormsg"); + unless ($nodeip) { + $failurenodes{$_} = 1; + } + } + if ($nodeip) { + $preparednodes{$_} = $nodeip; + } + } + + #if not shared tftpdir, then filter, otherwise, set up everything + if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command + # Filter those nodes not in the same subnet, and print error message in log file. + foreach (keys %preparednodes) { + # Only handle its boot configuration files if the node in same subnet + if (xCAT::NetworkUtils->nodeonmynet($preparednodes{$_})) { + push @nodes, $_; + } else { + xCAT::MsgUtils->trace(0, "W", "petitboot: configuration file was not created for [$_] because the node is not on the same network as this server"); + delete $preparednodes{$_}; + } + } } else { - @args = ($request->{arg}); + @nodes = keys %preparednodes; + } + + 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 + unless (@nodes) { + xCAT::MsgUtils->message("S", "xCAT: petitboot netboot: no valid nodes. Stop the operation on this server."); + + # It must be an error if my managed nodes are not handled. + if (xCAT::Utils->isMN() != 1 && $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; } + + # 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"); + return; + } + } + 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.\n"; + $callback->($rsp); + return; } #now run the begin part of the prescripts - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + unless ($args[0] eq '') { # or $args[0] eq 'enact') { $errored = 0; if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handle my own children xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: the call is distrubuted to the service node already, so only need to handle my own children"); @@ -517,7 +543,7 @@ sub process_request { xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: nodeset did not distribute to the service node"); xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue runbeginpre request"); $sub_req->({ command => ['runbeginpre'], - node => \@rnodes, + node => \@nodes, arg => [ $args[0] ] }, \&pass_along); } if ($errored) { @@ -535,7 +561,7 @@ sub process_request { if (!$inittime) { $inittime = 0; } my %bphash; - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + unless ($args[0] eq '') { # or $args[0] eq 'enact') { $errored = 0; xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue setdestiny request"); $sub_req->({ command => ['setdestiny'], @@ -561,6 +587,8 @@ sub process_request { }); xCAT::MsgUtils->message("S", "xCAT: petitboot netboot: clear node(s): @nodes boot device setting."); } + + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: starting to handle configuration..."); my $chaintab = xCAT::Table->new('chain', -create => 1); my $chainhash = $chaintab->getNodesAttribs(\@nodes, ['currstate']); my $noderestab = xCAT::Table->new('noderes', -create => 1); @@ -584,13 +612,10 @@ sub process_request { $tftpdir = $globaltftpdir; } $response{node}->[0]->{name}->[0] = $_; - if ($args[0] eq 'stat') { - $response{node}->[0]->{data}->[0] = getstate($_, $tftpdir); - $callback->(\%response); - } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate + if ($args[0]) { # send it on to the destiny plugin, then setstate my $ent = $typehash->{$_}->[0]; my $osimgname = $ent->{'provmethod'}; - my $linuximghash = $linuximghash = $linuximgtab->getAttribs({ imagename => $osimgname }, 'boottarget', 'addkcmdline'); + my $linuximghash = $linuximgtab->getAttribs({ imagename => $osimgname }, 'boottarget', 'addkcmdline'); ($rc, $errstr) = setstate($_, \%bphash, $chainhash, $machash, $tftpdir, $nodereshash, $linuximghash); @@ -601,11 +626,10 @@ sub process_request { } } } # end of foreach node + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: Finish to handle configurations"); my @normalnodeset = keys %normalnodes; my @breaknetboot = keys %breaknetbootnodes; - - #print "yaboot:inittime=$inittime; normalnodeset=@normalnodeset; breaknetboot=@breaknetboot\n"; my %osimagenodehash; for my $nn (@normalnodeset) { @@ -616,7 +640,7 @@ sub process_request { } #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time - unless (($args[0] eq 'stat') || ($inittime) || ($args[0] eq 'offline')) { + unless (($inittime) || ($args[0] eq 'offline')) { #dhcp stuff my $do_dhcpsetup = 1; @@ -626,16 +650,17 @@ sub process_request { if ($t_entry =~ /0|n|N/) { $do_dhcpsetup = 0; } } if ($do_dhcpsetup) { - if ($::request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command - xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue makedhcp request"); - $sub_req->({ command => ['makedhcp'], arg => ['-l'], - node => \@normalnodeset }, $callback); - } else { - xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue makedhcp request"); - $sub_req->({ command => ['makedhcp'], - node => \@normalnodeset }, $callback); - } + my @parameter; + push @parameter, '-l' if ($::request->{'_disparatetftp'}->[0]); + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue makedhcp request"); + + $sub_req->({ command => ['makedhcp'], + arg => \@parameter, + node => \@normalnodeset }, $callback); + } else { + xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: dhcpsetup=$do_dhcpsetup"); } + } if ($args[0] eq 'offline') { @@ -645,7 +670,7 @@ sub process_request { } #now run the end part of the prescripts - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') + unless ($args[0] eq '') { # or $args[0] eq 'enact') $errored = 0; if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue runendpre request"); @@ -655,7 +680,7 @@ sub process_request { } else { #nodeset did not distribute to the service node, here we need to let runednpre to distribute the nodes to their masters xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue runendpre request"); $sub_req->({ command => ['runendpre'], - node => \@rnodes, + node => \@nodes, arg => [ $args[0] ] }, \&pass_along); } if ($errored) { @@ -666,6 +691,15 @@ sub process_request { return; } } + + # Return error codes if there are failed nodes + if (%failurenodes) { + 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.\n"; + $callback->($rsp); + return; + } } #---------------------------------------------------------------------------- diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 6464a70c3..da8d8d467 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -331,10 +331,12 @@ sub preprocess_request { Getopt::Long::Configure("bundling"); Getopt::Long::Configure("pass_through"); my $HELP; + my $ALLFLAG; my $VERSION; my $VERBOSE; if (!GetOptions('h|?|help' => \$HELP, 'v|version' => \$VERSION, + 'a' =>\$ALLFLAG, 'V' => \$VERBOSE #>>>>>>>used for trace log>>>>>>> )) { if ($usage{$command}) { @@ -380,6 +382,13 @@ sub preprocess_request { return; } + if ($ARGV[0] ne "stat" && $ALLFLAG) { + my %rsp; + $rsp{error}->[0] = "'-a' could only be used with 'stat' subcommand."; + $rsp{errorcode}->[0] = 1; + $callback1->(\%rsp); + return; + } #Assume shared tftp directory for boring people, but for cool people, help sync up tftpdirectory contents when #they specify no sharedtftp in site table @@ -394,12 +403,12 @@ sub preprocess_request { xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN); unless (($args[0] eq 'stat') or ($args[0] eq 'enact')) { # mix is ok for these options if ((@SN > 0) && (@CN > 0)) { # there are both SN and CN - my $rsp; - $rsp->{data}->[0] = + my %rsp; + $rsp{errorcode}->[0] = 1; + $rsp{error}->[0] = "Nodeset was run with a noderange containing both service nodes and compute nodes. This is not valid. You must submit with either compute nodes in the noderange or service nodes. \n"; - xCAT::MsgUtils->message("E", $rsp, $callback1); + $callback1->(\%rsp); return; - } } @@ -408,7 +417,27 @@ sub preprocess_request { return [$req]; } if (@CN > 0) { # if compute nodes broadcast to all servicenodes - return xCAT::Scope->get_broadcast_scope_with_parallel($req); + + my @sn = xCAT::ServiceNodeUtils->getSNList(); + unless ( @sn > 0 ) { + return xCAT::Scope->get_parallel_scope($req) + } + + my $mynodeonly = 0; + my @entries = xCAT::TableUtils->get_site_attribute("disjointdhcps"); + my $t_entry = $entries[0]; + if (defined($t_entry)) { + $mynodeonly = $t_entry; + } + $req->{'_disjointmode'} = [$mynodeonly]; + xCAT::MsgUtils->trace(0, "d", "xnba: disjointdhcps=$mynodeonly"); + + if ($mynodeonly == 0 || $ALLFLAG) { # broadcast to all service nodes + return xCAT::Scope->get_broadcast_scope_with_parallel($req, \@sn); + } + + my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@CN, "xcat", "MN"); + return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash); } } # Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs. @@ -438,12 +467,14 @@ sub process_request { #>>>>>>>used for trace log end>>>>>>> + my @hostinfo = xCAT::NetworkUtils->determinehostname(); + $::myxcatname = $hostinfo[-1]; + xCAT::MsgUtils->trace(0, "d", "xnba: running on $::myxcatname"); if (ref($::XNBA_request->{node})) { @rnodes = @{ $::XNBA_request->{node} }; } else { if ($::XNBA_request->{node}) { @rnodes = ($::XNBA_request->{node}); } } - unless (@rnodes) { if ($usage{ $::XNBA_request->{command}->[0] }) { $::XNBA_callback->({ data => $usage{ $::XNBA_request->{command}->[0] } }); @@ -451,104 +482,101 @@ sub process_request { return; } - my @hostinfo = xCAT::NetworkUtils->determinehostname(); - $::myxcatname = $hostinfo[-1]; - xCAT::MsgUtils->trace(0, "d", "xnba: running on $::myxcatname"); + if ($args[0] eq 'stat') { + my $noderestab = xCAT::Table->new('noderes'); #in order to detect per-node tftp directories + my %nrhash = %{ $noderestab->getNodesAttribs(\@rnodes, [qw(tftpdir)]) }; + foreach my $node (@rnodes) { + my %response; + my $tftpdir; + if ($nrhash{$node}->[0] and $nrhash{$node}->[0]->{tftpdir}) { + $tftpdir = $nrhash{$node}->[0]->{tftpdir}; + } else { + $tftpdir = $globaltftpdir; + } + $response{node}->[0]->{name}->[0] = $node; + $response{node}->[0]->{data}->[0] = getstate($node, $tftpdir); + $::XNBA_callback->(\%response); + } + return; + } - my @unmanagednodes = (); - #if not shared tftpdir, then broadcast, otherwise, set up everything + my @nodes = (); + # Filter those nodes which have bad DNS: not resolvable or inconsistent IP + my %failurenodes = (); + my %preparednodes = (); + foreach (@rnodes) { + my $ipret = xCAT::NetworkUtils->checkNodeIPaddress($_); + my $errormsg = $ipret->{'error'}; + my $nodeip = $ipret->{'ip'}; + if ($errormsg) {# Add the node to failure set + xCAT::MsgUtils->trace(0, "E", "xnba: IP address of $_ is $nodeip. $errormsg"); + unless ($nodeip) { + $failurenodes{$_} = 1; + } + } + if ($nodeip) { + $preparednodes{$_} = $nodeip; + } + } + + #if not shared tftpdir, then filter, otherwise, set up everything if ($::XNBA_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command - @nodes = (); - - 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; - } - } - - my $notsamenet_nodes_err = ''; - my $notsamenet_nodes_warn = ''; - - 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{$_}); - if ($req2manage) { - push @unmanagednodes, $_; - # quick pass through if disjoint is set. - next if ( $mynodeonly == 1 && xCAT::Utils->isMN() != 1 ); - } - + # Filter those nodes not in the same subnet, and print error message in log file. + foreach (keys %preparednodes) { # Only handle its boot configuration files if the node in same subnet - if (xCAT::NetworkUtils->nodeonmynet($_)) { + if (xCAT::NetworkUtils->nodeonmynet($preparednodes{$_})) { push @nodes, $_; - } elsif ( $req2manage ) { - # report error when it is under my control but I cannot handle it. - $notsamenet_nodes_err .= " $_"; - } - else { - $notsamenet_nodes_warn .= " $_"; - } - } - - if ( $mynodeonly == 1 && scalar (@unmanagednodes) > 0 && xCAT::Utils->isMN() != 1) { - my $str_umnodes = join(" ", @unmanagednodes); - xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: unmanaged nodes are $str_umnodes"); - } - - if ( $notsamenet_nodes_err || $notsamenet_nodes_warn ) { - my $msg = "xnba configuration file was not created "; - $msg .= "on $::myxcatname " if ( $::myxcatname ); - $msg .= "for below nodes because sharedtftp attribute is not set and the nodes are not on same network as this xcatmaster: "; - xCAT::MsgUtils->message("S", $msg . $notsamenet_nodes_warn . $notsamenet_nodes_err); - # For managed children, need to report error - if ( $notsamenet_nodes_err ) { - my $rsp; - $rsp->{data}->[0] = $msg . $notsamenet_nodes_err; - xCAT::MsgUtils->message("E", $rsp, $::XNBA_callback); + } else { + xCAT::MsgUtils->trace(0, "W", "xnba: configuration file was not created for [$_] because the node is not on the same network as this server"); + delete $preparednodes{$_}; } } } else { - @nodes = @rnodes; + @nodes = keys %preparednodes; } - #>>>>>>>used for trace log>>>>>>> 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 unless (@nodes) { xCAT::MsgUtils->message("S", "xCAT: xnba netboot: no valid nodes. Stop the operation on this server."); + + # It must be an error if my managed nodes are not handled. + if (xCAT::Utils->isMN() != 1 && $::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; } + + # 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"); + return; + } + } + 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.\n"; + $::XNBA_callback->($rsp); return; } - if (ref($::XNBA_request->{arg})) { - @args = @{ $::XNBA_request->{arg} }; - } else { - @args = ($::XNBA_request->{arg}); - } - #now run the begin part of the prescripts - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + unless ($args[0] eq '') { # or $args[0] eq 'enact') { $errored = 0; if ($::XNBA_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: the call is distrubuted to the service node already, so only need to handles my own children"); @@ -560,7 +588,7 @@ sub process_request { xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: nodeset did not distribute to the service node"); xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue runbeginpre request"); $sub_req->({ command => ['runbeginpre'], - node => \@rnodes, + node => \@nodes, arg => [ $args[0] ] }, \&pass_along); } if ($errored) { @@ -592,7 +620,7 @@ sub process_request { if (!$inittime) { $inittime = 0; } my %bphash; - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + unless ($args[0] eq '') { # or $args[0] eq 'enact') { $errored = 0; xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue setdestiny request"); $sub_req->({ command => ['setdestiny'], @@ -607,6 +635,7 @@ sub process_request { } } + xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: starting to handle configuration..."); #Time to actually configure the nodes, first extract database data with the scalable calls my $chaintab = xCAT::Table->new('chain'); my $noderestab = xCAT::Table->new('noderes'); #in order to detect per-node tftp directories @@ -634,10 +663,7 @@ sub process_request { mkpath($tftpdir . "/xcat/xnba/nodes/"); my %response; $response{node}->[0]->{name}->[0] = $_; - if ($args[0] eq 'stat') { - $response{node}->[0]->{data}->[0] = getstate($_, $tftpdir); - $::XNBA_callback->(\%response); - } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate + if ($args[0]) { # Send it on to the destiny plugin, then setstate my $rc; my $errstr; my $ent = $typehash->{$_}->[0]; @@ -662,43 +688,36 @@ sub process_request { } } } + xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: Finish to handle configurations"); # for offline operation, remove the dhcp entries if ($args[0] eq 'offline') { $sub_req->({ command => ['makedhcp'], arg => ['-d'], node => \@nodes }, $::XNBA_callback); } - #dhcp stuff -- inittime is set when xcatd on sn is started - unless (($args[0] eq 'stat') || ($inittime) || ($args[0] eq 'offline')) { + unless (($inittime) || ($args[0] eq 'offline')) { my $do_dhcpsetup = 1; - - #my $sitetab = xCAT::Table->new('site'); - #if ($sitetab) { - #(my $ref) = $sitetab->getAttribs({key => 'dhcpsetup'}, 'value'); my @entries = xCAT::TableUtils->get_site_attribute("dhcpsetup"); my $t_entry = $entries[0]; if (defined($t_entry)) { if ($t_entry =~ /0|n|N/) { $do_dhcpsetup = 0; } } - - #} - if ($do_dhcpsetup) { - if ($::XNBA_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command - xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue makedhcp request"); - $sub_req->({ command => ['makedhcp'], arg => ['-l'], - node => \@nodes }, $::XNBA_callback); - } else { - xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue makedhcp request"); - $sub_req->({ command => ['makedhcp'], - node => \@nodes }, $::XNBA_callback); - } + my @parameter; + push @parameter, '-l' if ($::request->{'_disparatetftp'}->[0]); + xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue makedhcp request"); + + $sub_req->({ command => ['makedhcp'], + arg => \@parameter, + node => \@nodes }, $::XNBA_callback); + } else { + xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: dhcpsetup=$do_dhcpsetup"); } } #now run the end part of the prescripts - unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') + unless ($args[0] eq '') { # or $args[0] eq 'enact') $errored = 0; if ($::XNBA_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handle my own children xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue runendpre request"); @@ -708,7 +727,7 @@ sub process_request { } else { #nodeset did not distribute to the service node, here we need to let runednpre to distribute the nodes to their masters xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue runendpre request"); $sub_req->({ command => ['runendpre'], - node => \@rnodes, + node => \@nodes, arg => [ $args[0] ] }, \&pass_along); } if ($errored) { @@ -719,6 +738,15 @@ sub process_request { } } + # Return error codes if there are failed nodes + if (%failurenodes) { + 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.\n"; + $::XNBA_callback->($rsp); + return; + } + } From de9b4b575fcd625163a00c0c10003f48ca23e647 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Mon, 24 Jul 2017 10:18:30 -0400 Subject: [PATCH 05/35] Support passwordless ssh for pdu --- xCAT-server/lib/xcat/plugins/pdu.pm | 127 ++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index e79b906e0..83d6ad888 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -36,6 +36,8 @@ use Class::Struct; use XML::Simple; use Storable qw(dclone); use SNMP; +use Expect; +use Net::Ping; my $VERBOSE = 0; my %allerrornodes = (); @@ -62,6 +64,7 @@ sub handled_commands rpower => ["nodehm:mgt","pduoutlet:pdu=\.\*"], rinv => ["nodehm:mgt"], nodeset => ["nodehm:mgt"], + rspconfig => ["nodehm:mgt"], pdudiscover => "pdu", }; } @@ -170,6 +173,13 @@ sub process_request } } } + }elsif($command eq "rspconfig") { + my $subcmd = $exargs[0]; + if ($subcmd eq 'sshcfg') { + process_sshcfg($noderange, $subcmd, $callback); + } else { + $callback->({ errorcode => [1],error => "The input $command $subcmd is not support for pdu"}); + } }elsif($command eq "pdudiscover") { process_pdudiscover($request, $subreq, $callback); }elsif($command eq "nodeset") { @@ -457,6 +467,123 @@ sub connectTopdu { } +sub process_sshcfg { + my $noderange = shift; + my $subcmd = shift; + my $callback = shift; + + my $password = "password8"; + my $userid = "root"; + my $timeout = 10; + my $keyfile = "/root/.ssh/id_rsa.pub"; + my $rootkey = `cat /root/.ssh/id_rsa.pub`; + my $cmd; + + my $nodetab = xCAT::Table->new('hosts'); + my $nodehash = $nodetab->getNodesAttribs($noderange,['ip','otherinterfaces']); + + foreach my $pdu (@$noderange) { + my $msg = " process_sshcfg"; + xCAT::SvrUtils::sendmsg($msg, $callback, $pdu, %allerrornodes); + + #remove old host key from /root/.ssh/known_hosts + $cmd = `ssh-keygen -R $pdu`; + + my $static_ip = $nodehash->{$pdu}->[0]->{ip}; + my $discover_ip = $nodehash->{$pdu}->[0]->{otherinterfaces}; + my $ssh_ip; + + my $p = Net::Ping->new(); + if ($p->ping($static_ip)) { + $ssh_ip = $static_ip; + } elsif ($p->ping($discover_ip)) { + $ssh_ip = $discover_ip; + } else { + $msg = " is not reachable"; + xCAT::SvrUtils::sendmsg($msg, $callback, $pdu, %allerrornodes); + next; + } + + my ($exp, $errstr) = session_connect($ssh_ip, $userid, $password, $timeout); + if (!defined $exp) { + $msg = " Failed to connect $errstr"; + xCAT::SvrUtils::sendmsg($msg, $callback, $pdu, %allerrornodes); + next; + } + + my $ret; + my $err; + + ($ret, $err) = session_exec($exp, "mkdir -p /home/root/.ssh"); + ($ret, $err) = session_exec($exp, "chmod 700 /home/root/.ssh"); + ($ret, $err) = session_exec($exp, "echo \"$rootkey\" >/home/root/.ssh/authorized_keys"); + ($ret, $err) = session_exec($exp, "chmod 644 /home/root/.ssh/authorized_keys"); + #config dhcp ip address to static + if ($ssh_ip eq $discover_ip) { + # ($ret, $err) = session_exec($exp, "ifconfig eth0 $static_ip"); + } + + $exp->hard_close(); + } + + return; +} + +sub session_connect { + my $server = shift; + my $userid = shift; + my $password = shift; + my $timeout = shift; + + my $ssh = Expect->new; + my $command = 'ssh'; + my @parameters = ($userid . "@" . $server); + + $ssh->debug(0); + $ssh->log_stdout(0); # suppress stdout output.. + $ssh->slave->stty(qw(sane -echo)); + + unless ($ssh->spawn($command, @parameters)) + { + my $err = $!; + $ssh->soft_close(); + my $rsp; + return(undef, "unable to run command $command $err\n"); + } + + $ssh->expect($timeout, + [ "-re", qr/WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED/, sub {die "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!\n"; } ], + [ "-re", qr/\(yes\/no\)\?\s*$/, sub { $ssh->send("yes\n"); exp_continue; } ], + [ "-re", qr/ password:/, sub {$ssh->send("$password\n"); exp_continue; } ], + [ "-re", qr/:~\$/, sub { $ssh->send("sudo su\n"); exp_continue; } ], + [ "-re", qr/.*#/, sub { $ssh->clear_accum(); } ], + [ timeout => sub { die "No login.\n"; } ] + ); + $ssh->clear_accum(); + return ($ssh); +} + + +sub session_exec { + my $exp = shift; + my $cmd = shift; + my $timeout = shift; + my $prompt = shift; + + $timeout = 10 unless defined $timeout; + $prompt = qr/.*#/ unless defined $prompt; + + + $exp->clear_accum(); + $exp->send("$cmd\n"); + my ($mpos, $merr, $mstr, $mbmatch, $mamatch) = $exp->expect(6, "-re", $prompt); + + if (defined $merr) { + return(undef,$merr); + } + return($mbmatch); +} + sub process_pdudiscover { my $request = shift; my $sub_req = shift; From 9fd5f98bf2b22658a8f091f3d66d7c9530f3864a Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 24 Jul 2017 11:48:46 -0400 Subject: [PATCH 06/35] Supermicro rflash wait for ready RC from BMC --- xCAT-server/lib/xcat/plugins/ipmi.pm | 56 +++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 3627df69b..16a213695 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1705,6 +1705,9 @@ sub calc_ipmitool_version { # zz_retry: minimum number of 00 to receive before exiting # sessdata: session data for display # verbose: verbose output +# use_rc: Some machines, like IBM Power S822LC for Big Data (Supermicro), do not return +# a "00" ready string from calling ipmi raw command. Instead they return RC=0. This +# flag tells the check_bmc_status_with_ipmitool() to check the RC instead of "00" string # Returns: # 1 when bmc is up # 0 when no response from bmc @@ -1716,11 +1719,19 @@ sub check_bmc_status_with_ipmitool { my $zz_retry = shift; my $sessdata = shift; my $verbose = shift; + my $use_rc = shift; my $count = 0; my $zz_count = 0; my $bmc_response = 0; my $cmd = $pre_cmd . " raw 0x3a 0x0a"; + my $bmc_ready_code = "00"; + my $code_type = "ready"; + if ($use_rc) { + $cmd = $pre_cmd . " raw 0x3a 0x0a >> /dev/null 2>&1 ; echo \$?"; + $bmc_ready_code = "0"; + $code_type = "return"; + } # BMC response of " c0" means BMC still running IPL # BMC response of " 00" means ready to flash # @@ -1730,18 +1741,18 @@ sub check_bmc_status_with_ipmitool { # interrupts it. while ($count < $retry) { $bmc_response = xCAT::Utils->runcmd($cmd, -1); - if ($bmc_response =~ /00/) { + if ($bmc_response =~ /$bmc_ready_code/) { if ($zz_count > $zz_retry) { # zero-zero ready code was received for $zz_count iterations - good to exit if ($verbose) { - xCAT::SvrUtils::sendmsg("Received BMC ready code 00 for $zz_count iterations - BMC is ready.", $callback, $sessdata->{node}, %allerrornodes); + xCAT::SvrUtils::sendmsg("Received BMC $code_type code $bmc_ready_code for $zz_count iterations - BMC is ready.", $callback, $sessdata->{node}, %allerrornodes); } return 1; } else { # check to make sure zero-zero is received again if ($verbose) { - xCAT::SvrUtils::sendmsg("($zz_count) BMC ready code - 00", $callback, $sessdata->{node}, %allerrornodes); + xCAT::SvrUtils::sendmsg("($zz_count) BMC $code_type code - $bmc_ready_code", $callback, $sessdata->{node}, %allerrornodes); } $zz_count++; } @@ -1751,7 +1762,7 @@ sub check_bmc_status_with_ipmitool { # zero-zero was received before, but now we get something else. # reset the zero-zero counter to make sure we get $zz_count iterations of zero-zero if ($verbose) { - xCAT::SvrUtils::sendmsg("Resetting counter because BMC ready code - $bmc_response", $callback, $sessdata->{node}, %allerrornodes); + xCAT::SvrUtils::sendmsg("Resetting counter because BMC $code_type code - $bmc_response", $callback, $sessdata->{node}, %allerrornodes); } $zz_count = 0; } @@ -1760,7 +1771,7 @@ sub check_bmc_status_with_ipmitool { $count++; } if ($verbose) { - xCAT::SvrUtils::sendmsg("Never received 00 code after $count retries - BMC not ready.", $callback, $sessdata->{node}, %allerrornodes); + xCAT::SvrUtils::sendmsg("Never received $code_type code $bmc_ready_code after $count retries - BMC not ready.", $callback, $sessdata->{node}, %allerrornodes); } return 0; } @@ -2005,6 +2016,22 @@ sub do_firmware_update { # the specified data directory xCAT::SvrUtils::sendmsg("rflash started, Please wait...", $callback, $sessdata->{node}); + # step 1 power off + $cmd = $pre_cmd . " chassis power off"; + if ($verbose) { + xCAT::SvrUtils::sendmsg("Preparing to upgrade firmware, powering chassis off...", $callback, $sessdata->{node}, %allerrornodes); + } + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + $exit_with_error_func->($sessdata->{node}, $callback, + "Running ipmitool command $cmd failed: $output"); + } + unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 10, 2, $sessdata, $verbose, 1)) { + $exit_with_error_func->($sessdata->{node}, $callback, + "Timeout to check the bmc status"); + } + + # step 2 update BMC file or PNOR file, or both if ($bmc_file) { # BMC file was found in data directory, run update with it my $pUpdate_bmc_cmd = "$pUpdate_directory/pUpdate -f $bmc_file -i lan -h $bmc_addr -u $bmc_userid -p $bmc_password >".$rflash_log_file." 2>&1"; @@ -2018,10 +2045,12 @@ sub do_firmware_update { $exit_with_error_func->($sessdata->{node}, $callback, "Error running command $pUpdate_bmc_cmd"); } - if ($verbose) { - xCAT::SvrUtils::sendmsg([ 0, "Waiting for BMC to reboot (2 min)..." ], $callback, $sessdata->{node}); + # Wait for BMC to reboot before continuing to next step. + # Since this is a IBM Power S822LC for Big Data (Supermicro) machine, use RC to check if ready + unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 10, $sessdata, $verbose, 1)) { + $exit_with_error_func->($sessdata->{node}, $callback, + "Timeout to check the bmc status"); } - sleep (120); } @@ -2039,8 +2068,15 @@ sub do_firmware_update { "Error running command $pUpdate_pnor_cmd"); } } + # step 3 power on + $cmd = $pre_cmd . " chassis power on"; + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + $exit_with_error_func->($sessdata->{node}, $callback, + "Running ipmitool command $cmd failed: $output"); + } - $exit_with_success_func->($sessdata->{node}, $callback, "Firmware updated"); + $exit_with_success_func->($sessdata->{node}, $callback, "Firmware updated, powering chassis on to populate FRU information..."); } if (($hpm_data_hash{deviceID} ne $sessdata->{device_id}) || @@ -2339,7 +2375,7 @@ sub rflash { $sessdata->{subcommand} = "check"; # support verbose options for ipmitool command } elsif ($opt !~ /.*\.hpm$/i && $opt !~ /^-V{1,4}$|^--buffersize=|^--retry=|^-d=/) { - $callback->({ error => "The option $opt is not supported", + $callback->({ error => "The option $opt is not supported or invalid update file specified", errorcode => 1 }); return; } From 86e4b9ccb35f7b41d2a1ea8263b364cb90e2dbc6 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 25 Jul 2017 10:18:04 -0400 Subject: [PATCH 07/35] modify sshcfg --- xCAT-server/lib/xcat/plugins/pdu.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index 83d6ad888..facdc5ff8 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -487,7 +487,8 @@ sub process_sshcfg { xCAT::SvrUtils::sendmsg($msg, $callback, $pdu, %allerrornodes); #remove old host key from /root/.ssh/known_hosts - $cmd = `ssh-keygen -R $pdu`; + $cmd = "ssh-keygen -R $pdu"; + my $result = xCAT::Utils->runcmd($cmd, 0); my $static_ip = $nodehash->{$pdu}->[0]->{ip}; my $discover_ip = $nodehash->{$pdu}->[0]->{otherinterfaces}; From 649efc396e9d1283a6ea337bff439a7b478f57a3 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 25 Jul 2017 23:08:11 -0400 Subject: [PATCH 08/35] modify rsetboot depending on URL & data --- xCAT-server/lib/xcat/plugins/openbmc.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 229555314..e5839a0f7 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -217,15 +217,15 @@ my %status_info = ( RSETBOOT_SET_REQUEST => { method => "PUT", - init_url => "$openbmc_project_url/control/boot/bootsource/attr/Sources", - data => "xyz.openbmc_project.Control.Boot.Sources.", + init_url => "$openbmc_project_url/control/host0/boot_source/attr/BootSource", + data => "xyz.openbmc_project.Control.Boot.Source.Sources.", }, RSETBOOT_SET_RESPONSE => { process => \&rsetboot_response, }, RSETBOOT_STATUS_REQUEST => { method => "GET", - init_url => "$openbmc_project_url/control/boot/bootsource", + init_url => "$openbmc_project_url/control/host0/boot_source", }, RSETBOOT_STATUS_RESPONSE => { process => \&rsetboot_response, @@ -1363,7 +1363,7 @@ sub rsetboot_response { my $response_info = decode_json $response->content; - if ($node_info{$node}{cur_status} eq "RSETBOOT_GET_RESPONSE") { + if ($node_info{$node}{cur_status} eq "RSETBOOT_STATUS_RESPONSE") { xCAT::SvrUtils::sendmsg("Hard Drive", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Disk$/); xCAT::SvrUtils::sendmsg("Network", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Network$/); xCAT::SvrUtils::sendmsg("CD/DVD", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /ExternalMedia$/); From bd88e86214ce9d9ec243c644efaffc3b35b28f6c Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 26 Jul 2017 03:46:05 -0400 Subject: [PATCH 09/35] fix issue 3460: Changes required for 'rflash -c' to support more detailed firmware information for LC Big Data boxes --- xCAT-server/lib/xcat/plugins/ipmi.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 3627df69b..9c96245b8 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1622,6 +1622,13 @@ sub isopenpower { sub check_firmware_version { + sub _on_receive_ugp { + my $rsp = shift; + my $sessdta = shift; + shift @{ $rsp->{data} }; + return; + } + sub _on_receive_version { my $rsp = shift; my $sessdata = shift; @@ -1650,6 +1657,15 @@ sub check_firmware_version { my $sessdata = shift; my $firmware_version = shift; my $component_string = shift; + + # GET TARGET UPGRADE CAPABILITIES + $sessdata->{ipmisession}->subcmd(netfn => 0x2c, command => 0x2e, + data => [ 0 ], + callback => \&_on_receive_ugp, + callback_args => $sessdata); + while (xCAT::IPMI->waitforrsp()) { yield } + + foreach my $c_id (@{ $sessdata->{component_ids} }) { $sessdata->{c_id} = $c_id; From 71a7151d97c0db044c7eb5d0743a178d8f16808a Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 26 Jul 2017 09:11:12 -0400 Subject: [PATCH 10/35] remove results --- xCAT-server/lib/xcat/plugins/pdu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index facdc5ff8..c4e71ef96 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -488,7 +488,7 @@ sub process_sshcfg { #remove old host key from /root/.ssh/known_hosts $cmd = "ssh-keygen -R $pdu"; - my $result = xCAT::Utils->runcmd($cmd, 0); + xCAT::Utils->runcmd($cmd, 0); my $static_ip = $nodehash->{$pdu}->[0]->{ip}; my $discover_ip = $nodehash->{$pdu}->[0]->{otherinterfaces}; From 876ab8c7e71c4b218be01e43ca05bd4763c6ae08 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 25 Jul 2017 15:38:45 -0400 Subject: [PATCH 11/35] Fixes after the review --- xCAT-server/lib/xcat/plugins/ipmi.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 16a213695..d8c8b5c9d 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1707,7 +1707,8 @@ sub calc_ipmitool_version { # verbose: verbose output # use_rc: Some machines, like IBM Power S822LC for Big Data (Supermicro), do not return # a "00" ready string from calling ipmi raw command. Instead they return RC=0. This -# flag tells the check_bmc_status_with_ipmitool() to check the RC instead of "00" string +# flag if 1, tells the check_bmc_status_with_ipmitool() to check the RC +# instead of "00" string. If set to 0, the "00" ready string is checked. # Returns: # 1 when bmc is up # 0 when no response from bmc @@ -1728,7 +1729,7 @@ sub check_bmc_status_with_ipmitool { my $code_type = "ready"; if ($use_rc) { - $cmd = $pre_cmd . " raw 0x3a 0x0a >> /dev/null 2>&1 ; echo \$?"; + $cmd = $cmd . " >> /dev/null 2>&1 ; echo \$?"; $bmc_ready_code = "0"; $code_type = "return"; } @@ -1874,7 +1875,7 @@ sub do_firmware_update { # only 1.8.15 or above support hpm update for firestone machines. if (calc_ipmitool_version($ipmitool_ver) < calc_ipmitool_version("1.8.15")) { $callback->({ error => "IPMITool $ipmitool_ver do not support firmware update for " . - "firestone mathines, please setup IPMITool 1.8.15 or above.", + "firestone machines, please setup IPMITool 1.8.15 or above.", errorcode => 1 }); exit -1; } @@ -2191,7 +2192,7 @@ RETRY_UPGRADE: } # check reset status - unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 2, $sessdata, $verbose)) { + unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 2, $sessdata, $verbose, 0)) { $exit_with_error_func->($sessdata->{node}, $callback, "Timeout to check the bmc status"); } @@ -2257,7 +2258,7 @@ RETRY_UPGRADE: } # Wait for BMC to reboot before continuing to next step - unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 10, $sessdata, $verbose)) { + unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 10, $sessdata, $verbose, 0)) { $exit_with_error_func->($sessdata->{node}, $callback, "Timeout waiting for the bmc ready status. Firmware update suspended"); } @@ -2321,7 +2322,7 @@ RETRY_UPGRADE: # step 5 power on # check reset status - unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 10, $sessdata, $verbose)) { + unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 10, $sessdata, $verbose, 0)) { $exit_with_error_func->($sessdata->{node}, $callback, "Timeout to check the bmc status"); } From 24c78e6b1a4c0645d09dd4fc2cfa99cf0f7722f6 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 26 Jul 2017 22:51:40 -0400 Subject: [PATCH 12/35] modified depending on comments --- xCAT-server/lib/xcat/plugins/openbmc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index e5839a0f7..63c8bb413 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1367,7 +1367,7 @@ sub rsetboot_response { xCAT::SvrUtils::sendmsg("Hard Drive", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Disk$/); xCAT::SvrUtils::sendmsg("Network", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Network$/); xCAT::SvrUtils::sendmsg("CD/DVD", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /ExternalMedia$/); - xCAT::SvrUtils::sendmsg("boot override inactive", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Default$/); + xCAT::SvrUtils::sendmsg("Default", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Default$/); } if ($next_status{ $node_info{$node}{cur_status} }) { From f3e9b5a2e286ee750c204bd33c2de084ee2474fd Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 27 Jul 2017 02:21:43 -0400 Subject: [PATCH 13/35] Will not print EnergyManager error msg when run rvitals power --- xCAT-server/lib/xcat/plugins/ipmi.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 3627df69b..5cf301979 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -6702,9 +6702,9 @@ sub vitals { if ($sensor_filters{energy}) { if ($iem_support) { push @{ $sessdata->{sensorstoread} }, "energy"; - } elsif (not $doall) { - xCAT::SvrUtils::sendmsg([ 1, ":Energy data requires additional IBM::EnergyManager plugin in conjunction with IMM managed IBM equipment" ], $callback, $sessdata->{node}, %allerrornodes); - } + } #elsif (not $doall) { + #xCAT::SvrUtils::sendmsg([ 1, ":Energy data requires additional IBM::EnergyManager plugin in conjunction with IMM managed IBM equipment" ], $callback, $sessdata->{node}, %allerrornodes); + #} #my @energies; #($rc,@energies)=readenergy(); From 31ba541657272b12332ae0c34f0ef0f0888f3661 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Thu, 27 Jul 2017 15:55:30 +0800 Subject: [PATCH 14/35] Forwarding to MN if the request is accepted by SN --- perl-xCAT/xCAT/Scope.pm | 58 +++++++++++++++++------ xCAT-server/lib/xcat/plugins/grub2.pm | 11 +++-- xCAT-server/lib/xcat/plugins/petitboot.pm | 12 +++-- xCAT-server/lib/xcat/plugins/xnba.pm | 11 +++-- 4 files changed, 65 insertions(+), 27 deletions(-) diff --git a/perl-xCAT/xCAT/Scope.pm b/perl-xCAT/xCAT/Scope.pm index e58d1a279..103e1b65b 100644 --- a/perl-xCAT/xCAT/Scope.pm +++ b/perl-xCAT/xCAT/Scope.pm @@ -1,8 +1,8 @@ package xCAT::Scope; -#use Data::Dumper; use xCAT::Utils; use xCAT::Table; +use xCAT::TableUtils; use xCAT::ServiceNodeUtils qw(getSNList); @@ -148,22 +148,31 @@ sub get_broadcast_scope_with_parallel { if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } my $snlist = shift; + my @reqs = (); + $req->{_xcatpreprocessed}->[0] = 1; + my $isMN = xCAT::Utils->isMN(); #Handle the one for current management/service node - my $reqs = get_parallel_scope($req); + if ( $isMN ) { + $reqs = get_parallel_scope($req); + } else { + # get site.master and broadcast to it as MN will not be in SN list or defined in noderes.servicenode. + my @entries = xCAT::TableUtils->get_site_attribute("master"); + my $master = $entries[0]; + my $reqcopy = {%$req}; + $reqcopy->{'_xcatdest'} = $master; + $reqs = get_parallel_scope($reqcopy); + } my @requests = @$reqs; #Broadcast the request to other management/service nodes foreach (@$snlist) { my $xcatdest = $_; - if (xCAT::NetworkUtils->thishostisnot($xcatdest)) { - my $reqcopy = {%$req}; - $reqcopy->{'_xcatdest'} = $xcatdest; - $reqcopy->{_xcatpreprocessed}->[0] = 1; + my $reqcopy = {%$req}; + $reqcopy->{'_xcatdest'} = $xcatdest; - $reqs = get_parallel_scope($reqcopy); - foreach (@$reqs) { - push @requests, {%$_}; - } + $reqs = get_parallel_scope($reqcopy); + foreach (@$reqs) { + push @requests, {%$_}; } } return \@requests; @@ -197,12 +206,22 @@ sub get_broadcast_disjoint_scope_with_parallel { my $sn_hash = shift; my @reqs = (); + $req->{_xcatpreprocessed}->[0] = 1; + my $isMN = xCAT::Utils->isMN(); #Handle the one for current management/service node - if ( xCAT::Utils->isMN() ) { - $reqs = get_parallel_scope($req); + if ( $isMN ) { + $reqs = get_parallel_scope($req); + } else { + # get site.master and broadcast to it as MN will not be in SN list or defined in noderes.servicenode. + my @entries = xCAT::TableUtils->get_site_attribute("master"); + my $master = $entries[0]; + my $reqcopy = {%$req}; + $reqcopy->{'_xcatdest'} = $master; + $reqs = get_parallel_scope($reqcopy); } my @requests = @$reqs; + my $handled4me = 0; #Broadcast the request to other management/service nodes foreach (keys %$sn_hash) { my $xcatdest = $_; @@ -210,15 +229,26 @@ sub get_broadcast_disjoint_scope_with_parallel { my $reqcopy = {%$req}; $reqcopy->{'_xcatdest'} = $xcatdest; $reqcopy->{'node'} = $sn_hash->{$xcatdest}; - $reqcopy->{_xcatpreprocessed}->[0] = 1; $reqs = get_parallel_scope($reqcopy); foreach (@$reqs) { push @requests, {%$_}; } + } elsif ($isMN == 0) { + # avoid handle myself multiple times when different IP address used in `noderes.servicenode`. + next if $handled4me; + my $reqcopy = {%$req}; + $reqcopy->{'_xcatdest'} = $xcatdest; + $reqcopy->{'node'} = $sn_hash->{$xcatdest}; + + $reqs = get_parallel_scope($reqcopy); + foreach (@$reqs) { + push @requests, {%$_}; + } + $handled4me = 1; } } - #print Dumper(\@requests); + return \@requests; } diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 4820f4307..a09612745 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -573,7 +573,7 @@ sub process_request { my $errormsg = $ipret->{'error'}; my $nodeip = $ipret->{'ip'}; if ($errormsg) {# Add the node to failure set - xCAT::MsgUtils->trace(0, "E", "grub2: IP address of $_ is $nodeip. $errormsg"); + xCAT::MsgUtils->trace(0, "E", "grub2: Defined IP address of $_ is $nodeip. $errormsg"); unless ($nodeip) { $failurenodes{$_} = 1; } @@ -606,7 +606,10 @@ sub process_request { unless (@nodes) { xCAT::MsgUtils->message("S", "xCAT: grub2 netboot: no valid nodes. Stop the operation on this server."); - # It must be an error if my managed nodes are not handled. + # 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) { # 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. @@ -634,7 +637,7 @@ sub process_request { } my $rsp; $rsp->{errorcode}->[0] = 1; - $rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n"; + $rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details."; $callback->($rsp); return; } @@ -878,7 +881,7 @@ sub process_request { if (%failurenodes) { my $rsp; $rsp->{errorcode}->[0] = 1; - $rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n"; + $rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details."; $callback->($rsp); return; } diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 89c02fd3b..58d2bd794 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -1,7 +1,6 @@ # 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; @@ -464,7 +463,7 @@ sub process_request { my $errormsg = $ipret->{'error'}; my $nodeip = $ipret->{'ip'}; if ($errormsg) {# Add the node to failure set - xCAT::MsgUtils->trace(0, "E", "petitboot: IP address of $_ is $nodeip. $errormsg"); + xCAT::MsgUtils->trace(0, "E", "petitboot: Defined IP address of $_ is $nodeip. $errormsg"); unless ($nodeip) { $failurenodes{$_} = 1; } @@ -497,7 +496,10 @@ sub process_request { unless (@nodes) { xCAT::MsgUtils->message("S", "xCAT: petitboot netboot: no valid nodes. Stop the operation on this server."); - # It must be an error if my managed nodes are not handled. + # 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) { # 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. @@ -525,7 +527,7 @@ sub process_request { } 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.\n"; + $rsp->{error}->[0] = "Failed to generate petitboot configurations for some node(s) on $::myxcatname. Check xCAT log file for more details."; $callback->($rsp); return; } @@ -696,7 +698,7 @@ sub process_request { if (%failurenodes) { 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.\n"; + $rsp->{error}->[0] = "Failed to generate petitboot configurations for some node(s) on $::myxcatname. Check xCAT log file for more details."; $callback->($rsp); return; } diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index da8d8d467..d18b3d004 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -509,7 +509,7 @@ sub process_request { my $errormsg = $ipret->{'error'}; my $nodeip = $ipret->{'ip'}; if ($errormsg) {# Add the node to failure set - xCAT::MsgUtils->trace(0, "E", "xnba: IP address of $_ is $nodeip. $errormsg"); + xCAT::MsgUtils->trace(0, "E", "xnba: Defined IP address of $_ is $nodeip. $errormsg"); unless ($nodeip) { $failurenodes{$_} = 1; } @@ -542,7 +542,10 @@ sub process_request { unless (@nodes) { xCAT::MsgUtils->message("S", "xCAT: xnba netboot: no valid nodes. Stop the operation on this server."); - # It must be an error if my managed nodes are not handled. + # 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) { # 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. @@ -570,7 +573,7 @@ sub process_request { } 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.\n"; + $rsp->{error}->[0] = "Failed to generate xnba configurations for some node(s) on $::myxcatname. Check xCAT log file for more details."; $::XNBA_callback->($rsp); return; } @@ -742,7 +745,7 @@ sub process_request { if (%failurenodes) { 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.\n"; + $rsp->{error}->[0] = "Failed to generate xnba configurations for some node(s) on $::myxcatname. Check xCAT log file for more details."; $::XNBA_callback->($rsp); return; } From c45fd291232bb093be41651072299fc3d0a9fc8d Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 27 Jul 2017 21:27:17 -0400 Subject: [PATCH 15/35] modified depending on comments --- xCAT-server/lib/xcat/plugins/openbmc.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 63c8bb413..d00075d8a 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1364,10 +1364,18 @@ sub rsetboot_response { my $response_info = decode_json $response->content; if ($node_info{$node}{cur_status} eq "RSETBOOT_STATUS_RESPONSE") { - xCAT::SvrUtils::sendmsg("Hard Drive", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Disk$/); - xCAT::SvrUtils::sendmsg("Network", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Network$/); - xCAT::SvrUtils::sendmsg("CD/DVD", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /ExternalMedia$/); - xCAT::SvrUtils::sendmsg("Default", $callback, $node) if ($response_info->{'data'}->{BootSource} =~ /Default$/); + if ($response_info->{'data'}->{BootSource} =~ /Disk$/) { + xCAT::SvrUtils::sendmsg("Hard Drive", $callback, $node); + } elsif ($response_info->{'data'}->{BootSource} =~ /Network$/) { + xCAT::SvrUtils::sendmsg("Network", $callback, $node); + } elsif ($response_info->{'data'}->{BootSource} =~ /ExternalMedia$/) { + xCAT::SvrUtils::sendmsg("CD/DVD", $callback, $node); + } elsif ($response_info->{'data'}->{BootSource} =~ /Default$/) { + xCAT::SvrUtils::sendmsg("Default", $callback, $node); + } else { + my $error_msg = "Can not get valid rsetboot status, the data is " . $response_info->{'data'}->{BootSource}; + xCAT::SvrUtils::sendmsg("$error_msg", $callback, $node); + } } if ($next_status{ $node_info{$node}{cur_status} }) { From 915248a41952281f56c85219ccb46e49b9f1fecb Mon Sep 17 00:00:00 2001 From: yangsong Date: Thu, 27 Jul 2017 22:23:31 -0500 Subject: [PATCH 16/35] fix addkcmdline for deployed kernel only #3532, refine the document (#3536) --- .../guides/admin-guides/references/man5/bootparams.5.rst | 2 +- .../guides/admin-guides/references/man5/linuximage.5.rst | 2 +- perl-xCAT/xCAT/Schema.pm | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/bootparams.5.rst b/docs/source/guides/admin-guides/references/man5/bootparams.5.rst index e6596fcb4..13f261616 100644 --- a/docs/source/guides/admin-guides/references/man5/bootparams.5.rst +++ b/docs/source/guides/admin-guides/references/man5/bootparams.5.rst @@ -62,7 +62,7 @@ bootparams Attributes: \ **addkcmdline**\ - User specified one or more parameters to be passed to the kernel. For the kernel options need to be persistent after installation, specify them with prefix "R::" + User specified kernel options for os provision process(no prefix) or the provisioned os(with prefix "R::"). The options should be delimited with spaces(" ") diff --git a/docs/source/guides/admin-guides/references/man5/linuximage.5.rst b/docs/source/guides/admin-guides/references/man5/linuximage.5.rst index 74810be1c..66569e8c4 100644 --- a/docs/source/guides/admin-guides/references/man5/linuximage.5.rst +++ b/docs/source/guides/admin-guides/references/man5/linuximage.5.rst @@ -56,7 +56,7 @@ linuximage Attributes: \ **addkcmdline**\ - User specified arguments to be passed to the kernel. The user arguments are appended to xCAT.s default kernel arguments. For the kernel options need to be persistent after installation, specify them with prefix "R::". This attribute is ignored if linuximage.boottarget is set. + User specified kernel options for os provision process(no prefix) or the provisioned os(with prefix "R::"). The options should be delimited with spaces(" "). This attribute is ignored if linuximage.boottarget is set. diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 832c8566d..1314d5249 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -331,8 +331,8 @@ passed as argument rather than by table value', 'kernel' => 'The kernel that network boot actions should currently acquire and use. Note this could be a chained boot loader such as memdisk or a non-linux boot loader', 'initrd' => 'The initial ramdisk image that network boot actions should use (could be a DOS floppy or hard drive image if using memdisk as kernel)', 'kcmdline' => 'Arguments to be passed to the kernel', -'addkcmdline' => 'User specified one or more parameters to be passed to the kernel. For the kernel options need to be persistent after installation, specify them with prefix "R::"', -'dhcpstatements' => 'xCAT manipulated custom dhcp statements (not intended for user manipulation)', + 'addkcmdline' => 'User specified kernel options for os provision process(no prefix) or the provisioned os(with prefix "R::"). The options should be delimited with spaces(" ")', + 'dhcpstatements' => 'xCAT manipulated custom dhcp statements (not intended for user manipulation)', 'adddhcpstatements' => 'Custom dhcp statements for administrator use (not implemneted yet)', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", @@ -799,7 +799,7 @@ passed as argument rather than by table value', imagename => 'The name of this xCAT OS image definition.', template => 'The fully qualified name of the template file that will be used to create the OS installer configuration file for stateful installations (e.g. kickstart for RedHat, autoyast for SLES).', boottarget => 'The name of the boottarget definition. When this attribute is set, xCAT will use the kernel, initrd and kernel params defined in the boottarget definition instead of the default.', - addkcmdline => 'User specified arguments to be passed to the kernel. The user arguments are appended to xCAT.s default kernel arguments. For the kernel options need to be persistent after installation, specify them with prefix "R::". This attribute is ignored if linuximage.boottarget is set.', + addkcmdline => 'User specified kernel options for os provision process(no prefix) or the provisioned os(with prefix "R::"). The options should be delimited with spaces(" "). This attribute is ignored if linuximage.boottarget is set.', pkglist => 'The fully qualified name of the file that stores the distro packages list that will be included in the image. Make sure that if the pkgs in the pkglist have dependency pkgs, the dependency pkgs should be found in one of the pkgdir', pkgdir => 'The name of the directory where the distro packages are stored. It could be set to multiple paths. The multiple paths must be separated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other.', otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set to multiple paths. The multiple paths must be separated by ",".', From 38539f48bdc0e961d5bf81258859466238977929 Mon Sep 17 00:00:00 2001 From: yangsong Date: Fri, 28 Jul 2017 00:00:35 -0500 Subject: [PATCH 17/35] correct the generation of conf/distributions for xcat-dep (#3553) --- build-ubunturepo | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/build-ubunturepo b/build-ubunturepo index 4d1fbfb04..65e44c88d 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -338,7 +338,7 @@ __EOF__ echo "SignWith: yes" >> conf/distributions echo "" >> conf/distributions fi - done + done cat << __EOF__ > conf/options verbose @@ -457,15 +457,18 @@ Architectures: $tmp_out_arch Components: main Description: Repository automatically genereted conf __EOF__ + + if [ "$GPGSIGN" = "0" ];then + echo "GPGSIGN=$GPGSIGN specified, the repo will not be signed" + echo "" >> conf/distributions + else + echo "SignWith: yes" >> conf/distributions + echo "" >> conf/distributions + fi + done - if [ "$GPGSIGN" = "0" ];then - echo "GPGSIGN=$GPGSIGN specified, the repo will not be signed" - echo "" >> conf/distributions - else - echo "SignWith: yes" >> conf/distributions - echo "" >> conf/distributions - fi + cat << __EOF__ > conf/options verbose From d4fe16ddc1f3b2176c672611436489bd337604ec Mon Sep 17 00:00:00 2001 From: zet809 Date: Fri, 28 Jul 2017 15:58:22 +0800 Subject: [PATCH 18/35] =?UTF-8?q?remove=20the=20build=20mlx4-en=20and=20i4?= =?UTF-8?q?0e=20section=20when=20building=20xcat-genesis-=E2=80=A6=20(#351?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove the build mlx4-en and i40e section when building xcat-genesis-base * Add build env in description for xcat-genesis-base --- xCAT-genesis-builder/buildrpm | 32 ++------------------- xCAT-genesis-builder/xCAT-genesis-base.spec | 1 + 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/xCAT-genesis-builder/buildrpm b/xCAT-genesis-builder/buildrpm index 45de0953a..2b4a42964 100755 --- a/xCAT-genesis-builder/buildrpm +++ b/xCAT-genesis-builder/buildrpm @@ -5,7 +5,7 @@ # this whole dir into it somewhere (like /tmp). # Then run this script. The optional 1st arg should be mcp if you are building against mcp. -# Currently, *Fedora 23* is the only OS supported to build genesis-base for ppc64, and Centos 6.5 for x86_64 +# Currently, *Fedora 26* is the only OS supported to build genesis-base for ppc64, and Centos 6.5 for x86_64 HOSTOS="$1" DIR=`dirname $0` @@ -18,37 +18,9 @@ if [ $BUILDARCH = "ppc64le" ]; then BUILDARCH="ppc64" fi -# For xcat-genesis-base-ppc64, we need to update mlx4-en driver for Mellanox ethernet nics. -# IF you are sure you have installed newer driver on the build server you can use 'buildrpm -y' to skip the nodification if [ -z $1 ]; then - HOSTOS="fedora23" + HOSTOS="fedora26" fi -if [ $BUILDARCH = 'ppc64' -a $HOSTOS != 'mcp' -a $HOSTOS != '-y' ]; then - echo "The steps below are used to install mlnx driver 3.2-1 and i40e driver 1.5.16, if you are sure you have these or newer drivers, pls use \"-y\" to skip!" - echo "1. Install OS related packages" - echo " yum install rpmbuild" - echo " yum install kernel-devel-`uname -r`" - echo " yum install kernel-headers-`uname -r`" - echo " yum install gcc-c++" - echo "2. Download Mellanox EN Driver for Linux from http://www.mellanox.com/downloads/Drivers/mlnx-en-3.2-1.0.1.1.tgz" - echo " Download Intel EN Driver follow this link and download from webpage https://downloadcenter.intel.com/downloads/eula/26370/Intel-Network-Adapter-Driver-for-PCI-E-Intel-40-Gigabit-Ethernet-Network-Connections-under-Linux-?httpDown=https%3A%2F%2Fdownloadmirror.intel.com%2F26370%2Feng%2Fi40e-1.5.16.tar.gz" - echo "3. To install Mellanox Driver, extract it and run ./install.sh from the extracted directory" - echo " tar -xvf mlnx-en-3.2-1.0.1.1.tgz" - echo " ./mlnx-en-3.2-1.0.1.1/install.sh" - echo " To install Intel Driver, create rpm and install" - echo " rpmbuild -tb i40e-1.5.16.tar.gz" - echo " rpm -i //i40e-1.5.16-1.ppc64le.rpm" - echo " Additional Intel instructions can be found in README included in i40e-1.5.16.tar.gz" - echo "4. Check whether the drivers are updated" - echo " modprobe mlx4-en" - echo " modinfo mlx4-en | grep version" - echo " version: 3.2-1.0.1.1 (31 Jan 2016)" - echo " modinfo i40e | grep version" - echo " version: 1.5.16" - echo "5. Once the steps above done, run \"$0 -y\" to build xCAT-genesis-base-ppc64" - exit 0 -fi - # get the input files for dracut in the right place # Fedora 20 ppc64 uses /usr/lib/dracut/modules.d diff --git a/xCAT-genesis-builder/xCAT-genesis-base.spec b/xCAT-genesis-builder/xCAT-genesis-base.spec index 95e1e719d..f716c87db 100755 --- a/xCAT-genesis-builder/xCAT-genesis-base.spec +++ b/xCAT-genesis-builder/xCAT-genesis-base.spec @@ -37,6 +37,7 @@ Packager: IBM Corp. %Description xCAT genesis (Genesis Enhanced Netboot Environment for System Information and Servicing) is a small, embedded-like environment for xCAT's use in discovery and management actions when interaction with an OS is infeasible. This package comprises the base platform with most of the xCAT specific behavior left to xCAT-genesis-scripts package. +Built in environment "%dist" on %{_arch}. %Prep From c22d145c328c7799898c1e9d25158f911a494602 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 28 Jul 2017 04:16:47 -0400 Subject: [PATCH 19/35] add bunlds for rhels7.4 --- .../autotest/bundle/rhels7.4_ppc64.bundle | 314 ++++++++++++++++++ .../autotest/bundle/rhels7.4_ppc64le.bundle | 310 +++++++++++++++++ .../autotest/bundle/rhels7.4_x86_64.bundle | 239 +++++++++++++ 3 files changed, 863 insertions(+) create mode 100644 xCAT-test/autotest/bundle/rhels7.4_ppc64.bundle create mode 100644 xCAT-test/autotest/bundle/rhels7.4_ppc64le.bundle create mode 100644 xCAT-test/autotest/bundle/rhels7.4_x86_64.bundle diff --git a/xCAT-test/autotest/bundle/rhels7.4_ppc64.bundle b/xCAT-test/autotest/bundle/rhels7.4_ppc64.bundle new file mode 100644 index 000000000..34e13e857 --- /dev/null +++ b/xCAT-test/autotest/bundle/rhels7.4_ppc64.bundle @@ -0,0 +1,314 @@ +reg_linux_diskfull_installation_flat +updatenode_h +updatenode_v +updatenode_diskful_syncfiles +updatenode_diskful_syncfiles_rename +updatenode_diskful_syncfiles_dir +updatenode_diskful_syncfiles_multi_files +updatenode_syncfile_EXECUTE +updatenode_syncfile_EXECUTEALWAYS +updatenode_syncfile_APPEND +updatenode_syncfile_MERGE +updatenode_P_script1 +updatenode_P_script2 +updatenode_f_incompatible_flags +updatenode_k_incompatible_flags +updatenode_diskful_syncfiles_P_script1 +updatenode_script3 +updatenode_P_script1_script2 +updatenode_without_flag +confignetwork_secondarynic_nicnetworks_updatenode_false +confignetwork_secondarynic_nicips_updatenode_false +confignetwork_secondarynic_nictype_updatenode_false +chdef_null +chdef_t_node +chdef_t_network +chdef_p +chdef_m +chdef_z +chdef_group +chdef_group_p +chdef_dynamic_group +chdef_multiple_keys +chdef_n +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +copycds_n +copycds_a_err +copycds_n_err +packimage_o_p_a_m +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +getmacs_noderange +getmacs_d +getmacs_f_D +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_bus +rinv_config +rinv_serial +rinv_model +rinv_firm +rinv_all +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_off +rpower_stat +rpower_boot +rpower_on +rpower_reset +rpower_noderange +rpower_noderange_nodeps +rpower_err_noderange +rscan_noderange +rscan_x +rscan_z +rscan_w +rscan_x_w +rscan_z_w +rvitals_lcds +rvitals_all +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_p_auditlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makehosts_help +makehosts_n_noderange +makehosts_h +makehosts_null +makehosts_l +makehosts_d +makehosts_n +makehost_n_r +xdcp_src_dst +makedns_h +makedns_d_node +makedns_n +makedns +noderange_individual_node +noderange_individual_grp +noderange_node01-node10 +noderange_group1-group3 +noderange_10-20 +noderange_XCAT_NODE_PREFIX +noderange_XCAT_NODE_SUFFIX +noderange_exclusion +noderange_group_intersection +copycds_iso +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +psh_h +psh_v +psh_node_cmd_linux +psh_l +psh_i +prsync_h +prsync_v +prsync_dir_node +prsync_file_node +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +makentp_v +makentp_h +nodeset_check_warninginfo +runcmdinstaller_h +runcmdinstaller_command +get_xcat_postscripts_loginfo +updatenode_postscripts_loginfo +bmcdiscover_h +bmcdiscover_nmap_range +bmcdiscover_v +bmcdiscover_check_paswd +bmcdiscover_check_passwd_wrong +bmcdiscover_get_ipsource +bmcdiscover_range_w +bmcdiscover_range_z +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission +xcatconfig_u_check_xcatsslversion_rhels_sles +reg_linux_diskless_installation_flat +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +redhat_migration1 +redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.4_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.4_ppc64le.bundle new file mode 100644 index 000000000..2984952bb --- /dev/null +++ b/xCAT-test/autotest/bundle/rhels7.4_ppc64le.bundle @@ -0,0 +1,310 @@ +setup_vm +reg_linux_diskless_installation_flat +reg_linux_diskfull_installation_flat +go_xcat_noinput +updatenode_h +updatenode_v +updatenode_diskful_syncfiles +updatenode_diskful_syncfiles_rename +updatenode_diskful_syncfiles_dir +updatenode_diskful_syncfiles_multi_files +updatenode_syncfile_EXECUTE +updatenode_syncfile_EXECUTEALWAYS +updatenode_syncfile_APPEND +updatenode_syncfile_MERGE +updatenode_P_script1 +updatenode_P_script2 +updatenode_f_incompatible_flags +updatenode_k_incompatible_flags +updatenode_diskful_syncfiles_P_script1 +updatenode_script3 +updatenode_P_script1_script2 +updatenode_without_flag +confignetwork_s_installnic_secondarynic_updatenode +confignetwork_secondarynic_updatenode +confignetwork_secondarynic_nicaliases_updatenode +confignetwork_secondarynic_nicextraparams_updatenode +confignetwork_disable_set_to_yes +confignetwork_disable_set_to_1 +confignetwork_niccustomscripts +confignetwork_secondarynic_thirdnic_multiplevalue_updatenode +confignetwork_secondarynic_nicnetworks_updatenode_false +confignetwork_secondarynic_nicips_updatenode_false +confignetwork_secondarynic_nictype_updatenode_false +chdef_null +chdef_t_node +chdef_t_network +chdef_p +chdef_m +chdef_z +chdef_group +chdef_group_p +chdef_dynamic_group +chdef_multiple_keys +chdef_n +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +packimage_o_p_a_m +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_off +rpower_stat +rpower_boot +rpower_on +rpower_reset +rpower_noderange +rpower_noderange_nodeps +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_p_auditlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makehosts_h +makehosts_help +makehosts_null +makehosts_l +makehosts_d +makehosts_n +makehosts_n_noderange +makehost_n_r +xdcp_src_dst +makedns_h +makedns_d_node +makedns_n +makedns +noderange_individual_node +noderange_individual_grp +noderange_node01-node10 +noderange_group1-group3 +noderange_10-20 +noderange_XCAT_NODE_PREFIX +noderange_XCAT_NODE_SUFFIX +noderange_exclusion +noderange_group_intersection +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +psh_h +psh_v +psh_node_cmd_linux +psh_l +psh_i +prsync_h +prsync_v +prsync_dir_node +prsync_file_node +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +makentp_v +makentp_h +nodeset_check_warninginfo +runcmdinstaller_h +runcmdinstaller_command +get_xcat_postscripts_loginfo +updatenode_postscripts_loginfo +bmcdiscover_h +bmcdiscover_nmap_range +bmcdiscover_v +bmcdiscover_check_paswd +bmcdiscover_check_passwd_wrong +bmcdiscover_get_ipsource +bmcdiscover_range_w +bmcdiscover_range_z +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission +xcatconfig_u_check_xcatsslversion_rhels_sles +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +redhat_migration1 +redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.4_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.4_x86_64.bundle new file mode 100644 index 000000000..13f6f53c7 --- /dev/null +++ b/xCAT-test/autotest/bundle/rhels7.4_x86_64.bundle @@ -0,0 +1,239 @@ +setup_vm +reg_linux_diskfull_installation_flat +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +makehost_n_r +confignetwork_s_installnic_secondarynic_updatenode +confignetwork_secondarynic_updatenode +confignetwork_secondarynic_nicaliases_updatenode +confignetwork_secondarynic_nicextraparams_updatenode +confignetwork_disable_set_to_yes +confignetwork_disable_set_to_1 +confignetwork_niccustomscripts +confignetwork_secondarynic_thirdnic_multiplevalue_updatenode +confignetwork_secondarynic_nicnetworks_updatenode_false +confignetwork_secondarynic_nicips_updatenode_false +confignetwork_secondarynic_nictype_updatenode_false +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_imagename +packimage_h +packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +psh_h +psh_v +psh_node_cmd_linux +psh_l +psh_i +prsync_h +prsync_v +prsync_dir_node +prsync_file_node +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_check_warninginfo +nodeset_shell +nodeset_cmdline +nodeset_runimg +xcatconfig_u_check_xcatsslversion_rhels_sles +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +redhat_migration1 +redhat_migration2 +clean_up_env From 939c75cad02968e51343a86310c5d15f1945fca8 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 28 Jul 2017 07:45:23 -0400 Subject: [PATCH 20/35] modify hardware control testcase for physical machine --- xCAT-test/autotest/testcase/reventlog/cases0 | 8 ++++---- xCAT-test/autotest/testcase/rinv/cases0 | 4 ++-- xCAT-test/autotest/testcase/rpower/cases0 | 11 ++--------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/xCAT-test/autotest/testcase/reventlog/cases0 b/xCAT-test/autotest/testcase/reventlog/cases0 index d772ed285..7c65a6035 100644 --- a/xCAT-test/autotest/testcase/reventlog/cases0 +++ b/xCAT-test/autotest/testcase/reventlog/cases0 @@ -1,6 +1,6 @@ start:reventlog_null cmd:reventlog -check:rc!=0 +check:rc==0 check:output=~Usage end start:reventlog_all @@ -11,12 +11,12 @@ end start:reventlog_clear cmd:reventlog $$CN clear check:rc==0 -check:output=~$$CN\s*:\s*clear +check:output=~$$CN\s*:\s*clear |SEL cleared end start:reventlog_numofentries cmd:reventlog $$CN 5 check:rc==0 -check:output=~$$CN\s*:\s*.*\d\d/\d\d/\d\d\s*\S+ +check:output=~$$CN\s*:\s*.*\d\d/\d\d/\d\d\s*\S+ |$$CN: no SEL entries cmd:reventlog $$CN 3 | wc -l -check:output=~\s*3\s* +check:output=~\s*1\s* end diff --git a/xCAT-test/autotest/testcase/rinv/cases0 b/xCAT-test/autotest/testcase/rinv/cases0 index 68fb4b2c7..1958a8d7e 100644 --- a/xCAT-test/autotest/testcase/rinv/cases0 +++ b/xCAT-test/autotest/testcase/rinv/cases0 @@ -106,7 +106,7 @@ cmd:chdef -p -t node -o $$CN groups="test" check:rc==0 cmd:rinv test all check:rc==1 -check:output=~$$CN: SYSTEM +check:output=~$$CN: SYSTEM |$$CN: System cmd:chdef -m -t node -o $$CN groups="test" check:rc==0 cmd:rmdef testnode;if [[ -e /tmp/testnode.stanza ]]; then cat /tmp/testnode.stanza | chdef -z;rm -rf /tmp/testnode.stanza;fi @@ -129,5 +129,5 @@ start:rinv_errorcommand description:get right return if input error command cmd:rinv $$CN dafds check:rc==1 -check:output=~Unsupported command +check:output=~Unsupported command|Error: Usage: end diff --git a/xCAT-test/autotest/testcase/rpower/cases0 b/xCAT-test/autotest/testcase/rpower/cases0 index c7a1f70af..fd3890ed5 100644 --- a/xCAT-test/autotest/testcase/rpower/cases0 +++ b/xCAT-test/autotest/testcase/rpower/cases0 @@ -91,15 +91,8 @@ end start:rpower_reset description:This case is to test reset option could hard reset nodes when nodes are in on state. Attribute: $$CN-The operation object of rpower command -cmd:rpower $$CN on -cmd:a=0;while ! `rpower $$CN stat|grep "Running\|on" >/dev/null`; do sleep 5;((a++));if [ $a -gt 11 ];then break;fi done -cmd:rpower $$CN stat -check:ouptut=~Running|on -cmd:rpower $$CN reset +cmd:stat=`rpower $$CN stat`;if ([[ $stat =~ on ]] || [[ $stat =~ Running ]]) ;then rpower $$CN reset;sleep 30;stat1=`rpower $$CN stat`;if ([[ $stat1 =~ on ]] || [[ $stat1 =~ Running ]]);then exit 0;else exit 1;fi;else rpower $$CN reset;sleep 30;stat1=`rpower $$CN stat`;if ([[ $stat1 =~ off ]] || [[ $stat1 =~ "Not Activated" ]]);then exit 0;else exit 1;fi;fi check:rc==0 -cmd:a=0;while ! `rpower $$CN stat|grep "Running\|on" >/dev/null`; do sleep 5;((a++));if [ $a -gt 11 ];then break;fi done -cmd:rpower $$CN stat -check:output=~Running|on end start:rpower_noderange @@ -107,7 +100,7 @@ description:This case is to test rpower could process error usage and return hel Attribute: $$CN-The operation object of rpower command cmd:rpower $$CN check:rc!=0 -check:output=~Unsupported|Usage +check:output=~Unsupported|Usage|Please enter an action end start:rpower_noderange_nodeps From 4660bed50777c450bd62ccaec66d61080e280ab0 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 28 Jul 2017 08:14:10 -0400 Subject: [PATCH 21/35] modify hardware control testcase for physical machine --- xCAT-test/autotest/testcase/reventlog/cases0 | 4 ++-- xCAT-test/autotest/testcase/rinv/cases0 | 2 +- xCAT-test/autotest/testcase/rpower/cases0 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/reventlog/cases0 b/xCAT-test/autotest/testcase/reventlog/cases0 index 7c65a6035..cbb3aceba 100644 --- a/xCAT-test/autotest/testcase/reventlog/cases0 +++ b/xCAT-test/autotest/testcase/reventlog/cases0 @@ -11,12 +11,12 @@ end start:reventlog_clear cmd:reventlog $$CN clear check:rc==0 -check:output=~$$CN\s*:\s*clear |SEL cleared +check:output=~$$CN\s*:\s*clear|SEL cleared end start:reventlog_numofentries cmd:reventlog $$CN 5 check:rc==0 -check:output=~$$CN\s*:\s*.*\d\d/\d\d/\d\d\s*\S+ |$$CN: no SEL entries +check:output=~$$CN\s*:\s*.*\d\d/\d\d/\d\d\s*\S+|$$CN: no SEL entries cmd:reventlog $$CN 3 | wc -l check:output=~\s*1\s* end diff --git a/xCAT-test/autotest/testcase/rinv/cases0 b/xCAT-test/autotest/testcase/rinv/cases0 index 1958a8d7e..8e9c3f1cf 100644 --- a/xCAT-test/autotest/testcase/rinv/cases0 +++ b/xCAT-test/autotest/testcase/rinv/cases0 @@ -106,7 +106,7 @@ cmd:chdef -p -t node -o $$CN groups="test" check:rc==0 cmd:rinv test all check:rc==1 -check:output=~$$CN: SYSTEM |$$CN: System +check:output=~$$CN: SYSTEM|$$CN: System cmd:chdef -m -t node -o $$CN groups="test" check:rc==0 cmd:rmdef testnode;if [[ -e /tmp/testnode.stanza ]]; then cat /tmp/testnode.stanza | chdef -z;rm -rf /tmp/testnode.stanza;fi diff --git a/xCAT-test/autotest/testcase/rpower/cases0 b/xCAT-test/autotest/testcase/rpower/cases0 index fd3890ed5..94fde2054 100644 --- a/xCAT-test/autotest/testcase/rpower/cases0 +++ b/xCAT-test/autotest/testcase/rpower/cases0 @@ -91,7 +91,7 @@ end start:rpower_reset description:This case is to test reset option could hard reset nodes when nodes are in on state. Attribute: $$CN-The operation object of rpower command -cmd:stat=`rpower $$CN stat`;if ([[ $stat =~ on ]] || [[ $stat =~ Running ]]) ;then rpower $$CN reset;sleep 30;stat1=`rpower $$CN stat`;if ([[ $stat1 =~ on ]] || [[ $stat1 =~ Running ]]);then exit 0;else exit 1;fi;else rpower $$CN reset;sleep 30;stat1=`rpower $$CN stat`;if ([[ $stat1 =~ off ]] || [[ $stat1 =~ "Not Activated" ]]);then exit 0;else exit 1;fi;fi +cmd:stat=`rpower $$CN stat`;if ([[ $stat =~ on ]] || [[ $stat =~ Running ]]) ;then rpower $$CN reset;sleep 300;stat1=`rpower $$CN stat`;if ([[ $stat1 =~ on ]] || [[ $stat1 =~ Running ]]);then exit 0;else exit 1;fi;else rpower $$CN reset;sleep 300;stat1=`rpower $$CN stat`;if ([[ $stat1 =~ off ]] || [[ $stat1 =~ "Not Activated" ]]);then exit 0;else exit 1;fi;fi check:rc==0 end From 770d947c949d99f8abacd8e9fbdab4b14f9e6250 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Fri, 28 Jul 2017 16:36:15 +0800 Subject: [PATCH 22/35] Using networks.dhcpserver as one accept whole noderange for nodeset. --- perl-xCAT/xCAT/Scope.pm | 101 ++++++++++++---------- xCAT-server/lib/xcat/plugins/grub2.pm | 11 ++- xCAT-server/lib/xcat/plugins/petitboot.pm | 11 ++- xCAT-server/lib/xcat/plugins/xnba.pm | 11 ++- 4 files changed, 85 insertions(+), 49 deletions(-) diff --git a/perl-xCAT/xCAT/Scope.pm b/perl-xCAT/xCAT/Scope.pm index 103e1b65b..b35388fe3 100644 --- a/perl-xCAT/xCAT/Scope.pm +++ b/perl-xCAT/xCAT/Scope.pm @@ -146,33 +146,35 @@ sub get_broadcast_scope_with_parallel { } #Exit if the packet has been preprocessed in its history if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } + $req->{_xcatpreprocessed}->[0] = 1; my $snlist = shift; - my @reqs = (); - $req->{_xcatpreprocessed}->[0] = 1; - my $isMN = xCAT::Utils->isMN(); - #Handle the one for current management/service node - if ( $isMN ) { - $reqs = get_parallel_scope($req); - } else { - # get site.master and broadcast to it as MN will not be in SN list or defined in noderes.servicenode. + + my $reqs = get_parallel_scope($req); + + 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. + if ( xCAT::Utils->isServiceNode() ) { my @entries = xCAT::TableUtils->get_site_attribute("master"); my $master = $entries[0]; - my $reqcopy = {%$req}; - $reqcopy->{'_xcatdest'} = $master; - $reqs = get_parallel_scope($reqcopy); + foreach (@$reqs) { + my $reqcopy = {%$_}; + $reqcopy->{'_xcatdest'} = $master; + push @requests, $reqcopy; + } } - my @requests = @$reqs; - #Broadcast the request to other management/service nodes + #Broadcast the request to all service nodes foreach (@$snlist) { my $xcatdest = $_; - my $reqcopy = {%$req}; - $reqcopy->{'_xcatdest'} = $xcatdest; + next unless (xCAT::NetworkUtils->thishostisnot($xcatdest)); - $reqs = get_parallel_scope($reqcopy); foreach (@$reqs) { - push @requests, {%$_}; + my $reqcopy = {%$_}; + $reqcopy->{'_xcatdest'} = $xcatdest; + push @requests, $reqcopy; } } return \@requests; @@ -182,12 +184,13 @@ sub get_broadcast_scope_with_parallel { =head3 get_broadcast_disjoint_scope_with_parallel - Convert a request object to an array of multiple requests according to the - splitted node range. (Work under disjoint mode) + Convert a request object to an array of multiple request objects according to the + service node management scope. (Work under disjoint mode) Arguments: Reference of request SN hash: Hash of target service nodes => Managed CNs + Special servers: Array of servers, those servers are required to handle whole noderange. Returns: An array of requests Error: none @@ -203,48 +206,54 @@ sub get_broadcast_disjoint_scope_with_parallel { } #Exit if the packet has been preprocessed in its history if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } + $req->{_xcatpreprocessed}->[0] = 1; my $sn_hash = shift; - my @reqs = (); - $req->{_xcatpreprocessed}->[0] = 1; - my $isMN = xCAT::Utils->isMN(); - #Handle the one for current management/service node - if ( $isMN ) { - $reqs = get_parallel_scope($req); - } else { - # get site.master and broadcast to it as MN will not be in SN list or defined in noderes.servicenode. - my @entries = xCAT::TableUtils->get_site_attribute("master"); - my $master = $entries[0]; - my $reqcopy = {%$req}; - $reqcopy->{'_xcatdest'} = $master; - $reqs = get_parallel_scope($reqcopy); - } - my @requests = @$reqs; + my $extras = shift; - my $handled4me = 0; - #Broadcast the request to other management/service nodes + my @requests = (); # The request array will be return. + my $reqs = get_parallel_scope($req); + + my $handled4me = 0; # indicate myself is already handled. + my %prehandledhash = ();# the servers which is already handled. + foreach (@$extras) { + my $xcatdest = $_; + if (xCAT::NetworkUtils->thishostisnot($xcatdest)) { + # TODO, To avoid sending request to a multi-home server many times. + foreach (@$reqs) { + my $reqcopy = {%$_}; + $reqcopy->{'_xcatdest'} = $xcatdest; + push @requests, $reqcopy; + } + $prehandledhash{$xcatdest} = 1; + } elsif ($handled4me == 0) { + push @requests, @$reqs; + $handled4me = 1; + } + } + + #Broadcast the request to all available service nodes foreach (keys %$sn_hash) { my $xcatdest = $_; + # to check if the SN already handled + next if (exists($prehandledhash{$xcatdest})); + if (xCAT::NetworkUtils->thishostisnot($xcatdest)) { my $reqcopy = {%$req}; $reqcopy->{'_xcatdest'} = $xcatdest; $reqcopy->{'node'} = $sn_hash->{$xcatdest}; $reqs = get_parallel_scope($reqcopy); - foreach (@$reqs) { - push @requests, {%$_}; - } - } elsif ($isMN == 0) { - # avoid handle myself multiple times when different IP address used in `noderes.servicenode`. - next if $handled4me; + push @requests, @$reqs; + #foreach (@$reqs) { + # push @requests, {%$_}; + #} + } elsif ($handled4me == 0) { my $reqcopy = {%$req}; - $reqcopy->{'_xcatdest'} = $xcatdest; $reqcopy->{'node'} = $sn_hash->{$xcatdest}; $reqs = get_parallel_scope($reqcopy); - foreach (@$reqs) { - push @requests, {%$_}; - } + push @requests, @$reqs; $handled4me = 1; } } diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index a09612745..563595b72 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -499,7 +499,16 @@ sub preprocess_request { } my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@CN, "xcat", "MN"); - return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash); + my @dhcpsvrs = (); + my $ntab = xCAT::Table->new('networks'); + if ($ntab) { + foreach (@{ $ntab->getAllEntries() }) { + next unless ($_->{dynamicrange}); + # if dynamicrange specified but dhcpserver was not - issue error message + push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver}) + } + } + return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash, \@dhcpsvrs); } } # Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs. diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 58d2bd794..46b471f8f 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -385,7 +385,16 @@ sub preprocess_request { } my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@CN, "xcat", "MN"); - return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash); + my @dhcpsvrs = (); + my $ntab = xCAT::Table->new('networks'); + if ($ntab) { + foreach (@{ $ntab->getAllEntries() }) { + next unless ($_->{dynamicrange}); + # if dynamicrange specified but dhcpserver was not - issue error message + push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver}) + } + } + return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash, \@dhcpsvrs); } } # Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs. diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index d18b3d004..834434a98 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -437,7 +437,16 @@ sub preprocess_request { } my $sn_hash = xCAT::ServiceNodeUtils->getSNformattedhash(\@CN, "xcat", "MN"); - return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash); + my @dhcpsvrs = (); + my $ntab = xCAT::Table->new('networks'); + if ($ntab) { + foreach (@{ $ntab->getAllEntries() }) { + next unless ($_->{dynamicrange}); + # if dynamicrange specified but dhcpserver was not - issue error message + push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver}) + } + } + return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash, \@dhcpsvrs); } } # Do not dispatch to service nodes if non-sharedtftp or the node range contains only SNs. From a58e9b4f2eeca91791afe600c7c4ca29459a7d89 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 31 Jul 2017 04:21:08 -0400 Subject: [PATCH 23/35] fix issue [FVT] Failed to generate computes.log in rhels7.4GA #3561 --- xCAT/postscripts/syslog | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 8705aa168..2cb1a7824 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -219,7 +219,6 @@ config_rsyslog_V8() # Need to uncomment the lines $ModLoad imudp.so and $UDPServerRun 514, # to make the MN be able to receive syslog from remote hosts if [ -f "$remoteconf" ]; then - ##listen on tcp and udp port to enable receiving the xcat debug logs ##forwarded via tcp/udp protocol sed -i 's/#\$ModLoad imudp.so/\$ModLoad imudp.so/; @@ -228,9 +227,17 @@ config_rsyslog_V8() s/#\$InputTCPServerRun /\$InputTCPServerRun 514/' $remoteconf fi - #ubuntu16.04 ships rsyslog 8.16.0,which does not ship remote.conf - #the configuration for UDP and TCP syslog reception is in rsyslog.conf + + ##listen on tcp and udp port to enable receiving the xcat debug logs + ##forwarded via tcp/udp protocol if [ -f "$conf_file" ]; then + #rhels7.4 ships rsyslogd 8.24.0, which does not ship remote.conf + #the relevant sections are included in rsyslog.conf + sed -i '/#\$ModLoad \+imudp\|imtcp\|imudp.so\|imtcp.so/s/^#//; + /#\$InputTCPServerRun\|UDPServerRun.*/s/^#//' $conf_file + + #ubuntu16.04 ships rsyslog 8.16.0,which does not ship remote.conf + #the configuration for UDP and TCP syslog reception is in rsyslog.conf sed -i 's/#module(load="imudp")/module(load="imudp")/; s/#input(type="imudp" port="514")/input(type="imudp" port="514")/; s/#module(load="imtcp")/module(load="imtcp")/; @@ -242,17 +249,18 @@ config_rsyslog_V8() else # not logging local, forward logging # backup the existing remote.conf file from the install - if [ ! -f $remoteconf.XCATORIG ]; then - cp -f $remoteconf $remoteconf.XCATORIG + if [ -f $remoteconf ] && [ ! -f $remoteconf.XCATORIG ]; then + cp -f $remoteconf $remoteconf.XCATORIG fi if [ $isSN -eq 1 ];then - ##listen on tcp and udp port to enable receiving the xcat debug logs - ##forwarded via tcp/udp protocol - sed -i 's/#\$ModLoad imudp.so/\$ModLoad imudp.so/; - s/#\$UDPServerRun 514/\$UDPServerRun 514/; - s/#\$ModLoad imtcp.so/\$ModLoad imtcp.so/; - s/#\$InputTCPServerRun /\$InputTCPServerRun 514/' $remoteconf + ##listen on tcp and udp port to enable receiving the xcat debug logs + ##forwarded via tcp/udp protocol + [ -f "$remoteconf" ] && sed -i '/#\$ModLoad \+imudp\|imtcp\|imudp.so\|imtcp.so/s/^#//; + /#\$InputTCPServerRun\|UDPServerRun.*/s/^#//' $remoteconf + + [ -f "$conf_file" ] && sed -i '/#\$ModLoad \+imudp\|imtcp\|imudp.so\|imtcp.so/s/^#//; + /#\$InputTCPServerRun\|UDPServerRun.*/s/^#//' $conf_file fi From 61abd9c6c7e01a0f4e66f193c23fe6304367a9d4 Mon Sep 17 00:00:00 2001 From: bybai Date: Mon, 31 Jul 2017 04:37:17 -0400 Subject: [PATCH 24/35] fix 13.1.0.100 is existed in some unknown system --- xCAT-test/autotest/testcase/confignetwork/cases0 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/confignetwork/cases0 b/xCAT-test/autotest/testcase/confignetwork/cases0 index 55c1f07cc..f0a21ea0e 100644 --- a/xCAT-test/autotest/testcase/confignetwork/cases0 +++ b/xCAT-test/autotest/testcase/confignetwork/cases0 @@ -422,7 +422,7 @@ cmd:mkdef -t network -o 14_1_0_0-255_255_0_0 net=14.1.0.0 mask=255.255.0.0 mgtif check:rc==0 cmd:chdef $$CN nicips.$$SECONDNIC="11.1.0.100|12.1.0.100" nictypes.$$SECONDNIC=Ethernet nicnetworks.$$SECONDNIC="11_1_0_0-255_255_0_0|12_1_0_0-255_255_0_0" nichostnamesuffixes.$$SECONDNIC="-$$SECONDNIC-1|-$$SECONDNIC-2" check:rc==0 -cmd:chdef $$CN nicips.$$THIRDNIC="13.1.0.100|14.1.0.100" nictypes.$$THIRDNIC=Ethernet nicnetworks.$$THIRDNIC="13_1_0_0-255_255_0_0|14_1_0_0-255_255_0_0" nichostnamesuffixes.$$THIRDNIC="-$$THIRDNIC-1|-$$THIRDNIC-2" +cmd:chdef $$CN nicips.$$THIRDNIC="13.1.0.200|14.1.0.100" nictypes.$$THIRDNIC=Ethernet nicnetworks.$$THIRDNIC="13_1_0_0-255_255_0_0|14_1_0_0-255_255_0_0" nichostnamesuffixes.$$THIRDNIC="-$$THIRDNIC-1|-$$THIRDNIC-2" check:rc==0 cmd:cp /etc/hosts /etc/hosts.bak cmd:rc==0 @@ -439,8 +439,8 @@ cmd:if grep SUSE /etc/*release;then xdsh $$CN "grep 11.1.0.100 /etc/sysconfig/ne check:output=~11.1.0.100 cmd:if grep SUSE /etc/*release;then xdsh $$CN "grep 12.1.0.100 /etc/sysconfig/network/ifcfg-$$SECONDNIC"; elif grep "Red Hat" /etc/*release;then xdsh $$CN "grep 12.1.0.100 /etc/sysconfig/network-scripts/ifcfg-$$SECONDNIC:1"; elif grep Ubuntu /etc/*release;then xdsh $$CN "grep 12.1.0.100 /etc/network/interfaces.d/$$SECONDNIC";else echo "Sorry,this is not supported os"; fi check:output=~12.1.0.100 -cmd:if grep SUSE /etc/*release;then xdsh $$CN "grep 13.1.0.100 /etc/sysconfig/network/ifcfg-$$THIRDNIC"; elif grep "Red Hat" /etc/*release;then xdsh $$CN "grep 13.1.0.100 /etc/sysconfig/network-scripts/ifcfg-$$THIRDNIC"; elif grep Ubuntu /etc/*release;then xdsh $$CN "grep 13.1.0.100 /etc/network/interfaces.d/$$THIRDNIC";else echo "Sorry,this is not supported os"; fi -check:output=~13.1.0.100 +cmd:if grep SUSE /etc/*release;then xdsh $$CN "grep 13.1.0.200 /etc/sysconfig/network/ifcfg-$$THIRDNIC"; elif grep "Red Hat" /etc/*release;then xdsh $$CN "grep 13.1.0.200 /etc/sysconfig/network-scripts/ifcfg-$$THIRDNIC"; elif grep Ubuntu /etc/*release;then xdsh $$CN "grep 13.1.0.200 /etc/network/interfaces.d/$$THIRDNIC";else echo "Sorry,this is not supported os"; fi +check:output=~13.1.0.200 cmd:if grep SUSE /etc/*release;then xdsh $$CN "grep 14.1.0.100 /etc/sysconfig/network/ifcfg-$$THIRDNIC"; elif grep "Red Hat" /etc/*release;then xdsh $$CN "grep 14.1.0.100 /etc/sysconfig/network-scripts/ifcfg-$$THIRDNIC:1"; elif grep Ubuntu /etc/*release;then xdsh $$CN "grep 14.1.0.100 /etc/network/interfaces.d/$$THIRDNIC";else echo "Sorry,this is not supported os"; fi check:output=~14.1.0.100 cmd:rmdef -t network -o 11_1_0_0-255_255_0_0 @@ -453,7 +453,7 @@ cmd:if grep SUSE /etc/*release;then xdsh $$CN "rm -rf /etc/sysconfig/network/ifc check:rc==0 cmd:xdsh $$CN "ip addr del 11.1.0.100/16 dev $$SECONDNIC" cmd:xdsh $$CN "ip addr del 12.1.0.100/16 dev $$SECONDNIC" -cmd:xdsh $$CN "ip addr del 13.1.0.100/16 dev $$THIRDNIC" +cmd:xdsh $$CN "ip addr del 13.1.0.200/16 dev $$THIRDNIC" cmd:xdsh $$CN "ip addr del 14.1.0.100/16 dev $$THIRDNIC" cmd:if [ -e /tmp/CN.standa ]; then rmdef $$CN; cat /tmp/CN.standa | mkdef -z; rm -rf /tmp/CN.standa; fi check:rc==0 From 1586ca799197f8cd41a469698bde8aeaf3e23a85 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 31 Jul 2017 04:59:41 -0400 Subject: [PATCH 25/35] fix issue The line 71 of postbootscript setbootfromnet is wrong in rhels7.4GA #3562 --- xCAT/postscripts/setbootfromnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/setbootfromnet b/xCAT/postscripts/setbootfromnet index df5a898e4..a979a03f3 100755 --- a/xCAT/postscripts/setbootfromnet +++ b/xCAT/postscripts/setbootfromnet @@ -47,7 +47,7 @@ if [ ! -z $NODE_NAME ]; then if [[ $OS = "Linux" ]]; then CLIENT_IP=`ping -c 3 $NODE_NAME | sed '/icmp_seq/!d;s/.*(\([0-9.]\+\)).*/\1/' | uniq 2>&1` RET=`echo $?` - NIC=`ip route | grep "src $CLIENT_IP" | sed -r 's/.*dev (.*) proto.*/\1/' 2>&1` + NIC=`ip route | grep "src $CLIENT_IP" | sed -r 's/.*dev (.*) +proto.*/\1/' 2>&1` NRET=`echo $?` else ## for AIX CLIENT_IP=`ping -c 3 $NODE_NAME | grep "icmp_seq" | sed 's/.*from \([0-9.]*\):.*/\1/' | uniq 2>&1` From 57be67ad31b4eb7e689f3e81180ab5b0013c86b9 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Mon, 31 Jul 2017 06:46:40 -0400 Subject: [PATCH 26/35] modify genesis testcase for if xcatmaster=nodename --- xCAT-test/autotest/testcase/genesis/genesistest.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/genesis/genesistest.pl b/xCAT-test/autotest/testcase/genesis/genesistest.pl index f7b376049..47ee8f50d 100755 --- a/xCAT-test/autotest/testcase/genesis/genesistest.pl +++ b/xCAT-test/autotest/testcase/genesis/genesistest.pl @@ -18,6 +18,7 @@ my $check_genesis_file; my $noderange; my $clear_env; my $help = 0; +my $nodestanza; $::USAGE = "Usage: $program_name -h $program_name -n -s @@ -79,7 +80,11 @@ my $master=`lsdef -t site -i master -c 2>&1 | awk -F'=' '{print \$2}'`; if (!$master) { $master=hostname(); } chomp($master); print "master is $master\n"; - +$nodestanza="/tmp/$noderange.stanza"; +if (!(-e $nodestanza)) { + `lsdef $noderange -z > $nodestanza`; + `chdef $noderange xcatmaster=$master`; +} #################################### ####nodesetshell test for genesis #################################### @@ -306,6 +311,10 @@ sub clearenv { send_msg(0, "rinstall node failed"); exit 1; } + if (-e "$nodestanza") { + `cat $nodestanza | chdef -z`; + unlink("$nodestanza"); + } return 0; } #################################### From 2fe55ff4836fca758f0e66ab743bbd5fc42fa87c Mon Sep 17 00:00:00 2001 From: junxiawang Date: Mon, 31 Jul 2017 07:04:40 -0400 Subject: [PATCH 27/35] modify genesis testcase for if xcatmaster=nodename --- xCAT-test/autotest/testcase/genesis/genesistest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/genesis/genesistest.pl b/xCAT-test/autotest/testcase/genesis/genesistest.pl index 47ee8f50d..5d24812a0 100755 --- a/xCAT-test/autotest/testcase/genesis/genesistest.pl +++ b/xCAT-test/autotest/testcase/genesis/genesistest.pl @@ -83,7 +83,7 @@ print "master is $master\n"; $nodestanza="/tmp/$noderange.stanza"; if (!(-e $nodestanza)) { `lsdef $noderange -z > $nodestanza`; - `chdef $noderange xcatmaster=$master`; + `chdef $noderange xcatmaster= `; } #################################### ####nodesetshell test for genesis From bf9c57f325b913ade079773eb5914a8c04f677ca Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 31 Jul 2017 21:15:08 -0400 Subject: [PATCH 28/35] Add 'Error' label when unable to get information --- xCAT-server/lib/xcat/plugins/openbmc.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 08c9abc5d..5d76bd340 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -877,7 +877,7 @@ sub parse_node_info { if ($openbmc_hash->{$node}->[0]->{'bmc'}) { $node_info{$node}{bmc} = $openbmc_hash->{$node}->[0]->{'bmc'}; } else { - xCAT::SvrUtils::sendmsg("Unable to get attribute bmc", $callback, $node); + xCAT::SvrUtils::sendmsg("Error: Unable to get attribute bmc", $callback, $node); $rst = 1; next; } @@ -887,7 +887,7 @@ sub parse_node_info { } elsif ($passwd_hash and $passwd_hash->{username}) { $node_info{$node}{username} = $passwd_hash->{username}; } else { - xCAT::SvrUtils::sendmsg("Unable to get attribute username", $callback, $node); + xCAT::SvrUtils::sendmsg("Error: Unable to get attribute username", $callback, $node); delete $node_info{$node}; $rst = 1; next; @@ -898,7 +898,7 @@ sub parse_node_info { } elsif ($passwd_hash and $passwd_hash->{password}) { $node_info{$node}{password} = $passwd_hash->{password}; } else { - xCAT::SvrUtils::sendmsg("Unable to get attribute password", $callback, $node); + xCAT::SvrUtils::sendmsg("Error: Unable to get attribute password", $callback, $node); delete $node_info{$node}; $rst = 1; next; @@ -906,7 +906,7 @@ sub parse_node_info { $node_info{$node}{cur_status} = "LOGIN_REQUEST"; } else { - xCAT::SvrUtils::sendmsg("Unable to get information from openbmc table", $callback, $node); + xCAT::SvrUtils::sendmsg("Error: Unable to get information from openbmc table", $callback, $node); $rst = 1; next; } From 9226f1f1f44d5eaab0e22df2ea5fe591dae6c1f0 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Mon, 31 Jul 2017 21:35:31 -0400 Subject: [PATCH 29/35] Remove the openbmc version information when running xCAT commands --- xCAT-server/lib/xcat/plugins/openbmc.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 08c9abc5d..d3503e4ea 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -467,9 +467,6 @@ sub parse_args { my $extrargs = shift; my $noderange = shift; my $check = undef; - - xCAT::SvrUtils::sendmsg("[OpenBMC development support] Using this version of xCAT, ensure firmware level is at v1.99.6-0-r1, or higher.", $callback); - my $subcommand = undef; my $verbose = undef; unless (GetOptions( From 38d0f9ba25622646a9b9ef020e704ead8ccf7403 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 1 Aug 2017 13:01:34 +0800 Subject: [PATCH 30/35] Add symbolic for ubuntu 16.04.2 support (#3576) --- .../share/xcat/netboot/ubuntu/compute.ubuntu16.04.2.pkglist | 1 + 1 file changed, 1 insertion(+) create mode 120000 xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.2.pkglist diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.2.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.2.pkglist new file mode 120000 index 000000000..e08894338 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.2.pkglist @@ -0,0 +1 @@ +compute.ubuntu16.04.1.pkglist \ No newline at end of file From cb00d0e154cb42022364590bf69f745e936993a4 Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 1 Aug 2017 02:31:24 -0400 Subject: [PATCH 31/35] [fvt] 'pgsqlsetup -i ' does not work well in rhels7.3 and rhels7.4 #3579 --- xCAT-client/bin/pgsqlsetup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-client/bin/pgsqlsetup b/xCAT-client/bin/pgsqlsetup index 7446f7aeb..5e9152c3c 100755 --- a/xCAT-client/bin/pgsqlsetup +++ b/xCAT-client/bin/pgsqlsetup @@ -760,7 +760,7 @@ sub initpgdb { $insertstr .= "host all all "; $insertstr .= $hbaaccess; - $insertstr .= "\/32 md5\n "; # add entry line to string + $insertstr .= "\/32 md5\\n "; # add entry line to string } } $cmd = "awk '{gsub(\"\IPv4 local connections:\",\"\IPv4 local connections:\\n$insertstr \"); print}' $hbafile > $hbafile.xcat"; From 71444ec61351178a45ff979d5447a2b653604d6a Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 1 Aug 2017 03:41:56 -0400 Subject: [PATCH 32/35] Install Capture::Tiny for Z in CI test environment --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a04874d6c..25ab2393e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ sudo: required before_install: - sudo apt-get install -y git reprepro devscripts debhelper libsoap-lite-perl libdbi-perl quilt openssh-server dpkg looptools genometools software-properties-common - perl -v +- echo "yes" | sudo cpan -f -i Capture::Tiny script: - echo $TRAVIS_BUILD_ID From c173fd3f0e257ca99110e448c3175980232a3b70 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Tue, 1 Aug 2017 06:40:34 -0400 Subject: [PATCH 33/35] modify rsetboot test dure to failed cases --- xCAT-test/autotest/testcase/rsetboot/cases0 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-test/autotest/testcase/rsetboot/cases0 b/xCAT-test/autotest/testcase/rsetboot/cases0 index 63b280588..bcec836d4 100644 --- a/xCAT-test/autotest/testcase/rsetboot/cases0 +++ b/xCAT-test/autotest/testcase/rsetboot/cases0 @@ -56,10 +56,10 @@ cmd:if [[ -f /tmp/rsetboot.stat ]];then mv -f /tmp/rsetboot.stat /tmp/rsetboot.s check:rc==0 cmd:rsetboot $$CN default check:rc==0 -check:output=~boot override inactive +check:output=~boot override inactive|Default cmd:rsetboot $$CN stat check:rc==0 -check:output=~$$CN: boot override inactive +check:output=~boot override inactive|$$CN: Default cmd:if [[ `grep CD /tmp/rsetboot.stat` ]];then rsetboot $$CN cd;elif [[ `grep Network /tmp/rsetboot.stat` ]];then rsetboot $$CN net;else rsetboot $$CN hd;fi check:rc==0 cmd:if [[ -f /tmp/rsetboot.stat.bak ]];then mv -f /tmp/rsetboot.stat.bak /tmp/rsetboot.stat;else rm -rf /tmp/rsetboot.stat;fi @@ -120,7 +120,7 @@ description:rsetboot node using invalidaction Attribute: $$CN-The operation object of rsetboot command. cmd:rsetboot $$CN dsdf check:rc!=0 -check:output=~Error: unsupported command +check:output=~Error: unsupported command|Unsupported command end start:rsetboot_group_net From b167c2932b8f7cfd7b31d7fb6b26a84e5898a7dc Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 1 Aug 2017 01:00:18 -0400 Subject: [PATCH 34/35] fix issue rinstall/winstall -c doesn't open console #3535 --- xCAT-client/bin/rinstall | 17 ++++++--- xCAT-server/lib/xcat/plugins/rinstall.pm | 45 +++++------------------- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/xCAT-client/bin/rinstall b/xCAT-client/bin/rinstall index 9d989a2e7..789222ba3 100755 --- a/xCAT-client/bin/rinstall +++ b/xCAT-client/bin/rinstall @@ -21,6 +21,7 @@ use Getopt::Long; use xCAT::MsgUtils; use xCAT::Utils; use xCAT::Client; +use xCAT::NodeRange; use Cwd; use strict; @@ -65,15 +66,23 @@ while ($arg =~ /^-/) { $cmdref->{noderange}->[0] = $arg; push(@{ $cmdref->{arg} }, @ARGV); +my $startconsole=0; +if(grep m/^-c|--console$/,@ARGV){ + $startconsole=1; +} + my $noderange = $cmdref->{noderange}->[0]; # save the noderange +my @noderange=xCAT::NodeRange::noderange($noderange); + +if($bname eq "rinstall" and $startconsole==1 and scalar @noderange!=1 ){ + xCAT::MsgUtils->message("E", "Error: rinstall can only be run against one node! Please use winstall for multiple nodes."); + exit 1; +} # ok call Client to run the plugin rinstall.pm xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response); - if ($xCAT::Client::EXITCODE == 0) # no errors { - my $startconsole = $cmdref->{startconsole}->[0]; - # if startconsole requested ( -c flag) for rinstall always for winstall # This is set in the rinstall plugin if ($startconsole == 1) { @@ -82,9 +91,7 @@ if ($xCAT::Client::EXITCODE == 0) # no errors exec("rcons $noderange"); } elsif (basename($0) =~ /winstall/) { - # winstall can commence a wcons command to the noderange for monitoring the provision cycle - exec("wcons $noderange"); } } diff --git a/xCAT-server/lib/xcat/plugins/rinstall.pm b/xCAT-server/lib/xcat/plugins/rinstall.pm index ea2f0003a..787fbc63d 100644 --- a/xCAT-server/lib/xcat/plugins/rinstall.pm +++ b/xCAT-server/lib/xcat/plugins/rinstall.pm @@ -335,6 +335,7 @@ sub rinstall { $rsp->{data}->[0] = "Provision node(s): @nodes"; xCAT::MsgUtils->message("I", $rsp, $callback); } + %nodes = map { $_, 1 } @nodes; # Run nodeset $noderange $parameter @@ -355,8 +356,8 @@ sub rinstall { push @{ $rsp->{data} }, @$res; xCAT::MsgUtils->message("D", $rsp, $callback); } - unless ($rc == 0) { + unless ($rc == 0) { # We got an error with the nodeset my @successnodes; my @failurenodes; @@ -364,12 +365,8 @@ sub rinstall { my @lines = @$res; foreach my $line (@lines) { $rsp->{data}->[0] = $line; - if (($line =~ /: install/) or ($line =~ /: netboot/)) { - my $successnode; - my $restline; - ($successnode, $restline) = split(/:/, $line, 2); - $nodes{$successnode} = 0; - push @successnodes, $successnode; + if($line =~ /The (\S+) can not be resolved/){ + push @failurenodes,$1; } if ($line =~ /dhcp server is not running/) { my $rsp = {}; @@ -380,18 +377,18 @@ sub rinstall { } xCAT::MsgUtils->message("I", $rsp, $callback); } - foreach my $node (@nodes) { - if ($nodes{$node} == 1) { - push @failurenodes, $node; - } + + foreach my $node (@failurenodes) { + delete $nodes{$node}; } + my $rsp = {}; if (0+@failurenodes > 0) { $rsp->{error}->[0] = "Failed to run 'nodeset' against the following nodes: @failurenodes"; $rsp->{errorcode}->[0] = 1; xCAT::MsgUtils->message("E", $rsp, $callback); } - @nodes = @successnodes; + @nodes = keys %nodes; } # Group the nodes according to the nodehm.mgt @@ -591,30 +588,6 @@ sub rinstall { } } - # Check if they asked to bring up a console (-c) from rinstall always for winstall - $req->{startconsole}->[0] = 0; - if ($command =~ /rinstall/) { - - # For rinstall, the -c|--console option can provide the remote console for only 1 node - if ($CONSOLE) { - if (scalar @nodes != 1) { - my $rsp = {}; - $rsp->{error}->[0] = "rinstall -c only accepts one node in the noderange. See winstall for support of consoles on multiple nodes."; - $rsp->{errorcode}->[0] = 1; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } - else { - # Tell rinstall client ok to start rcons - $req->{startconsole}->[0] = 1; - } - } - } - elsif ($command =~ /winstall/) { - - # Command winstall can start a wcons command to multiple nodes for monitoring the provision cycle - $req->{startconsole}->[0] = 1; - } return 0; } From 0d85cd441be3d7f42a8266ecd0b4e6cb210a9519 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Wed, 2 Aug 2017 14:39:28 +0800 Subject: [PATCH 35/35] 1, Make the function header and comments more clear --- perl-xCAT/xCAT/Scope.pm | 15 ++++++++------- xCAT-server/lib/xcat/plugins/grub2.pm | 16 +++++----------- xCAT-server/lib/xcat/plugins/petitboot.pm | 16 +++++----------- xCAT-server/lib/xcat/plugins/xnba.pm | 16 +++++----------- 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/perl-xCAT/xCAT/Scope.pm b/perl-xCAT/xCAT/Scope.pm index b35388fe3..39bb3da44 100644 --- a/perl-xCAT/xCAT/Scope.pm +++ b/perl-xCAT/xCAT/Scope.pm @@ -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}; diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 563595b72..03482eeb4 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -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; diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 46b471f8f..af3320ae2 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -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."; diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 834434a98..7250f1b6c 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -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.";