From 9893a2dd714082f3479b09667a1417b229770bd3 Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Sun, 2 Mar 2014 13:11:41 -0500 Subject: [PATCH] template and postscript for softlayer node install --- xCAT-SoftLayer/bin/modifygrub | 2 +- xCAT-SoftLayer/bin/pushinitrd | 23 +++- xCAT-SoftLayer/postscripts/setdefaultroute | 6 + .../scripts/post.sles.softlayer.common | 20 ++++ .../sles/compute.sles11.softlayer.tmpl | 105 ++++++++++++++++++ 5 files changed, 150 insertions(+), 6 deletions(-) create mode 100755 xCAT-SoftLayer/postscripts/setdefaultroute create mode 100644 xCAT-SoftLayer/share/xcat/install/scripts/post.sles.softlayer.common create mode 100644 xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl diff --git a/xCAT-SoftLayer/bin/modifygrub b/xCAT-SoftLayer/bin/modifygrub index fca672660..a6d28407f 100755 --- a/xCAT-SoftLayer/bin/modifygrub +++ b/xCAT-SoftLayer/bin/modifygrub @@ -62,7 +62,7 @@ sub addKernelParms { # get node ip and add it to the kernel parms my ($nic, $ip, $netmask, $gateway) = getNodeIpInfo($args); if (!$ip) { die "Error: could not find the NIC that would connect to the xCAT mgmt node's IP (".$args->{mnip}.").\n"; } - $args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway netdevice=$nic netwait=$WAITTIME"; + $args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1"; } diff --git a/xCAT-SoftLayer/bin/pushinitrd b/xCAT-SoftLayer/bin/pushinitrd index 401076eed..7e3cd5a7e 100755 --- a/xCAT-SoftLayer/bin/pushinitrd +++ b/xCAT-SoftLayer/bin/pushinitrd @@ -14,6 +14,7 @@ use Data::Dumper; my $HELP; my $VERBOSE; my $WAITTIME; +my $NOAUTOINST; my $usage = sub { my $exitcode = shift @_; @@ -31,11 +32,11 @@ my $usage = sub { Getopt::Long::Configure("bundling"); #Getopt::Long::Configure("pass_through"); Getopt::Long::Configure("no_pass_through"); -if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME)) { $usage->(1); } +if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME, 'a|noautoinst' => \$NOAUTOINST)) { $usage->(1); } if ($HELP) { $usage->(0); } if (scalar(@ARGV) != 1) { $usage->(1); } -if (!defined($WAITTIME)) { $WAITTIME = 60; } # seconds to wait after configuring the nic (to let the switch handle the state change) +if (!defined($WAITTIME)) { $WAITTIME = 75; } # seconds to wait after configuring the nic (to let the switch handle the state change) my $noderange = $ARGV[0]; my %bootparms = getBootParms($noderange); @@ -44,7 +45,7 @@ copyFilesToNodes($noderange, \%bootparms); updateGrubOnNodes($noderange, \%bootparms); -modifyAutoinstFiles($noderange, \%bootparms); +if (!$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); } exit(0); @@ -61,7 +62,7 @@ sub getBootParms { my $attr = "bootparams.$a"; @gresults = grep(/^\S+:\s+$attr:/, @output); if (!scalar(@gresults)) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset osimage=' ?\n"; } - # for now just pick the 1st one. They should all be the same, except for the node name kcmdline + # for now just pick the 1st one. They should all be the same, except for the node name in kcmdline chomp($gresults[0]); $gresults[0] =~ s/^\S+:\s+$attr:\s*//; $bootparms{$a} = $gresults[0]; @@ -140,11 +141,13 @@ sub modifyAutoinstFiles { 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 escape for sed - my $waitstring = 'echo Waiting to reach xCAT mgmt node...;while \[ \$\(\(xcati+=1\)\) -le 30 \] \&\& ! ping -c2 -w2 ' . $bootparms->{mnip} .'; do : ; done'; + my $waitstring = 'echo Waiting to reach xCAT mgmt node...;while \[ \$\(\(xcati+=1\)\) -le 60 \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .'; do echo i=\$xcati ; done; sleep 10'; # 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 actually update the file print "Updating /install/autoinst files.\n"; foreach my $n (@nodes) { my $f = "/install/autoinst/$n"; @@ -169,6 +172,16 @@ sub sed { #verbose('file length is '.length($lines)); close FILE; + # we also need to look for this string 1st + my $replacecopy = $replace; # a search string can't have special chars in it + $replacecopy =~ s/(\W)/\\$1/g; # so escape all of the meta characters + #print "replacecopy=$replacecopy\n"; + # check to see if the replace string is already in the file + if ($lines =~ m/$replacecopy/s) { + print "$file did not need updating.\n"; + return 1; + } + # search/replace and see if there were any matches my $matches; if ($options{mode} eq 'insertbefore') { $matches = $lines =~ s/($search)/\n$replace\n$1/s; } diff --git a/xCAT-SoftLayer/postscripts/setdefaultroute b/xCAT-SoftLayer/postscripts/setdefaultroute new file mode 100755 index 000000000..6932b0d79 --- /dev/null +++ b/xCAT-SoftLayer/postscripts/setdefaultroute @@ -0,0 +1,6 @@ +#!/bin/bash + +# set the default route of the node to the ip address and nic passed in + +set -x +ip route replace to default via $1 dev $2 diff --git a/xCAT-SoftLayer/share/xcat/install/scripts/post.sles.softlayer.common b/xCAT-SoftLayer/share/xcat/install/scripts/post.sles.softlayer.common new file mode 100644 index 000000000..ded409aac --- /dev/null +++ b/xCAT-SoftLayer/share/xcat/install/scripts/post.sles.softlayer.common @@ -0,0 +1,20 @@ +#!/bin/sh + +# This is modified from the standard xcat post.sles.common in that it does not set up +# the ifcfg-eth0 file to do dhcp and it does not restart the network. It just leaves +# ifcfg-eth0 the way autoyast configured it, assuming we set it statically. + +# save what autoyast set network config to, to help with debugging +cp /etc/sysconfig/network/ifcfg-eth0 /tmp/ifcfg-eth0.orig +cp /etc/hosts /tmp/hosts.orig +cp /etc/resolv.conf /tmp/resolv.conf.orig +cp /etc/HOSTNAME /tmp/HOSTNAME.orig + +#cd /etc/sysconfig/network +perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config + +# autoyast already set hostname correctly + +HOSTNAME=$(hostname -s) +echo $HOSTNAME + diff --git a/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl b/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl new file mode 100644 index 000000000..cd1f56b70 --- /dev/null +++ b/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl @@ -0,0 +1,105 @@ + + + + + + + true + true + + false + false + mbr + + + + GMT + #TABLE:site:key=timezone:value# + + + english-us + + en_US + + false + false + false + true + + + non + + + true + true + true + + + + + + + XCATPARTITIONHOOK + true + all + + + + + + #INCLUDE_DEFAULT_PTRNLIST_S# + + + #INCLUDE_DEFAULT_PKGLIST_S# + + + + + + + root + #CRYPT:passwd:key=system,username=root:password# + true + + + + + + true + + #TABLE:site:key=domain:value# + #TABLE:nodelist:$NODE:node# + + #XCATVAR:XCATMASTER# + + + #TABLE:site:key=domain:value# + + + + false + + + + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles# + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles# + + + + + +