2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-07-16 01:21:10 +00:00

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

This commit is contained in:
GONG Jie
2015-05-13 13:42:16 +08:00
39 changed files with 1318 additions and 545 deletions

View File

@@ -263,6 +263,9 @@ do : ; done
# Upload the README to the SF FRS Area
cd xcat-dep
# add a comment to indicate the latest xcat-dep tar ball name
sed "6 iThe latest xcat-dep tar ball is ${DFNAME}" -i README
i=0
echo "Uploading README to $FRS/xcat-dep/$FRSDIR/ ..."
while [ $((i+=1)) -le 5 ] && ! rsync -v README $UPLOADUSER,xcat@web.sourceforge.net:$FRS/xcat-dep/$FRSDIR/

View File

@@ -643,7 +643,7 @@ noderes => {
descriptions => {
node => 'The node name or group name.',
servicenode => 'A comma separated list of node names (as known by the management node) that provides most services for this node. The first service node on the list that is accessible will be used. The 2nd node on the list is generally considered to be the backup service node for this node when running commands like snmove.',
netboot => 'The type of network booting to use for this node. Valid values: pxe or xnba for x86* architecture, yaboot for POWER architecture, grub2-tftp and grub2-http for RHEL7 on Power and all the os deployment on Power LE. Notice: yaboot is not supported from rhels7 on Power,use grub2-tftp or grub2-http instead, the difference between the 2 is the file transfer protocol(i.e, http or tftp)',
netboot => 'The type of network booting to use for this node. Valid values: pxe or xnba for x86* architecture, yaboot for ppc64 RHEL 6 and SLES 11, grub2 for ppc64 RHEL7 and all the Little-Endian os deployment on PowerKVM guests, petiboot for the PowerNV deployment',
tftpserver => 'The TFTP server for this node (as known by this node). If not set, it defaults to networks.tftpserver.',
tftpdir => 'The directory that roots this nodes contents from a tftp and related perspective. Used for NAS offload by using different mountpoints.',
nfsserver => 'The NFS or HTTP server for this node (as known by this node).',
@@ -771,7 +771,7 @@ linuximage => {
permission => 'The mount permission of /.statelite directory is used, its default value is 755',
dump => qq{The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs://<nfs_server_ip>/<kdump_path>". If you want to use the node's "xcatmaster" (its SN or MN), <nfs_server_ip> can be left blank. For example, "nfs:///<kdump_path>" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN.},
crashkernelsize => 'the size that assigned to the kdump kernel. If the kernel size is not set, 256M will be the default value.',
partitionfile => 'The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "<partition file absolute path>" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES). "s:<partitioning script absolute path>" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify "<partition file absolute path>"; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.',
partitionfile => 'The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "<partition file absolute path>" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:<partitioning script absolute path>" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify "<partition file absolute path>"; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "<partition file absolute path>" or "s:<partitioning script absolute path>", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:<the absolute path of the disk name file>" which contains the disk name(s) to partition and "s:d:<the absolute path of the disk script>" which runs in pressed/early_command and writes the disk names into the "/tmp/boot_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:<the absolute path of the additional pressed config file>" which contains the additional pressed entries in "d-i ..." form and "s:c:<the absolute path of the additional pressed config script>" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," ',
driverupdatesrc => 'The source of the drivers which need to be loaded during the boot. Two types of driver update source are supported: Driver update disk and Driver rpm package. The value for this attribute should be comma separated sources. Each source should be the format tab:full_path_of_srouce_file. The tab keyword can be: dud (for Driver update disk) and rpm (for driver rpm). If missing the tab, the rpm format is the default. e.g. dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
@@ -1739,6 +1739,7 @@ foreach my $tabname (keys(%xCAT::ExtTab::ext_tabspec)) {
osdistro=> { attrs => [], attrhash => {}, objkey => 'osdistroname' },
osdistroupdate=> { attrs => [], attrhash => {}, objkey => 'osupdatename' },
zone=> { attrs => [], attrhash => {}, objkey => 'zonename' },
switch=> { attrs => [], attrhash => {}, objkey => 'switch' },
);
@@ -3760,6 +3761,67 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs);
);
#############################
# switch object #
#############################
# switch table #
#############################
@{$defspec{switch}->{'attrs'}} = (
{attr_name => 'switch',
tabentry => 'switches.switch',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'snmpusername',
tabentry => 'switches.username',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'snmppassword',
tabentry => 'switches.password',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'snmpversion',
tabentry => 'switches.snmpversion',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'privacy',
tabentry => 'switches.privacy',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'auth',
tabentry => 'switches.auth',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'linkports',
tabentry => 'switches.linkports',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'sshusername',
tabentry => 'switches.sshusername',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'sshpassword',
tabentry => 'switches.sshpassword',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'protocol',
tabentry => 'switches.protocol',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'switchtype',
tabentry => 'switches.switchtype',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'comments',
tabentry => 'switches.comments',
access_tabentry => 'switches.switch=attr:switch',
},
{attr_name => 'disable',
tabentry => 'switches.disable',
access_tabentry => 'switches.switch=attr:switch',
},
);
###################################################
###################################################

View File

@@ -286,6 +286,9 @@ my %usage = (
"Usage: lsslp [-h|--help|-v|--version]
lsslp [<noderange>][-V|--verbose][-i ip[,ip..]][-w][-r|-x|-z][-n][-I][-s FRAME|CEC|MM|IVM|RSA|HMC|CMM|IMM2|FSP]
[-u] [--range IPranges][-t tries][--vpdtable][-C counts][-T timeout]",
"switchdiscover" =>
"Usage: switchdiscover [-h|--help|-v|--version]
switchdiscover [<noderange>][-V|--verbose][-i adpt[,adpt..]][-w][-r|-x|-z][-n][-s scan_methods]",
"rflash" =>
"Usage:
rflash [ -h|--help|-v|--version]
@@ -481,6 +484,7 @@ my %version = (
"chvm" => "$vers",
"rmvm" => "$vers",
"lsslp" => "$vers",
"switchdiscover" => "$vers",
"rflash" => "$vers",
"renergy" => "$vers",
"lsflexnode" => "$vers",

View File

@@ -20,7 +20,10 @@ use xCAT::Utils;
use Getopt::Long;
use POSIX qw(:signal_h :errno_h :sys_wait_h);
use Thread qw(yield);
$::asucmd = '/opt/ibm/toolscenter/asu/asu64';
$::asucmd = '/opt/lenovo/toolscenter/asu/asu64';
if (! -x $::asucmd) {
$::asucmd = '/opt/ibm/toolscenter/asu/asu64';
}
my $interface;
my $username;
my $passwd;

View File

@@ -0,0 +1,81 @@
=head1 NAME
B<switchdiscover> - Discover all the switches on the subnets.
=head1 SYNOPSIS
I<switchdiscover [-h| --help]>
I<switchdiscover [-v| --version]>
I<switchdiscover [noderange] [-V] [-i adpt[,adpt..]][-w][-r|-x|-z][-n][-s scan_methods]>
=head1 DESCRIPTION
The switchdiscover command scan the subnets and discover all the swithches on the subnets. The default subnets will be the ones that the xCAT management node is on. The command will also take a subnet as an input. The default discovery method will be lldpd. The nmap and snmp methods will be supported as options chosen by -s option. The optional -r -x and -z format the output.
=head1 OPTIONS
B<noderange> The switches which the user want to discover.
If the user specify the noderange, switchdiscover will just return the switches
in the node range. Which means it will help to add the new switches to the xCAT
database without modifying the existed definitions. But the switches' name
specified in noderange should be defined in database in advance. The ips of the
switches will be defined in /etc/hosts file. This command will fill the switch
attributes for the switches defined.
B<-i> adapter(s) the command will search through (defaults to all available adapters).
B<-h> Display usage message.
B<-n> Only display and write the newly discovered switches.
B<--range> Specify one or more IP ranges.
It accepts multiple formats. For example, 192.168.1.1/24, 40-41.1-2.3-4.1-100.
If the range is huge, for example, 192.168.1.1/8, lsslp may take a very long
time for node scan. So the range should be exactly specified.
B<-r> Display Raw response.
B<-s> It is a comma separated list of methods for switch discovery.
The possible switch scan methods are: llpd, nmap and snmp. The default is lldpd.
B<-v> Command Version.
B<-V> Verbose output.
B<-w> Writes output to xCAT database.
B<-x> XML format.
B<-z> Stanza formated output.
=head1 RETURN VALUE
0 The command completed successfully.
1 An error has occurred.
=head1 EXAMPLES
=head1 FILES
/opt/xcat/bin/switchdiscover
=head1 SEE ALSO

View File

@@ -163,6 +163,7 @@ ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/lsflexnode
ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/rmflexnode
ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/mkflexnode
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/lsslp
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/switchdiscover
ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/imgcapture
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/swapnodes
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/nodegrpch

View File

@@ -23,6 +23,15 @@ fi
mkdir -p $DRACUTMODDIR
cp $DIR/* $DRACUTMODDIR
# Remove the ipr(IBM Power RAID) stuff when building on x86_64
if [ $BUILDARCH = "x86_64" ]; then
sed -i 's/dracut_install \/lib64\/libform.so.5//' $DRACUTMODDIR/install
sed -i 's/\/lib64\/libpanel.so.5//' $DRACUTMODDIR/install
sed -i 's/\/lib64\/libmenu.so.5//' $DRACUTMODDIR/install
sed -i 's/\/lib64\/libsysfs.so.2//' $DRACUTMODDIR/install
sed -i 's/\/usr\/sbin\/iprconfig//' $DRACUTMODDIR/install
sed -i 's/instmods ipr//' $DRACUTMODDIR/installkernel
fi
if [ "$HOSTOS" = "mcp" ]; then
#Special handlings for MCP PPC64 platform building.
if [ $BUILDARCH = "ppc64" ]; then

View File

@@ -623,3 +623,4 @@ dracut_install /lib/udev/rules.d/11-dm-lvm.rules
dracut_install /lib/udev/rules.d/13-dm-disk.rules
dracut_install /lib/udev/rules.d/69-dm-lvm-metad.rules
dracut_install /lib/udev/rules.d/95-dm-notify.rules
dracut_install /lib64/libform.so.5 /lib64/libpanel.so.5 /lib64/libmenu.so.5 /lib64/libsysfs.so.2 /usr/sbin/iprconfig # iprconfig for IBM Power RAID configuration

View File

@@ -10,3 +10,4 @@ instmods ibmvscsi # ppc64 virtual disk
instmods ehea # ppc64 hea ethernet
instmods dm-mod #support LVM for sysclone
instmods sg # Lenovo thinkserver firmware update support
instmods ipr # IBM Power RAID

View File

@@ -1,4 +1,4 @@
%define version 2.9
%define version 2.10
%ifarch i386 i586 i686 x86
%define tarch x86
%endif

View File

@@ -393,8 +393,8 @@ sub subvars {
$partcontent .= "/tmp/partscript\n";
}else{
# Put the code to decode the preseed recipe file
#$partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partscript.enc\",\"rb\").read())' >/tmp/partitioning\n";
$partcontent .= "base64decode</tmp/partscript.enc >/tmp/partitioning\n";
#$partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partscript.enc\",\"rb\").read())' >/tmp/partitionfile\n";
$partcontent .= "base64decode</tmp/partscript.enc >/tmp/partitionfile\n";
}
#replace the #XCA_PARTMAN_RECIPE_SCRIPT#

View File

@@ -260,11 +260,11 @@ sub mknetboot
if (!defined($::DISABLENODESETWARNING)) { # set by AAsn.pm
$callback->(
{
warning => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated. They should continue to work in this release, but have not been tested as carefully, and some new functions are not available with these options. For full function and support, use \"nodeset <noderange> osimage=<osimage_name>\" instead."],
error => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], errorcode => [1]
}
);
# Do not print this warning message multiple times
last;
exit(1);
}
}
}
@@ -981,11 +981,11 @@ sub mkinstall
if (!defined($::DISABLENODESETWARNING)) { # set by AAsn.pm
$callback->(
{
warning => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated. They should continue to work in this release, but have not been tested as carefully, and some new functions are not available with these options. For full function and support, use \"nodeset <noderange> osimage=<osimage_name>\" instead."],
error => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], errorcode => [1]
}
);
# Do not print this warning message multiple times
last;
exit(1);
}
}
}
@@ -1629,11 +1629,11 @@ sub mksysclone
if (!defined($::DISABLENODESETWARNING)) { # set by AAsn.pm
$callback->(
{
warning => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated. They should continue to work in this release, but have not been tested as carefully, and some new functions are not available with these options. For full function and support, use \"nodeset <noderange> osimage=<osimage_name>\" instead."],
error => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], errorcode => [1]
}
);
# Do not print this warning message multiple times
last;
exit(1);
}
}
}

View File

@@ -0,0 +1,521 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------
=head1
xCAT plugin package to handle BMC discovery
=cut
#-------------------------------------------------------
package xCAT_plugin::bmcdiscover;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
use IO::Socket;
use Thread qw(yield);
use POSIX "WNOHANG";
use Storable qw(store_fd fd_retrieve);
use strict;
use warnings "all";
use Getopt::Long;
use xCAT::Table;
use xCAT::Utils;
use xCAT::MsgUtils;
use Getopt::Long;
use Data::Dumper;
use File::Basename;
use File::Path;
use Cwd;
my $nmap_path;
my $debianflag = 0;
my $tempstring = xCAT::Utils->osver();
if ( $tempstring =~ /debian/ || $tempstring =~ /ubuntu/ ){
$debianflag = 1;
}
my $parent_fd;
#-------------------------------------------------------
=head3 handled_commands
Return list of commands handled by this plugin
=cut
#-------------------------------------------------------
sub handled_commands
{
return {
bmcdiscover => "bmcdiscover",
};
}
#-------------------------------------------------------
=head3 process_request
Process the command
=cut
#-------------------------------------------------------
sub process_request
{
my $request = shift;
my $callback = shift;
my $request_command = shift;
$::CALLBACK = $callback;
$::args = $request->{arg};
unless(defined($request->{arg})){
bmcdiscovery_usage();
return 2;
}
@ARGV = @{$request->{arg}};
if($#ARGV eq -1){
return 2;
}
my $command = $request->{command}->[0];
my $rc;
if ($command eq "bmcdiscover"){
$rc = bmcdiscovery($request, $callback, $request_command);
} else{
$callback->({error=>["Error: $command not found in this module."],errorcode=>[1]});
return 1;
}
}
#----------------------------------------------------------------------------
=head3 bmcdiscover_usage
Display the bmcdiscover usage
=cut
#-----------------------------------------------------------------------------
sub bmcdiscovery_usage {
my $rsp;
push @{ $rsp->{data} },
"\nUsage: bmcdiscover - discover bmc using scan method,now scan_method can be nmap .\n";
push @{ $rsp->{data} }, "\tbmcdiscover [-h|--help|-?]\n";
push @{ $rsp->{data} }, "\tbmcdiscover [-v|--version]\n ";
push @{ $rsp->{data} }, "\tbmcdiscover [-m|--method] scan_method [-r|--range] ip_range \n ";
push @{ $rsp->{data} }, "\tFor example: \n ";
push @{ $rsp->{data} }, "\tbmcdiscover -m nmap -r \"10.4.23.100-254 50.3.15.1-2\" \n ";
push @{ $rsp->{data} }, "\tNote : ip_range should be a string, can pass hostnames, IP addresses, networks, etc. \n ";
push @{ $rsp->{data} }, "\tIf there is bmc,bmcdiscover returns bmc ip or hostname, or else, it returns null. \n ";
push @{ $rsp->{data} }, "\tEx: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254 \n ";
xCAT::MsgUtils->message( "I", $rsp, $::CALLBACK );
return 0;
}
#----------------------------------------------------------------------------
=head3 bmcdiscovery_processargs
Process the bmcdiscovery command line
Returns:
0 - OK
1 - just print version
2 - just print help
3 - error
=cut
#-----------------------------------------------------------------------------
sub bmcdiscovery_processargs {
if ( defined ($::args) && @{$::args} ){
@ARGV = @{$::args};
}
# parse the options
# options can be bundled up like -v, flag unsupported options
Getopt::Long::Configure( "bundling", "no_ignore_case", "no_pass_through" );
my $getopt_success = Getopt::Long::GetOptions(
'help|h|?' => \$::opt_h,
'method|m=s' => \$::opt_M,
'range|r=s' => \$::opt_R,
#'user|U=s' => \$::opt_U,
#'password|P=s' => \$::opt_P,
'version|v' => \$::opt_v,
);
if (!$getopt_success) {
return 3;
}
######################################
# check if there is nmap or not
######################################
if ( -x '/usr/bin/nmap' )
{
$nmap_path="/usr/bin/nmap";
}
elsif ( -x '/usr/local/bin/nmap' )
{
$nmap_path="/usr/local/bin/nmap";
}
else
{
my $rsp;
push @{ $rsp->{data} }, "\tThere is no nmap in /usr/bin/ or /usr/local/bin/. \n ";
xCAT::MsgUtils->message( "E", $rsp, $::CALLBACK );
return 1;
}
#########################################
# This command is for linux
#########################################
if ($^O ne 'linux') {
my $rsp = {};
push @{ $rsp->{data}}, "The bmcdiscovery command is only supported on Linux.\n";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
return 1;
}
##########################################
# Option -h for Help
##########################################
if ( defined($::opt_h) ) {
return 2;
}
#########################################
# Option -v for version
#########################################
if ( defined($::opt_v) ) {
create_version_response('bmcdiscover');
# no usage - just exit
return 1;
}
#########################################
# Option -m -r are must
######################################33
if ( defined($::opt_M) && defined($::opt_R) ) {
#$::method = split_comma_delim_str($::opt_M);
#$::range = split_comma_delim_str ($::opt_R);
return 0;
}
#########################################
# Other attributes are not allowed
#########################################
return 3;
}
#----------------------------------------------------------------------------
=head3 scan_process
Process the bmcdiscovery command line
Returns:
0 - OK
1 - just print version
2 - just print help
3 - error
=cut
#-----------------------------------------------------------------------------
sub scan_process{
my $method = shift;
my $range = shift;
my $callback = $::CALLBACK;
my $children; # The number of child process
my %sp_children; # Record the pid of child process
my $sub_fds = new IO::Select; # Record the parent fd for each child process
my $ip_list;
############################################################
# get live ip list
###########################################################
if ( $method eq "nmap" ) {
my $bcmd = join(" ",$nmap_path," -sn $range | grep for |cut -d ' ' -f5 |tr -s '\n' ' ' ");
$ip_list = xCAT::Utils->runcmd("$bcmd", -1);
if ($::RUNCMD_RC != 0) {
my $rsp = {};
push @{ $rsp->{data} }, "Nmap scan is failed.\n";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
return 2;
}
}
else
{
my $rsp = {};
push @{ $rsp->{data}}, "The bmcdiscover method should be nmap.\n";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
return 2;
}
my $live_ip=split_comma_delim_str($ip_list);
if (defined($live_ip)){
if ( scalar (@{$live_ip}) > 0 )
{
###############################
# Set the signal handler for ^c
###############################
$SIG{TERM} = $SIG{INT} = sub {
foreach (keys %sp_children) {
kill 2, $_;
}
$SIG{ALRM} = sub {
while (wait() > 0) {
yield;
}
exit @_;
};
alarm(1); # wait 1s for grace exit
};
######################################################
# Set the singal handler for child process finished it's work
######################################################
$SIG{CHLD} = sub {
my $cpid;
while (($cpid = waitpid(-1, WNOHANG)) > 0) {
if ($sp_children{$cpid}) {
delete $sp_children{$cpid};
$children--;
}
}
};
for (my $i = 0; $i < scalar (@{$live_ip}); $i ++) {
# fork a sub process to handle the communication with service processor
$children++;
my $cfd;
# the $parent_fd will be used by &send_rep() to send response from child process to parent process
socketpair($parent_fd, $cfd,AF_UNIX,SOCK_STREAM,PF_UNSPEC) or die "socketpair: $!";
$cfd->autoflush(1);
$parent_fd->autoflush(1);
my $child = xCAT::Utils->xfork;
if ($child == 0) {
close($cfd);
$callback = \&send_rep;
bmcdiscovery_ipmi(${$live_ip}[$i]);
exit 0;
} else {
# in the main process, record the created child process and add parent fd for the child process to an IO:Select object
# the main process will check all the parent fd and receive response
$sp_children{$child}=1;
close ($parent_fd);
$sub_fds->add($cfd);
}
do {
sleep(1);
} until ($children < 32);
}
#################################################
# receive data from child processes
################################################
while ($sub_fds->count > 0 or $children > 0) {
forward_data($callback,$sub_fds);
}
while (forward_data($callback,$sub_fds)) {
}
}
}
}
#----------------------------------------------------------------------------
=head3 send_rep
DESCRIPTION:
Send date from forked child process to parent process.
This subroutine will be replace the original $callback in the forked child process
ARGUMENTS:
$resp - The response which generated in xCAT::Utils->message();
=cut
#----------------------------------------------------------------------------
sub send_rep {
my $resp=shift;
unless ($resp) { return; }
store_fd($resp,$parent_fd);
}
#----------------------------------------------------------------------------
=head3 forward_data
DESCRIPTION:
Receive data from forked child process and call the original $callback to forward data to xcat client
=cut
#----------------------------------------------------------------------------
sub forward_data {
my $callback = shift;
my $fds = shift;
my @ready_fds = $fds->can_read(1);
my $rfh;
my $rc = @ready_fds;
foreach $rfh (@ready_fds) {
my $data;
my $responses;
eval {
$responses = fd_retrieve($rfh);
};
if ($@ and $@ =~ /^Magic number checking on storable file/) { #this most likely means we ran over the end of available input
$fds->remove($rfh);
close($rfh);
} else {
eval { print $rfh "ACK\n"; }; #Ignore ack loss due to child giving up and exiting, we don't actually explicitly care about the acks
$callback->($responses);
}
}
yield; #Try to avoid useless iterations as much as possible
return $rc;
}
#----------------------------------------------------------------------------
=head3 split_comma_delim_str
Split comma-delimited list of strings into an array.
Arguments: comma-delimited string
Returns: Returns list of strings (ref)
=cut
#-----------------------------------------------------------------------------
sub split_comma_delim_str {
my $input_str = shift;
my @result = split(/ /, $input_str);
return \@result;
}
#----------------------------------------------------------------------------
=head3 create_version_response
Create a response containing the command name and version
=cut
#-----------------------------------------------------------------------------
sub create_version_response {
my $command = shift;
my $rsp;
my $version = xCAT::Utils->Version();
push @{ $rsp->{data} }, "$command - xCAT $version";
xCAT::MsgUtils->message( "I", $rsp, $::CALLBACK );
}
#----------------------------------------------------------------------------
=head3 create_error_response
Create a response containing a single error message
Arguments: error message
=cut
#-----------------------------------------------------------------------------
sub create_error_response {
my $error_msg = shift;
my $rsp;
push @{ $rsp->{data} }, $error_msg;
xCAT::MsgUtils->message( "I", $rsp, $::CALLBACK );
}
#----------------------------------------------------------------------------
=head3 bmcdiscovery
Support for discovering bmc
Returns:
0 - OK
1 - help
2 - error
=cut
#-----------------------------------------------------------------------------
sub bmcdiscovery {
#my $request = shift;
#my $callback = shift;
#my $request_command = shift;
my $rc = 0;
##############################################################
# process the command line
# 0=success, 1=version, 2=help, 3=error
##############################################################
$rc = bmcdiscovery_processargs(@_);
if ( $rc != 0 ) {
if ( $rc != 1) {
bmcdiscovery_usage(@_);
}
return ( $rc - 1 );
}
scan_process($::opt_M,$::opt_R);
return 0;
}
#----------------------------------------------------------------------------
=head3 bmcdiscovery_ipmi
Support for discovering bmc using ipmi
Returns:
if it is bmc, it returns bmc ip or host;
if it is not bmc, it returns nothing;
=cut
#-----------------------------------------------------------------------------
sub bmcdiscovery_ipmi {
my $ip = shift;
my $bmcstr = "BMC Session ID";
my $icmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -U USERID -P PASSW0RD -H $ip chassis status ";
my $output = xCAT::Utils->runcmd("$icmd", -1);
if ( $output =~ $bmcstr ){
my $rsp = {};
push @{ $rsp->{data} }, "$ip";
xCAT::MsgUtils->message("I", $rsp, $::CALLBACK);
}
}
1;

View File

@@ -489,9 +489,9 @@ sub mkinstall {
my $site_ent = $ents[0];
if (!defined($site_ent) || ($site_ent =~ /no/i) || ($site_ent =~ /0/))
{
$callback->( { warning => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated. They should continue to work in this release, but have not been tested as carefully, and some new functions are not available with these options. For full function and support, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], });
$callback->( { error => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], errorcode => [1] });
# Do not print this warning message multiple times
last;
exit(1);
}
}
}
@@ -982,11 +982,11 @@ sub mknetboot
{
$callback->(
{
warning => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated. They should continue to work in this release, but have not been tested as carefully, and some new functions are not available with these options. For full function and support, use \"nodeset <noderange> osimage=<osimage_name>\" instead."],
error => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], errorcode => [1]
}
);
# Do not print this warning message multiple times
last;
exit(1);
}
}
}

View File

@@ -616,6 +616,14 @@ sub addnode
$lstatements = 'if option vendor-class-identifier = \"ScaleMP\" { filename = \"vsmp/pxelinux.0\"; } else { filename = \"pxelinux.0\"; }'.$lstatements;
}
}
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'yaboot') {
$lstatements = 'filename = \"/yb/node/yaboot-'.$node.'\";'.$lstatements;
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'grub2') {
$lstatements = 'filename = \"/boot/grub2/grub2-'.$node.'\";'.$lstatements;
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'petitboot') {
$lstatements = 'option conf-file \"http://'.$nxtsrv.'/tftpboot/petitboot/'.$node.'\";'.$lstatements;
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'nimol') {
$lstatements = 'supersede server.filename=\"/vios/nodes/'.$node.'\"'.$lstatements;
}
@@ -2033,7 +2041,14 @@ sub addnet6
$idx++;
}
unless ($dhcp6conf[$idx] =~ /\} # $iface nic_end\n/) {
return 1; #TODO: this is an error condition
$callback->(
{
error =>
["Could not add the subnet $net for interface $iface into $dhcpconffile.\nPlease verify the xCAT database matches networks defined on this system."],
errorcode => [1]
}
);
return 1;
}
}
@@ -2045,6 +2060,7 @@ sub addnet6
my @netent = (
" subnet6 $net {\n",
" authoritative;\n",
" max-lease-time $dhcplease;\n",
" min-lease-time $dhcplease;\n",
" default-lease-time $dhcplease;\n",
@@ -2158,21 +2174,21 @@ sub addnet
while ($idx <= $#dhcpconf)
{
if ($dhcpconf[$idx] =~ /\} # $nic nic_end\n/)
{
last;
}
$idx++;
{
last;
}
$idx++;
}
unless ($dhcpconf[$idx] =~ /\} # $nic nic_end\n/)
{
$callback->(
{
error =>
["Could not add the subnet $net/$mask for nic $nic into $dhcpconffile."],
$callback->(
{
error =>
["Could not add the subnet $net for interface $nic into $dhcpconffile.\nPlease verify the xCAT database matches networks defined on this system."],
errorcode => [1]
}
);
return 1; #TODO: this is an error condition
}
);
return 1;
}
}
@@ -2326,6 +2342,7 @@ sub addnet
}
@netent = (
" subnet $net netmask $mask {\n",
" authoritative;\n",
" max-lease-time $dhcplease;\n",
" min-lease-time $dhcplease;\n",
" default-lease-time $dhcplease;\n"
@@ -2684,7 +2701,6 @@ sub newconfig
my $passtab = xCAT::Table->new('passwd', -create => 1);
push @dhcpconf, "#xCAT generated dhcp configuration\n";
push @dhcpconf, "\n";
push @dhcpconf, "authoritative;\n";
push @dhcpconf, "option conf-file code 209 = text;\n";
push @dhcpconf, "option space isan;\n";
push @dhcpconf, "option isan-encap-opts code 43 = encapsulate isan;\n";

View File

@@ -580,27 +580,36 @@ sub process_request {
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
chdir("$tftpdir/boot/grub2/");
foreach my $tmp_node (@{$osimagenodehash{$osimage}}) {
unless (-e "grub2-$tmp_node") {
symlink("grub2.".$validarch, "grub2-$tmp_node");
}
}
if ($do_dhcpsetup) {
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=>\@{$osimagenodehash{$osimage}},
arg=>['-l','-s','filename = \"'.$grub2.'\";']},$callback);
node=>\@{$osimagenodehash{$osimage}}}, $callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@{$osimagenodehash{$osimage}},
arg=>['-s','filename = \"'.$grub2.'\";']},$callback);
node=>\@{$osimagenodehash{$osimage}}},$callback);
}
}
} #end of foreach osimagenodehash
foreach my $tmp_node (@breaknetboot) {
if (-e "$tftpdir/boot/grub2/grub2-$tmp_node") {
unlink("$tftpdir/boot/grub2/grub2-$tmp_node");
}
}
if ($do_dhcpsetup) {
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=>\@breaknetboot,
arg=>['-l','-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback);
arg=>['-l']},$callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@breaknetboot,
arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback);
node=>\@breaknetboot},$callback);
}
}
}

View File

@@ -409,8 +409,13 @@ sub create_imgconf_file {
my $subreq = shift;
my $nim_root = shift;
my $bootimg_root = shift;
my $relative_path = $bootimg_root;
my $bootimg_link = "/tftpboot/vios/nodes";
my $relative_path = $bootimg_link;
$relative_path =~ s/^\/tftpboot//;
# check the dir where the bootimage link file and bootimage configuration file stored
unless (-e $bootimg_link) {
mkpath($bootimg_link);
}
# Get nodes network information
my %nethash = ();
%nethash = xCAT::DBobjUtils->getNetwkInfo($nodes);
@@ -428,7 +433,7 @@ sub create_imgconf_file {
unless (-e $bootimg_root."/viobootimg") {
return "Unable to find VIOS bootimg file";
}
chdir($bootimg_root);
chdir($bootimg_link);
foreach my $node (@$nodes) {
my $bootimg_conf_fd;
my $gateway = $nethash{$node}{gateway};
@@ -438,18 +443,17 @@ sub create_imgconf_file {
my $master = xCAT::NetworkUtils->gethostname($master_node);
my $master_ip = xCAT::NetworkUtils->getipaddr($master);
my $node_ip = xCAT::NetworkUtils->getipaddr($node);
my $relative_bootfile = $relative_path."/viobootimg-$node";
unless (-e "viobootimg-$node") {
symlink("viobootimg", "viobootimg-$node");
unless (-e "$node") {
symlink($bootimg_root."/viobootimg", "$node");
}
if (-e $bootimg_root."/viobootimg-$node.info") {
unlink($bootimg_root."/viobootimg-$node.info");
if (-e $bootimg_link."/$node.info") {
unlink($bootimg_link."/$node.info");
}
open ($bootimg_conf_fd, ">", $bootimg_root."/viobootimg-$node.info");
open ($bootimg_conf_fd, ">", $bootimg_link."/$node.info");
print $bootimg_conf_fd "export NIM_SERVER_TYPE=linux\n";
print $bootimg_conf_fd "export NIM_SYSLOG_PORT=514\n";
print $bootimg_conf_fd "export NIM_SYSLOG_FACILITY=local2\n";
print $bootimg_conf_fd "export NIM_NAME=viobootimg-$node\n";
print $bootimg_conf_fd "export NIM_NAME=$node\n";
print $bootimg_conf_fd "export NIM_HOSTNAME=$node\n";
print $bootimg_conf_fd "export NIM_CONFIGURATION=standalone\n";
print $bootimg_conf_fd "export NIM_MASTER_HOSTNAME=$master\n";
@@ -472,8 +476,7 @@ sub create_imgconf_file {
close($bootimg_conf_fd);
$subreq->({command=>['makedhcp'],
node=>[$node],
arg=>['-s', 'supersede server.filename=\"'.$relative_bootfile.'\";']}, $global_callback);
node=>[$node]}, $global_callback);
}
}
@@ -506,7 +509,7 @@ sub nodeset {
if ($ref) {
if ($ref->{provmethod} and $ref->{provmethod} eq 'nimol' and $ref->{osdistroname}) {
$nim_root = $installroot."/nim/".$ref->{osdistroname};
$bootimg_root = "/tftpboot/".$ref->{osdistroname}."/nodes";
$bootimg_root = "/tftpboot/".$ref->{osdistroname};
} else {
$callback->({error=>["The 'provmethod' for OS image $osimage can only be 'nimol'."], errorcode=>[1]});
return;

View File

@@ -472,24 +472,19 @@ sub process_request {
if (defined($t_entry) ) {
if ($t_entry =~ /0|n|N/) { $do_dhcpsetup=0; }
}
if ($do_dhcpsetup) {
foreach my $node (@normalnodeset) {
my $server = xCAT::TableUtils->GetMasterNodeName($node);
my $ipfn = xCAT::NetworkUtils->my_ip_facing($server);
if(($server != 1) and defined($ipfn)) {
my $fpath = "http://$ipfn/tftpboot/petitboot/$node";
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=> [$node],
arg=>['-l','-s','option conf-file \"'.$fpath.'\";']},$callback);
} else {
$sub_req->({command=>['makedhcp'],
node=> [$node],
arg=>['-s','option conf-file \"'.$fpath.'\";']},$callback);
}
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=> [$node],
arg=>['-l']},$callback);
#arg=>['-l','-s','option conf-file \"'.$fpath.'\";']},$callback);
} else {
$sub_req->({command=>['makedhcp'],
node=> [$node]}, $callback);
#arg=>['-s','option conf-file \"'.$fpath.'\";']},$callback);
}
}
}
}
}

View File

@@ -146,33 +146,25 @@ sub rinstall
# call "nodeset ... osimage= ..." to set the boot state of the noderange to the specified osimage,
# "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod
# verify input
&checkoption("[-O|--osimage] $OSIMAGE",$OSVER,$PROFILE,$ARCH,$callback);
&checkoption("[-O|--osimage] $OSIMAGE",$OSVER,$PROFILE,$ARCH,$callback);
# run nodeset $noderange osimage=$OSIMAGE
my @osimageargs;
push @osimageargs,"osimage=$OSIMAGE" ;
my $res =
xCAT::Utils->runxcmd(
my @osimageargs;
push @osimageargs,"osimage=$OSIMAGE" ;
my $res =
xCAT::Utils->runxcmd(
{
command => ["nodeset"],
node => \@nodes,
arg => \@osimageargs
},
$subreq, -1, 1);
my $rsp = {};
if ($::RUNCMD_RC ==0 ) {
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
} else {
foreach my $line (@$res) {
$rsp->{error} ->[0] = $line;
xCAT::MsgUtils->message("E", $rsp, $callback);
}
return 1;
}
$rc=$::RUNCMD_RC;
my $rsp = {};
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
}
else
{
@@ -268,19 +260,12 @@ sub rinstall
arg => \@nodesetarg
},
$subreq, -1, 1);
$rc = $::RUNCMD_RC;
my $rsp = {};
$rc=$::RUNCMD_RC;
if ($rc ==0 ) {
foreach my $line (@$res) {
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
} else { # error
foreach my $line (@$res) {
$rsp->{error} ->[0] = $line;
xCAT::MsgUtils->message("E", $rsp, $callback);
}
}
}
}
@@ -300,31 +285,23 @@ sub rinstall
arg => \@nodesetarg
},
$subreq, -1, 1);
$rc = $::RUNCMD_RC;
my $rsp = {};
$rc=$::RUNCMD_RC;
if ($rc ==0 ) {
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
} else { # error
foreach my $line (@$res) {
$rsp->{error} ->[0] = $line;
xCAT::MsgUtils->message("E", $rsp, $callback);
}
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
}
}
} # end nodech/nodeset for each group
if ($rc != 0) # we got an error with the nodeset
if ($rc != 0) # we got an error with the nodeset
{
my $rsp = {};
$rsp->{error}->[0] = "nodeset failure will not continue ";
$rsp->{error}->[0] = "nodeset failed on certain nodes.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others,
@@ -342,28 +319,23 @@ sub rinstall
arg => \@rsetbootarg
},
$subreq, -1, 1);
$rc = $::RUNCMD_RC;
# fix output it is a hash and you must get error out of the hash.
my $rsp = {};
$rc=$::RUNCMD_RC;
if ($rc ==0 ) {
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
} else { # error
foreach my $line (@$res) {
$rsp->{error} ->[0] = $line;
xCAT::MsgUtils->message("E", $rsp, $callback);
}
}
if ($rc != 0) # we got an error with the rsetboot
{
my $rsp = {};
$rsp->{error}->[0] = "rsetboot failure will not continue ";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
if ($rc != 0) # we got an error with the rsetboot
{
my $rsp = {};
$rsp->{error}->[0] = "rsetboot failed on certain nodes.";
xCAT::MsgUtils->message("E", $rsp, $callback);
}
# call "rpower" to start the node provision process
#run rpower $noderange boot
@@ -377,20 +349,22 @@ sub rinstall
arg => \@rpowerarg
},
$subreq, -1, 1);
$rc = $::RUNCMD_RC;
my $rsp = {};
$rc=$::RUNCMD_RC;
if ($rc ==0 ) {
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
} else { # error
foreach my $line (@$res) {
$rsp->{error} ->[0] = $line;
xCAT::MsgUtils->message("E", $rsp, $callback);
}
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
if ($rc != 0) # we got an error with the rsetboot
{
my $rsp = {};
$rsp->{error}->[0] = "rpower failed on certain nodes.";
xCAT::MsgUtils->message("E", $rsp, $callback);
}
# Check if they asked to bring up a console ( -c) from rinstall always for winstall
$req->{startconsole}->[0] =0;
if ($command =~ /rinstall/)

View File

@@ -129,11 +129,11 @@ sub mknetboot
{
$callback->(
{
warning => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated. They should continue to work in this release, but have not been tested as carefully, and some new functions are not available with these options. For full function and support, use \"nodeset <noderange> osimage=<osimage_name>\" instead."],
error => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], errorcode => [1]
}
);
# Do not print this warning message multiple times
last;
exit(1);
}
}
}
@@ -776,11 +776,11 @@ sub mkinstall
{
$callback->(
{
warning => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated. They should continue to work in this release, but have not been tested as carefully, and some new functions are not available with these options. For full function and support, use \"nodeset <noderange> osimage=<osimage_name>\" instead."],
error => ["The options \"install\", \"netboot\", and \"statelite\" have been deprecated, use \"nodeset <noderange> osimage=<osimage_name>\" instead."], errorcode => [1]
}
);
# Do not print this warning message multiple times
last;
exit(1);
}
}
}

View File

@@ -0,0 +1,396 @@
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT_plugin::switchdiscover;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
use strict;
use Getopt::Long;
use xCAT::Usage;
use xCAT::NodeRange;
use xCAT::Utils;
#global variables for this module
my %globalopt;
my @filternodes;
my %global_scan_type = (
lldp => "lldp_scan",
nmap => "nmap_scan",
snmp => "snmp_scan"
);
#-------------------------------------------------------------------------------
=head1 xCAT_plugin:switchdiscover
=head2 Package Description
Handles switch discovery functions. It uses lldp, nmap or snmap to scan
the network to find out the switches attached to the network.
=cut
#-------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
=head3 send_msg
Invokes the callback with the specified message
Arguments:
request: request structure for plguin calls
ecode: error code. 0 for succeful.
msg: messages to be displayed.
Returns:
none
=cut
#--------------------------------------------------------------------------------
sub send_msg {
my $request = shift;
my $ecode = shift;
my $msg = shift;
my %output;
#################################################
# Called from child process - send to parent
#################################################
if ( exists( $request->{pipe} )) {
my $out = $request->{pipe};
$output{errorcode} = $ecode;
$output{data} = \@_;
print $out freeze( [\%output] );
print $out "\nENDOFFREEZE6sK4ci\n";
}
#################################################
# Called from parent - invoke callback directly
#################################################
elsif ( exists( $request->{callback} )) {
my $callback = $request->{callback};
$output{errorcode} = $ecode;
$output{data} = $msg;
$callback->( \%output );
}
}
#--------------------------------------------------------------------------------
=head3 handled_commands
It returns a list of commands handled by this plugin.
Arguments:
none
Returns:
a list of commands.
=cut
#--------------------------------------------------------------------------------
sub handled_commands {
return( {switchdiscover=>"switchdiscover"} );
}
#--------------------------------------------------------------------------------
=head3 parse_args
Parse the command line options and operands.
Arguments:
request: the request structure for plugin
Returns:
Usage string or error message.
0 if no user promp needed.
=cut
#--------------------------------------------------------------------------------
sub parse_args {
my $request = shift;
my $args = $request->{arg};
my $cmd = $request->{command};
my %opt;
#############################################
# Responds with usage statement
#############################################
local *usage = sub {
my $usage_string = xCAT::Usage->getUsage($cmd);
return( [$_[0], $usage_string] );
};
#############################################
# No command-line arguments - use defaults
#############################################
if ( !defined( $args )) {
return(0);
}
#############################################
# Checks case in GetOptions, allows opts
# to be grouped (e.g. -vx), and terminates
# at the first unrecognized option.
#############################################
@ARGV = @$args;
$Getopt::Long::ignorecase = 0;
Getopt::Long::Configure( "bundling" );
#############################################
# Process command-line flags
#############################################
if (!GetOptions( \%opt,
qw(h|help V|Verbose v|version i=s x z w r n range=s s=s))) {
return( usage() );
}
#############################################
# Check for node range
#############################################
if ( scalar(@ARGV) eq 1 ) {
my @nodes = xCAT::NodeRange::noderange( @ARGV );
foreach (@nodes) {
push @filternodes, $_;
}
unless (@filternodes) {
return(usage( "Invalid Argument: $ARGV[0]" ));
}
} elsif ( scalar(@ARGV) > 1 ) {
return(usage( "Invalid flag, please check and retry." ));
}
#############################################
# Option -V for verbose output
#############################################
if ( exists( $opt{V} )) {
$globalopt{verbose} = 1;
}
#############################################
# Check for mutually-exclusive formatting
#############################################
if ( (exists($opt{r}) + exists($opt{x}) + exists($opt{z}) ) > 1 ) {
return( usage() );
}
#############################################
# Check for unsupported scan types
#############################################
if ( exists( $opt{s} )) {
my @stypes = split ',', $opt{s};
my $error;
foreach my $st (@stypes) {
if (! exists($global_scan_type{$st})) {
$error = $error . "Invalide scan type: $st\n";
}
}
if ($error) {
return usage($error);
}
$globalopt{scan_types} = \@stypes;
}
#############################################
# Check the validation of -i option
#############################################
if ( exists( $opt{i} )) {
foreach ( split /,/, $opt{i} ) {
}
$globalopt{i} = $opt{i};
}
#############################################
# write to the database
#############################################
if ( exists( $opt{w} )) {
$globalopt{w} = 1;
}
#############################################
# list the raw information
#############################################
if ( exists( $opt{r} )) {
$globalopt{r} = 1;
}
#############################################
# list the xml formate data
#############################################
if ( exists( $opt{x} )) {
$globalopt{x} = 1;
}
#############################################
# list the stanza formate data
#############################################
if ( exists( $opt{z} )) {
$globalopt{z} = 1;
}
#########################################################
# only list the nodes that discovered for the first time
#########################################################
if ( exists( $opt{n} )) {
$globalopt{n} = 1;
}
#########################################################
# only list the nodes that discovered for the first time
#########################################################
if ( exists( $opt{n} )) {
$globalopt{n} = 1;
}
return;
}
#--------------------------------------------------------------------------------
=head3 preprocess_request
Parse the arguments and display the usage or the version string.
=cut
#--------------------------------------------------------------------------------
sub preprocess_request {
my $req = shift;
if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; }
my $callback=shift;
my $command = $req->{command}->[0];
my $extrargs = $req->{arg};
my @exargs=($req->{arg});
if (ref($extrargs)) {
@exargs=@$extrargs;
}
my $usage_string=xCAT::Usage->parseCommand($command, @exargs);
if ($usage_string) {
$callback->({data=>[$usage_string]});
$req = {};
return;
}
my @result = ();
my $mncopy = {%$req};
push @result, $mncopy;
return \@result;
}
#--------------------------------------------------------------------------------
=head3 process_request
Pasrse the arguments and call the correspondent functions
to do switch discovery.
=cut
#--------------------------------------------------------------------------------
sub process_request {
my $req = shift;
my $callback = shift;
###########################################
# Build hash to pass around
###########################################
my %request;
$request{arg} = $req->{arg};
$request{callback} = $callback;
$request{command} = $req->{command}->[0];
####################################
# Process command-specific options
####################################
my $result = parse_args( \%request );
####################################
# Return error
####################################
if ( ref($result) eq 'ARRAY' ) {
send_msg( \%request, 1, @$result );
return(1);
}
# call the relavant functions to start the scan
my @scan_types = ("lldp");
if (exists($globalopt{scan_types})) {
@scan_types = @{$globalopt{scan_types}};
}
foreach my $st (@scan_types) {
no strict;
my $fn = $global_scan_type{$st};
my $result = &$fn(\%request, $callback);
}
return;
}
#--------------------------------------------------------------------------------
=head3 lldp_scan
Use lldpd to scan the subnets to do switch discovery.
Arguments:
request: request structure with callback pointer.
Returns:
A hash containing the swithes discovered.
Each element is a hash of switch attributes. For examples:
{
"1.2.3.5" =>{name=>"switch1", vendor=>"ibm", mac=>"AABBCCDDEEFA"},
"1.2.4.6" =>{name=>"switch2", vendor=>"cisco", mac=>"AABBCCDDEEFF"}
}
=cut
#--------------------------------------------------------------------------------
sub lldp_scan {
my $request = shift;
send_msg($request, 0, "Discovering switches using lldpd...");
my %switches = (
"1.2.3.5" => { name=>"switch1", vendor=>"ibm", mac=>"AABBCCDDEEFA" },
"1.2.4.6" => { name=>"switch2", vendor=>"cisco", mac=>"AABBCCDDEEFF" }
);
return %switches
}
#--------------------------------------------------------------------------------
=head3 nmap_scan
Use nmap to scan the subnets to do switch discovery.
Arguments:
request: request structure with callback pointer.
Returns:
A hash containing the swithes discovered.
Each element is a hash of switch attributes. For examples:
{
"1.2.3.5" =>{name=>"switch1", vendor=>"ibm", mac=>"AABBCCDDEEFA"},
"1.2.4.6" =>{name=>"switch2", vendor=>"cisco", mac=>"AABBCCDDEEFF"}
}
=cut
#--------------------------------------------------------------------------------
sub nmap_scan {
my $request = shift;
send_msg($request, 0, "Discovering switches using nmap...");
my %switches = (
"1.2.3.5" => { name=>"switch1", vendor=>"ibm", mac=>"AABBCCDDEEFA" },
"1.2.4.6" => { name=>"switch2", vendor=>"cisco", mac=>"AABBCCDDEEFF" }
);
return %switches
}
#--------------------------------------------------------------------------------
=head3 snmp_scan
Use lldpd to scan the subnets to do switch discovery.
Arguments:
request: request structure with callback pointer.
Returns:
A hash containing the swithes discovered.
Each element is a hash of switch attributes. For examples:
{
"1.2.3.5" =>{name=>"switch1", vendor=>"ibm", mac=>"AABBCCDDEEFA"},
"1.2.4.6" =>{name=>"switch2", vendor=>"cisco", mac=>"AABBCCDDEEFF"}
}
=cut
#--------------------------------------------------------------------------------
sub snmp_scan {
my $request = shift;
send_msg($request, 0, "Discovering switches using snmp...");
my %switches = (
"1.2.3.5" => { name=>"switch1", vendor=>"ibm", mac=>"AABBCCDDEEFA" },
"1.2.4.6" => { name=>"switch2", vendor=>"cisco", mac=>"AABBCCDDEEFF" }
);
return %switches
}
1;

View File

@@ -655,6 +655,12 @@ sub process_request {
xCAT::MsgUtils->message("E", $rsp, $::YABOOT_callback);
return;
}
} elsif ($osv !~ /fedora/i) {
my $rsp;
push @{$rsp->{data}},
"stop configuration because yaboot DOES NOT work for $os provision, please change noderes.netboot=grub2 instead.\n";
xCAT::MsgUtils->message("E", $rsp, $::YABOOT_callback);
return;
}
} #end of foreach osimagenodehash
@@ -671,10 +677,13 @@ sub process_request {
if ($t_entry =~ /0|n|N/) { $do_dhcpsetup=0; }
}
#}
if ($do_dhcpsetup) {
if (%osimagenodehash) {
chdir("$tftpdir");
foreach my $osimage (keys %osimagenodehash) {
unless (-e "$tftpdir/yb/node") {
system("mkdir -p $tftpdir/yb/node");
}
my $osimgent = $osimagetab->getAttribs({imagename => $osimage },'osvers');
my $osentry = $osimgent->{'osvers'};
@@ -694,16 +703,26 @@ sub process_request {
if (($osv =~ /rh/ and int($osn) >= 6) or
($osv =~ /sles/ and int($osn) >= 11)) {
my $fpath = "/yb/". $osentry."/yaboot";
foreach my $tmp_node (@{$osimagenodehash{$osimage}}) {
unless (-e "yb/node/yaboot-$tmp_node") {
symlink("yb/$osentry/yaboot", "yb/node/yaboot-$tmp_node");
}
}
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=>\@{$osimagenodehash{$osimage}},
arg=>['-l','-s','filename = \"'.$fpath.'\";']},$::YABOOT_callback);
arg=>['-l']},$::YABOOT_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@{$osimagenodehash{$osimage}},
arg=>['-s','filename = \"'.$fpath.'\";']},$::YABOOT_callback);
node=>\@{$osimagenodehash{$osimage}}},$::YABOOT_callback);
}
} else {
foreach my $tmp_node (@{$osimagenodehash{$osimage}}) {
unless (-e "yb/node/yaboot-$tmp_node") {
symlink("yaboot", "yb/node/yaboot-$tmp_node");
}
}
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command, only change local settings if already farmed
$sub_req->({command=>['makedhcp'],arg=>['-l'],
node=>\@{$osimagenodehash{$osimage}}},$::YABOOT_callback);
@@ -722,14 +741,18 @@ sub process_request {
node=>\@normalnodeset},$::YABOOT_callback);
}
}
foreach my $tmp_node (@breaknetboot) {
if (-e "$tftpdir/yb/node/yaboot-$tmp_node") {
unlink("$tftpdir/yb/node/yaboot-$tmp_node");
}
}
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=>\@breaknetboot,
arg=>['-l','-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$::YABOOT_callback);
arg=>['-l']},$::YABOOT_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@breaknetboot,
arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$::YABOOT_callback);
node=>\@breaknetboot}, $::YABOOT_callback);
}
}
}

View File

@@ -179,22 +179,22 @@ base64decode()
}
if [ -d /sys/firmware/efi ]; then
echo "ubuntu-efi ::" > /tmp/partitioning
echo " 512 512 1024 fat16" >> /tmp/partitioning
echo ' $iflabel{ gpt } $reusemethod{ } method{ efi } format{ }' >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "ubuntu-efi ::" > /tmp/partitionfile
echo " 512 512 1024 fat16" >> /tmp/partitionfile
echo ' $iflabel{ gpt } $reusemethod{ } method{ efi } format{ }' >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
else
echo "ubuntu-boot ::" > /tmp/partitioning
echo "100 50 100 ext3" >> /tmp/partitioning
echo ' $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ /boot }' >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "ubuntu-boot ::" > /tmp/partitionfile
echo "100 50 100 ext3" >> /tmp/partitionfile
echo ' $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ /boot }' >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
fi
echo "500 10000 1000000000 ext3" >> /tmp/partitioning
echo " method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ / }" >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "2048 512 300% linux-swap" >> /tmp/partitioning
echo " method{ swap } format{ }" >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "500 10000 1000000000 ext3" >> /tmp/partitionfile
echo " method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ / }" >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
echo "2048 512 300% linux-swap" >> /tmp/partitionfile
echo " method{ swap } format{ }" >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
#XCA_PARTMAN_RECIPE_SCRIPT#
#XCA_PARTMAN_DISK_SCRIPT#

View File

@@ -193,27 +193,27 @@ base64decode()
}
if [ -d /sys/firmware/efi ]; then
echo "ubuntu-efi ::" > /tmp/partitioning
echo " 512 512 1024 fat16" >> /tmp/partitioning
echo ' $iflabel{ gpt } $reusemethod{ } method{ efi } format{ }' >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "ubuntu-efi ::" > /tmp/partitionfile
echo " 512 512 1024 fat16" >> /tmp/partitionfile
echo ' $iflabel{ gpt } $reusemethod{ } method{ efi } format{ }' >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
else
echo "ubuntu-boot ::" > /tmp/partitioning
echo "ubuntu-boot ::" > /tmp/partitionfile
echo "8 1 1 prep" >> /tmp/partitioning
echo ' $primary{ } $bootable{ } method{ prep }' >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "8 1 1 prep" >> /tmp/partitionfile
echo ' $primary{ } $bootable{ } method{ prep }' >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
#echo "100 50 100 ext4" >> /tmp/partitioning
#echo ' $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ /boot }' >> /tmp/partitioning
#echo " ." >> /tmp/partitioning
#echo "100 50 100 ext4" >> /tmp/partitionfile
#echo ' $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ /boot }' >> /tmp/partitionfile
#echo " ." >> /tmp/partitionfile
fi
echo "500 10000 1000000000 ext4" >> /tmp/partitioning
echo " method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ / }" >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "2048 512 300% linux-swap" >> /tmp/partitioning
echo " method{ swap } format{ }" >> /tmp/partitioning
echo " ." >> /tmp/partitioning
echo "500 10000 1000000000 ext4" >> /tmp/partitionfile
echo " method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ / }" >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
echo "2048 512 300% linux-swap" >> /tmp/partitionfile
echo " method{ swap } format{ }" >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
#XCA_PARTMAN_RECIPE_SCRIPT#

View File

@@ -37,7 +37,7 @@ d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
#create the /tmp/partitioning based on the uefi or legacy bios
#create the /tmp/partitionfile based on the uefi or legacy bios
d-i partman/early_command string \
set -x; \
if [ -f /tmp/boot_disk ]; then \
@@ -59,11 +59,18 @@ d-i partman/early_command string \
rm /tmp/devs-with-boot 2>/dev/null || true; \
else \
DEV=`ls /dev/disk/by-path/* -l | egrep -o '/dev.*[s|h|v]d[^0-9]$' | sort -t : -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -g | head -n1 | egrep -o '[s|h|v]d.*$'`; \
if [[ "$DEV" == "" ]]; then DEV="sda"; fi; \
if [[ "$DEV" == "" ]]; then \
for line in $(list-devices disk); do \
DEV=$line; DEV=${DEV##/dev/}; break; \
done; \
if [[ "$DEV" == "" ]]; then \
DEV="sda"; \
fi \
fi; \
echo "/dev/$DEV" > /tmp/boot_disk; \
fi; \
debconf-set partman-auto/disk "$(cat /tmp/boot_disk)"
d-i partman-auto/expert_recipe_file string /tmp/partitioning
d-i partman-auto/expert_recipe_file string /tmp/partitionfile
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
@@ -141,5 +148,6 @@ d-i preseed/late_command string wget http://`cat /tmp/xcatserver`/install/autoin
mount -o bind /dev /target/dev; \
mount -o bind /dev/pts /target/dev/pts -t devpts; \
mount -o bind /sys /target/sys; \
chroot /target /root/post.script
chroot /target /root/post.script; \
cp /target/etc/network/interfaces /etc/network/interfaces

View File

@@ -1,138 +0,0 @@
### Localization
d-i debian-installer/locale string en_US
d-i localechooser/supported-locales multiselect en_US.UTF-8
# Keyboard Selection
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string en
### Network Configuration
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string
d-i netcfg/dhcp_timeout string 120
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
d-i mirror/country string manual
d-i mirror/protocol string http
d-i mirror/http/directory string #INCLUDE_OSIMAGE_PKGDIR#
d-i mirror/http/proxy string
# Suite to install.
#d-i mirror/suite string testing
# Suite to use for loading installer components (optional).
#d-i mirror/udeb/suite string testing
### Partitioning
# This creates a small /boot partition, suitable
# swap, and uses the rest of the space for the root partition:
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
#create the /tmp/partitioning based on the uefi or legacy bios
d-i partman/early_command string \
set -x; \
rm /tmp/devs-with-boot 2>/dev/null || true; \
for d in $(list-devices partition); do \
mkdir -p /tmp/mymount; \
rc=0; \
mount $d /tmp/mymount || rc=$?; \
if [[ $rc -eq 0 ]]; then \
[[ -d /tmp/mymount/boot ]] && echo $d >>/tmp/devs-with-boot; \
umount /tmp/mymount; \
fi \
done; \
if [[ -e /tmp/devs-with-boot ]]; then \
head -n1 /tmp/devs-with-boot | egrep -o '\S+[^0-9]' > /tmp/boot_disk; \
rm /tmp/devs-with-boot 2>/dev/null || true; \
else \
DEV=`ls /dev/disk/by-path/* -l | egrep -o '/dev.*sd[^0-9]$' | sort -t : -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -g | head -n1 | egrep -o 'sd.*$'`; \
if [[ "$DEV" == "" ]]; then DEV="sda"; fi; \
echo "/dev/$DEV" > /tmp/boot_disk; \
fi; \
debconf-set partman-auto/disk "$(cat /tmp/boot_disk)"
d-i partman-auto/expert_recipe_file string /tmp/partitioning
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
### Account setup
d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
d-i passwd/root-password-crypted password #CRYPT:passwd:key=system,username=root:password#
### Clock and time zone setup
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string #TABLE:site:key=master:value#
d-i clock-setup/utc boolean true
d-i time/zone string #TABLE:site:key=timezone:value#
### Apt setup
d-i apt-setup/multiverse boolean false
d-i apt-setup/universe boolean false
d-i apt-setup/backports boolean false
d-i apt-setup/updates boolean false
### Boot loader installation
d-i grub-installer/only_debian boolean true
### Package selection
tasksel tasksel/first multiselect standard
# gawk required for the xCAT scripts to work
# Otherwise it installs mawk, which doesn't work
d-i pkgsel/include string #INCLUDE_DEFAULT_PKGLIST_PRESEED#
d-i debian-installer/allow_unauthenticated string true
d-i pkgsel/update-policy select none
d-i pkgsel/updatedb boolean false
### Finishing up the installation
d-i finish-install/reboot_in_progress note
### X configuration
xserver-xorg xserver-xorg/autodetect_monitor boolean true
xserver-xorg xserver-xorg/config/monitor/selection-method \
select medium
xserver-xorg xserver-xorg/config/monitor/mode-list \
select 1024x768 @ 60 Hz
d-i preseed/early_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.pre; \
chmod u+x #HOSTNAME#.pre; \
./#HOSTNAME#.pre
# To workaround the "Unmount partitions that are in use?" question
d-i preseed/early_command string umount /media || true
d-i preseed/late_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.post; \
chmod u+x #HOSTNAME#.post; \
cp ./#HOSTNAME#.post /target/root/post.script; \
mount -o bind /proc /target/proc -t proc; \
mount -o bind /dev /target/dev; \
mount -o bind /dev/pts /target/dev/pts -t devpts; \
mount -o bind /sys /target/sys; \
chroot /target /root/post.script

View File

@@ -0,0 +1 @@
compute.tmpl

View File

@@ -1,139 +0,0 @@
### Localization
d-i debian-installer/locale string en_US
d-i localechooser/supported-locales multiselect en_US.UTF-8
# Keyboard Selection
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string en
### Network Configuration
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string
d-i netcfg/dhcp_timeout string 120
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
#MIRRORSPEC#
# Suite to install.
#d-i mirror/suite string testing
# Suite to use for loading installer components (optional).
#d-i mirror/udeb/suite string testing
# Use the following option to add additional boot parameters for the
# installed system (if supported by the bootloader installer).
# Note: options passed to the installer will be added automatically.
d-i debian-installer/add-kernel-opts string #XCATVAR:PERSKCMDLINE#
### Partitioning
# This creates a small /boot partition, suitable
# swap, and uses the rest of the space for the root partition:
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
#create the /tmp/partitioning based on the uefi or legacy bios
d-i partman/early_command string \
set -x; \
rm /tmp/devs-with-boot 2>/dev/null || true; \
for d in $(list-devices partition); do \
mkdir -p /tmp/mymount; \
rc=0; \
mount $d /tmp/mymount || rc=$?; \
if [[ $rc -eq 0 ]]; then \
[[ -d /tmp/mymount/boot ]] && echo $d >>/tmp/devs-with-boot; \
umount /tmp/mymount; \
fi \
done; \
if [[ -e /tmp/devs-with-boot ]]; then \
head -n1 /tmp/devs-with-boot | egrep -o '\S+[^0-9]' > /tmp/boot_disk; \
rm /tmp/devs-with-boot 2>/dev/null || true; \
else \
DEV=`ls /dev/disk/by-path/* -l | egrep -o '/dev.*sd[^0-9]$' | sort -t : -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -g | head -n1 | egrep -o 'sd.*$'`; \
if [[ "$DEV" == "" ]]; then DEV="sda"; fi; \
echo "/dev/$DEV" > /tmp/boot_disk; \
fi; \
debconf-set partman-auto/disk "$(cat /tmp/boot_disk)"
d-i partman-auto/expert_recipe_file string /tmp/partitioning
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
### Account setup
d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
d-i passwd/root-password-crypted password #CRYPT:passwd:key=system,username=root:password#
### Clock and time zone setup
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string #TABLE:site:key=master:value#
d-i clock-setup/utc boolean true
d-i time/zone string #TABLE:site:key=timezone:value#
### Apt setup
d-i apt-setup/multiverse boolean false
d-i apt-setup/universe boolean false
d-i apt-setup/backports boolean false
d-i apt-setup/updates boolean false
### Boot loader installation
d-i grub-installer/only_debian boolean true
### Package selection
tasksel tasksel/first multiselect standard
# gawk required for the xCAT scripts to work
# Otherwise it installs mawk, which doesn't work
d-i pkgsel/include string #INCLUDE_DEFAULT_PKGLIST_PRESEED#
d-i debian-installer/allow_unauthenticated boolean true
d-i pkgsel/update-policy select none
d-i pkgsel/updatedb boolean false
### Finishing up the installation
d-i finish-install/reboot_in_progress note
### X configuration
xserver-xorg xserver-xorg/autodetect_monitor boolean true
xserver-xorg xserver-xorg/config/monitor/selection-method \
select medium
xserver-xorg xserver-xorg/config/monitor/mode-list \
select 1024x768 @ 60 Hz
# To workaround the "Unmount partitions that are in use?" question,
# run the "umount /media" after the preseed is read in
d-i preseed/early_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.pre; \
chmod u+x #HOSTNAME#.pre; \
./#HOSTNAME#.pre; \
umount /media || true
d-i preseed/late_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.post; \
chmod u+x #HOSTNAME#.post; \
cp ./#HOSTNAME#.post /target/root/post.script; \
mount -o bind /proc /target/proc -t proc; \
mount -o bind /dev /target/dev; \
mount -o bind /dev/pts /target/dev/pts -t devpts; \
mount -o bind /sys /target/sys; \
chroot /target /root/post.script; \
cp /target/etc/network/interfaces /etc/network/interfaces

View File

@@ -0,0 +1 @@
compute.tmpl

View File

@@ -369,8 +369,7 @@ unless ($onlyinitrd) {
if ($pkglist) {
$updates{'pkglist'} = $pkglist if ($tempfile);
} else {
print "Unable to find package list for $profile!";
exit 1;
xdie "Unable to find package list for $profile!";
}
my %pkg_hash=imgutils::get_package_names($pkglist);
@@ -380,8 +379,7 @@ unless ($onlyinitrd) {
my $pkgnames = "";
foreach (keys(%{$pkg_hash{$pass}})) {
if($_ eq "INCLUDEBAD") {
print "Unable to open the following pkglist files:\n".join("\n",@{$pkg_hash{$pass}{INCLUDEBAD}});
exit 1;
xdie "Unable to open the following pkglist files:\n".join("\n",@{$pkg_hash{$pass}{INCLUDEBAD}});
}
if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next;}
@@ -406,8 +404,7 @@ unless ($onlyinitrd) {
}
}
if ($found eq 0) {
print "Cannot find the kernel with version $kernelver.\n";
exit 1;
xdie "Cannot find the kernel with version $kernelver.\n";
}
push @npa, $kernelname;
}
@@ -434,8 +431,7 @@ unless ($onlyinitrd) {
print "$envlist $aptgetcmdby install $pkgnames\n";
my $rc = system("$envlist $aptgetcmdby install --allow-unauthenticated $pkgnames");
if ($rc) {
print "Failed to install packages $pkgnames\n";
exit 1;
xdie "Failed to install packages $pkgnames\n";
}
}
@@ -492,9 +488,7 @@ unless ($onlyinitrd) {
foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) {
foreach (keys(%{$extra_hash{$pass}})) {
if($_ eq "INCLUDEBAD") {
#print "Unable to open the following pkglist files:\n".join("\n",@{$extra_hash{$pass}{INCLUDEBAD}});
xdie "Unable to open the following pkglist files:\n".join("\n",@{$extra_hash{$pass}{INCLUDEBAD}});
# exit 1;
}
if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next;}
@@ -554,8 +548,6 @@ unless ($onlyinitrd) {
print "$envlist $aptgetcmd\n";
my $rc = system("$envlist $aptgetcmd");
if ($rc) {
#print "apt-get invocation failed\n";
#exit 1;
xdie "apt-get invocation failed\n";
}
} else {

View File

@@ -595,19 +595,16 @@ sub install_xcat {
$arch="x86_64" if($mn !~ /aix/ && $mn =~ /x/);
if($mn =~ /rh/){
if($os =~ /rhels7/){
system("xdsh $confkeys{$mn} \"cd /xcat-dep/rh7.0/$arch && ./mklocalrepo.sh\" >/dev/null 2>&1");
$os =~ /(\D+)(\d+)\.?(\d?)/;
system("xdsh $confkeys{$mn} \"cd /xcat-dep/rh$2/$arch && ./mklocalrepo.sh\" >/dev/null 2>&1");
system("xdsh $confkeys{$mn} \"rpm --import /RPM-GPG-KEY-redhat-release\" >/dev/null 2>&1");
system("xdsh $confkeys{$mn} \"yum -y install xCAT xCAT-test > /var/log/xcat/install_xcat.log 2>&1\" >/dev/null 2>&1");
if($os =~ /rhels7/){
system("xdsh $confkeys{$mn} \"yum -y install mariadb-devel-5.5.35-3.el7 mariadb-libs-5.5.35-3.el7 mariadb-server-5.5.35-3.el7 mariadb-bench-5.5.35-3.el7 mariadb-5.5.35-3.el7 perl-DBD-MySQL mysql-connector-odbc unixODBC\" >/dev/null 2>&1");
}elsif($os =~ /rhels6/){
$os =~ /(\D+)(\d+)\.?(\d?)/;
system("xdsh $confkeys{$mn} \"cd /xcat-dep/rh$2/$arch && ./mklocalrepo.sh\" >/dev/null 2>&1");
system("xdsh $confkeys{$mn} \"rpm --import /RPM-GPG-KEY-redhat-release\" >/dev/null 2>&1");
system("xdsh $confkeys{$mn} \"yum -y install xCAT xCAT-test > /var/log/xcat/install_xcat.log 2>&1\" >/dev/null 2>&1");
system("xdsh $confkeys{$mn} \"yum -y install mysql-server mysql mysql-bench mysql-devel mysql-connector-odbc\" >/dev/null 2>&1");
system("xdsh $confkeys{$mn} \"source /etc/profile.d/xcat.sh\" >/dev/null 2>&1");
}
system("xdsh $confkeys{$mn} \"source /etc/profile.d/xcat.sh\" >/dev/null 2>&1");
if($mn =~ /rhx/){
system("xdsh $confkeys{$mn} \"yum install -y perl-Sys-Virt\" >/dev/null 2>&1");
}

View File

@@ -6,15 +6,10 @@ cmd:chdef $$CN nicips.$$SECONDNIC=100.1.0.100 nictypes.$$SECONDNIC=Ethernet nicn
check:rc==0
cmd:updatenode $$CN -P confignics
check:rc==0
cmd:xdsh $$CN ifconfig
check:output=~100.1.0.100
cmd:xdsh $$CN netstat -rn
check:output=~100.1.0.0
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN cat /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
check:output=~100.1.0.100
check:output!~dhcp
cmd:rmdef -t network -o 100_1_0_0-255_255_0_0
cmd:xdsh $$CN ifdown $$SECONDNIC
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
end
@@ -30,12 +25,6 @@ cmd:chdef $$CN nicips.$$THIRDNIC=200.1.0.100 nictypes.$$THIRDNIC=Ethernet nicnet
check:rc==0
cmd:updatenode $$CN -P confignics
check:rc==0
cmd:xdsh $$CN ifconfig
check:output=~100.1.0.100
check:output=~200.1.0.100
cmd:xdsh $$CN netstat -rn
check:output=~100.1.0.0
check:output=~200.1.0.0
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN cat /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
check:output=~100.1.0.100
check:output!~dhcp
@@ -44,8 +33,6 @@ check:output=~200.1.0.100
check:output!~dhcp
cmd:rmdef -t network -o 100_1_0_0-255_255_0_0
cmd:rmdef -t network -o 200_1_0_0-255_255_0_0
cmd:xdsh $$CN ifdown $$SECONDNIC
cmd:xdsh $$CN ifdown $$THIRDNIC
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$THIRDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$THIRDNIC; fi
end
@@ -66,16 +53,6 @@ cmd:chdef $$CN nicips.$$THIRDNIC="13.1.0.100|14.1.0.100" nictypes.$$THIRDNIC=Eth
check:rc==0
cmd:updatenode $$CN -P confignics
check:rc==0
cmd:xdsh $$CN ifconfig
check:output=~11.1.0.100
check:output=~12.1.0.100
check:output=~13.1.0.100
check:output=~14.1.0.100
cmd:xdsh $$CN netstat -rn
check:output=~11.1.0.0
check:output=~12.1.0.0
check:output=~13.1.0.0
check:output=~14.1.0.0
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN cat /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
check:output=~11.1.0.100
check:output!~dhcp
@@ -92,8 +69,6 @@ cmd:rmdef -t network -o 11_1_0_0-255_255_0_0
cmd:rmdef -t network -o 12_1_0_0-255_255_0_0
cmd:rmdef -t network -o 13_1_0_0-255_255_0_0
cmd:rmdef -t network -o 14_1_0_0-255_255_0_0
cmd:xdsh $$CN ifdown $$SECONDNIC
cmd:xdsh $$CN ifdown $$THIRDNIC
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC:1; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC:1; fi
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$THIRDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$THIRDNIC; fi
@@ -125,16 +100,6 @@ check:output=~$$CN-$$THIRDNIC-1
check:output=~$$CN-$$THIRDNIC-2
cmd:updatenode $$CN -P confignics
check:rc==0
cmd:xdsh $$CN ifconfig
check:output=~11.1.0.100
check:output=~12.1.0.100
check:output=~13.1.0.100
check:output=~14.1.0.100
cmd:xdsh $$CN netstat -rn
check:output=~11.1.0.0
check:output=~12.1.0.0
check:output=~13.1.0.0
check:output=~14.1.0.0
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN cat /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
check:output=~11.1.0.100
check:output!~dhcp
@@ -151,8 +116,6 @@ cmd:rmdef -t network -o 11_1_0_0-255_255_0_0
cmd:rmdef -t network -o 12_1_0_0-255_255_0_0
cmd:rmdef -t network -o 13_1_0_0-255_255_0_0
cmd:rmdef -t network -o 14_1_0_0-255_255_0_0
cmd:xdsh $$CN ifdown $$SECONDNIC
cmd:xdsh $$CN ifdown $$THIRDNIC
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC:1; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC:1; fi
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$THIRDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$THIRDNIC; fi
@@ -183,16 +146,6 @@ check:output=~aliases2-1
check:output=~aliases2-2
cmd:updatenode $$CN -P confignics
check:rc==0
cmd:xdsh $$CN ifconfig
check:output=~11.1.0.100
check:output=~12.1.0.100
check:output=~13.1.0.100
check:output=~14.1.0.100
cmd:xdsh $$CN netstat -rn
check:output=~11.1.0.0
check:output=~12.1.0.0
check:output=~13.1.0.0
check:output=~14.1.0.0
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN cat /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
check:output=~11.1.0.100
check:output!~dhcp
@@ -209,8 +162,6 @@ cmd:rmdef -t network -o 11_1_0_0-255_255_0_0
cmd:rmdef -t network -o 12_1_0_0-255_255_0_0
cmd:rmdef -t network -o 13_1_0_0-255_255_0_0
cmd:rmdef -t network -o 14_1_0_0-255_255_0_0
cmd:xdsh $$CN ifdown $$SECONDNIC
cmd:xdsh $$CN ifdown $$THIRDNIC
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC; fi
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$SECONDNIC:1; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$SECONDNIC:1; fi
cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN rm -rf /etc/network/interfaces.d/$$THIRDNIC; else xdsh $$CN rm -rf /etc/sysconfig/network*/ifcfg-$$THIRDNIC; fi
@@ -228,10 +179,6 @@ cmd:chtab node=$$CN nics.disable=yes
check:rc==0
cmd:updatenode $$CN -P confignics
check:rc==0
cmd:xdsh $$CN ifconfig
check:output!~100.1.0.100
cmd:xdsh $$CN netstat -rn
check:output!~100.1.0.0
cmd:if [ "$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN cat /etc/sysconfig/network-scripts/ifcfg-$$SECONDNIC; fi
check:output!~100.1.0.100
cmd:rmdef -t network -o 100_1_0_0-255_255_0_0
@@ -249,14 +196,9 @@ cmd:chtab node=$$CN nics.disable=1
check:rc==0
cmd:updatenode $$CN -P confignics
check:rc==0
cmd:xdsh $$CN ifconfig
check:output!~100.1.0.100
cmd:xdsh $$CN netstat -rn
check:output!~100.1.0.0
cmd:if [ "$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$$SECONDNIC; else xdsh $$CN cat /etc/sysconfig/network-scripts/ifcfg-$$SECONDNIC; fi
check:output!~100.1.0.100
cmd:rmdef -t network -o 100_1_0_0-255_255_0_0
cmd:chtab node=$$CN nics.disable=0
end

View File

@@ -18,6 +18,8 @@ cmd:copycds -n __GETNODEATTR($$CN,os)__ $$ISO
check:rc==0
check:output=~Copying media to /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__
check:output=~Media copy operation successful
cmd:lsdef $$CN
cmd:ps -aux |grep copycds
cmd:ls /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__
check:rc==0
end

View File

@@ -3,7 +3,7 @@ os:Linux
cmd:chtab key=nameservers site.value="<xcatmaster>"
check:rc==0
cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then chdef -t node -o $$CN vmstorage=dir:///var/lib/libvirt/images/ && mkvm $$CN -s 25G; fi
cmd:if [[ "__GETNODEATTR($$SN,arch)__" =~ "x86_64" ]];then chdef -t node -o $$SN vmstorage=dir:///var/lib/libvirt/images/ && rmvm $$SN -f -p && mkvm $$SN -s 25G; fi
cmd:makedns -n
check:rc==0

View File

@@ -5,7 +5,7 @@ cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;fi
cmd:chdef -t node -o $$CN servicenode= monserver=$$MN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN
check:rc==0
cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then chdef -t node -o $$CN vmstorage=dir:///var/lib/libvirt/images/ && mkvm $$CN -s 15G; fi
cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then chdef -t node -o $$CN vmstorage=dir:///var/lib/libvirt/images/ && rmvm $$CN -f -p && mkvm $$CN -s 15G; fi
cmd:makedns -n
check:rc==0
cmd:makeconservercf
@@ -19,6 +19,7 @@ cmd:makedhcp -n
check:rc==0
cmd:makedhcp -a
check:rc==0
cmd:sleep 10
cmd:if cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi
check:output=~$$CN

View File

@@ -57,7 +57,7 @@ check:rc==0
cmd:liteimg __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute
check:rc==0
cmd:nodeset $$CN statelite
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute
check:rc==0
cmd:lsdef $$CN |grep provmethod
check:rc==0

View File

@@ -69,7 +69,7 @@ check:rc==0
cmd:prsync /install $$SN:/
check:rc==0
cmd:nodeset $$CN statelite
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute
check:rc==0
cmd:lsdef $$CN |grep provmethod
check:rc==0

View File

@@ -2,7 +2,7 @@ start:Ubuntu_diskless_installation_flat_x86_vm
os:Linux
cmd:copycds $$ISO
check:rc==0
cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then chdef -t node -o $$CN vmstorage=dir:///var/lib/libvirt/images/ && mkvm $$CN -s 15G; fi
cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then chdef -t node -o $$CN vmstorage=dir:///var/lib/libvirt/images/ && rmvm $$CN -f -p && mkvm $$CN -s 15G; fi
cmd:makedns -n
check:rc==0
cmd:makedhcp -n

View File

@@ -5,9 +5,12 @@ cmd:makedhcp -n
check:rc==0
cmd:ls /etc/dhcp/dhcpd.conf || ls /etc/dhcpd.conf
check:rc==0
cmd:sleep 20
cmd:ps -e | grep dhcpd
check:rc==0
check:output=~dhcpd
cmd:if cat /etc/*release |grep Ubuntu >/dev/null;then service isc-dhcp-server status;else service dhcpd status;fi
check:output=~running
cmd:if [ -f "/etc/dhcp/dhcpd.conf" ]; then mv -f /etc/dhcp/dhcpd.conf.bak /etc/dhcp/dhcpd.conf; elif [ -f "/etc/dhcpd.conf" ]; then mv -f /etc/dhcpd.conf.bak /etc/dhcpd.conf; fi
end

View File

@@ -631,12 +631,13 @@ sub loadcase
sub getnodeattr
{
my ($node, $attr) = @_;
my @output = runcmd("lsdef -t node -o $node -i $attr");
my @output = runcmd("XCATBYPASS=1 lsdef -t node -o $node -i $attr");
if($::RUNCMD_RC){
return "Unknown";
}else{
foreach my $output1 (@output){
if($output1 =~ /$attr=(\w.+)/){
log_this("$attr is $1");
return $1;
}
}

View File

@@ -26,9 +26,9 @@ if [ ! -d "/opt/xcat" ]; then
fi
infofile="/opt/xcat/xcatinfo"
if [ "$RUNBOOTSCRIPTS" = "yes" ] || [ "$RUNBOOTSCRIPTS" = "YES" ]; then
RUNBOOTSCRIPTS=YES
RUNBOOTSCRIPTS=yes
else
RUNBOOTSCRIPTS=NO
RUNBOOTSCRIPTS=no
fi
# check to see if current setting is already in the file, if so nothing to do
if [ -f $infofile ]; then