sequential discovery phase 2: add -n, osimage and -s flags

This commit is contained in:
ligc 2013-10-15 16:06:26 +08:00
parent f788778e48
commit 6375fb72ad
2 changed files with 101 additions and 2 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

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