2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-02 19:40:10 +00:00

Merge branch 'master' of ssh://git.code.sf.net/p/xcat/xcat-core

This commit is contained in:
wanghuaz 2013-10-15 02:32:43 -07:00
commit 882d64f809
3 changed files with 120 additions and 21 deletions

14
xCAT-client/pods/man1/nodediscoverstart.1.pod Normal file → Executable file
View File

@ -10,7 +10,7 @@ B<Sequential Discovery Specific:>
=over 2
B<nodediscoverstart> B<noderange=>I<noderange> [B<hostiprange=>I<imageprofile>] [B<bmciprange=>I<bmciprange>] [B<groups=>I<groups>] [B<rack=>I<rack>] [B<chassis=>I<chassis>] [B<height=>I<height>] [B<unit=>I<unit>] [B<-V|--verbose>]
B<nodediscoverstart> B<noderange=>I<noderange> [B<hostiprange=>I<imageprofile>] [B<bmciprange=>I<bmciprange>] [B<groups=>I<groups>] [B<rack=>I<rack>] [B<chassis=>I<chassis>] [B<height=>I<height>] [B<unit=>I<unit>] [osimage=<osimagename>] [-n|--dns] [-s|--skipbmcsetup] [B<-V|--verbose>]
=back
@ -115,6 +115,18 @@ Sets the start unit value for the node in the rack, for either the Sequential Di
Specifies the starting rank number that is used in the node name format, for the Profile Discovery method. The rank number must be a valid integer between 0 and 254. This option must be specified with nodenameformat option. For example, if your node name format is compute-#RR-#NN. The rack's number is 2 and rank is specified as 5, the node name is generated as follows: compute-02-05, compute-02-06, ..., compute-02-99.
=item B<osimage=>I<osimagename>
Specifies the osimage name that will be associated with the new discovered node, the os provisioning will be started automatically at the end of the discovery process.
=item B<-n|--dns>
Specifies to run makedns <nodename> for any new discovered node. This is useful mainly for non-predefined configuration, before running the "nodediscoverstart -n", the user needs to run makedns -n to initialize the named setup on the management node.
=item B<-s|--skipbmcsetup>
Specifies to skip the bmcsetup during the sequential discovery process, if the bmciprange is specified with nodediscoverstart command, the BMC will be setup automatically during the discovery process, if the user does not want to run bmcsetup, could specify the "-s|--skipbmcsetup" with nodediscoverstart command to skip the bmcsetup.
=item B<-V|--verbose>
Enumerates the free node names and host/bmc ips that are being specified in the ranges given. Use this option

View File

@ -1710,35 +1710,35 @@ sub validate_os{
unless ( $catched ) {
# my %rsp;
# push@{ $rsp{data} }, "osimage $os doesn't fit to kit component $kitcomp->{kitcompname} with attribute OS";
# push@{ $rsp{data} }, "osimage $os is not compatible with kit component $kitcomp->{kitcompname} with attribute OS";
# xCAT::MsgUtils->message( "E", \%rsp, $::CALLBACK );
return 1;
}
if ( $osimage->{majorversion} ne $kitcomp->{osmajorversion} ) {
# my %rsp;
# push@{ $rsp{data} }, "osimage $os doesn't fit to kit component $kitcomp->{kitcompname} with attribute majorversion";
# push@{ $rsp{data} }, "osimage $os is not compatible with kit component $kitcomp->{kitcompname} with attribute majorversion";
# xCAT::MsgUtils->message( "E", \%rsp, $::CALLBACK );
return 1;
}
if ( $kitcomp->{osminorversion} and ($osimage->{minorversion} ne $kitcomp->{osminorversion}) ) {
# my %rsp;
# push@{ $rsp{data} }, "osimage $os doesn't fit to kit component $kitcomp->{kitcompname} with attribute minorversion";
# push@{ $rsp{data} }, "osimage $os is not compatible with kit component $kitcomp->{kitcompname} with attribute minorversion";
# xCAT::MsgUtils->message( "E", \%rsp, $::CALLBACK );
return 1;
}
if ( $osimage->{arch} ne $kitcomp->{osarch} ) {
# my %rsp;
# push@{ $rsp{data} }, "osimage $os doesn't fit to kit component $kitcomp->{kitcompname} with attribute arch";
# push@{ $rsp{data} }, "osimage $os is not compatible with kit component $kitcomp->{kitcompname} with attribute arch";
# xCAT::MsgUtils->message( "E", \%rsp, $::CALLBACK );
return 1;
}
if ( $osimage->{type} ne $kitcomp->{ostype} ) {
# my %rsp;
# push@{ $rsp{data} }, "osimage $os doesn't fit to kit component $kitcomp->{kitcompname} with attribute type";
# push@{ $rsp{data} }, "osimage $os is not compatible with kit component $kitcomp->{kitcompname} with attribute type";
# xCAT::MsgUtils->message( "E", \%rsp, $::CALLBACK );
return 1;
}
@ -1760,7 +1760,7 @@ sub validate_os{
}
if ( !$match ) {
# my %rsp;
# push@{ $rsp{data} }, "osimage $os doesn't fit to kit component $kitcomp->{kitcompname} with attribute serverrole";
# push@{ $rsp{data} }, "osimage $os is not compatible with kit component $kitcomp->{kitcompname} with attribute serverrole";
# xCAT::MsgUtils->message( "E", \%rsp, $::CALLBACK );
return 1;
}
@ -1993,35 +1993,35 @@ sub addkitcomp
unless ( $catched ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute OS";
push@{ $rsp{data} }, "osimage $osimage is not compatible with kit component $kitcomp with attribute OS";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $os{$osimage}{majorversion} ne $kitcomps{$kitcomp}{osmajorversion} ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute majorversion";
push@{ $rsp{data} }, "osimage $osimage is not compatible with kit component $kitcomp with attribute majorversion";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $kitcomps{$kitcomp}{osminorversion} and ($os{$osimage}{minorversion} ne $kitcomps{$kitcomp}{osminorversion}) ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute minorversion";
push@{ $rsp{data} }, "osimage $osimage is not compatible with kit component $kitcomp with attribute minorversion";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $os{$osimage}{arch} ne $kitcomps{$kitcomp}{osarch} ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute arch";
push@{ $rsp{data} }, "osimage $osimage is not compatible with kit component $kitcomp with attribute arch";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $os{$osimage}{type} ne $kitcomps{$kitcomp}{ostype} ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute type";
push@{ $rsp{data} }, "osimage $osimage is not compatible with kit component $kitcomp with attribute type";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
@ -2044,7 +2044,7 @@ sub addkitcomp
}
if ( !$match ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute serverrole";
push@{ $rsp{data} }, "osimage $osimage is not compatible with kit component $kitcomp with attribute serverrole";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
@ -3308,35 +3308,35 @@ sub chkkitcomp
}
unless ( $catched ) {
my %rsp;
push@{ $rsp{data} }, "kit component $kitcomp doesn't fit to osimage $osimage with attribute OS";
push@{ $rsp{data} }, "kit component $kitcomp is not compatible with osimage $osimage with attribute OS";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $os{$osimage}{majorversion} ne $kitcomps{$kitcomp}{osmajorversion} ) {
my %rsp;
push@{ $rsp{data} }, "kit component $kitcomp doesn't fit to osimage $osimage with attribute majorversion";
push@{ $rsp{data} }, "kit component $kitcomp is not compatible with osimage $osimage with attribute majorversion";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $kitcomps{$kitcomp}{osminorversion} and ($os{$osimage}{minorversion} ne $kitcomps{$kitcomp}{osminorversion}) ) {
my %rsp;
push@{ $rsp{data} }, "kit component $kitcomp doesn't fit to osimage $osimage with attribute minorversion";
push@{ $rsp{data} }, "kit component $kitcomp is not compatible with osimage $osimage with attribute minorversion";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $os{$osimage}{arch} ne $kitcomps{$kitcomp}{osarch} ) {
my %rsp;
push@{ $rsp{data} }, "kit component $kitcomp doesn't fit to osimage $osimage with attribute arch";
push@{ $rsp{data} }, "kit component $kitcomp is not compatible with osimage $osimage with attribute arch";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
if ( $os{$osimage}{type} ne $kitcomps{$kitcomp}{ostype} ) {
my %rsp;
push@{ $rsp{data} }, "kit component $kitcomp doesn't fit to osimage $osimage with attribute type";
push@{ $rsp{data} }, "kit component $kitcomp is not compatible with osimage $osimage with attribute type";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
@ -3359,7 +3359,7 @@ sub chkkitcomp
}
if ( !$match ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute serverrole";
push@{ $rsp{data} }, "osimage $osimage is not compatible with kit component $kitcomp with attribute serverrole";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
@ -3382,7 +3382,7 @@ sub chkkitcomp
my $kitcompnamelist = join ',', @kitcompnames;
my %rsp;
push@{ $rsp{data} }, "Kit components $kitcompnamelist fit to osimage $osimage";
push@{ $rsp{data} }, "Kit components $kitcompnamelist are compatible with osimage $osimage";
xCAT::MsgUtils->message( "I", \%rsp, $callback );
return;

89
xCAT-server/lib/xcat/plugins/seqdiscovery.pm Normal file → Executable file
View File

@ -77,6 +77,7 @@ sub findme {
my $mac;
my $ip = $request->{'_xcat_clientip'};
if (defined $request->{nodetype} and $request->{nodetype}->[0] eq 'virtual') {
xCAT::MsgUtils->message("S", "Sequential discovery does not support virtual machines, exiting...");
return;
}
my $arptable;
@ -211,6 +212,16 @@ sub findme {
$req->{command}=['makehosts'];
$req->{node} = \@newhosts;
$subreq->($req);
# run makedns only when -n flag was specified with nodediscoverstart,
# dns=yes in site.__SEQDiscover
if (defined($param{'dns'}) && ($param{'dns'} eq 'yes'))
{
my $req;
$req->{command}=['makedns'];
$req->{node} = \@newhosts;
$subreq->($req);
}
}
# set the specific attributes from parameters
@ -291,6 +302,65 @@ sub findme {
$hmtab->setNodeAttribs($node, {mgt=>"ipmi"});
}
my $chaintab = xCAT::Table->new('chain');
# Could not open chain table, but do not fail the discovery process
if (!$chaintab) {
xCAT::MsgUtils->message("S", "Error: could not open chain table");
} else {
my $chainent = $chaintab->getNodeAttribs($node, ['chain']);
my $nodechain = '';
my $origchain = '';
if (defined($chainent->{'chain'})) {
$nodechain = $chainent->{'chain'};
$origchain = $nodechain;
}
# If the bmciprange=xxx is specified with nodediscoverstart command,
# add the runcmd=bmcsetup at the beginning of the chain attribute
# the skipbmcsetup could be used to skip the bmcsetup for the node
if ($param{'bmciprange'} && !$param{'skipbmcsetup'}) {
if (!$nodechain) {
$nodechain = "runcmd=bmcsetup";
} else {
# do not add duplicate runcmd=bmcsetup in the chain attribute
if ($nodechain !~ /runcmd=bmcsetup/) {
$nodechain = "runcmd=bmcsetup," . $nodechain;
}
}
} # end if $param{'bmciprange'}
# Remove the runcmd=bmcsetup from chain if skipbmcsetup is specified
# this is useful for predefined configuration, or attributes inherit from groups
if ($param{'skipbmcsetup'}) {
if ($nodechain =~ /runcmd=bmcsetup/) {
$nodechain =~ s/runcmd=bmcsetup,//;
$nodechain =~ s/runcmd=bmcsetup//;
}
}
# If the osimage=xxx is specified with nodediscoverstart command,
# append the osimage=xxx at the end of the chain attribute
if ($param{'osimage'}) {
if (!$nodechain) {
$nodechain = "osimage=$param{'osimage'}";
} else {
# do not add multiple osimage=xxx in the chain attribute
# replace the old one with the new one
if ($nodechain !~ /osimage=/) {
$nodechain = $nodechain . ",osimage=$param{'osimage'}";
} else {
$nodechain =~ s/osimage=\w+/osimage=$param{'osimage'}/;
}
}
} # end if $param{'osimage'}
# Update the table only when the chain attribute is changed
if ($nodechain ne $origchain) {
$chaintab->setNodeAttribs($node, {chain => $nodechain});
}
$chaintab->close();
}
# call the discovered command to update the discovery request to a node
$request->{command}=['discovered'];
$request->{noderange} = [$node];
@ -343,7 +413,7 @@ Usage:
Common:
nodediscoverstart [-h|--help|-v|--version|-V|--verbose]
Sequential Discovery:
nodediscoverstart noderange=<noderange> [hostiprange=<imageprofile>] [bmciprange=<bmciprange>] [groups=<groups>] [rack=<rack>] [chassis=<chassis>] [height=<height>] [unit=<unit>]
nodediscoverstart noderange=<noderange> [hostiprange=<hostiprange>] [bmciprange=<bmciprange>] [groups=<groups>] [rack=<rack>] [chassis=<chassis>] [height=<height>] [unit=<unit>] [osimage=<osimagename>] [-n|--dns] [-s|--skipbmcsetup] [-V|--verbose]
Profile Discovery:
nodediscoverstart networkprofile=<networkprofile> imageprofile=<imageprofile> hostnameformat=<hostnameformat> [hardwareprofile=<hardwareprofile>] [groups=<groups>] [rack=<rack>] [chassis=<chassis>] [height=<height>] [unit=<unit>] [rank=rank-num]";
$rsp = ();
@ -361,6 +431,7 @@ Usage:
'chassis' => 1,
'height' => 1,
'unit' => 1,
'osimage' => 1,
);
if ($args) {
@ -370,6 +441,8 @@ Usage:
if (!GetOptions(
'h|help' => \$help,
'V|verbose' => \$::VERBOSE,
'-n|dns' => \$::DNS,
'-s|skipbmcsetup' => \$::SKIPBMCSETUP,
'v|version' => \$ver)) {
$usage->($callback);
return;
@ -423,6 +496,20 @@ Usage:
$textparam .= $name.'='.$param{$name}.',';
}
# If the -n flag is specified,
# add setupdns=yes into site.__SEQDiscover
if ($::DNS)
{
$textparam .= "dns=yes,";
}
# If the -s flag is specified,
# add skipbmcsetup=yes into site.__SEQDiscover
if ($::SKIPBMCSETUP)
{
$textparam .= "skipbmcsetup=yes,";
}
$textparam =~ s/,\z//;
# Check the running of profile-based discovery