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

This commit is contained in:
Jarrod Johnson 2014-05-27 11:28:25 -04:00
commit ef3653559f
33 changed files with 713 additions and 99 deletions

View File

@ -1 +1 @@
2.8.4
2.8.5

View File

@ -1992,50 +1992,6 @@ sub isIpaddr
}
#-------------------------------------------------------------------------------
=head3 getSubnetGateway
Description:
Get gateway from the networks table of the specified net.
Arguments:
net: the net, ie. the "net" field of the networks table
Returns:
Return a string, of the gateway
undef - Failed to get the gateway
Globals:
none
Error:
none
Example:
my $gateway = xCAT::NetworkUtils::getSubnetGateway('192.168.1.0');
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub getSubnetGateway
{
my $netname=shift;
if( $netname =~ /xCAT::NetworkUtils/)
{
$netname=shift;
}
my $gateway=undef;
my $nettab = xCAT::Table->new("networks");
unless($nettab) { die "No entry defined in networks"; }
my @nets = $nettab->getAllAttribs('net','gateway');
foreach(@nets)
{
if("$_->{net}" eq "$netname")
{
$gateway = $_->{gateway};
last;
}
}
return $gateway;
}
#-------------------------------------------------------------------------------
@ -2093,6 +2049,50 @@ sub getNodeNameservers{
return \%nodenameservers;
}
#-------------------------------------------------------------------------------
=head3 getNodeGateway
Description:
Get gateway from the networks table of the node.
Arguments:
ip: the ip address of the node
Returns:
Return a string, of the gateway
undef - Failed to get the gateway
Globals:
none
Error:
none
Example:
my $gateway = xCAT::NetworkUtils::getNodeGateway('192.168.1.0');
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub getNodeGateway
{
my $ip=shift;
if( $ip =~ /xCAT::NetworkUtils/)
{
$ip=shift;
}
my $gateway=undef;
my $nettab = xCAT::Table->new("networks");
if ($nettab) {
my @nets = $nettab->getAllAttribs('net','mask','gateway');
foreach my $net (@nets) {
if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) {
$gateway=$net->{'gateway'};
}
}
}
return $gateway;
}
#-------------------------------------------------------------------------------
=head3 getNodeNetworkCfg
@ -2122,8 +2122,8 @@ sub getNodeNetworkCfg
if( $node =~ /xCAT::NetworkUtils/)
{
$node =shift;
}
}
my $nets = xCAT::NetworkUtils::my_nets();
my $ip = xCAT::NetworkUtils->getipaddr($node);
my $mask = undef;
@ -2132,12 +2132,14 @@ sub getNodeNetworkCfg
{
my $netname;
($netname,$mask) = split /\//, $net;
$gateway=xCAT::NetworkUtils::getSubnetGateway($netname);
last if ( xCAT::NetworkUtils::isInSameSubnet( $netname, $ip, $mask, 1));
}
$gateway=xCAT::NetworkUtils::getNodeGateway($ip);
return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask,1,0));
}
#-------------------------------------------------------------------------------
=head3 get_hdwr_ip

View File

@ -810,6 +810,10 @@ sub senddeviceskeys
# add to the command
$setupcmd .=$key;
$setupcmd .="\"";
# Special case for vios
if ($ENV{DEVICETYPE} eq 'vios') {
$setupcmd = "\"echo $key | tee -a ~/.ssh/authorized_keys2\"";
}
# For each input device
my @nodelist=split(/,/,$nodes);
foreach my $node (@nodelist) {

View File

@ -92,7 +92,7 @@ rm -rf $RPM_BUILD_ROOT
%ifos linux
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then
/etc/init.d/xcatd reload
/etc/init.d/xcatd restart
fi
fi
%endif

View File

@ -106,7 +106,7 @@ fi
%ifos linux
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then
/etc/init.d/xcatd reload
/etc/init.d/xcatd restart
fi
fi
%else

View File

@ -92,6 +92,7 @@ sub process_request {
my @commandslist;
my %argslist;
my $noupdate_flag = 0;
my %msghash = ( "makehosts" => "Updating hosts entries",
"makedns" => "Updating DNS entries",
"makedhcp" => "Update DHCP entries",
@ -143,6 +144,10 @@ sub process_request {
if($macflag)
{
if ($chainarray[0]){
if($chainarray[0] =~ m/^osimage=/)
{
$noupdate_flag = 1;
}
push @commandslist, ['nodeset', $chainarray[0]];
}
}
@ -161,6 +166,7 @@ sub process_request {
my $firstnode = (@$nodelist)[0];
if (exists $profilehash{$firstnode}{"ImageProfile"}){
my $osimage = 'osimage='.$profilehash{$firstnode}{"ImageProfile"};
$noupdate_flag = 1;
push @commandslist, ['nodeset', $osimage];
}
}
@ -170,7 +176,14 @@ sub process_request {
my $current_cmd = $_->[0];
my $current_args = $_->[1];
setrsp_progress($msghash{$current_cmd});
my $retref = xCAT::Utils->runxcmd({command=>[$current_cmd], node=>$nodelist, arg=>[$current_args]}, $request_command, 0, 2);
if(($current_cmd eq "nodeset") && $noupdate_flag)
{
$retref = xCAT::Utils->runxcmd({command=>[$current_cmd], node=>$nodelist, arg=>[$current_args, "--noupdateinitrd"]}, $request_command, 0, 2);
}
else
{
$retref = xCAT::Utils->runxcmd({command=>[$current_cmd], node=>$nodelist, arg=>[$current_args]}, $request_command, 0, 2);
}
log_cmd_return($retref);
}

View File

@ -7,6 +7,7 @@ use xCAT::Utils;
use xCAT::TableUtils;
use Getopt::Long;
use Sys::Hostname;
use xCAT::SvrUtils;
use strict;
use Data::Dumper;

View File

@ -571,6 +571,7 @@ sub nextdestiny {
}
my $node;
my $noupdate_flag = 0;
$chaintab = xCAT::Table->new('chain');
my $chainents = $chaintab->getNodesAttribs(\@nodes,[qw(currstate currchain chain)]);
foreach $node (@nodes) {
@ -598,13 +599,28 @@ sub nextdestiny {
my %requ;
$requ{node}=[$node];
$requ{arg}=[$ref->{currstate}];
if($ref->{currstate} =~ /noupdateinitrd$/)
{
my @items = split /[:]/,$ref->{currstate};
$requ{arg}= \@items;
$noupdate_flag = 1;
}
setdestiny(\%requ, $flag+1);
}
if ($callnodeset) {
my $args;
if($noupdate_flag)
{
$args = ['enact', '--noupdateinitrd'];
}
else
{
$args = ['enact'];
}
$subreq->({command=>['nodeset'],
node=> \@nodes,
arg=>['enact']});
arg=>$args});
}
}

View File

@ -1802,7 +1802,7 @@ sub make_files {
}
if ( $hasplugin ) {
# Issue xcatd reload to load the new plugins
system("/etc/init.d/xcatd reload");
system("/etc/init.d/xcatd restart");
$hasplugin=0;
}

View File

@ -1411,7 +1411,7 @@ sub addkit
if ( $hasplugin ) {
# Issue xcatd reload to load the new plugins
system("/etc/init.d/xcatd reload");
system("/etc/init.d/xcatd restart");
}
}
}
@ -1494,6 +1494,7 @@ sub rmkit
my %kitnames;
my $des = shift @ARGV;
my @kits = split ',', $des;
my $DBname = xCAT::Utils->get_DBName; # support for DB2
foreach my $kit (@kits) {
# Check if it is a kitname or basename
@ -1508,7 +1509,12 @@ sub rmkit
}
$kitnames{$kit} = 1;
} else {
my @entries = $tabs{kit}->getAllAttribsWhere( "basename = '$kit'", 'kitname', 'isinternal');
my @entries;
if ($DBname =~ /^DB2/) {
@entries = $tabs{kit}->getAllAttribsWhere( "\"basename\" = '$kit'", 'kitname', 'isinternal');
} else {
@entries = $tabs{kit}->getAllAttribsWhere( "basename = '$kit'", 'kitname', 'isinternal');
}
unless (@entries) {
my %rsp;
push@{ $rsp{data} }, "Kit $kit could not be found in DB $t";
@ -1545,8 +1551,12 @@ sub rmkit
# Find all the components in this kit.
my $kitcompnames;
my @kitcomphash = $tabs{kitcomponent}->getAllAttribsWhere( "kitname = '$kitname'", 'kitcompname', 'postbootscripts', 'genimage_postinstall');
my @kitcomphash;
if ($DBname =~ /^DB2/) {
@kitcomphash = $tabs{kitcomponent}->getAllAttribsWhere( "\"kitname\" = '$kitname'", 'kitcompname', 'postbootscripts', 'genimage_postinstall');
} else {
@kitcomphash = $tabs{kitcomponent}->getAllAttribsWhere( "kitname = '$kitname'", 'kitcompname', 'postbootscripts', 'genimage_postinstall');
}
if (@entries && (@entries > 0)) {
if($::VERBOSE and !$test){
@ -1682,7 +1692,12 @@ sub rmkit
}
# Remove kitrepo
my @kitrepohash = $tabs{kitrepo}->getAllAttribsWhere( "kitname = '$kitname'", 'kitreponame');
my @kitrepohash;
if ($DBname =~ /^DB2/) {
@kitrepohash = $tabs{kitrepo}->getAllAttribsWhere( "\"kitname\" = '$kitname'", 'kitreponame');
} else {
@kitrepohash = $tabs{kitrepo}->getAllAttribsWhere( "kitname = '$kitname'", 'kitreponame');
}
foreach my $kitrepo ( @kitrepohash ) {
my $kitreponame = $kitrepo->{kitreponame};
$tabs{kitrepo}->delEntries({kitreponame => $kitreponame});
@ -1716,7 +1731,7 @@ sub rmkit
if ( $hasplugin ) {
# Issue xcatd reload to load the new plugins
system("/etc/init.d/xcatd reload");
system("/etc/init.d/xcatd restart");
}
}
@ -1878,7 +1893,7 @@ sub addkitcomp
return 1;
}
my $DBname = xCAT::Utils->get_DBName; # support for DB2
my %tabs = ();
my @tables = qw(kit kitrepo kitcomponent osimage osdistro linuximage);
foreach my $t ( @tables ) {
@ -1911,7 +1926,12 @@ sub addkitcomp
$kitcomps{$kitcomponent}{name} = $kitcomponent;
$kitcomps{$kitcomponent}{basename} = $kitcomptable->{'basename'};
} else {
my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release');
my @entries;
if ($DBname =~ /^DB2/) {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcomponent'", 'kitcompname' , 'version', 'release');
} else {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release');
}
unless (@entries) {
my %rsp;
push@{ $rsp{data} }, "$kitcomponent kitcomponent does not exist";
@ -2101,7 +2121,12 @@ sub addkitcomp
my @kitcompdeps = split ',', $kitcomptable->{'kitcompdeps'};
foreach my $kitcompdependency ( @kitcompdeps ) {
my ($kitcompdep, $vers) = split /<=|>=|=|<|>/, $kitcompdependency;
my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitreponame', 'kitname', 'kitcompname' , 'serverroles', 'kitcompdeps', 'version', 'prerequisite', 'release');
my @entries;
if ($DBname =~ /^DB2/) {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcompdep'", 'kitreponame', 'kitname', 'kitcompname' , 'serverroles', 'kitcompdeps', 'version', 'prerequisite', 'release');
} else {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitreponame', 'kitname', 'kitcompname' , 'serverroles', 'kitcompdeps', 'version', 'prerequisite', 'release');
}
unless (@entries) {
my %rsp;
push@{ $rsp{data} }, "Cannot find any matched kit component for kit component $kitcomp dependency $kitcompdep";
@ -2413,7 +2438,7 @@ sub rmkitcomp
return 1;
}
my $DBname = xCAT::Utils->get_DBName; # support for DB2
my %tabs = ();
my @tables = qw(kit kitrepo kitcomponent osimage osdistro linuximage);
foreach my $t ( @tables ) {
@ -2456,7 +2481,12 @@ sub rmkitcomp
$kitcomps{$kitcomponent}{driverpacks} = $kitcomptable->{driverpacks};
$kitcomps{$kitcomponent}{genimage_postinstall} = $kitcomptable->{genimage_postinstall};
} else {
my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release');
my @entries;
if ($DBname =~ /^DB2/) {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcomponent'", 'kitcompname' , 'version', 'release');
} else {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release');
}
unless (@entries) {
my %rsp;
push@{ $rsp{data} }, "$kitcomponent kitcomponent does not exist";
@ -2530,7 +2560,12 @@ sub rmkitcomp
my ($kitcompdep, $vers) = split /<=|>=|=|<|>/, $kitcompdependency;
# Get the kit component full name from basename.
my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitcompname' , 'version', 'release');
my @entries;
if ($DBname =~ /^DB2/) {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcompdep'", 'kitcompname' , 'version', 'release');
} else {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitcompname' , 'version', 'release');
}
unless (@entries) {
my %rsp;
push@{ $rsp{data} }, "kitcomponent $kitcompdep basename does not exist";
@ -3214,7 +3249,7 @@ sub chkkitcomp
create_version_response('chkkitcomp');
return 1; # no usage - just exit
}
my $DBname = xCAT::Utils->get_DBName; # support for DB2
my %tabs = ();
my @tables = qw(kit kitrepo kitcomponent osimage osdistro linuximage);
foreach my $t ( @tables ) {
@ -3248,7 +3283,12 @@ sub chkkitcomp
$kitcomps{$kitcomponent}{serverroles} = $kitcomptable->{serverroles};
$kitcompbasename{$kitcomptable->{basename}} = 1;
} else {
my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release');
my @entries;
if ($DBname =~ /^DB2/) {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcomponent'", 'kitcompname' , 'version', 'release');
} else {
@entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release');
}
unless (@entries) {
my %rsp;
push@{ $rsp{data} }, "$kitcomponent kitcomponent does not exist";
@ -4660,6 +4700,7 @@ sub db_get_table_rows {
my $table = xCAT::Table->new($tablename);
my @table_rows = ();
# todo fix for DB2 support
if (defined($filter_stmt)) {
if (length($filter_stmt) > 0) {
@table_rows = $table->getAllAttribsWhere($filter_stmt, @{$attrs});

View File

@ -1385,6 +1385,13 @@ sub updatenoderunps
foreach my $snkey (keys %servernodes)
{
if ((!defined($snkey)) or ($snkey eq "")) { # if we could not find the xcatmaster
my $rsp = {};
$rsp->{error}->[0] = "Could not find xcatmaster for @{$servernodes{$snkey}}. Will skip this node. ";
$callback->($rsp);
next;
}
my $nodestring = join(',', @{$servernodes{$snkey}});
my $args;
my $mode;

View File

@ -0,0 +1,5 @@
[main]
ssh-setup-command=echo
[xdsh]
pre-command=NULL
post-command=NULL

View File

@ -59,7 +59,7 @@ do
mv $i/postscripts /xcatpost
rm -rf $i
chmod +x /xcatpost/*
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep MASTER /xcatpost/mypostscript`
MAX_RETRIES=10
RETRY=0
@ -72,7 +72,7 @@ do
let SLI=$RANDOM%10+10
sleep $SLI
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep MASTER /xcatpost/mypostscript`
done

View File

@ -61,7 +61,7 @@ do
mv $i/postscripts /xcatpost
rm -rf $i
chmod +x /xcatpost/*
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep MASTER /xcatpost/mypostscript`
MAX_RETRIES=10
RETRY=0
@ -74,7 +74,7 @@ do
let SLI=$RANDOM%10+10
sleep $SLI
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep MASTER /xcatpost/mypostscript`
done

View File

@ -44,7 +44,7 @@ do
if [ ! -x /xcatpost/mypostscript ]; then
chmod +x /xcatpost/*
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep MASTER /xcatpost/mypostscript`
@ -59,7 +59,7 @@ do
let SLI=$RANDOM%10+10
sleep $SLI
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep MASTER /xcatpost/mypostscript`
done

View File

@ -5,10 +5,8 @@ dhclient
kernel
openssh-server
openssh-clients
busybox
wget
rsyslog
dash
vim-minimal
ntp
rsyslog

View File

@ -25,9 +25,6 @@ cat <<END >$installroot/etc/fstab
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
${profile}_${arch} / tmpfs rw 0 1
none /tmp tmpfs defaults,size=10m 0 2
none /var/tmp tmpfs defaults,size=10m 0 2
END

View File

@ -6,8 +6,6 @@ dhclient
kernel
openssh-server
openssh-clients
busybox
dash
iputils
bc
irqbalance

View File

@ -25,9 +25,6 @@ cat <<END >$installroot/etc/fstab
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
${profile}_${arch} / tmpfs rw 0 1
none /tmp tmpfs defaults,size=10m 0 2
none /var/tmp tmpfs defaults,size=10m 0 2
END
#-- Uncomment the line contains "cons" in /etc/inittab

View File

@ -0,0 +1,3 @@
#!/bin/sh
[ "$1" = "-d" ] && echo network
exit 0

View File

@ -0,0 +1,9 @@
#!/bin/sh
echo $drivers
dracut_install wget cpio gzip modprobe touch echo cut wc
dracut_install grep ifconfig hostname awk egrep grep dirname expr
dracut_install mount.nfs
dracut_install parted mke2fs bc mkswap swapon chmod
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
inst "$moddir/xcatroot" "/sbin/xcatroot"
inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"

View File

@ -0,0 +1,8 @@
#!/bin/sh
echo $drivers
dracut_install wget cpio gzip modprobe wc touch echo cut
dracut_install grep ifconfig hostname awk egrep grep dirname expr
dracut_install parted mke2fs bc mkswap swapon chmod
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
inst_hook pre-mount 5 "$moddir/xcat-premount.sh"
inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh"

View File

@ -0,0 +1,2 @@
#!/bin/bash
instmods nfs sunrpc

View File

@ -0,0 +1,4 @@
root=1
rootok=1
netroot=xcat
echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/xcatroot.sh

View File

@ -0,0 +1,18 @@
#!/bin/sh
#script to update nodelist.nodestatus during provision
MASTER=`echo $XCAT |awk -F: '{print $1}'`
getarg nonodestatus
NODESTATUS=$?
XCATIPORT="$(getarg XCATIPORT=)"
if [ $? -ne 0 ]; then
XCATIPORT="3002"
fi
if [ $NODESTATUS -ne 0 ];then
/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting"
fi

View File

@ -0,0 +1,174 @@
#!/bin/sh
NEWROOT=/sysroot
SERVER=${SERVER%%/*}
SERVER=${SERVER%:}
RWDIR=.statelite
if [ ! -z $STATEMNT ]; then #btw, uri style might have left future options other than nfs open, will u se // to detect uri in the future I guess
SNAPSHOTSERVER=${STATEMNT%:*}
SNAPSHOTROOT=${STATEMNT#*/}
#echo $SNAPSHOTROOT
#echo $SNAPSHOTSERVER
# may be that there is not server and just a directory.
if [ -z $SNAPSHOTROOT ]; then
SNAPSHOTROOT=$SNAPSHOTSERVER
SNAPSHOTSERVER=
fi
fi
echo Setting up Statelite
mkdir -p $NEWROOT
# now we need to mount the rest of the system. This is the read/write portions
# echo Mounting snapshot directories
MAXTRIES=7
ITER=0
if [ ! -e "$NEWROOT/$RWDIR" ]; then
echo ""
echo "This NFS root directory doesn't have a /$RWDIR directory for me to mount a rw filesystem. You'd better create it... "
echo ""
/bin/sh
fi
if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then
echo ""
echo "$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with th e -m statelite mode"
echo ""
/bin/sh
fi
mount -t tmpfs rw $NEWROOT/$RWDIR
mkdir -p $NEWROOT/$RWDIR/tmpfs
ME=`hostname`
if [ ! -z $NODE ]; then
ME=$NODE
fi
# mount the SNAPSHOT directory here for persistent use.
if [ ! -z $SNAPSHOTSERVER ]; then
mkdir -p $NEWROOT/$RWDIR/persistent
MAXTRIES=5
ITER=0
if [ -z $MNTOPTS ]; then
MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14"
else
MNT_OPTIONS=$MNTOPTS
fi
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
ITER=$(( ITER + 1 ))
if [ "$ITER" == "$MAXTRIES" ]; then
echo "Your are dead, rpower $ME boot to play again."
echo "Possible problems:
1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ?
2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER."
/bin/sh
exit
fi
RS= $(( $RANDOM % 20 ))
echo "Trying again in $RS seconds..."
sleep $RS
done
# create directory which is named after my node name
mkdir -p $NEWROOT/$RWDIR/persistent/$ME
ITER=0
# umount current persistent mount
while ! umount -l $NEWROOT/$RWDIR/persistent; do
ITER=$(( ITER + 1 ))
if [ "$ITER" == "$MAXTRIES" ]; then
echo "Your are dead, rpower $ME boot to play again."
echo "Cannot umount $NEWROOT/$RWDIR/persistent."
/bin/sh
exit
fi
RS= $(( $RANDOM % 20 ))
echo "Trying again in $RS seconds..."
sleep $RS
done
# mount persistent to server:/rootpath/nodename
ITER=0
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
ITER=$(( ITER + 1 ))
if [ "$ITER" == "$MAXTRIES" ]; then
echo "Your are dead, rpower $ME boot to play again."
echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME."
/bin/sh
exit
fi
RS= $(( $RANDOM % 20 ))
echo "Trying again in $RS seconds..."
sleep $RS
done
fi
# TODO: handle the dhclient/resolv.conf/ntp, etc
echo "Get to enable localdisk"
$NEWROOT/etc/init.d/localdisk
$NEWROOT/etc/init.d/statelite
READONLY=yes
export READONLY
fastboot=yes
export fastboot
keep_old_ip=yes
export keep_old_ip
mount -n --bind /dev $NEWROOT/dev
mount -n --bind /proc $NEWROOT/proc
mount -n --bind /sys $NEWROOT/sys
function getdevfrommac() {
boothwaddr=$1
ip link show | while read line
do
dev=`echo $line | egrep "^[0-9]+: [0-9A-Za-z]+" | cut -d ' ' -f 2 | cut -d ':' -f 1`
if [ "X$dev" != "X" ]; then
devname=$dev
fi
if [ "X$devname" != "X" ]; then
hwaddr=`echo $line | egrep "^[ ]*link" | awk '{print $2}'`
if [ "X$hwaddr" = "X$boothwaddr" ]; then
echo $devname
fi
fi
done
}
for lf in /tmp/dhclient.*.lease; do
netif=${lf#*.}
netif=${netif%.*}
cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases"
done
if [ ! -z "$ifname" ]; then
MACX=${ifname#*:}
ETHX=${ifname%:$MACX*}
elif [ ! -z "$netdev" ]; then
ETHX=$netdev
MACX=`ip link show $netdev | grep ether | awk '{print $2}'`
elif [ ! -z "$BOOTIF" ]; then
MACX=$BOOTIF
ETHX=$(getdevfrommac $BOOTIF)
fi
if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then
if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then
touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
fi
echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
fi
cp /etc/resolv.conf "$NEWROOT/etc/"
if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then
echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux"
fi
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh
# force udevsettle to break
> $hookdir/initqueue/work

View File

@ -0,0 +1,24 @@
#!/bin/awk -f
#script to feedback the node provision status to xcatd
BEGIN {
xcatdhost = ARGV[1]
xcatiport = ARGV[2]
ns = "/inet/tcp/0/" xcatdhost "/" xcatiport
print "xCAT_xcatd" |& ns
while(1) {
ns |& getline
if($0 == "ready")
print ARGV[3] |& ns
if($0 == "done")
break
}
close(ns)
exit 0
}

View File

@ -0,0 +1,278 @@
#!/bin/sh
NEWROOT=$3
RWDIR=.statelite
XCATMASTER=$XCAT
. /lib/dracut-lib.sh
rootlimit="$(getarg rootlimit=)"
getarg nonodestatus
NODESTATUS=$?
MASTER=`echo $XCATMASTER |awk -F: '{print $1}'`
XCATIPORT="$(getarg XCATIPORT=)"
if [ $? -ne 0 ]; then
XCATIPORT="3002"
fi
if [ $NODESTATUS -ne 0 ];then
/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting"
fi
if [ ! -z "$imgurl" ]; then
if [ xhttp = x${imgurl%%:*} ]; then
NFS=0
FILENAME=${imgurl##*/}
while [ ! -r "$FILENAME" ]; do
echo Getting $imgurl...
if ! wget $imgurl; then
rm -f $FILENAME
sleep 27
fi
done
elif [ xnfs = x${imgurl%%:*} ]; then
NFS=1
SERVER=${imgurl#nfs:}
SERVER=${SERVER#/}
SERVER=${SERVER#/}
ROOTDIR=$SERVER
SERVER=${SERVER%%/*}
SERVER=${SERVER%:}
ROOTDIR=/${ROOTDIR#*/}
fi
fi
#echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug
if [ -r /rootimg.sfs ]; then
echo Setting up squashfs with ram overlay.
mknod /dev/loop0 b 7 0
mkdir -p /ro
mkdir -p /rw
mount -t squashfs /rootimg.sfs /ro
mount -t tmpfs rw /rw
mount -t aufs -o dirs=/rw:/ro mergedroot $NEWROOT
mkdir -p $NEWROOT/ro
mkdir -p $NEWROOT/rw
mount --move /ro $NEWROOT/ro
mount --move /rw $NEWROOT/rw
elif [ -r /rootimg.gz ]; then
echo Setting up RAM-root tmpfs.
if [ -z $rootlimit ];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
else
mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT
fi
cd $NEWROOT
echo -n "Extracting root filesystem:"
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.gz |/bin/cpio -idum
else
gzip -cd /rootimg.gz |cpio -idum
fi
$NEWROOT/etc/init.d/localdisk
echo Done
elif [ -r /rootimg-statelite.gz ]; then
echo Setting up RAM-root tmpfs for statelite mode.
if [ -z $rootlimit];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
else
mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT
fi
cd $NEWROOT
echo -n "Extracting root filesystem:"
if [ -x /bin/cpio ]; then
gzip -cd /rootimg-statelite.gz |/bin/cpio -idum
else
gzip -cd /rootimg-statelite.gz |cpio -idum
fi
echo Done
# then, the statelite staffs will be processed
echo Setting up Statelite
modprobe nfs
MAXTRIES=7
ITER=0
if [ ! -e "$NEWROOT/$RWDIR" ]; then
echo ""
echo "The /$RWDIR directory doesn't exist in the rootimg... "
echo ""
/bin/sh
fi
if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then
echo ""
echo "$NEWROOT/etc/init.d/statelite doesn't exist... "
echo ""
/bin/sh
fi
mount -t tmpfs rw $NEWROOT/$RWDIR
mkdir -p $NEWROOT/$RWDIR/tmpfs
ME=`hostname`
if [ ! -z $NODE ]; then
ME=$NODE
fi
# mount the SNAPSHOT directory here for persistent use.
if [ ! -z $STATEMNT ]; then
SNAPSHOTSERVER=${STATEMNT%:*}
SNAPSHOTROOT=${STATEMNT#*/}
if [ -z $SNAPSHOTROOT ]; then
SNAPSHOTROOT=$SNAPSHOTSERVER
SNAPSHOTSERVER=
fi
fi
if [ ! -z $SNAPSHOTSERVER ]; then
mkdir -p $NEWROOT/$RWDIR/persistent
MAXTRIES=5
ITER=0
if [ -z $MNTOPTS ]; then
MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14"
else
MNT_OPTIONS=$MNTOPTS
fi
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
ITER=$(( ITER + 1 ))
if [ "$ITER" == "$MAXTRIES" ]; then
echo "You are dead, rpower $ME boot to play again."
echo "Possible problems:
1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ?
2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER."
/bin/sh
exit
fi
RS=$(( $RANDOM % 20 ))
echo "Trying again in $RS seconds ..."
sleep $RS
done
# create directory which is named after my node name
mkdir -p $NEWROOT/$RWDIR/persistent/$ME
ITER=0
# umount current persistent mount
while ! umount -l $NEWROOT/$RWDIR/persistent; do
ITER=$(( ITER + 1 ))
if [ "$ITER" == "$MAXTRIES" ]; then
echo "Your are dead, rpower $ME boot to play again."
echo "Cannot umount $NEWROOT/$RWDIR/persistent."
/bin/sh
exit
fi
RS= $(( $RANDOM % 20 ))
echo "Trying again in $RS seconds..."
sleep $RS
done
# mount persistent to server:/rootpath/nodename
ITER=0
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
ITER=$(( ITER + 1 ))
if [ "$ITER" == "$MAXTRIES" ]; then
echo "Your are dead, rpower $ME boot to play again."
echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME."
/bin/sh
exit
fi
RS= $(( $RANDOM % 20 ))
echo "Trying again in $RS seconds..."
sleep $RS
done
fi
$NEWROOT/etc/init.d/localdisk
$NEWROOT/etc/init.d/statelite
fastboot=yes
export fastboot
keep_old_ip=yes
export keep_old_ip
mount -n --bind /dev $NEWROOT/dev
mount -n --bind /proc $NEWROOT/proc
mount -n --bind /sys $NEWROOT/sys
else
echo -n Failed to download image, panicing in 5...
for i in 4 3 2 1 0; do
/bin/sleep 1
echo -n $i...
done
echo
echo "You're dead. rpower nodename reset to play again.
* Did you packimage with -m cpio, -m squashfs, or -m nfs?
* If using -m squashfs did you include aufs.ko with geninitrd?
e.g.: -n tg3,squashfs,aufs,loop
* If using -m nfs did you export NFS and sync rootimg? And
did you include the aufs and nfs modules in the proper order:
e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs
"
/bin/dash
exit
fi
cd /
function getdevfrommac() {
boothwaddr=$1
ip link show | while read line
do
dev=`echo $line | egrep "^[0-9]+: [0-9A-Za-z]+" | cut -d ' ' -f 2 | cut -d ':' -f 1`
if [ "X$dev" != "X" ]; then
devname=$dev
fi
if [ "X$devname" != "X" ]; then
hwaddr=`echo $line | egrep "^[ ]*link" | awk '{print $2}'`
if [ "X$hwaddr" = "X$boothwaddr" ]; then
echo $devname
fi
fi
done
}
if [ -z $STATEMNT ]; then
for lf in /tmp/dhclient.*.lease; do
netif=${lf#*.}
netif=${netif%.*}
cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases"
done
if [ ! -z "$ifname" ]; then
MACX=${ifname#*:}
ETHX=${ifname%:$MACX*}
elif [ ! -z "$netdev" ]; then
ETHX=$netdev
MACX=`ip link show $netdev | grep ether | awk '{print $2}'`
elif [ ! -z "$BOOTIF" ]; then
MACX=$BOOTIF
ETHX=$(getdevfrommac $BOOTIF)
fi
if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then
if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then
touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
fi
echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
fi
fi
cp /etc/resolv.conf "$NEWROOT/etc/"
if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then
echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux"
fi
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh
# force udevsettle to break
> $hookdir/initqueue/work

View File

@ -583,8 +583,8 @@ if ( (-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")
my $dracutver = `rpm --root $rootimg_dir -qi dracut | grep Version | awk -F' ' '{print \$3}'`;
chomp($dracutver);
if ($dracutver =~ /^\d\d\d$/) {
if (($dracutver >= "009") and ($dracutver < "033")) {
$dracutdir = "dracut_009";
if ($dracutver >= "033") {
$dracutdir = "dracut_033";
} else {
$dracutdir = "dracut"; # The default directory
}
@ -779,8 +779,8 @@ system("chroot $rootimg_dir depmod $kernelver");
# the other one is for statelite
if ($dracutmode) {
mkinitrd_dracut("statelite");
mkinitrd_dracut("stateless");
mkinitrd_dracut("statelite");
} else {
mkinitrd("statelite");
mkinitrd("stateless");
@ -924,7 +924,11 @@ sub mkinitrd_dracut {
$additional_options= qq{--include /tmp/cmdline /etc/cmdline};
}
system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver");
# force the dracut run in non-hostonly mode for dracut higher than version 033
if ($dracutver > "033") {
$additional_options .= " -N";
}
system("chroot $rootimg_dir dracut -N $additional_options -f /tmp/initrd.$$.gz $kernelver");
print "the initial ramdisk for $mode is generated successfully.\n";
move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz");
}
@ -1665,7 +1669,11 @@ sub using_systemd {
my $os = shift;
if ($os =~ /fedora(\d+)/) {
if ($1 >= 15) {
return 1;
return 1;
}
}elsif ($os =~ /rhels(\d+)/) {
if ($1 >= 7) {
return 1;
}
}

View File

@ -34,7 +34,7 @@ Obsoletes: atftp-xcat
%ifos linux
%ifnarch s390x
# PCM does not use or ship grub2-xcat
#Requires: grub2-xcat
Requires: grub2-xcat
%endif
%endif
%endif

View File

@ -124,7 +124,7 @@ my %URIdef = (
GET => {
desc => "Get the running status for the node {noderange}.",
usage => "||$usagemsg{objreturn}|",
example => "|Get the running status for node node1|GET|/nodes/node1/nodestat|x|",
example => "|Get the running status for node node1|GET|/nodes/node1/nodestat|{\n \"node1\":{\n \"nodestat\":\"noping\"\n }\n}|",
cmd => "nodestat",
fhandler => \&actionhdl,
outhdler => \&actionout,
@ -1401,6 +1401,9 @@ sub defout {
$lines = \@alldata;
}
foreach my $l (@$lines) {
if ($l =~ /No responses/) { # handle the case that no output from lsslp command
return;
}
if ($l =~ /^Object name: / || $l =~ /^\S+:$/) { # start new node
if ($l =~ /^Object name:\s+(\S+)/) { # handle the output of lsdef -t <type> <obj>
$nodename = $1;

View File

@ -19,16 +19,19 @@ function splitconfig(){
IFS=$','
array_conf_temp=($1)
IFS=$old_ifs
for i in ${array_conf_temp[@]}
i=0
while [ $i -lt ${#array_conf_temp[@]} ]
do
token="${array_conf_temp[$i]}"
D=
if [ `echo $i | grep "!"` ];then
if echo "$token" | grep "!"; then
D="!"
else
D=":"
fi
key=`echo $i | cut -d"$D" -f 1`
str_temp_value=`echo $i | cut -d"$D" -f 2`
key=`echo "$token" | cut -d"$D" -f 1`
str_temp_value=`echo "$token" | cut -d"$D" -f 2`
str_temp=$(hashget hash_defined_nics $key)
if [ -n "$str_temp" ];then
@ -37,7 +40,8 @@ function splitconfig(){
str_temp="$str_temp_value"
str_all_nics=$str_all_nics"$key "
fi
hashset hash_defined_nics $key $str_temp
hashset hash_defined_nics $key "$str_temp"
i=$((i+1))
done
}
@ -198,8 +202,8 @@ if [ -z "$NICIPS" ];then
exit 0
fi
splitconfig $NICIPS
splitconfig $NICCUSTOMSCRIPTS
splitconfig "$NICIPS"
splitconfig "$NICCUSTOMSCRIPTS"
if [ $boot_myscript -eq 1 ];then
. $str_dir_name/$myscript

View File

@ -508,7 +508,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then
useflowcontrol=0
fi
fi
/$xcatpost/getpostscript.awk | egrep '<data>' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /$xcatpost/mypostscript;
/$xcatpost/getpostscript.awk | egrep '<data>' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /$xcatpost/mypostscript;
MYCONT=`grep MASTER /$xcatpost/mypostscript`
@ -539,7 +539,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then
useflowcontrol=0
fi
fi
/$xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /$xcatpost/mypostscript;
/$xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /$xcatpost/mypostscript;
MYCONT=`grep MASTER /$xcatpost/mypostscript`
if [ ! -z "$MYCONT" ]; then
break;