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

This commit is contained in:
Lei Ai 2014-06-25 08:50:59 +08:00
commit 2c266e9ac9
27 changed files with 1383 additions and 283 deletions

View File

@ -19,7 +19,7 @@ use File::Path;
use Math::BigInt;
use Socket;
use xCAT::GlobalDef;
use Data::Dumper;
#use Data::Dumper;
use strict;
use warnings "all";
my $socket6support = eval { require Socket6 };
@ -1601,58 +1601,124 @@ sub thishostisnot
=cut
#-----------------------------------------------------------------------------
#sub gethost_ips1
#{
# my ($class) = @_;
# my $cmd;
# my @ipaddress;
# $cmd = "ifconfig" . " -a";
# $cmd = $cmd . "| grep \"inet\"";
# my @result = xCAT::Utils->runcmd($cmd, 0);
# if ($::RUNCMD_RC != 0)
# {
# xCAT::MsgUtils->message("S", "Error from $cmd\n");
# exit $::RUNCMD_RC;
# }
# foreach my $addr (@result)
# {
# my @ip;
# if (xCAT::Utils->isLinux())
# {
# if ($addr =~ /inet6/)
# {
# #TODO, Linux ipv6
# }
# else
# {
# my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
# #@ip = split(":", $addr1);
# #push @ipaddress, $ip[1];
# $addr1 =~ s/.*://;
# push @ipaddress, $addr1;
# }
# }
# else
# { #AIX
# if ($addr =~ /inet6/)
# {
# $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
# my $v6ip = $1;
# my $v6mask = $2;
# if ($v6ip)
# {
# push @ipaddress, $v6ip;
# }
# }
# else
# {
# my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
# split(" ", $addr);
# push @ipaddress, $addr1;
# }
#
# }
# }
# my @names = @ipaddress;
# foreach my $ipaddr (@names)
# {
# my $hostname = xCAT::NetworkUtils->gethostname($ipaddr);
# if ($hostname)
# {
# my @shorthost = split(/\./, $hostname);
# push @ipaddress, $shorthost[0];
# }
# }
#
# return @ipaddress;
#}
sub gethost_ips
{
my ($class) = @_;
my $cmd;
my @ipaddress;
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet\"";
my @result = xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
if (xCAT::Utils->isLinux())
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
$cmd="ip -4 --oneline addr show |awk -F ' ' '{print \$4}'|awk -F '/' '{print \$1}'";
my @result =xCAT::Utils->runcmd($cmd);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
push @ipaddress, @result;
}
foreach my $addr (@result)
{
my @ip;
if (xCAT::Utils->isLinux())
{
if ($addr =~ /inet6/)
{
#TODO, Linux ipv6
}
else
{
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
#@ip = split(":", $addr1);
#push @ipaddress, $ip[1];
$addr1 =~ s/.*://;
push @ipaddress, $addr1;
}
}
else
{ #AIX
if ($addr =~ /inet6/)
{
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
my $v6ip = $1;
my $v6mask = $2;
if ($v6ip)
{
push @ipaddress, $v6ip;
}
}
else
{
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
push @ipaddress, $addr1;
}
else
{ #AIX
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet\"";
my @result = xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
foreach my $addr (@result)
{
if ($addr =~ /inet6/)
{
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
my $v6ip = $1;
my $v6mask = $2;
if ($v6ip)
{
push @ipaddress, $v6ip;
}
}
else
{
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
push @ipaddress, $addr1;
}
}
}
}
my @names = @ipaddress;
foreach my $ipaddr (@names)
{
@ -1663,9 +1729,9 @@ sub gethost_ips
push @ipaddress, $shorthost[0];
}
}
return @ipaddress;
}
#-------------------------------------------------------------------------------
=head3 get_subnet_aix

View File

@ -1339,11 +1339,30 @@ sub runxcmd_output
}
}
}
if (defined($node->{error}))
{
if (ref(\($node->{error}->[0])) eq 'SCALAR')
{
$desc = $desc . ": " . $node->{error}->[0];
}
}
if (defined($node->{errorcode}))
{
if (ref(\($node->{errorcode}->[0])) eq 'SCALAR')
{
$::RUNCMD_RC |= $node->{errorcode}->[0];
}
}
push @$::xcmd_outref, $desc;
}
if (defined($resp->{error}))
{
push @$::xcmd_outref, @{$resp->{error}};
if (ref($resp->{error}) eq 'ARRAY')
{
push @$::xcmd_outref, @{$resp->{error}};
} else {
push @$::xcmd_outref, $resp->{error};
}
}
if (defined($resp->{errorcode}))
{

View File

@ -19,7 +19,7 @@ if (scalar(@ARGV) < 2 || scalar(@ARGV) > 3) {
my $bond = shift(@ARGV);
my $nic = $ARGV[0];
my @devs;
push(@devs,@ARGV);
foreach my $a (@ARGV) { push(@devs,split('@',$a)); } # support the new syntax in the xcat configbond postscript
my $nicips = $ENV{NICIPS};
my $nicnetworks = $ENV{NICNETWORKS};
my $net_cnt = $ENV{NETWORKS_LINES};

View File

@ -1,4 +1,5 @@
#!/bin/bash
#Used only by sysclone
# This SI post-install script is needed because the initrd that autoyast/kickstart/ubuntu builds when installing
# sles/rh/ubuntu on the golden node may not have the drivers when that initrd runs on the node that is
@ -9,10 +10,11 @@
# And do whatever is necessary on ubuntu.
if [[ -f /sbin/dracut ]]; then
#todo: implement rh case using dracut
echo "Note: not regenerating the initrd, because dracut is not supported by this node yet."
# redhat/centos
echo "Running dracut to regenerate the initrd with the drivers needed by this node:"
dracut --force
else
# suse/sles
echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:"
mkinitrd
# suse/sles
echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:"
mkinitrd
fi

View File

@ -84,4 +84,9 @@ rm -rf $RPM_BUILD_ROOT
%post
# We are shipping the postscripts in a sysclone dir and then copying them to /install/postscripts here,
# because we want to allow base xcat to eventually ship them and not conflict on the file name/path
cp -f /%{prefix}/share/xcat/sysclone/postscripts/* /install/postscripts
# But base xcat now has a newer/better configbond written in bash, so if that is there do not overwrite it.
head /install/postscripts/configbond | grep -q -E '^#! */bin/bash'
if [[ $? != 0 ]]; then
# the new configbond from xcat 2.8.5 is not there, so copy ours
cp -f /%{prefix}/share/xcat/sysclone/postscripts/* /install/postscripts
fi

View File

@ -1,12 +1,11 @@
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# Used as a convience command combined of [nodech]-nodeset-rpower-[rcons/wcons]
# Used as a convience command combined of [nodech]-nodeset-rsetboot-rpower-[rcons/wcons]
# to make ease of node OS provision
# To use this, sym link your cmd name to this script.
# This is the client front-end to rinstall/winstall commands
use strict;
BEGIN
{
@ -20,180 +19,69 @@ use lib "$::XCATROOT/lib/perl";
use File::Basename;
use Getopt::Long;
use xCAT::MsgUtils;
use xCAT::Table;
use xCAT::NodeRange;
use xCAT::Utils;
use xCAT::Client;
use Cwd;
use strict;
sub usage {
print basename($0)." usage:\n";
print " ".basename($0)." [-o|--osver] [-p|--profile] [-a|--arch] [-O|--osimage] [-c|--console] <noderange>\n"
}
my $OSVER;
my $PROFILE;
my $ARCH;
my $CONSOLE;
my $OSIMAGE;
Getopt::Long::Configure("bundling");
unless (GetOptions(
'o|osver=s' => \$OSVER,
'p|profile=s' => \$PROFILE,
'a|arch=s' => \$ARCH,
'O|osimage=s' => \$OSIMAGE,
'c|console' => \$CONSOLE
)) {
usage;
exit 1;
}
my $arraysize=@ARGV;
if ($arraysize > 1) {
print "noderange invalid\n";
usage;
exit 1;
}
if ($arraysize == 0) {
print "noderange not supplied\n";
usage;
exit 1;
}
my $noderange=@ARGV[0];
my $rc=0;
my %pnhash;
my @allnodes;
#use Data::Dumper;
# check and complain about the invalid combination of the options,
# called when -O is specified or nodetype.provmethod=<osimage>,
# ignore -o,-p and -a options and prompt a warning message
sub checkoption{
my $optstring=shift;
if($OSVER) {print 'warning: "'.$optstring.'" specified, "[-o|--osver] '.$OSVER."\" ignored\n"};
if($PROFILE) {print 'warning: "'.$optstring.'" specified, "[-p|--profile] '.$PROFILE."\" ignored\n"};
if($ARCH) {print 'warning: "'.$optstring.'" specified, "[-a|--arch] '.$OSVER."\" ignored\n"};
}
@allnodes=noderange($noderange);
if($OSIMAGE){
# -O|--osimage is specified, ignore any -a,-p,-o options,
# 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
&checkoption("[-O|--osimage] $OSIMAGE");
$rc=system("nodeset $noderange osimage=$OSIMAGE");
if ($rc) {
xCAT::MsgUtils->message("E","nodeset failure");
exit 1;
};
}else
# build a request to go the rinstall plugin
my $bname = basename($0);
my $cmdref;
$cmdref->{command}->[0] = $bname;
$cmdref->{cwd}->[0] = cwd();
# allows our plugins to get the stdin of the cmd that invoked the plugin
my $data;
if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) )
{
# no osimage specified, update the node attributes specified by -a,-p,-o options thru "nodech",
# then set the boot state of each node based on the nodetype.provmethod:
# 1) if nodetype.provmethod = <osimage>, ignore any -p,-o,-a option, then call "nodeset ... osimage"
# 2) if nodetype.provmethod = [install/netboot/statelite], update the node attributes specified by -a,-p,-o options thru "nodech", call "nodeset ... [install/netboot/statelite]"
# 3) if nodetype.provmethod is not set, use 'install' as the default value
# group the nodes according to the nodetype.provmethod
foreach(@allnodes){
my $tab=xCAT::Table->new("nodetype");
my $nthash=$tab->getNodeAttribs($_,['provmethod']);
$tab->close();
if(defined($nthash) and defined($nthash->{'provmethod'}))
{
push(@{$pnhash{$nthash->{'provmethod'}}},$_);
}
else
{
#if nodetype.provmethod is not specified,
push(@{$pnhash{'install'}},$_);
}
}
foreach my $key (keys %pnhash)
{
my $rclocal=0;
my $nodes=join(',',@{$pnhash{$key}});
if($key =~ /^(install|netboot|statelite)$/)
{
# nodetype.provmethod = [install|netboot|statelite]
my $nodechline = "";
if ($OSVER) {
$nodechline = "nodetype.os=$OSVER";
}
if ($PROFILE) {
$nodechline .= " nodetype.profile=$PROFILE";
}
if ($ARCH) {
$nodechline .= " nodetype.arch=$ARCH";
}
if ($nodechline) {
$rclocal=system("nodech $nodes $nodechline");
if ($rclocal) {
print "nodech failure\n";
$rc=$rclocal;
}
}
unless($rc){
$rclocal=system("nodeset $nodes $key");
if ($rclocal) {
print "nodeset $nodes failure\n";
$rc=$rclocal;
}
}
}
else
{
# nodetype.provmethod = <osimage>
&checkoption("nodetype.provmethod=$key");
$rclocal=system("nodeset $nodes osimage");
if ($rclocal) {
print "nodeset $nodes failure\n";
$rc=$rclocal;
}
}
}
my $rin="";
my $rout;
vec($rin,fileno(STDIN),1)=1;
my $nfound=select($rout=$rin,"","",1);
if ($nfound)
{
while ( <STDIN> ) { $data.=$_; }
$cmdref->{stdin}->[0]=$data;
}
}
if($rc){
xCAT::MsgUtils->message("E","nodeset failure");
exit 1;
else
{
if (-p STDIN) {
while ( <STDIN> ) { $data.=$_; }
$cmdref->{stdin}->[0]=$data;
}
}
my $arg;
my @tmpargv = @ARGV;
# first
$arg=shift(@ARGV);
# first 1st non-hyphen arg is the noderange
while ($arg =~ /^-/) {
push (@{$cmdref->{arg}}, $arg);
$arg=shift(@ARGV);
}
$cmdref->{noderange}->[0]=$arg;
push (@{$cmdref->{arg}}, @ARGV);
# call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others, assume user has set the correct boot order before "rinstall"
system("rsetboot $noderange net");
my $noderange=$cmdref->{noderange}->[0]; # save the noderange
# call "rpower" to start the node provision process
$rc=system("rpower $noderange boot");
if ($rc) {
xCAT::MsgUtils->message("E","rpower failure");
exit 1;
};
# ok call Client to run the plugin rinstall.pm
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
if ($xCAT::Client::EXITCODE == 0) # no errors
{
my $startconsole=$cmdref->{startconsole}->[0];
# if startconsole requested ( -c flag) for rinstall always for winstall
# This is set in the rinstall plugin
if ($startconsole == 1) {
if (basename($0) =~ /rinstall/) {
if (basename($0) =~ /rinstall/) {
# for rinstall, the -c|--console option can provide the remote console for only 1 node
if ($CONSOLE) {
if(scalar @allnodes ne 1){
xCAT::MsgUtils->message("E","rinstall [-c|--console] will only work if there is only one node in the noderange. See winstall(8) for consoles on multiple systems");
exit 1;
}
exec("rcons $noderange");
}
} elsif (basename($0) =~ /winstall/) {
# winstall can commence a wcons command to the noderange for monitoring the provision cycle
elsif (basename($0) =~ /winstall/) {
# winstall can commence a wcons command to the noderange for monitoring the provision cycle
exec("wcons $noderange");
exec("wcons $noderange");
}
}
}
exit $xCAT::Client::EXITCODE;

View File

@ -4,32 +4,42 @@ B<rinstall> - Begin OS provision on a noderange
=head1 B<Synopsis>
B<rinstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-O>|I<--osimage>] [I<-c>|I<--console>] [I<noderange>]
B<rinstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-c>|I<--console>] [I<noderange>]
B<rinstall> [I<-O>|I<--osimage>] [I<-c>|I<--console>] [I<noderange>]
=head1 B<Description>
B<rinstall> is a convience command that will change tables as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<rinstall>), and B<rpower> to begin a boot cycle.
B<rinstall> is a convenience command that will change tables as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<rinstall>), and B<rpower> to begin a boot cycle.
If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
If -c is specified, it will then become the text console of the node. If wanting consoles on multiple nodes with a similar command, see L<winstall(8)|winstall.8>.
If -c is specified, it will then run rcons on the node. This is allowed only if one node in the noderange. If need consoles on multiple nodes , see L<winstall(8)|winstall.8>.
=head1 B<Options>
=over 7
=item B<-h>|B<--help>
Display usage message.
=item B<-v>|B<--version>
Display version.
=item B<-o>|B<--osver>
Specifies which os version to provision. If unspecified, the current table values are used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-p>|B<--profile>
Specifies what profile should be used of the operating system. If not specified the tables are used as is. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-a>|B<--arch>
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-O>|B<--osimage>
@ -37,7 +47,7 @@ Specifies the osimage to provision.
=item B<-c>|B<--console>
Requests that rinstall become rcons once the provision commences. This will only work if there is only one node in the noderange. See L<winstall(8)|winstall.8> for consoles on multiple systems.
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L<winstall(8)|winstall.8> for starting nsoles on multiple nodes.
=back
@ -46,17 +56,17 @@ Requests that rinstall become rcons once the provision commences. This will onl
B<rinstall> I<node1-node20>
Provison nodes 1 through 20, using configuration as is from tables.
Provison nodes 1 through 20, using their current configuration.
B<rinstall> -o rhels5.1 -p compute I<node1-node20>
B<rinstall> I<node1-node20> -o rhels5.1 -p compute
Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
B<rinstall> -O rhels6.4-ppc64-netboot-compute I<node1-node20>
B<rinstall> I<node1-node20> -O rhels6.4-ppc64-netboot-compute
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
B<rinstall> -c I<node1>
B<rinstall> I<node1> -c
Provisoon node1 and start a console to monitor the process.

View File

@ -1,53 +1,64 @@
=head1 Name
B<winstall> - Begin OS provision on a noderange and display in wcons
B<winstall> - Begin OS provision on a noderange
=head1 B<Synopsis>
B<winstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-O>|I<--osimage>] [I<noderange>]
B<winstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<noderange>]
B<winstall> [I<-O>|I<--osimage>] [I<noderange>]
=head1 B<Description>
B<winstall> is a convience command that will change tables as requested for operating system version, profile, and architecture, call nodeset to modify the network boot configuration, and rpower to begin a boot cycle.
B<winstall> is a convenience tool that will change attributes as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes
with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<winstall>), and B<rpower> to begin a boot cycle.
If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified
If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
It will then commence a wcons command to the noderange for monitoring.
It will then run wcons on the nodes.
=head1 B<Options>
=over 7
=item B<-h>|B<--help>
Display usage message.
=item B<-v>|B<--version>
Display version.
=item B<-o>|B<--osver>
Specifies which os version to provision. If unspecified, the current table values are used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-p>|B<--profile>
Specifies what profile should be used of the operating system. If not specified the tables are used as is. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-a>|B<--arch>
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-O>|B<--osimage>
Specifies the osimage to provision.
Specifies the osimage to provision.
=back
=head1 B<Examples>
B<rinstall> I<node1-node20>
B<winstall> I<node1-node20>
Provison nodes 1 through 20, using configuration as is from tables.
Provison nodes 1 through 20, using their current configuration.
B<rinstall> -o rhels5.1 -p compute I<node1-node20>
B<winstall> I<node1-node20> -o rhels5.1 -p compute
Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
B<rinstall> -O rhels6.4-ppc64-netboot-compute I<node1-node20>
B<winstall> I<node1-node20> -O rhels6.4-ppc64-netboot-compute
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.

View File

@ -121,6 +121,7 @@ sub new {
unless ($ipmi2support) {
$self->{ipmi15only} = 1;
}
$self->{privlevel} = 4;
unless ($args{'bmc'} and defined $args{'userid'} and defined $args{'password'}) {
$self->{error}="bmc, userid, and password must be specified";
return $self;
@ -308,7 +309,7 @@ sub session_activated {
sub set_admin_level {
my $self= shift;
$self->subcmd(netfn=>0x6,command=>0x3b,data=>[4],callback=>\&admin_level_set,callback_args=>$self);
$self->subcmd(netfn=>0x6,command=>0x3b,data=>[$self->{privlevel}],callback=>\&admin_level_set,callback_args=>$self);
}
sub admin_level_set {
my $rsp = shift;
@ -319,6 +320,14 @@ sub admin_level_set {
0x82 => "Cannot disable User Level authentication",
);
my $code = $rsp->{code};
if (($code == 0x80 or $code == 0x81) and $self->{privlevel} == 4) {
$self->{privlevel} = 3;
$self->{logged}=1;
$self->logout();
$self->relog();
return;
}
if ($code) {
my $errtxt = sprintf("ERROR: Failed requesting administrator privilege %02xh",$code);
if ($localcodes{$code}) {
@ -686,7 +695,7 @@ sub send_rakp3 {
$self->{rmcptag}+=1;
my @payload = ($self->{rmcptag},0,0,0,@{$self->{pendingsessionid}});
my @user = unpack("C*",$self->{userid});
push @payload,unpack("C*",hmac_sha1(pack("C*",@{$self->{remoterandomnumber}},@{$self->{sidm}},4,scalar @user,@user),$self->{password}));
push @payload,unpack("C*",hmac_sha1(pack("C*",@{$self->{remoterandomnumber}},@{$self->{sidm}},$self->{privlevel},scalar @user,@user),$self->{password}));
$self->sendpayload(payload=>\@payload,type=>$payload_types{'rakp3'});
}
@ -700,7 +709,7 @@ sub send_rakp1 {
push @{$self->{randomnumber}},$randomnumber;
}
push @payload, @{$self->{randomnumber}};
push @payload,(4,0,0); # request admin
push @payload,($self->{privlevel},0,0); # request priv
my @user = unpack("C*",$self->{userid});
push @payload,scalar @user;
push @payload,@user;
@ -709,6 +718,8 @@ sub send_rakp1 {
}
sub init {
my $self = shift;
$self->{confalgo} = undef;
$self->{integrityalgo}=undef;
$self->{sessionestablishmentcontext} = 0;
$self->{'sequencenumber'} = 0; #init sequence number
$self->{'sequencenumberbytes'} = [0,0,0,0]; #init sequence number
@ -816,6 +827,13 @@ sub got_rakp2 {
}
$byte = shift @data;
unless ($byte == 0x00) {
if (($byte == 0x9 or $byte == 0xd) and $self->{privlevel} == 4) {
# this is probably an environment that wants to give us only operator
# try to connect again at 3.
$self->{privlevel} = 3;
$self->relog();
return;
}
if ($byte == 0x02) { #invalid session id is almost certainly because a retry on rmcp+ open session response rendered our session id invalid, ignore this in the hope that we'll get an answer for our retry that invalidated us..
#$self->relog();
#TODO: probably should disable RAKP1 retry here... high likelihood that we'll just spew a bad RAKP1 and Open Session Request retry would be more appropriate to try to discern a valid session id
@ -840,7 +858,7 @@ sub got_rakp2 {
#Data now represents authcode.. sha1 only..
my @user = unpack("C*",$self->{userid});
my $ulength = scalar @user;
my $hmacdata = pack("C*",(@{$self->{sidm}},@{$self->{pendingsessionid}},@{$self->{randomnumber}},@{$self->{remoterandomnumber}},@{$self->{remoteguid}},4,$ulength,@user));
my $hmacdata = pack("C*",(@{$self->{sidm}},@{$self->{pendingsessionid}},@{$self->{randomnumber}},@{$self->{remoterandomnumber}},@{$self->{remoteguid}},$self->{privlevel},$ulength,@user));
my @expectedhash = (unpack("C*",hmac_sha1($hmacdata,$self->{password})));
foreach (0..(scalar(@expectedhash)-1)) {
if ($expectedhash[$_] != $data[$_]) {
@ -849,7 +867,7 @@ sub got_rakp2 {
return 9;
}
}
$self->{sik} = hmac_sha1(pack("C*",@{$self->{randomnumber}},@{$self->{remoterandomnumber}},4,$ulength,@user),$self->{password});
$self->{sik} = hmac_sha1(pack("C*",@{$self->{randomnumber}},@{$self->{remoterandomnumber}},$self->{privlevel},$ulength,@user),$self->{password});
$self->{k1} = hmac_sha1(pack("C*",1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),$self->{sik});
$self->{k2} = hmac_sha1(pack("C*",2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2),$self->{sik});
my @aeskey = unpack("C*",$self->{k2});

View File

@ -178,19 +178,21 @@ sub subvars {
while (not $doneincludes) {
$doneincludes=1;
$inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; # handle the variable in #INCLUDE
if ($inc =~ /#INCLUDE_PKGLIST:[^#^\n]+#/) {
if ($inc =~ /#INCLUDE_PKGLIST:[^\n]+#/) {
# get in this section but might not do the replace since it needs wait
# for the replace of sting inside the #INCLUDE_PKGLIST:xx#
$doneincludes=0;
$inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1, 0, 1)/eg;
}
if ($inc =~ /#INCLUDE_PTRNLIST:[^#^\n]+#/) {
if ($inc =~ /#INCLUDE_PTRNLIST:[^\n]+#/) {
$doneincludes=0;
$inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1, 0, 2)/eg;
}
if ($inc =~ /#INCLUDE_RMPKGLIST:[^#^\n]+#/) {
if ($inc =~ /#INCLUDE_RMPKGLIST:[^\n]+#/) {
$doneincludes=0;
$inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1, 0, 3)/eg;
}
if ($inc =~ /#INCLUDE:[^#^\n]+#/) {
if ($inc =~ /#INCLUDE:[^\n]+#/) {
$doneincludes=0;
$inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg;
}

View File

@ -1671,6 +1671,7 @@ sub mksysclone
copy("$installroot/postscripts/$script1","$pspath/15all.$script1");
copy("$installroot/postscripts/$script2","$pspath/16all.$script2");
copy("$installroot/postscripts/runxcatpost","$pspath/17all.runxcatpost");
copy("$installroot/postscripts/makeinitrd","$pspath/20all.makeinitrd");
unless (-r "$pspath/10all.fix_swap_uuids")
{

View File

@ -2225,7 +2225,7 @@ sub initfru_zero {
$fru = FRU->new();
$fru->rec_type("misc");
$fru->desc("System Manufacturer");
if ($fruhash->{product}->{product}->{encoding}==3) {
if ($fruhash->{product}->{manufacturer}->{encoding}==3) {
$fru->value($fruhash->{product}->{manufacturer}->{value});
} else {
$fru->value(phex($fruhash->{product}->{manufacturer}->{value}));

View File

@ -761,7 +761,7 @@ Usage:
}
# make sure there are something changed, otherwise we should quit without any changes.
unless ($changeflag){
setrsp_errormsg("No profile changes detect.");
setrsp_infostr("Warning: no profile changes detect.");
return;
}
@ -931,11 +931,15 @@ Usage:
#6. Generate new free IPs for each network.
my @allknownips = keys %allips;
my %netFreeIPsHash = ();
foreach my $updnic (@updateNics){
#No need generate for removed nics.
unless (grep {$_ eq $updnic} @removedNics){
my $netname = $netProfileNicsRef->{$netProfileName}->{$updnic}->{"network"};
$freeIPsHash{$updnic} = xCAT::ProfiledNodeUtils->get_allocable_staticips_innet($netname, \@allknownips);
if ( not exists $netFreeIPsHash{$netname} ){
$netFreeIPsHash{$netname} = xCAT::ProfiledNodeUtils->get_allocable_staticips_innet($netname, \@allknownips);
}
$freeIPsHash{$updnic} = $netFreeIPsHash{$netname};
}
}

View File

@ -0,0 +1,481 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------
=head1
xCAT plugin package to handle rinstall and winstall
Supported command:
rinstall - runs nodeset, rsetboot,rpower commands
winstall - also opens the console
=cut
#-------------------------------------------------------
package xCAT_plugin::rinstall;
use strict;
require xCAT::Utils;
require xCAT::MsgUtils;
use xCAT::NodeRange;
use xCAT::Table;
use Data::Dumper;
use Getopt::Long;
#-------------------------------------------------------
=head3 handled_commands
Return list of commands handled by this plugin
=cut
#-------------------------------------------------------
sub handled_commands
{
return {
rinstall => "rinstall",
winstall => "rinstall",
};
}
#-------------------------------------------------------
=head3 Process the command
=cut
#-------------------------------------------------------
sub process_request
{
my $request = shift;
my $callback = shift;
my $subreq = shift;
rinstall($request, $callback, $subreq);
}
#-------------------------------------------------------
=head3 rinstall
Wrapper around nodeset, rsetboot, rpower for the admin convenience
=cut
#-------------------------------------------------------
sub rinstall
{
my ($req, $callback, $subreq) = @_;
$::CALLBACK=$callback;
my $OSVER;
my $PROFILE;
my $ARCH;
my $CONSOLE;
my $OSIMAGE;
my $HELP;
my $VERSION;
my $command = $req->{command}->[0]; # could be rinstall on winstall
my $args;
if (defined($req->{arg}) ) { # there are arguments
$args=$req->{arg}; # argument
@ARGV = @{$args};
}
my $nodes;
my @nodes;
if (defined ($req->{node})) { # there are nodes
$nodes = $req->{node};
@nodes=@$nodes;
}
# no arguments, no nodes then input wrong
if ((scalar(@nodes) == 0) && (scalar(@ARGV) == 0)){
&usage($command,$callback);
return 1;
}
#print Dumper($req);
Getopt::Long::Configure("bundling");
unless (
GetOptions(
'o|osver=s' => \$OSVER,
'p|profile=s' => \$PROFILE,
'a|arch=s' => \$ARCH,
'O|osimage=s' => \$OSIMAGE,
'h|help' => \$HELP,
'v|version' => \$VERSION,
'c|console' => \$CONSOLE
)
)
{
&usage($command,$callback);
return 1;
}
if ($HELP)
{
&usage($command,$callback);
return 0;
}
if ($VERSION)
{
my $version = xCAT::Utils->Version();
my $rsp = {};
$rsp->{data}->[0] = "$version";
xCAT::MsgUtils->message("I", $rsp, $callback);
return (0);
}
if (scalar @$nodes eq 0)
{
my $rsp = {};
$rsp->{error}->[0] ="noderange not supplied";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
my $rc = 0;
my %pnhash;
if ($OSIMAGE)
{
# -O|--osimage is specified, ignore any -a,-p,-o options,
# 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);
# run nodeset $noderange osimage=$OSIMAGE
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;
}
}
else
{
# no osimage specified, update the node attributes specified by -a,-p,-o options thru "nodech",
# then set the boot state of each node based on the nodetype.provmethod:
# 1) if nodetype.provmethod = <osimage>, ignore any -p,-o,-a option,
# then call "nodeset ... osimage"
# 2) if nodetype.provmethod = [install/netboot/statelite],
# update the node attributes specified by -a,-p,-o options thru "nodech",
# call "nodeset ... [install/netboot/statelite]"
# 3) if nodetype.provmethod is not set, use 'install' as the default value
# group the nodes according to the nodetype.provmethod
foreach (@$nodes)
{
my $tab = xCAT::Table->new("nodetype");
my $nthash = $tab->getNodeAttribs($_, ['provmethod']);
$tab->close();
if (defined($nthash) and defined($nthash->{'provmethod'}))
{
push(@{$pnhash{$nthash->{'provmethod'}}}, $_);
}
else
{
#if nodetype.provmethod is not specified,
push(@{$pnhash{'install'}}, $_);
}
}
# Now for each group based on provmethod
foreach my $key (keys %pnhash)
{
$::RUNCMD_RC =0;
my $nodes = join(',', @{$pnhash{$key}});
if ($key =~ /^(install|netboot|statelite)$/)
{
# nodetype.provmethod = [install|netboot|statelite]
my @nodechline;
if ($OSVER)
{
push @nodechline, "nodetype.os=$OSVER";
}
if ($PROFILE)
{
push @nodechline, "nodetype.profile=$PROFILE";
}
if ($ARCH)
{
push @nodechline, "nodetype.arch=$ARCH";
}
if (@nodechline)
{
# run nodech $nodes $nodechline
my $res =
xCAT::Utils->runxcmd(
{
command => ["nodech"],
node => \@nodes,
arg => \@nodechline
},
$subreq, -1, 1);
my $rsp = {};
$rc=$::RUNCMD_RC;
if ($rc == 0 ) {
foreach my $line (@$res) {
$rsp->{data} ->[0] = $line;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
} else { # error
$rsp->{error} ->[0] = "nodech error";
xCAT::MsgUtils->message("E", $rsp, $callback);
foreach my $line (@$res) {
$rsp->{error} ->[0] = $line;
xCAT::MsgUtils->message("E", $rsp, $callback);
}
}
} # end nodechline
if ($rc == 0) # if no error from nodech then run nodeset
{
# run nodeset $nodes $key ( where key is install/netboot/statelite)
my @nodesetarg;
push @nodesetarg, "$key";
my $res =
xCAT::Utils->runxcmd(
{
command => ["nodeset"],
node => \@nodes,
arg => \@nodesetarg
},
$subreq, -1, 1);
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);
}
}
}
}
else # if not install/netboot/statelite
{
# nodetype.provmethod = <osimage>
&checkoption("nodetype.provmethod=$key",$OSVER,$PROFILE,$ARCH,$callback);
# run nodeset $nodes osimage
my @nodesetarg;
push @nodesetarg, "osimage";
my $res =
xCAT::Utils->runxcmd(
{
command => ["nodeset"],
node => \@nodes,
arg => \@nodesetarg
},
$subreq, -1, 1);
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);
}
}
}
}
} # end nodech/nodeset for each group
if ($rc != 0) # we got an error with the nodeset
{
my $rsp = {};
$rsp->{error}->[0] = "nodeset failure will not continue ";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others,
# assume user has set the correct boot order before "rinstall"
# run rsetboot $noderange net
my @rsetbootarg;
push @rsetbootarg, "net";
my $res =
xCAT::Utils->runxcmd(
{
command => ["rsetboot"],
node => \@nodes,
arg => \@rsetbootarg
},
$subreq, -1, 1);
# 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;
}
# call "rpower" to start the node provision process
#run rpower $noderange boot
my @rpowerarg;
push @rpowerarg, "boot";
my $res =
xCAT::Utils->runxcmd(
{
command => ["rpower"],
node => \@nodes,
arg => \@rpowerarg
},
$subreq, -1, 1);
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);
}
}
# Check if they asked to bring up a console ( -c) from rinstall always for winstall
$req->{startconsole}->[0] =0;
if ($command =~ /rinstall/)
{
# for rinstall, the -c|--console option can provide the remote console for only 1 node
if ($CONSOLE)
{
if (scalar @$nodes ne 1)
{
my $rsp = {};
$rsp->{error}->[0] = "rinstall -c only accepts one node in the noderange. See winstall for support for support of consoles on multiple nodes.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
} else { # tell rinstall client ok to start rcons
$req->{startconsole}->[0] =1;
}
}
}
elsif ($command =~ /winstall/)
{
# winstall can start a wcons command to multiple nodes for monitoring the provision cycle
$req->{startconsole}->[0] =1;
}
return 0;
}
#-------------------------------------------------------
=head3 Usage
=cut
#-------------------------------------------------------
sub usage
{
my $command = shift;
my $callback = shift;
my $rsp = {};
$rsp->{data}->[0] = "$command usage:";
if ($command =~ /rinstall/) {
$rsp->{data}->[1] = " [-o|--osver] [-p|--profile] [-a|--arch] [-c|--console] <noderange>";
} else { # winstall
$rsp->{data}->[1] = " [-o|--osver] [-p|--profile] [-a|--arch] <noderange>";
}
if ($command =~ /rinstall/) {
$rsp->{data}->[2] = " [-O|--osimage] [-c|--console] <noderange>";
} else { # wininstall
$rsp->{data}->[2] = " [-O|--osimage] <noderange>";
}
$rsp->{data}->[3] = " [-h|--help]";
$rsp->{data}->[4] = " [-v|--version]";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
# check and complain about the invalid combination of the options,
# ignore -o,-p and -a options and prompt a warning message when provmethod=osimagename
sub checkoption{
my $optstring=shift;
my $OSVER=shift;
my $PROFILE=shift;
my $ARCH=shift;
my $callback=shift;
my $rsp = {};
if($OSVER) {
$rsp->{data}->[0] = "-o option not valid with $optstring. It is ignored.";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
if($PROFILE) {
$rsp->{data}->[0] = "-p option not valid with $optstring. It is ignored.";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
if($ARCH) {
$rsp->{data}->[0] = "-a option not valid with $optstring. It is ignored.";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
}
1;

View File

@ -1353,6 +1353,7 @@ sub mksysclone
copy("$installroot/postscripts/configefi","$pspath/15all.configefi");
copy("$installroot/postscripts/updatenetwork","$pspath/16all.updatenetwork");
copy("$installroot/postscripts/runxcatpost","$pspath/17all.runxcatpost");
copy("$installroot/postscripts/makeinitrd","$pspath/20all.makeinitrd");
copy("$installroot/postscripts/killsyslog","$pspath/99all.killsyslog");
unless (-r "$pspath/10all.fix_swap_uuids")
@ -1512,12 +1513,41 @@ sub mksysclone
}
my $cmd =qq{echo "$node:compute:$imagename:" >> $clusterfile};
my $out = xCAT::Utils->runcmd($cmd, -1);
my $rc = xCAT::Utils->runcmd($cmd, -1);
unless (-r "$installroot/sysclone/images/$imagename/opt/xcat/xcatdsklspost")
my $imagedir;
my $osimagetab = xCAT::Table->new('linuximage');
my $osimageentry = $osimagetab->getAttribs({imagename => $imagename}, 'rootimgdir');
if($osimageentry){
$imagedir = $osimageentry->{rootimgdir};
$imagedir =~ s/^(\/.*)\/.+\/?$/$1/;
}else{
$imagedir = "$installroot/sysclone/images";
$cmd = "chdef -t osimage $imagename rootimgdir=$imagedir/$imagename";
$rc = `$cmd`;
}
my $cfgimagedir = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`;
chomp($cfgimagedir);
$cfgimagedir =~ s/^\s+path=(\/.*)\/.+$/$1/g;
if($imagedir ne $cfgimagedir){
my $oldstr = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`;
chomp($oldstr);
$oldstr =~ s/\//\\\\\//g;
my $targetstr="\tpath=".$imagedir."/".$imagename;
$targetstr =~ s/\//\\\\\//g;
$cmd= "sed -i \"s/$oldstr/$targetstr/\" /etc/systemimager/rsync_stubs/40$imagename";
$rc = `$cmd`;
}
$rc = `export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_mkrsyncd_conf`;
unless (-r "$imagedir/$imagename/opt/xcat/xcatdsklspost")
{
mkpath("$installroot/sysclone/images/$imagename/opt/xcat/");
copy("$installroot/postscripts/xcatdsklspost","$installroot/sysclone/images/$imagename/opt/xcat/");
mkpath("$imagedir/$imagename/opt/xcat/");
copy("$installroot/postscripts/xcatdsklspost","$imagedir/$imagename/opt/xcat/");
}
}

View File

@ -1924,7 +1924,7 @@ sub updatenodesoftware
my $cmd;
my $args1;
$cmd =
"$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
"$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs,syscloneimgupdate' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
# add flowcontrol flag
if ($flowcontrol == 1){
$cmd .= " -F";

View File

@ -0,0 +1,154 @@
#
#cmdline
lang en_US
#KICKSTARTNET#
#
# Where's the source?
# nfs --server hostname.of.server or IP --dir /path/to/RH/CD/image
#
#nfs --server #XCATVAR:INSTALL_NFS# --dir #XCATVAR:INSTALL_SRC_DIR#
%include /tmp/repos
#device ethernet e100
keyboard "us"
#
# Clear the MBR
#
zerombr
#
# Wipe out the disk
#
clearpart --all --initlabel
#clearpart --linux
#key --skip
#
# Customize to fit your needs
#
#XCAT_PARTITION_START#
#No RAID
#/boot really significant for this sort of setup nowadays?
#part /boot --size 50 --fstype ext3
%include /tmp/partitioning
#part swap --size 1024
#part / --size 1 --grow --fstype ext4
#XCAT_PARTITION_END#
#RAID 0 /scr for performance
#part / --size 1024 --ondisk sda
#part swap --size 512 --ondisk sda
#part /var --size 1024 --ondisk sdb
#part swap --size 512 --ondisk sdb
#part raid.01 --size 1 --grow --ondisk sda
#part raid.02 --size 1 --grow --ondisk sdb
#raid /scr --level 0 --device md0 raid.01 raid.02
#Full RAID 1 Sample
#part raid.01 --size 50 --ondisk sda
#part raid.02 --size 50 --ondisk sdb
#raid /boot --level 1 --device md0 raid.01 raid.02
#
#part raid.11 --size 1024 --ondisk sda
#part raid.12 --size 1024 --ondisk sdb
#raid / --level 1 --device md1 raid.11 raid.12
#
#part raid.21 --size 1024 --ondisk sda
#part raid.22 --size 1024 --ondisk sdb
#raid /var --level 1 --device md2 raid.21 raid.22
#
#part raid.31 --size 1024 --ondisk sda
#part raid.32 --size 1024 --ondisk sdb
#raid swap --level 1 --device md3 raid.31 raid.32
#
#part raid.41 --size 1 --grow --ondisk sda
#part raid.42 --size 1 --grow --ondisk sdb
#raid /scr --level 1 --device md4 raid.41 raid.42
#
# bootloader config
# --append <args>
# --useLilo
# --md5pass <crypted MD5 password for GRUB>
#
bootloader
#
# install or upgrade
#
install
#
# text mode install (default is graphical)
#
text
#
# firewall
#
firewall --disabled
#
# Select a zone
# Add the --utc switch if your hardware clock is set to GMT
#
#timezone US/Hawaii
#timezone US/Pacific
#timezone US/Mountain
#timezone US/Central
#timezone US/Eastern
timezone --utc "#TABLE:site:key=timezone:value#"
#
# Don't do X
#
skipx
#
# To generate an encrypted root password use:
#
# perl -e 'print crypt("blah","Xa") . "\n";'p
# openssl passwd -apr1 -salt xxxxxxxx password
#
# where "blah" is your root password.
#
#rootpw --iscrypted XaLGAVe1C41x2
#rootpw XaLGAVe1C41x2 --iscrypted
rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password#
#
# NIS setup: auth --enablenis --nisdomain sensenet
# --nisserver neptune --useshadow --enablemd5
#
# OR
auth --useshadow --enablemd5
#
# SE Linux
#
selinux --disabled
#
# Reboot after installation
#
reboot
#
#end of section
#
%packages
#INCLUDE_DEFAULT_PKGLIST#
%end
%pre
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.rh.rhel7#
%end
%post
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat#
%end

View File

@ -0,0 +1,37 @@
#Please make sure there is a space between @ and group name
@ Network Infrastructure Server
@ System administration tools
@ System Management
@ X Window System
@ Development Tools
autofs
ksh
tcsh
ntp
tftp
xinetd
rsh
rsh-server
psacct
nfs-utils
net-snmp
rsync
yp-tools
ypserv
ypbind
m4
sendmail-cf
gdb
binutils
openssh-server
openssl098e.ppc
openssl098e.ppc64
util-linux
perl-DBD-MySQL
perl-Socket6
unixODBC
perl-DBD-MySQL
mysql-connector-odbc
perl-DBD-Pg
wget
util-linux-ng

View File

@ -0,0 +1,28 @@
#Please make sure there is a space between @ and group name
autofs
ksh
tcsh
ntp
tftp
xinetd
rsh
rsh-server
psacct
nfs-utils
net-snmp
rsync
yp-tools
ypserv
ypbind
m4
sendmail-cf
gdb
binutils
openssh-server
util-linux
unixODBC
perl-DBD-MySQL
mysql-connector-odbc
perl-DBD-Pg
wget
util-linux-ng

257
xCAT/postscripts/configbond Executable file
View File

@ -0,0 +1,257 @@
#! /bin/bash
# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html
# Usage:
# configbond bondname nic1@nic2@... [opt1@opt2@...]
#
# Description:
# This script is used to configure bond interface base on the arguments from the
# command line and the network information from nics and networks tables.
#
# This script will create bond interface named <bondname> with 'nic1','nic2'... as slave
# devices. The bonding options 'opt1','opt2'... will be configured to bond interface.
#
# The network information for the bond interface will be gotten from the nics.nicsip and
# nics.nicnetworks for interface <bondname>. If cannot get for <bondname>, try to
# search for nic1. If failed too, then nic2 ...
#
# It only supports to configure one bond device at each run. If you want to create
# multiple bond devices, call it multiple times.
#
# Note:
# This script only works for IPv4 so far.
# Following are examples of variables which are exported from mypostscript. Mostly, we need the nics and
# networks related varirables which are exported from xcat nics and networks tables.
# NICIPS=bond0!10.0.0.12
# NICTYPES=bond0!Ethernet
# NICHOSTNAMESUFFIXES=bond0!-bond0
# NICNETWORKS=bond0!10_0_0_0-255_255_255_0
# NICCUSTOMSCRIPTS=bond0!configbond
# NETWORKS_LINES=2
# NETWORKS_LINE1=netname=10_0_0_0-255_255_255_0||net=10.0.0.0||mask=255.255.255.0||mgtifname=eth1||gateway=<xcatmaster>||dhcpserver=||tftpserver=10.0.0.10||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments=
# NETWORKS_LINE2=netname=10_0_2_0-255_255_255_0||net=10.0.2.0||mask=255.255.255.0||mgtifname=eth0||gateway=10.0.2.2||dhcpserver=||tftpserver=10.0.2.15||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments=
# locd library for network caculation
str_dir_name=`dirname $0`
. $str_dir_name/xcatlib.sh
# Subroutine to display message and pass it to syslog
# Usage: showmsg "message to putput" ["error"]
function showmsg() {
msg="configbond: $1"
error=$2
if [ -n "$error" ]; then
$(logger -t xcat -p local4.err $msg)
else
$(logger -t xcat -p local4.info $msg)
fi
echo $msg
}
# Check OS version and get the directory of network configuration file
str_bond_name=''
str_os_type=`uname | tr 'A-Z' 'a-z'`
str_cfg_dir=''
str_temp=''
if [ "$str_os_type" = "linux" ];then
str_temp=`echo $OSVER | grep -E '(sles|suse)'`
if [ -f "/etc/redhat-release" ];then
str_os_type="redhat"
str_cfg_dir="/etc/sysconfig/network-scripts"
elif [ -f "/etc/SuSE-release" -o -n "$str_temp" ];then
str_os_type="sles"
str_cfg_dir="/etc/sysconfig/network"
else
showmsg "Only supports RHEL and SLES" "error"
exit -1
fi
else
showmsg "Does NOT support non-Linux Operating System" "error"
exit -1
fi
# Parse arguments
old_ifs=$IFS
IFS=$'@'
if [ $# -eq 2 ];then
array_bond_opts="mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1"
elif [ $# -eq 3 ]; then
array_bond_opts=($3)
else
showmsg "Only supports 2 or 3 arguments. Usage: configbond bondname nic1@nic2@... [opt1@opt2@...]"
exit -1
fi
str_bond_name=$1
array_bond_slaves=($2)
IFS=$old_ifs
# examples of variables
# str_bond_name=bond0
# array_bond_slaves=(eth1 eth2)
# array_bond_opts=(mode=1 miimon=100)
# Check the existence of slave devices and remove the inactive ones
realdevs=$(ip addr show 2>&1 | grep -E '^[1-9]' | cut -d: -f2)
for slave in ${array_bond_slaves[*]}; do
active=0
for rdev in $realdevs; do
if [ $rdev = $slave ]; then
active=1
fi
done
if [ $active -eq 0 ]; then
showmsg "Warning: device $slave does not exist. It will not be configured as a slave device."
# remove the device from slave list
allslaves=${array_bond_slaves[*]}
allslaves=${allslaves/$slave/}
array_bond_slaves=($allslaves)
fi
done
if [ ${#array_bond_slaves[*]} -eq 0 ]; then
showmsg "No available slave devices to use." "error"
exit -1
fi
showmsg "Create bond interface $str_bond_name with slaves=\"${array_bond_slaves[*]}\" opts=\"${array_bond_opts[*]}\""
# Get bond device's IP address
str_bond_ip=""
if [ -z "$NICIPS" ]; then
showmsg "Failed to get IP for bond interface: $str_bond_name. No IP is set in nics.nicips table."
exit 1
else
for devname in $str_bond_name ${array_bond_slaves[*]}; do # for each "bondname nic1 nic2 ..."
for ifipinfo in ${NICIPS//,/ }; do # for each "ifname!ifip"
old_ifs=$IFS
IFS=$'!'
arrayifinfo=($ifipinfo) # [0] - ifname; [1] - if ip address
IFS=$old_ifs
if [ "$devname" = "${arrayifinfo[0]}" ]; then
str_bond_ip=${arrayifinfo[1]}
break 2
fi
done
done
fi
# remove the left part from |. that means only keeping the first ip in the interface if there are alias ip
str_bond_ip=${str_bond_ip%%|*}
if [ -z "str_bond_ip" ]; then
showmsg "Failed to get IP for $str_bond_name ${array_bond_slaves[*]} from $NICIPS"
exit 1
fi
# Get the network and netmask info for the $str_bond_ip from networks table
str_bond_net=
str_bond_mask=
num_i=1
while [ $num_i -le $NETWORKS_LINES ];do
eval str_bond_network=\$NETWORKS_LINE$num_i
str_temp_net=${str_bond_network#*net=} # remove the left part from 'net='
str_temp_net=${str_temp_net%%|*} # remove the right part from first '|'
str_temp_mask=${str_bond_network#*mask=} # remove the left part from 'mask='
str_temp_mask=${str_temp_mask%%|*} # remove the right part from first '|'
str_temp_net1=$(v4calcnet $str_bond_ip $str_temp_mask)
str_temp_net2=$(v4calcnet $str_temp_net $str_temp_mask)
if [ "$str_temp_net1" = "$str_temp_net2" ];then
str_bond_net=$str_temp_net
str_bond_mask=$str_temp_mask
break
fi
num_i=$((num_i+1))
done
if [ -z "$str_bond_net" ] || [ -z "$str_bond_mask" ]; then
showmsg "Cannot find network information for bond IP $str_bond_ip from networks table." "error"
exit 1
fi
showmsg "IP information for $str_bond_name: IP=$str_bond_ip; network=$str_bond_net; netmask=$str_bond_mask"
# Create bond config file
str_master_file="${str_cfg_dir}/ifcfg-${str_bond_name}"
if [ "$str_os_type" = "redhat" ];then
# Create the master file
cat > $str_master_file <<EOF
DEVICE=${str_bond_name}
BOOTPROTO=none
IPADDR=${str_bond_ip}
NETMASK=${str_bond_mask}
ONBOOT=yes
USERCTL=no
BONDING_OPTS="${array_bond_opts[*]}"
EOF
# Create the slave files
for slave in ${array_bond_slaves[*]}; do
str_slave_file="${str_cfg_dir}/ifcfg-${slave}"
cat > $str_slave_file <<EOF
DEVICE=${slave}
MASTER=${str_bond_name}
SLAVE=yes
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
EOF
done
elif [ "$str_os_type" = "sles" ];then
# Create the master file
cat > $str_master_file <<EOF
NAME='Bonded Interface'
BOOTPROTO=static
BONDING_MASTER=yes
IPADDR=${str_bond_ip}
NETMASK=${str_bond_mask}
STARTMODE=onboot
USERCONTROL=no
BONDING_MODULE_OPTS="${array_bond_opts[*]}"
EOF
# Create the slave entries and files
num_index=0
for slave in ${array_bond_slaves[*]}; do
# this is a special part to inject each slave device to master cfg
echo "BONDING_SLAVE_${num_index}=$slave" >> $str_master_file
num_index=$((num_index+1))
str_slave_file="${str_cfg_dir}/ifcfg-${slave}"
echo "BOOTPROTO=none" > $str_slave_file
echo "STARTMODE=hotplug" >> $str_slave_file
done
fi
# add bonding driver alias for <bondname>
echo "alias $str_bond_name bonding" > /etc/modprobe.d/$str_bond_name.conf
# Bring down the salve devices first
for slave in ${str_bond_name} ${array_bond_slaves[*]}; do
$(ifdown $slave &>/dev/null)
done
# Bring up bond device
$(ifup ${str_bond_name} &>/dev/null)
if [ $? -ne 0 ]; then
showmsg "Failed to bring up $str_bond_name" "error"
exit 1
fi
showmsg "Finished the configuration for bond interface $str_bond_name"
exit 0

View File

@ -1,3 +1,9 @@
#!/bin/bash
#Used only by sysclone
# SI post-install script to configure the efi boot mgr or grub after SI has installed the OS
# SI post-install scripts run in a chroot environment of the final OS image
if [ -d /sys/firmware/efi ]; then
echo "Setting Boot Manager for the next boot."
echo "delete all sysclone boot list"
@ -25,32 +31,50 @@ else
if [ -f "/etc/systemconfig/systemconfig.conf" ];then
boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'`
else
str_temp=`mount | awk '{print $1","$3}'`
for line in $str_temp
do
mp=`echo $line | awk -F, '{print $2}'`
if [ "$mp" = "/" ];then
boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'`
break
fi
done
boot_root=`mount | grep -E ' on\s+/ type ' | awk '{print $1}'`
boot_device=`echo $boot_root | sed -e 's/[0-9]*$//'`
#str_temp=`mount | awk '{print $1","$3}'`
#for line in $str_temp
#do
# mp=`echo $line | awk -F, '{print $2}'`
# if [ "$mp" = "/" ];then
# boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'`
# break
# fi
#done
fi
if [ -n "$boot_device" ];then
echo "the boot device is $boot_device"
echo "The boot device is $boot_device"
echo "The boot root device is $boot_root"
else
echo "Can not find the boot device, return error"
exit 1
fi
#for sles10, should run grub-install with parameters
echo "grub-install --no-floppy --recheck $boot_device"
grub-install --no-floppy --recheck $boot_device
if [ $? -ne 0 ];then
# set grub to use this boot device
if grep -qe '^VERSION\s*=\s*11' /etc/SuSE-release; then
#sles11, run grub-install.unsupported directly
echo "grub-install.unsupported --no-floppy --recheck $boot_device"
grub-install.unsupported --no-floppy --recheck $boot_device
# note: the error about grub-set-default not existing is harmless, because we want the default to be 0 anyway
else
#for sles10, should run grub-install with parameters
echo "grub-install --no-floppy --recheck $boot_device"
grub-install --no-floppy --recheck $boot_device
fi
# change the entries in the grub conf file to use the correct boot root device
# (not the one leftover from the golden image)
if [ -f "/boot/grub/grub.conf" ];then
conffile="/boot/grub/grub.conf"
else
conffile="/boot/grub/menu.lst"
fi
sed -i 's| root=\S*| root='$boot_root'|' $conffile
sed -i 's| resume=\S*| noresume|' $conffile
if [ -e /etc/mtab.bak ];then
mv -f /etc/mtab.bak /etc/mtab
else

View File

@ -32,7 +32,7 @@ for i in `/bin/cat /proc/cmdline`; do
elif [ "$KEY" = "BOOTIF" ]; then
MACX=`/bin/echo $i | /bin/awk -F= '{print $2}'|sed -e s/^01-// -e s/-/:/g`
#ETHX=`/sbin/ifconfig | /bin/grep -i $MACX | /bin/awk '{print $1}'`
ETHX=`/sbin/ip -oneline link show ens33|/bin/grep -i $MACX |/bin/awk -F ":" '{print $2}'|/bin/grep -o "[^ ]\+\( \+[^ ]\+\)*"`
ETHX=`/sbin/ip -oneline link show |/bin/grep -i $MACX |/bin/awk -F ":" '{print $2}'|/bin/grep -o "[^ ]\+\( \+[^ ]\+\)*"`
break
fi
done

View File

@ -1,3 +1,10 @@
#!/bin/bash
#Used only by sysclone
# SI post-install script, run after SI has installed the OS, to kill processes SI does not kill
# (so /a can be umounted cleanly)
# SI post-install scripts run in a chroot environment of the final OS image
if [ -f "/etc/SuSE-release" ];then
str_out=`ps -ef | grep -v grep | grep syslog-ng`
if [ $? -eq 0 ];then
@ -5,3 +12,15 @@ if [ -f "/etc/SuSE-release" ];then
kill -9 $str_id
fi
fi
# SI starts klogd in the chroot, but does not kill it. Remove this line when SI fixes their bug.
killall klogd
# flush all write buffers, just in case SI can not umount /a
echo "Syncing file systems"
sync
#todo: remove
#echo "Processes still using /:"
#fuser -v /
#sleep 30

20
xCAT/postscripts/makeinitrd Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
#Used only by sysclone
# This SI post-install script is needed because the initrd that autoyast/kickstart/ubuntu builds when installing
# sles/rh/ubuntu on the golden node may not have the drivers when that initrd runs on the node that is
# being deployed with this image (specifically, drivers to be able to mount the disk).
# So rebuild the initrd on the to-node after putting the image on the disk, but before rebooting.
#todo: Make this script work on red hat by checking for dracut and using that if it exists.
# And do whatever is necessary on ubuntu.
if [[ -f /sbin/dracut ]]; then
# redhat/centos
echo "Running dracut to regenerate the initrd with the drivers needed by this node:"
dracut --force
else
# suse/sles
echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:"
mkinitrd
fi

View File

@ -1,4 +1,5 @@
#!/bin/bash
#Used only by sysclone
if [ ! -f "/opt/xcat/xcatdsklspost" ];then
echo "sysclone require /opt/xcat/xcatdsklspost, but it can not be found. return error!"
@ -27,6 +28,11 @@ fi
XCATSERVER="$XCATSERVER:3001"
export XCATSERVER
if [ ! -d "/etc/xcat/" ];then
mkdir -p /etc/xcat
fi
echo "sysclone" > /etc/xcat/xcatinstallinfo
cd /xcatpost/
#save the postboot scripts to /xcatpost/mypostscript.post
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /xcatpost/mypostscript`
@ -68,4 +74,6 @@ echo "$TMP" > /tmp/xcatenv
. /tmp/xcatenv
/xcatpost/addsiteyum
/xcatpost/updateflag.awk $MASTER 3002
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
/xcatpost/updateflag.awk $MASTER 3002
fi

View File

@ -1,11 +1,15 @@
#!/bin/bash
#Used only by sysclone
if [ "$NODESETSTATE" != "sysclone" ];then
installmethods=`cat /etc/xcat/xcatinstallinfo`
if [ "$installmethods" != "sysclone" ];then
echo "This node didn't be installed by sysclone"
exit 0
fi
#update the exclude configuration file
#do not sync the following files
for filename in /etc/fstab /boot/grub /etc/grub.conf /boot/efi /etc/elilo.conf /xcatpost
for filename in /etc/fstab /boot/grub /etc/grub.conf /boot/efi /etc/elilo.conf /xcatpost /etc/xcat
do
if [ ! -e $filename ];then
continue
@ -33,5 +37,15 @@ fi
str_server_ip=`echo $str_server_ip | sed "s/'//g"`
#call system imager command to update the image
echo "si_updateclient --server $str_server_ip --no-bootloader --yes"
export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_updateclient --server $str_server_ip --no-bootloader --yes
echo "si_updateclient --server $str_server_ip --yes"
export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_updateclient --server $str_server_ip --yes
if [[ -f /sbin/dracut ]]; then
#redhat or centos
echo "Running dracut to regenerate the initrd with the drivers needed by this node:"
dracut --force
else
# suse/sles
echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:"
mkinitrd
fi

View File

@ -1,4 +1,6 @@
#!/bin/bash
#Used only by sysclone
. /tmp/post-install/variables.txt
#delete the udev rule in the image