diff --git a/build-ubunturepo b/build-ubunturepo
index f8ae7a10d..d2d81d47d 100755
--- a/build-ubunturepo
+++ b/build-ubunturepo
@@ -86,7 +86,7 @@ if [ "$c_flag" -a "$d_flag" ];then
exit 2
fi
-uploader="bp-sawyers"
+uploader="ligc"
# Find where this script is located to set some build variables
old_pwd=`pwd`
cd `dirname $0`
@@ -279,7 +279,7 @@ __EOF__
cat << '__EOF__' > mklocalrepo.sh
. /etc/lsb-release
cd `dirname $0`
-echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
+echo deb [arch=amd64] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
__EOF__
chmod 775 mklocalrepo.sh
@@ -380,7 +380,7 @@ __EOF__
cat << '__EOF__' > mklocalrepo.sh
. /etc/lsb-release
cd `dirname $0`
-echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
+echo deb [arch=amd64] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
__EOF__
chmod 775 mklocalrepo.sh
diff --git a/xCAT-IBMhpc/share/xcat/IBMhpc/compilers/compilers_xlf15_xlc13.bnd b/xCAT-IBMhpc/share/xcat/IBMhpc/compilers/compilers_xlf15_xlc13.bnd
new file mode 100644
index 000000000..15b5898d2
--- /dev/null
+++ b/xCAT-IBMhpc/share/xcat/IBMhpc/compilers/compilers_xlf15_xlc13.bnd
@@ -0,0 +1,10 @@
+# AIX Bundle file for compiler runtime packages
+
+I:xlC.aix61
+I:xlC.rte
+I:xlfrte
+I:xlfrte.aix61
+I:xlfrte.msg.en_US
+I:xlsmp.aix61.rte
+I:xlsmp.msg.en_US.rte
+I:xlsmp.rte
diff --git a/xCAT-OpenStack/xCAT-OpenStack.spec b/xCAT-OpenStack/xCAT-OpenStack.spec
index d0ff64bab..7f1817951 100644
--- a/xCAT-OpenStack/xCAT-OpenStack.spec
+++ b/xCAT-OpenStack/xCAT-OpenStack.spec
@@ -89,7 +89,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
diff --git a/xCAT-SoftLayer/bin/modifygrub b/xCAT-SoftLayer/bin/modifygrub
index a2e70caff..d0ee65475 100755
--- a/xCAT-SoftLayer/bin/modifygrub
+++ b/xCAT-SoftLayer/bin/modifygrub
@@ -86,7 +86,7 @@ sub addKernelParms {
# get this nodes nic, ip, netmask, gateway, and mac. Returns them in a 5 element array.
sub getNodeIpInfo {
my $args = shift @_;
- my ($ipprefix) = $args->{mnip}=~m/^(\d+\.\d+)\./; #todo: this is a hack, just using the 1st 2 octets of the mn ip addr
+ my ($ipprefix) = $args->{mnip}=~m/^(\d+)\./; #todo: this is a hack, just using the 1st octet of the mn ip addr
verbose("using IP prefix $ipprefix");
# parse ip addr show output, looking for ipprefix, to determine nic and ip
@@ -106,12 +106,13 @@ sub getNodeIpInfo {
my @nics = grep(m/\s+master\s+$nic\s+/, @output);
if (!scalar(@nics)) { die "Error: can't find the NICs that are part of $nic.\n"; }
($realnic) = $nics[0]=~m/^\d+:\s+(\S+): /;
- # go back thru the ip add show output and find the mac of this nic
- foreach my $line (@output) {
- my ($nictmp, $mactmp, $foundnic);
- if (($nictmp) = $line=~m/^\d+:\s+(\S+): / && $nictmp eq $realnic) { $foundnic = 1; }
- if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) | && $foundnic) { $mac = $mactmp; last; } # got mac, we are done
- }
+ # do not need to go back thru the ip addr show output and find the mac of this nic because the mac
+ # of the bond nic is the same. Plus the code below does not work right for some reason anyway.
+ #foreach my $line (@output) {
+ # my ($nictmp, $mactmp, $foundnic);
+ # if (($nictmp) = $line=~m/^\d+:\s+(\S+): / && $nictmp eq $realnic) { $foundnic = 1; }
+ # if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) | && $foundnic) { $mac = $mactmp; last; } # got mac, we are done
+ #}
}
# finally, find the gateway
diff --git a/xCAT-SoftLayer/bin/pushinitrd b/xCAT-SoftLayer/bin/pushinitrd
index bcad30198..2485d186c 100755
--- a/xCAT-SoftLayer/bin/pushinitrd
+++ b/xCAT-SoftLayer/bin/pushinitrd
@@ -131,8 +131,7 @@ sub updateGrubOnNodes {
}
-# Hack the autoinst files to wait in a key spot to make them work even tho it takes
-# the NICs almost a min before they can transmit after a state change.
+# Hack the autoinst files to overcome the nic coming up delay.
#todo: this has only been tested with SLES nodes
sub modifyAutoinstFiles {
my $nr = shift @_;
@@ -142,21 +141,28 @@ sub modifyAutoinstFiles {
my @nodes = runcmd("nodels $nr");
chomp(@nodes);
+ # Modify chroot.sles to insert a wait in the /etc/init.d/network of each node. This is
+ # necessary because even tho compute.sles11.softlayer.tmpl configures bonding, when autoyast
+ # reboots the node after installing the rpms, it does not bring up the network in the normal way
+ # at first and seems to skip any bonding and the if-up.d scripts. So we are left doing this.
+ # (After autoyast is done with all of its post-configuration, it brings up the network in the
+ # normal way, so bonding gets done then, which is good at least.)
+
# Edit each file to have chroot.sles insert a wait at the end of /etc/init.d/network
# this finds the end of boot.sh script (which is chroot.sles)
my $search = '\n\]\]>\s*\s*\s*';
-
# hack the /etc/init.d/network script to put a wait in it
my $file = '/mnt/etc/init.d/network'; # at this point in the installation, the permanent file system is just mounted
- #my $waitstring = 'echo Sleeping for 55s;sleep 55';
# this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escaped for sed
- my $waitstring = 'echo -n Waiting to reach xCAT mgmt node ' . $bootparms->{mnip} . '.;xcatretries=60;while \[ \$\(\(xcati+=1\)\) -le \$xcatretries \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .' \>\/dev\/null 2\>\&1; do echo -n .; done; if \[ \$xcati -le \$xcatretries \]; then echo success; else echo failed; fi; sleep 3';
+ my $waitstring = 'echo -n Waiting to reach xCAT mgmt node ' . $bootparms->{mnip} . '.;xcatretries=60;while \[ \$\(\(xcati+=1\)\) -le \$xcatretries \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .' \>\/dev\/null 2\>\&1; do echo -n .; done; if \[ \$xcati -le \$xcatretries \]; then echo success; else echo failed; fi';
# this crazy sed string is from google. It gathers up the whole file into the hold buffer, and then the substitution is done on the whole file
my $sedstring = q|sed -n '1h;1!H;${;g;s/\(\t\treload_firewall\n\)\n/\1\t\t| . $waitstring . q(\n\n/g;p;}') . " $file > $file.new";
# finally create the perl replace string that will be used to modify the autoinst file
my $replace = "$sedstring\nchmod 755 $file.new; mv -f $file.new $file";
- # Now instead we add a script that gets invoked by the OS after the nic is brought up
+ # Add a script that gets invoked by the OS after the nic is brought up
+ # Note: this does not work, because midway thru the autoyast process, the if-up.d scripts do not seem to get invoked
+ # so autoyast fails to get the media
# these are specific to SLES
#my $netdir = '/etc/sysconfig/network';
#my $filename = '/etc/sysconfig/network/if-up.d/xcat-sl-wait';
@@ -164,9 +170,6 @@ sub modifyAutoinstFiles {
#todo: to support rhel, use these values instead
#my $netdir='/etc/sysconfig/network-scripts';
#my $filename='/sbin/ifup-local';
-
- # this does not work, because midway thru the autoyast process, the if-up.d scripts do not seem to get invoked
- # so autoyast fails to get he media
#my $replace = qq(
#FILENAME=$filename
#NETDIR=$netdir
@@ -194,10 +197,15 @@ sub modifyAutoinstFiles {
#chmod +x $FILENAME
#);
- # now actually update the file
+ # The compute.sles11.softlayer.tmpl file contains 2 variables (node ip and netmask) that are
+ # not replaced by Template.pm. Substitute those in the autoinst files now.
+ # Also use our own multiline sed to put the network script hack in.
print "Updating /install/autoinst files.\n";
foreach my $n (@nodes) {
my $f = "/install/autoinst/$n";
+ my ($ip, $netmask, $gateway) = getNodeIpInfo($n);
+ runcmd("sed -i 's/#NODEIPADDR#/$ip/;s/#NODENETMASK#/$netmask/;s/#NODEGATEWAY#/$gateway/' $f");
+
my $matches = sed($f, $search, $replace, mode=>'insertbefore');
if (!$matches) { die "Error: could not find the right place in $f to insert the sed of the network wait.\n"; }
}
@@ -213,8 +221,65 @@ sub copySyscloneFiles {
}
+# Get IP and network of a node
+sub getNodeIpInfo {
+ my $node = shift;
+
+ # get ip for the node
+ my @output = runcmd("nodels $node hosts.ip");
+ chomp($output[0]);
+ my ($junk, $ip) = split(/\s+/, $output[0]);
+ #todo: also support getting the ip from name resolution
+ if (!$ip) { die "Error: the ip attribute must be set for $node.\n"; }
+
+ # find relevant network in the networks table
+ # first get the networks in a hash
+ my %networks;
+ @output = runcmd("lsdef -t network -ci net,mask,gateway");
+ foreach my $line (@output) {
+ chomp($line);
+ my ($netname, $attr, $val) = $line =~ m/^(.+):\s+(.+?)=(.+)$/;
+ $networks{$netname}->{$attr} = $val;
+ }
+ # now go thru the networks looking for the correct one
+ my ($netmask, $gateway);
+ foreach my $key (keys %networks) {
+ if (isIPinNet($ip, $networks{$key}->{net}, $networks{$key}->{mask})) { # found it
+ $netmask = $networks{$key}->{mask};
+ $gateway = $networks{$key}->{gateway};
+ last;
+ }
+ }
+ if (!$netmask) { die "Error: could not find a network in the networks table that $node $ip is part of.\n"; }
+ if (!$gateway) { die "Error: gateway not specified in the networks table for the network that $node $ip is part of.\n"; }
+
+ verbose("IP info for $node: ip=$ip, netmask=$netmask, gateway=$gateway");
+ return ($ip, $netmask, $gateway);
+}
+
+
+# Is the IP in the network/netmask combo
+sub isIPinNet {
+ my ($ip, $net, $mask) = @_;
+ my $ipbin = convert2bin($ip);
+ my $netbin = convert2bin($net);
+ my $maskbin = convert2bin($mask);
+ $ipbin &= $maskbin;
+ if ($ipbin && $netbin && ($ipbin == $netbin)) { return 1; }
+ else { return 0; }
+}
+
+
+# Convert dotted decimal format (1.2.3.4) to a binary number
+sub convert2bin {
+ my @arr=split(/\./, shift);
+ my ($bin) = unpack('N', pack('C4',@arr ) );
+ return $bin;
+}
+
+
# this is like multi-line sed replace function
-# Args: filename, search-string, replace-string
+# Args: filename, search-string, replace-string, options (mode=>{insertbefore,insertafter,replace})
sub sed {
my ($file, $search, $replace, %options) = @_;
#my $opts = 's';
diff --git a/xCAT-SoftLayer/postscripts/configbond b/xCAT-SoftLayer/postscripts/configbond
new file mode 100755
index 000000000..0cd4e033d
--- /dev/null
+++ b/xCAT-SoftLayer/postscripts/configbond
@@ -0,0 +1,228 @@
+#!/usr/bin/perl
+
+# xCAT postscript for configuring bonding of nics.
+# Usage: configbond bond1 eth1 [eth3]
+#
+# Note: this postscript currently has some assumptions that are specific to the softlayer environment.
+# It is only used to configure bond1, because bond0 gets configured by the node provisioning process.
+
+use strict;
+# Check number of args
+
+my $nargs = $#ARGV + 1;
+if (scalar(@ARGV) < 2 || scalar(@ARGV) > 3) {
+ system("logger -t xcat -p local4.err 'Usage: configbond bond dev0 [dev1]'");
+ exit 1;
+}
+
+my $bond = shift(@ARGV);
+my $nic = $ARGV[0];
+my @devs = ();
+push(@devs,$ARGV[0]);
+if (defined($ARGV[1])) { push(@devs,$ARGV[1]); }
+my $nicips = $ENV{NICIPS};
+my $nicnetworks = $ENV{NICNETWORKS};
+my $net_cnt = $ENV{NETWORKS_LINES};
+
+#todo: these are specific to softlayer. They should be another attribute or argument
+my $bondingopts = 'mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1';
+
+my $netmask ='';
+my $ipaddr = '';
+my $nic_num = '';
+my $subnet = '';
+my $nic_net = '';
+my $net_name = '';
+my @nic_nets = (); # array of networks for this nic
+my @nic_ips =(); # array of ipaddresses for this nic
+my @networks = (); # array of all networks from networks table.
+ # { network_name, subnet, netmask }
+
+system("logger -t xcat -p local4.err 'configbond: Master: $bond'");
+system("logger -t xcat -p local4.err 'configbond: Slaves: @devs'");
+#system("logger -t xcat -p local4.err 'configbond: NIC: $nic'");
+system("logger -t xcat -p local4.err 'configbond: NICNETWORKS: $nicnetworks'");
+system("logger -t xcat -p local4.err 'configbond: NICIPS: $nicips'");
+
+# Update modprobe
+my $file = "/etc/modprobe.d/$bond.conf";
+if (!open(FILE, ">$file")) { system("logger -t xcat -p local4.err 'configbond: cannot open $file.'"); exit 1; }
+
+print FILE "alias $bond bonding\n";
+# the bonding options are put in the ifcfg file instead
+#print FILE "options $bond mode=balance-rr miimon=100\n";
+close FILE;
+
+# create array of network info. Needed in case where there are
+# more than one ip address per nic and shouldn't be many networks.
+my $net_info;
+my $cnt = 1;
+
+while ( $cnt <= $net_cnt ) {
+ $net_info = $ENV{"NETWORKS_LINE$cnt"};
+ $net_info =~ /^netname=([^\|]*)\|\|/;
+ $net_name = $1;
+ $net_info =~ /net=([^\|]*)\|\|/;
+ $subnet = $1;
+ $net_info =~ /mask=([^\|]*)\|\|/;
+ $netmask = $1;
+ push @{ $networks[$cnt-1] }, ($net_name, $subnet, $netmask);
+ $cnt +=1;
+}
+
+# get network or networks for this nic from NICNETWORKS:
+# eth0:1_0_0_0-255_255_0_0|network2,eth1:1_1_0_0
+# create array of networks for this nic
+foreach my $nic_networks (split(/,/,$nicnetworks)) {
+ my @net = ();
+ if ( $nic_networks =~ /!/ ) {
+ @net = split(/!/,$nic_networks);
+ } else {
+ @net = split(/:/,$nic_networks);
+ }
+ if ($net[0] eq $nic) {
+ @nic_nets = split(/\|/,$net[1]);
+ last;
+ }
+}
+
+# get all nic ipaddress from $nicips: i.e. eth0:1.0.0.1|2.0.0.1,eth1:1.1.1.1
+# Then get all ips for this specific nic, i.e. eth0.
+foreach my $ips (split(/,/,$nicips)) {
+ my @ip = ();
+ if ( $ips =~ /!/ ) {
+ @ip = split(/!/,$ips);
+ } else {
+ @ip = split(/:/,$ips);
+ }
+ if ($ip[0] eq $nic ) {
+ @nic_ips = split(/\|/,$ip[1]);
+ }
+}
+
+
+my $i;
+for ($i=0; $i < (scalar @nic_ips) ; $i++ ) {
+
+ # Time to create the interfaces.
+ # loop through the nic networks, find the matching networks to get the
+ # subnet and netmask and then create the appropriate ifcfg file for linux
+ my $specific_nic = $nic;
+ if ($i > 0) {
+ $specific_nic = $nic . ":" . ($i);
+ }
+
+ #todo: support case in which nicnetworks is not specified, find the correct network by calculation
+ $cnt = 0;
+ $subnet = "";
+ $netmask = "";
+ $net_name = "";
+ while ( $cnt < $net_cnt ) {
+ if ( $networks[$cnt][0] eq $nic_nets[$i] ) {
+
+ $subnet = $networks[$cnt][1];
+ $netmask = $networks[$cnt][2];
+ $cnt = $net_cnt; # found match - get out.
+ }
+ else {
+ $cnt++;
+ }
+ }
+
+ # check that there is a subnet and netmask set
+ if ( !(length($subnet) > 0) || !(length($netmask) > 0) ) {
+ system("logger -t xcat -p local4.err 'configbond: network subnet or netmask not set.'");
+ exit 1;
+ }
+ system("logger -t xcat -p local4.err 'configbond: network subnet and netmask: $subnet, $netmask'");
+ system("logger -t xcat -p local4.err 'configbond: $specific_nic, $nic_ips[$i]'");
+
+ # Write the master info to the ifcfg file
+ if (-d "/etc/sysconfig/network-scripts") {
+ # rhel/centos/fedora
+ my $dir = "/etc/sysconfig/network-scripts";
+ if (!open(FILE, ">$dir/ifcfg-$bond")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$bond.'"); exit 1; }
+
+ print FILE "DEVICE=$bond\n";
+ print FILE "BOOTPROTO=none\n";
+ print FILE "IPADDR=$nic_ips[$i]\n";
+ print FILE "NETMASK=$netmask\n";
+ print FILE "ONBOOT=yes\n";
+ print FILE "USERCTL=no\n";
+ print FILE qq(BONDING_OPTS="$bondingopts"\n);
+ close FILE;
+
+ # Configure slaves
+ foreach my $dev (@devs) {
+ system("logger -t xcat -p local4.err 'configbond: slave dev: $dev'");
+ if (!open(FILE, ">$dir/ifcfg-$dev")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$dev'"); exit 1; }
+ print FILE "DEVICE=$dev\n";
+ print FILE "BOOTPROTO=none\n";
+ print FILE "MASTER=$bond\n";
+ print FILE "ONBOOT=yes\n";
+ print FILE "SLAVE=yes\n";
+ print FILE "USERCTL=no\n";
+ close FILE;
+ }
+ }
+ elsif (-d "/etc/sysconfig/network") {
+ # sles
+ my $dir = "/etc/sysconfig/network";
+ if (!open(FILE, ">$dir/ifcfg-$bond")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$bond.'"); exit 1; }
+
+ print FILE "BOOTPROTO=static\n";
+ print FILE "BONDING_MASTER=yes\n";
+ print FILE "BONDING_MODULE_OPTS='$bondingopts'\n";
+ print FILE "NAME='Bonded Interface'\n";
+ print FILE "IPADDR=$nic_ips[$i]\n";
+ print FILE "NETMASK=$netmask\n";
+ print FILE "STARTMODE=onboot\n";
+ print FILE "USERCONTROL=no\n";
+ my $devnum = 0;
+ foreach my $dev (@devs) {
+ print FILE "BONDING_SLAVE_$devnum=$dev\n";
+ $devnum++;
+ }
+ close FILE;
+
+ # Configure slaves
+ foreach my $dev (@devs) {
+ system("logger -t xcat -p local4.err 'configbond: slave dev: $dev'");
+ if (!open(FILE, ">$dir/ifcfg-$dev")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$dev'"); exit 1; }
+ print FILE "BOOTPROTO=none\n";
+ print FILE "STARTMODE=hotplug\n";
+ close FILE;
+ }
+ }
+ else {
+ # do not recognize this distro
+ system("logger -t xcat -p local4.err 'configbond: network directory is not either the Red Hat or SuSE format.'");
+ exit 1;
+ }
+
+ # Apply the changes. Since we are only doing bond1 right now, lets not restart the whole network
+ # so we dont disrupt the installnic connection. Instead we just need to bring down the slave nics,
+ # and then bring up the bond nic.
+ #runcmd("service network restart");
+ foreach my $dev (@devs) {
+ runcmd("ifdown $dev");
+ }
+ runcmd("ifdown $bond"); # in case it was already up
+ runcmd("ifup $bond"); # note: this wont reload the bonding kernel module, so we are depending on the provisioning process to already have set the correct bonding options
+ system("logger -t xcat -p local4.info 'configbond: successfully configured $specific_nic.'");
+
+}
+exit 0;
+
+sub runcmd {
+ my $cmd = shift @_;
+ $cmd .= ' 2>&1';
+ my @output = `$cmd`;
+ my $rc = $? >> 8;
+ if ($rc) {
+ system("logger -t xcat -p local4.err 'configeth: command $cmd failed with rc $rc: " . join('',@output) . "'");
+ my $errout= "configeth: command $cmd failed with rc $rc.";
+ `echo $errout`;
+ exit $rc;
+ }
+}
diff --git a/xCAT-SoftLayer/postscripts/setdefaultroute b/xCAT-SoftLayer/postscripts/setdefaultroute
index 6932b0d79..7e574ca4c 100755
--- a/xCAT-SoftLayer/postscripts/setdefaultroute
+++ b/xCAT-SoftLayer/postscripts/setdefaultroute
@@ -1,6 +1,28 @@
#!/bin/bash
# set the default route of the node to the ip address and nic passed in
+# this should be added to the postbootscripts, NOT postscripts
-set -x
-ip route replace to default via $1 dev $2
+gateway="$1"
+nic="$2"
+
+# set it temporarily
+echo "ip route replace to default via $gateway dev $nic"
+ip route replace to default via $gateway dev $nic
+
+# set it permanently
+#todo: this is only for sles right now
+file=/etc/sysconfig/network/routes
+if grep -q -E '^default ' $file; then
+ # replace the default route that is already in there
+ sed -i 's/^default .*$/default '$gateway' - -/' $file
+else
+ # no default route yet, append to file
+ echo "default $gateway - -" >>$file
+fi
+
+# While we are here, clean up the network wait hack, if it is still there.
+# (It was added during scripted install, because autoyast will not use the bond
+# configuration for 1 part of the process.) Do not know a better place to clean
+# this up.
+sed -i '/Waiting to reach xCAT mgmt node/d' /etc/init.d/network
\ No newline at end of file
diff --git a/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl b/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl
index 96bf8ed28..e0ac43fdd 100644
--- a/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl
+++ b/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl
@@ -67,7 +67,6 @@
- true
#TABLE:site:key=domain:value#
#TABLE:nodelist:$NODE:node#
@@ -78,10 +77,46 @@
#TABLE:site:key=domain:value#
+
+
+ yes
+ mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1
+ eth0
+ bond0
+ static
+ auto
+ #NODEIPADDR#
+ #NODENETMASK#
+ no
+
+
+ none
+ eth0
+ Ethernet Card 0
+ off
+
+
false
+
+
+ default
+ -
+ #NODEGATEWAY#
+ -
+
+
+
+
+
+ root
+ /etc/modprobe.d/bond0.conf
+ 644
+
+
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles#
diff --git a/xCAT-SoftLayer/si-post-install/14all.addnetworkdelay b/xCAT-SoftLayer/si-post-install/14all.addnetworkdelay
deleted file mode 100755
index a1f205dfe..000000000
--- a/xCAT-SoftLayer/si-post-install/14all.addnetworkdelay
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-
-# Add a script that will run when the network is brought up to wait until the
-# xcat mn can be pinged.
-
-. /tmp/post-install/variables.txt
-
-if [ -d "/etc/sysconfig/network-scripts/" ];then
- #redhat
- NETDIR=/etc/sysconfig/network-scripts
- filename=/sbin/ifup-local
-elif [ -d "/etc/sysconfig/network/" ];then
- #suse
- NETDIR=/etc/sysconfig/network
- filename=/etc/sysconfig/network/if-up.d/xcat-sl-wait
-else
- #ubuntu
- echo "Does not support ubuntu."
- exit 1
-fi
-
-# Create the wait script, overwriting a copy that may have come from the golden client
-# (in case the mn/image server is different).
-# this part of the file we want to expand the variables in the content
-cat >$filename << EOF1
-MNIP=$IMAGESERVER
-NETDIR=$NETDIR
-EOF1
-
-# this part of the file we do NOT want to expand the variables in the content
-cat >>$filename << 'EOF2'
-NIC="$1"
-# look in this ifcfg script to get the nics ip to see if this is the one we should be waiting on
-NICIP=`awk -F= '/^IPADDR/ {print $2}' $NETDIR/ifcfg-$NIC | tr -d \' `
-if [ "${NICIP%.*.*}" != "${MNIP%.*.*}" ]; then exit; fi # hack: compare the 1st 2 octets
-echo -n Waiting to reach xCAT mgmt node $MNIP.
-xcatretries=60
-while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $MNIP >/dev/null 2>&1; do echo -n .; done
-if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi
-sleep 3
-EOF2
-
-chmod +x $filename
\ No newline at end of file
diff --git a/xCAT-SoftLayer/si-post-install/15all.configefi b/xCAT-SoftLayer/si-post-install/15all.configefi
new file mode 100755
index 000000000..34b112f0c
--- /dev/null
+++ b/xCAT-SoftLayer/si-post-install/15all.configefi
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+# 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"
+ str_bootnums=`efibootmgr | grep 'syscloneLinux' | awk '{print $1}' | sed 's/boot//i' | sed 's/*//'`
+ for str_num in $str_bootnums
+ do
+ efibootmgr -b $str_num -B -q
+ done
+
+ if [ -f "/boot/efi/EFI/redhat/grub.efi" ];then
+ efibootmgr -c -l \\EFI\\redhat\\grub.efi -L syscloneLinux
+ elif [ -f "/boot/efi/efi/SuSE/elilo.efi" ];then
+ efibootmgr -c -l \\efi\\SuSE\\elilo.efi -L syscloneLinux
+ else
+ echo "Can not find the boot loader."
+ exit 1
+ fi
+else
+ echo "run grub-install to configure the MBR."
+ if [ -e /etc/mtab ];then
+ mv /etc/mtab /etc/mtab.bak
+ fi
+ grep -v rootfs /proc/mounts > /etc/mtab
+ boot_device=''
+ if [ -f "/etc/systemconfig/systemconfig.conf" ];then
+ boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'`
+ else
+ 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 root device is $boot_root"
+ else
+ echo "Can not find the boot device, return error"
+ exit 1
+ fi
+
+ # 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
+ rm -f /etc/mtab
+ fi
+fi
diff --git a/xCAT-SoftLayer/si-post-install/16all.updatenetwork b/xCAT-SoftLayer/si-post-install/16all.updatenetwork
index 2d80690aa..db6830859 100755
--- a/xCAT-SoftLayer/si-post-install/16all.updatenetwork
+++ b/xCAT-SoftLayer/si-post-install/16all.updatenetwork
@@ -1,9 +1,12 @@
#!/bin/bash
-# Configure network settings after SI has installed the OS
+# SI post-install script to configure network settings after SI has installed the OS
+# SI post-install scripts run in a chroot environment of the final OS image
. /tmp/post-install/variables.txt
+bondingopts='mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1'
+
# determine if we should be using a static ip or dhcp
staticIP () {
# Eventually we should use the SI variable IP_ASSIGNMENT_METHOD below to determine this.
@@ -35,11 +38,13 @@ if [ -n "$rule_file" ];then
fi
hostname $HOSTNAME
+bond=bond0
device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'`
str_cfg_file=''
if [ -d "/etc/sysconfig/network-scripts/" ];then
#redhat
+ dir="/etc/sysconfig/network-scripts"
grep -i HOSTNAME /etc/sysconfig/network
if [ $? -eq 0 ];then
sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network
@@ -47,21 +52,44 @@ if [ -d "/etc/sysconfig/network-scripts/" ];then
echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network
fi
if staticIP; then
+ # delete all nic cfg files left over from the golden node
+ for i in $device_names;do
+ rm -f "$dir/ifcfg-$i"
+ done
+
# set static ip from variables in variables.txt
- i="$DEVICE"
- str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i"
+ # write ifcfg-bond0. For now we assume the installnic should be part of bond0,
+ # because in SL i think that is always the case.
+ i="$bond"
+ str_cfg_file="$dir/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
- echo "BOOTPROTO=static" >> $str_cfg_file
+ echo "BOOTPROTO=none" >> $str_cfg_file
echo "ONBOOT=yes" >> $str_cfg_file
+ echo "USERCTL=no" >> $str_cfg_file
+ echo 'BONDING_OPTS="'$bondingopts'"' >> $str_cfg_file
echo "IPADDR=$IPADDR" >> $str_cfg_file
echo "NETMASK=$NETMASK" >> $str_cfg_file
echo "NETWORK=$NETWORK" >> $str_cfg_file
echo "BROADCAST=$BROADCAST" >> $str_cfg_file
#todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway
+
+ # write ifcfg-eth0
+ i="$DEVICE"
+ str_cfg_file="$dir/ifcfg-$i"
+ echo "DEVICE=$i" > $str_cfg_file
+ echo "BOOTPROTO=none" >> $str_cfg_file
+ echo "MASTER=$bond" >> $str_cfg_file
+ echo "ONBOOT=yes" >> $str_cfg_file
+ echo "SLAVE=yes" >> $str_cfg_file
+ echo "USERCTL=no" >> $str_cfg_file
+
+ # write modprobe alias config
+ str_cfg_file="/etc/modprobe.d/$bond.conf"
+ echo "alias $bond bonding" > $str_cfg_file
else
# use dhcp for all nics
for i in $device_names;do
- str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i"
+ str_cfg_file="$dir/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "NM_CONTROLLED=yes" >> $str_cfg_file
@@ -70,23 +98,54 @@ if [ -d "/etc/sysconfig/network-scripts/" ];then
fi
elif [ -d "/etc/sysconfig/network/" ];then
#suse
+ dir="/etc/sysconfig/network"
echo "$HOSTNAME" > /etc/HOSTNAME
if staticIP; then
+ # delete all nic cfg files left over from the golden node
+ for i in $device_names;do
+ rm -f "$dir/ifcfg-$i"
+ done
+
# set static ip from variables in variables.txt
- i="$DEVICE"
- str_cfg_file="/etc/sysconfig/network/ifcfg-$i"
- echo "DEVICE=$i" > $str_cfg_file
- echo "BOOTPROTO=static" >> $str_cfg_file
+ # write ifcfg-bond0. For now we assume the installnic should be part of bond0,
+ # because in SL i think that is always the case.
+ i="$bond"
+ str_cfg_file="$dir/ifcfg-$i"
+ echo "BOOTPROTO=static" > $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
+ echo "BONDING_MASTER=yes" >> $str_cfg_file
+ echo "BONDING_MODULE_OPTS='$bondingopts'" >> $str_cfg_file
+ echo "NAME='Bonded Interface'" >> $str_cfg_file
echo "IPADDR=$IPADDR" >> $str_cfg_file
echo "NETMASK=$NETMASK" >> $str_cfg_file
echo "NETWORK=$NETWORK" >> $str_cfg_file
echo "BROADCAST=$BROADCAST" >> $str_cfg_file
+ echo "USERCONTROL=no" >> $str_cfg_file
+ echo "BONDING_SLAVE_0=$DEVICE" >> $str_cfg_file
+
+ # write ifcfg-eth0
+ i="$DEVICE"
+ str_cfg_file="$dir/ifcfg-$i"
+ echo "BOOTPROTO=none" > $str_cfg_file
+ echo "STARTMODE=hotplug" >> $str_cfg_file
+
+ # write modprobe alias config
+ str_cfg_file="/etc/modprobe.d/$bond.conf"
+ echo "alias $bond bonding" > $str_cfg_file
+
+ # this was the original config of the eth0 nic (without bonding)
+ #echo "DEVICE=$i" > $str_cfg_file
+ #echo "BOOTPROTO=static" >> $str_cfg_file
+ #echo "STARTMODE=onboot" >> $str_cfg_file
+ #echo "IPADDR=$IPADDR" >> $str_cfg_file
+ #echo "NETMASK=$NETMASK" >> $str_cfg_file
+ #echo "NETWORK=$NETWORK" >> $str_cfg_file
+ #echo "BROADCAST=$BROADCAST" >> $str_cfg_file
#todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway
else
# use dhcp for all nics
for i in $device_names;do
- str_cfg_file="/etc/sysconfig/network/ifcfg-$i"
+ str_cfg_file="$dir/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
diff --git a/xCAT-SoftLayer/si-post-install/99all.killsyslog b/xCAT-SoftLayer/si-post-install/99all.killsyslog
new file mode 100755
index 000000000..7df9b06fe
--- /dev/null
+++ b/xCAT-SoftLayer/si-post-install/99all.killsyslog
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# 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
+ str_id=`echo $str_out | awk '{print $2}'`
+ kill -9 $str_id
+ fi
+fi
+
+# SI starts klogd in the chroot, but does not kill it
+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
\ No newline at end of file
diff --git a/xCAT-client/bin/rcons b/xCAT-client/bin/rcons
index 979759c49..86497d9f1 100755
--- a/xCAT-client/bin/rcons
+++ b/xCAT-client/bin/rcons
@@ -115,7 +115,11 @@ else
length=`expr $index2 - $index1`
length=`expr $length - 1`
cons_ip=`expr substr "$result" $pos $length`
- ifconfig |grep "$cons_ip"
+ if [ "$os" == "AIX" ]; then
+ ifconfig |grep "$cons_ip"
+ else
+ ip addr |grep "$cons_ip"
+ fi
if [ $? -eq 0 ]; then
CONSERVER=""
fi
diff --git a/xCAT-rmc/xCAT-rmc.spec b/xCAT-rmc/xCAT-rmc.spec
index 6262886df..d7c6f6e73 100644
--- a/xCAT-rmc/xCAT-rmc.spec
+++ b/xCAT-rmc/xCAT-rmc.spec
@@ -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
diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm
index 7e03dff72..d6bc2c818 100644
--- a/xCAT-server/lib/perl/xCAT/Template.pm
+++ b/xCAT-server/lib/perl/xCAT/Template.pm
@@ -105,11 +105,6 @@ sub subvars {
}
- my @managedaddressmode = xCAT::TableUtils->get_site_attribute("managedaddressmode");
- my $tmp=$managedaddressmode[0];
- if( defined($tmp) ){
- $ENV{MANAGEDADDRESSMODE}=$tmp;
- }
#replace the env with the right value so that correct include files can be found
$inc =~ s/#ENV:([^#]+)#/envvar($1)/eg;
@@ -249,6 +244,7 @@ sub subvars {
$inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg;
$inc =~ s/#MANAGEDADDRESSMODE#/managed_address_mode()/eg;
$inc =~ s/#HOSTNAME#/$node/g;
+ $inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg;
my $nrtab = xCAT::Table->new("noderes");
my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']);
@@ -638,6 +634,22 @@ sub get_win_prodkey {
sub managed_address_mode {
return $::XCATSITEVALS{managedaddressmode};
}
+
+
+sub get_node_domain {
+ my $lcnode=shift;
+ if ( $lcnode eq 'THISNODE' ){
+ $lcnode=$node;
+ }
+
+ my $nd = xCAT::NetworkUtils->getNodeDomains([$lcnode]);
+ my %nodedomains = %$nd;
+ my $domain=$nodedomains{$lcnode};
+
+ return $domain;
+
+}
+
sub esxipv6setup {
if (not $::XCATSITEVALS{managedaddressmode} or $::XCATSITEVALS{managedaddressmode} =~ /v4/) { return ""; } # blank line for ipv4 schemes
my $v6addr;
@@ -705,7 +717,7 @@ sub kickstartnetwork {
push @nameserversIP, $ip;
}
-
+ #there is no network option to set dns search domain in kickstart, it will be set in %post
if (scalar @nameserversIP) {
$line .=" --nameserver=". join(",",@nameserversIP);
}
diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm
index 7dc5e2b96..028515366 100644
--- a/xCAT-server/lib/xcat/plugins/anaconda.pm
+++ b/xCAT-server/lib/xcat/plugins/anaconda.pm
@@ -1548,9 +1548,9 @@ sub mkinstall
foreach(@addfiles){
$kcmdline .= " --- $rtftppath/$_";
}
- }elsif ($pkvm) {
- $k = "$httpmethod://$instserver:$httpport$tftppath/vmlinuz";
- $i = "$httpmethod://$instserver:$httpport$tftppath/initrd.img";
+ #}elsif ($pkvm) {
+ # $k = "$httpmethod://$instserver:$httpport$tftppath/vmlinuz";
+ # $i = "$httpmethod://$instserver:$httpport$tftppath/initrd.img";
}else{
$k = "$rtftppath/vmlinuz";
$i = "$rtftppath/initrd.img";
diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm
index 21c5456b9..0d59f9c87 100755
--- a/xCAT-server/lib/xcat/plugins/dhcp.pm
+++ b/xCAT-server/lib/xcat/plugins/dhcp.pm
@@ -884,10 +884,15 @@ sub check_options
# if not help and not -n, dhcpd needs to be running
if (!($opt->{h})&& (!($opt->{n}))) {
if (xCAT::Utils->isLinux()) {
- my @output = xCAT::Utils->runcmd("service dhcpd status", -1);
+ my $DHCPSERVER="dhcpd";
+ if( -e "/etc/init.d/isc-dhcp-server" ){
+ $DHCPSERVER="isc-dhcp-server";
+ }
+
+ my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1);
if ($::RUNCMD_RC != 0) { # not running
my $rsp = {};
- $rsp->{data}->[0] = "dhcpd is not running. Run service dhcpd start and rerun your command.";
+ $rsp->{data}->[0] = "$DHCPSERVER is not running. Run service $DHCPSERVER start and rerun your command.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return 1;
}
diff --git a/xCAT-server/lib/xcat/plugins/imgport.pm b/xCAT-server/lib/xcat/plugins/imgport.pm
index c5a88e336..cec8609d2 100644
--- a/xCAT-server/lib/xcat/plugins/imgport.pm
+++ b/xCAT-server/lib/xcat/plugins/imgport.pm
@@ -1901,7 +1901,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;
}
diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm
index 0d6912c54..0a074fa70 100644
--- a/xCAT-server/lib/xcat/plugins/kit.pm
+++ b/xCAT-server/lib/xcat/plugins/kit.pm
@@ -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");
}
}
}
@@ -1716,7 +1716,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");
}
}
diff --git a/xCAT-server/lib/xcat/plugins/mic.pm b/xCAT-server/lib/xcat/plugins/mic.pm
index 1037c69b3..6da7c7395 100644
--- a/xCAT-server/lib/xcat/plugins/mic.pm
+++ b/xCAT-server/lib/xcat/plugins/mic.pm
@@ -612,7 +612,25 @@ sub rflash {
# run the cmd on the host to flash the mic
my @args = ("-s", "-v", "-e");
push @args, "$::XCATROOT/sbin/flashmic";
- my $master = $request->{'_xcatdest'};
+ # assume that all hosts are on the same network connected to this master
+ # (otherwise, will need to move this call into loop above for each host
+ # and build separate miccfg calls for each unique returned value from
+ # my_ip_facing)
+ my $ipfn = xCAT::NetworkUtils->my_ip_facing(@hosts[0]);
+ if ($ipfn) {
+ $master = $ipfn;
+ } else {
+ my $hostname = "";
+ my $hostnamecmd = "/bin/hostname";
+ my @thostname = xCAT::Utils->runcmd($hostnamecmd, 0);
+ if ($::RUNCMD_RC = 0) {
+ $hostname = "from server $thostname[0]";
+ }
+ xCAT::MsgUtils->message("E", {error=>["Cannot detect an active network interface $hostname to @hosts[0]."], errorcode=>["1"]}, $callback);
+ return;
+ }
+
+}
push @args, ("-m", "$master");
push @args, ("-p", "$tftpdir/xcat/miccfg");
@@ -912,7 +930,23 @@ sub nodeset {
# run the cmd on the host to configure the mic
my @args = ("-s", "-v", "-e");
push @args, "$::XCATROOT/sbin/configmic";
- my $master = $request->{'_xcatdest'};
+ # assume that all hosts are on the same network connected to this master
+ # (otherwise, will need to move this call into loop above for each host
+ # and build separate miccfg calls for each unique returned value from
+ # my_ip_facing)
+ my $ipfn = xCAT::NetworkUtils->my_ip_facing(@hosts[0]);
+ if ($ipfn) {
+ $master = $ipfn;
+ } else {
+ my $hostname = "";
+ my $hostnamecmd = "/bin/hostname";
+ my @thostname = xCAT::Utils->runcmd($hostnamecmd, 0);
+ if ($::RUNCMD_RC = 0) {
+ $hostname = "from server $thostname[0]";
+ }
+ xCAT::MsgUtils->message("E", {error=>["Cannot detect an active network interface $hostname to @hosts[0]."], errorcode=>["1"]}, $callback);
+ return;
+ }
push @args, ("-m", "$master");
push @args, ("-p", "$tftpdir/xcat/miccfg");
diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm
index 3e44a097d..dda254b19 100644
--- a/xCAT-server/lib/xcat/plugins/petitboot.pm
+++ b/xCAT-server/lib/xcat/plugins/petitboot.pm
@@ -10,6 +10,10 @@ my $globaltftpdir = xCAT::TableUtils->getTftpDir();
my %usage = (
"nodeset" => "Usage: nodeset osimage[=]",
);
+
+my $httpmethod="http";
+my $httpport = "80";
+
sub handled_commands {
return {
nodeset => "noderes:netboot"
@@ -79,7 +83,21 @@ sub setstate {
my %nrhash = %{shift()};
my $linuximghash = shift();
my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']);
- if ($kern->{kcmdline} =~ /!myipfn!/) {
+ #my $nodereshash=$noderestab->getNodesAttribs(\@nodes,['tftpdir','xcatmaster','nfsserver', 'servicenode']);
+ if ($kern->{kernel} !~ /^$tftpdir/) {
+ my $nodereshash = $nrhash{$node}->[0];
+ my $installsrv;
+ if ($nodereshash and $nodereshash->{nfsserver} ) {
+ $installsrv = $nodereshash->{nfsserver};
+ } elsif ($nodereshash->{xcatmaster}) {
+ $installsrv = $nodereshash->{xcatmaster};
+ } else {
+ $installsrv = '!myipfn!';
+ }
+ $kern->{kernel} = "$httpmethod://$installsrv:$httpport$tftpdir/".$kern->{kernel};
+ $kern->{initrd} = "$httpmethod://$installsrv:$httpport$tftpdir/".$kern->{initrd};
+ }
+ if ($kern->{kcmdline} =~ /!myipfn!/ or $kern->{kernel} =~ /!myipfn!/) {
my $ipfn = xCAT::NetworkUtils->my_ip_facing($node);
unless ($ipfn) {
my $servicenodes = $nrhash{$node}->[0];
@@ -118,6 +136,8 @@ sub setstate {
$kern->{kcmdline} =~ s/!myipfn!/$ipfn/g;
}
}
+
+
if ($kern->{addkcmdline}) {
$kern->{kcmdline} .= " ".$kern->{addkcmdline};
}
@@ -303,6 +323,8 @@ sub process_request {
my $command = $request->{command}->[0];
%breaknetbootnodes=();
%normalnodes=();
+ if ($::XCATSITEVALS{"httpmethod"}) { $httpmethod = $::XCATSITEVALS{"httpmethod"}; }
+ if ($::XCATSITEVALS{"httpport"}) { $httpport = $::XCATSITEVALS{"httpport"}; }
my @args;
my @nodes;
@@ -384,11 +406,9 @@ sub process_request {
my $chaintab=xCAT::Table->new('chain',-create=>1);
my $chainhash=$chaintab->getNodesAttribs(\@nodes,['currstate']);
my $noderestab=xCAT::Table->new('noderes',-create=>1);
- my $nodereshash=$noderestab->getNodesAttribs(\@nodes,['tftpdir']);
+ my $nodereshash=$noderestab->getNodesAttribs(\@nodes,['tftpdir','xcatmaster','nfsserver', 'servicenode']);
my $mactab=xCAT::Table->new('mac',-create=>1);
my $machash=$mactab->getNodesAttribs(\@nodes,['mac']);
- my $nrtab=xCAT::Table->new('noderes',-create=>1);
- my $nrhash=$nrtab->getNodesAttribs(\@nodes,['servicenode']);
my $typetab=xCAT::Table->new('nodetype',-create=>1);
my $typehash=$typetab->getNodesAttribs(\@nodes,['os','provmethod','arch','profile']);
my $linuximgtab=xCAT::Table->new('linuximage',-create=>1);
@@ -415,7 +435,7 @@ sub process_request {
my $linuximghash = $linuximghash = $linuximgtab->getAttribs({imagename => $osimgname}, 'boottarget', 'addkcmdline');
- ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash,$tftpdir,$nrhash,$linuximghash);
+ ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash,$tftpdir,$nodereshash,$linuximghash);
if ($rc) {
$response{node}->[0]->{errorcode}->[0]= $rc;
$response{node}->[0]->{errorc}->[0]= $errstr;
diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm
index d53db653b..61ac8b8ac 100755
--- a/xCAT-server/lib/xcat/plugins/sles.pm
+++ b/xCAT-server/lib/xcat/plugins/sles.pm
@@ -1182,11 +1182,19 @@ sub mkinstall
}
if(scalar @nameserversIP){
- $kcmdline .=" dns=".join(",",@nameserversIP);
+ $kcmdline .=" Nameserver=".join(",",@nameserversIP);
}
+
+ my $nd = xCAT::NetworkUtils->getNodeDomains([$node]);
+ my %nodedomains = %$nd;
+ my $domain=$nodedomains{$node};
+
+ $kcmdline .=" Domain=$domain ";
}
+
+
if (defined $sent->{serialport})
{
diff --git a/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl b/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl
index 3b09adb42..8a8cbcc6b 100644
--- a/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl
+++ b/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl
@@ -27,7 +27,8 @@ rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password#
#partition / --ondisk=/dev/mapper/ibmpkvm_vg_root-ibmpkvm_lv_root
partition / --ondisk=/dev/sda
-network --bootproto dhcp
+#the --devicename must specify right now, but without network command, it can also work, so we delete it.
+#network --bootproto dhcp
%post
touch "/startpost"
diff --git a/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl
index ec75d88bd..b32f1f01d 100644
--- a/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl
+++ b/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl
@@ -2,6 +2,7 @@
#cmdline
lang en_US
+#KICKSTARTNET#
#
# Where's the source?
diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl
index ff7321d77..55b0aa2f8 100644
--- a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl
+++ b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl
@@ -3,6 +3,7 @@
#cmdline
lang en_US
+#KICKSTARTNET#
#
# Where's the source?
diff --git a/xCAT-server/share/xcat/install/scripts/post.rh.common b/xCAT-server/share/xcat/install/scripts/post.rh.common
index f34fe6e5d..79bc733a7 100644
--- a/xCAT-server/share/xcat/install/scripts/post.rh.common
+++ b/xCAT-server/share/xcat/install/scripts/post.rh.common
@@ -2,6 +2,8 @@
# Setup hostname
#
echo "post scripts" >/root/post.log
+
+
export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic#
if [ "$PRINIC" == "mac" ]
then
diff --git a/xCAT-server/share/xcat/install/scripts/post.sles.common b/xCAT-server/share/xcat/install/scripts/post.sles.common
index cfe6f29cc..ae6db1e24 100644
--- a/xCAT-server/share/xcat/install/scripts/post.sles.common
+++ b/xCAT-server/share/xcat/install/scripts/post.sles.common
@@ -1,5 +1,5 @@
#!/bin/sh
-export MANAGEDADDRESSMODE="#XCATVAR:MANAGEDADDRESSMODE#"
+export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE#
cd /etc/sysconfig/network
diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh
index 113c5760b..346b6de73 100644
--- a/xCAT-server/share/xcat/install/scripts/pre.rh
+++ b/xCAT-server/share/xcat/install/scripts/pre.rh
@@ -14,6 +14,17 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then
fi
+#there is no boot option to set dns search domain in kickstart file,
+#the search domain in /etc/resolv.conf is set in the pre installation script
+export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE#
+export SEARCHDOMAIN=#GETNODEDOMAIN:THISNODE#
+
+if [ "$MANAGEDADDRESSMODE" == "static" ]; then
+ echo "#appended by %pre " >> /etc/resolv.conf
+ echo "search $SEARCHDOMAIN" >> /etc/resolv.conf
+fi
+
+
cat >/tmp/baz.py < $hookdir/initqueue/finished/xcatroot.sh
diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh
new file mode 100644
index 000000000..40c1dbbe5
--- /dev/null
+++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh
@@ -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
diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh
new file mode 100755
index 000000000..d6eac21f9
--- /dev/null
+++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh
@@ -0,0 +1,126 @@
+#!/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
+
+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
diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag
new file mode 100755
index 000000000..2f9ac3165
--- /dev/null
+++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag
@@ -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
+}
diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot
new file mode 100755
index 000000000..feed0dcd3
--- /dev/null
+++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot
@@ -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
diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage
index 37eadfd8f..7fc298298 100755
--- a/xCAT-server/share/xcat/netboot/rh/genimage
+++ b/xCAT-server/share/xcat/netboot/rh/genimage
@@ -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;
}
}
diff --git a/xCAT-test/restapitest b/xCAT-test/restapitest
new file mode 100755
index 000000000..1e0682fc2
--- /dev/null
+++ b/xCAT-test/restapitest
@@ -0,0 +1,507 @@
+#!/usr/bin/env perl
+###############################################################################
+# This script is used for rest-api automation test
+# Flags are used for test input:
+# -m method. Should be GET, POST, PUT, DELETE
+# -r resource
+# -t token
+# -h host
+# -u user
+# -p passwd
+# -P port (BC)
+# -d data
+# -c cert
+# -n hostname
+# Flags are used for check output:
+# -o expected output
+# -O logical operator
+#
+# Expected result format is '{ANY:{ANY:content}}'
+# These steps are used to explain how to scan result
+# step 1. go through to see if content can be found
+# step 2. compare content if found
+# options are used as followed:
+# == returns 0 if found and equal, returns 1 if not found or found but not equal
+# != returns 0 if found, returns 1 if not found
+# =~ returns 0 if match, returns 1 if not match
+# !=~ returns 0 if not match, returns 1 if match
+################################################################################
+BEGIN
+{
+ $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
+}
+use Getopt::Long qw{:config bundling no_ignore_case};
+use Data::Dumper;
+use strict;
+my $help;
+my $method;
+my $token;
+my $resource;
+my $host;
+my $user;
+my $passwd;
+my $port;
+my $data;
+my $cert;
+my $hostname;
+my $output;
+my $loperator;
+my $debug;
+my $defaulthash;
+my $defaulthttpresult = 0;
+my $outputfile = "/tmp/testrestapiresult";
+
+if (
+ !GetOptions("h|?" => \$help,
+ "m=s" => \$method,
+ "t=s" => \$token,
+ "r=s" => \$resource,
+ "h=s" => \$host,
+ "u=s" => \$user,
+ "p=s" => \$passwd,
+ "P=s" => \$port,
+ "d=s" => \$data,
+ "c=s" => \$cert,
+ "n=s" => \$hostname,
+ "o=s" => \$output,
+ "O=s" => \$loperator,
+ "debug" => \$debug,
+ )
+ ) {
+ &usage;
+ exit 1;
+}
+
+##############################################################
+# check result
+##############################################################
+if ($output) {
+ if ($method or $resource) {
+ &usage;
+ exit 1;
+ }
+
+ my $res = check_result($output,$loperator,$outputfile);
+ print_debug( "check result runs with $output and $loperator, result is $res\n" );
+ exit $res;
+}
+##############################################################
+# return help
+##############################################################
+if ($help) {
+ &usage;
+ exit 0;
+}
+##############################################################
+# Give default values for optional vars.
+###############################################################
+my $rootdir = "$::XCATROOT/share/xcat/tools/autotest";
+my $resultdir = "$rootdir/result";
+my $logfile = "$rootdir/result/restapitest.log"; #/opt/xcat/share/xcat/tools/autotest/result/restapitest.log
+my $cert1 = "/root/ca-cert.pem";
+# get token
+my $gettoken = `curl -X POST -k 'https://127.0.0.1/xcatws/tokens?userName=root&password=cluster' -H Content-Type:application/json --data '{"userName":"root","password":"cluster"}' 2>/dev/null`;
+my $reshash = parse_json($gettoken);
+my $token1 = $$reshash{token}{id};
+
+
+# get hostname
+unless ($hostname) {
+ $hostname = `hostname`;
+ chomp($hostname);
+
+}
+
+# keey default test result for save
+my $res = run_restapi($method, $resource, $data, "", $port, "127.0.0.1", "root", "cluster");
+$defaulthash = parse_json($res);
+$defaulthttpresult = check_errcode();
+
+# debug info
+print_debug( "get token $token1. \n" );
+print_debug( "get hostname $hostname.\n");
+print_debug( "default result is $res. \n" );
+print_debug( "default resulthash is: \n" );
+print_debug($defaulthash);
+print_debug( "default errcode is $defaulthttpresult \n" );
+
+
+####################################################
+# Begin to run test cases
+####################################################
+my @users = ("root","wsuser", $user);
+my @passwds = ("cluster","cluster", $passwd);
+my @tokens = ("", $token1, $token);
+my @certs = ("", $cert1, $cert);
+unless ($host) {
+ $host = "127.0.0.1";
+}
+log_me("**************begin restapi test***************");
+my $i = 0;
+for my $u (@users) {
+ next unless($u);
+ my $p = $passwds[$i];
+ $i++;
+ for my $t (@tokens) {
+ for my $c (@certs){
+ my $res = run_restapi($method, $resource, $data, $c, $port, $host, $u, $p, $t);
+ if($res){
+ my $reshash = parse_json($res);
+ print_debug("parse curl result and got:\n");
+ print_debug($reshash);
+ if (%$reshash != %$defaulthash) {
+ log_me("restapi test cases run different result");
+ print_debug( "restapi test cases run different result with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" );
+ exit 1;
+ }
+ }
+ my $errcode = check_errcode();
+ print_debug("get curl error code: $errcode\n");
+ if ($errcode != $defaulthttpresult) {
+ log_me("restapi test cases run different errcode");
+ print_debug( "restapi test cases run different error code with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" );
+ exit 1;
+ }
+ }
+ }
+}
+exit $defaulthttpresult;
+
+################################################
+# begin subroutine
+################################################
+
+##########
+# usage #
+##########
+sub usage
+{
+ print "Usage:testrestapi - Run xcat test cases.\n";
+ print " testrestapi [-?|-h]\n";
+ print " testrestapi [-m method] [-r resource] [-t tocken]\n";
+ print " [-h host] [-P port][-u user] [-p passwd]\n";
+ print " [-d data] [-c cert] [-n hostname]\n";
+ print " [-o expect_output] [-O logical_operator] \n";
+ print " [--debug]\n";
+ print "\n";
+ return;
+}
+
+###############
+# record log #
+###############
+sub log_me
+{
+ my $msg = shift;
+ open (LOG, ">>$logfile")
+ or return 1;
+ my $date = `date`;
+ print LOG "$date\: $msg\n";
+}
+
+#####################
+# print debug infor #
+#####################
+sub print_debug
+{
+ my $msg = shift;
+ return 0 unless($debug);
+ if(ref($msg) eq 'HASH') {
+ print Dumper($msg);
+ } elsif( ref($msg) eq 'ARRAY') {
+ print Dumper($msg);
+ } else {
+ print "$msg";
+ }
+}
+#########################
+# run rest-api command #
+#########################
+sub run_restapi
+{
+ my ($m,$r,$d,$c,$p,$h,$u,$a,$t) = @_;
+ my $cmd = "curl";
+ $cmd .= " -X $m";
+ unless ($c) {
+ $cmd .= " -k ";
+ }else {
+ $cmd .= " --cacert $c";
+ }
+ if($t){
+ $cmd .= " -H X-Auth-Token:$t ";
+ }
+ if($t or $c){
+ $cmd .= " 'https://$hostname";
+ } else {
+ $cmd .= " 'https://$h";
+ }
+ if ($p) {
+ $cmd .= ":$p";
+ }
+ $cmd .= "/xcatws";
+ $cmd .= "$r?";
+ unless($t){
+ $cmd .= "userName=$u&password=$a'";
+ }else {
+ $cmd .= "'";
+ }
+ if($d) {
+ $cmd .= " -H Content-Type:application/json --data '$d'";
+ }
+ $cmd .= " -D /tmp/err.log";
+ log_me("Begin to run restapi test with $cmd");
+ my $res = `$cmd 2>/dev/null`;
+ print_debug("run curl: $cmd\n");
+ print_debug("result is $res\n");
+ if (!open (RESULT, ">$outputfile")) {
+ log_me("wirte outputfile error");
+ }
+ print RESULT $res;
+ close RESULT;
+ return $res;
+}
+
+############################
+# transfer json into hash #
+############################
+sub parse_json
+{
+ my $input = shift;
+ my %hash;
+ if ($input =~ /:/) {
+ # for those who look like:
+ # {"networks":[{"mgtifname":"eth1","mask":"255.255.255.0"},{"mgtifname":"eth1","mask":"255.255.255.0"}]}
+ if ($input =~ /^\[(.*)\]$/s) {
+ my $content = $1;
+ print "[:] content is $content \n" if($debug);
+ parse_json($content);
+ }
+ # for those who look like
+ # {"clustersite":{"domain":"cluster.com","master":"192.168.1.15"}}
+ elsif ($input =~ /^\s*{(.*)}\s*$/s) {
+ my $content = $1;
+ print "{} content is $content \n" if($debug);
+ parse_json($content);
+ }
+ # for those who look like
+ # "domain":"cluster.com","master":"192.168.1.15"
+ elsif ($input =~ /,/ and !($input =~ /}/)) {
+ my @contents = split /,/, $input;
+ my @reval;
+ # record result
+ foreach my $t (@contents) {
+ print ", content is $t \n" if($debug);
+ my $re = parse_json($t);
+ push @reval, $re;
+ }
+ # merge hash
+ foreach my $t (@reval) {
+ if(ref($t) =~ "HASH") {
+ foreach my $k (keys %$t){
+ $hash{$k} = $$t{$k};
+ }
+ }
+ }
+ return \%hash;
+
+ }
+ # for those who look like:
+ # "clustersite":{"domain":"cluster.com","master":"192.168.1.15"}
+ # "domain":"cluster.com"
+ elsif ($input =~ /\"(\S+?)\":(.+)/s) {
+ my $key = $1;
+ my $value = $2;
+ if ($value =~ /{/) {
+ # "clustersite":{"domain":"cluster.com","master":"192.168.1.15"}
+ print "{ content is $value \n" if($debug);
+ $hash{$key} = parse_json($value, $key);
+ return \%hash;
+ } else {
+ # "domain":"cluster.com"
+ $value =~ /\"(\S+)\"/;
+ $hash{$key} = $1;
+ return \%hash;
+ }
+ }
+ }
+ # for those who look like
+ # ["10.1.255.250","192.168.200.16","192.168.200.19","192.168.200.22"]
+ else {
+ if ($input =~ /^\[(.*)\]/s) {
+ my $content = $1;
+ print "[] content is $content \n" if($debug);
+ my @all = split /,/, $content;
+ foreach my $n (@all) {
+ $n =~ /\"(.*)\"/;
+ $hash{$1} = "restapiarray";
+ }
+ return \%hash;
+ }
+ }
+}
+
+############################
+# check curl running code #
+############################
+sub check_errcode
+{
+ if(!open (ERRLOG, "){
+ if (/HTTP\/\w*\.*\w* (\w+) (\w+)/) {
+ $num = $1;
+ last;
+ }
+ }
+ close ERRLOG;
+ print_debug("can't get errorcode\n") unless($num);
+ return $num;
+}
+
+############################
+# check curl return result #
+############################
+sub check_result
+{
+ my $data = shift;
+ my $opterator = shift;
+ my $output = shift;
+ if ( !open (OUTPUT, "<$output")) {
+ log_me("can't read output file");
+ return 1;
+ }
+ my $res;
+ while (