From 4d35d617eddc11f846e85856a72563894598c369 Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Wed, 28 May 2014 10:21:43 -0400 Subject: [PATCH] got cross-vlan sysclone working in softlayer --- xCAT-SoftLayer/bin/khrem | 1 + xCAT-SoftLayer/postscripts/configbond | 17 +++++++++++ .../si-post-install/16all.updatenetwork | 29 +++++++++++++------ xCAT-SoftLayer/xCAT-SoftLayer.spec | 2 ++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/xCAT-SoftLayer/bin/khrem b/xCAT-SoftLayer/bin/khrem index 7f5f25d1b..ac212c484 100755 --- a/xCAT-SoftLayer/bin/khrem +++ b/xCAT-SoftLayer/bin/khrem @@ -15,6 +15,7 @@ my $file = '~/.ssh/known_hosts'; my $usage = sub { my $exitcode = shift @_; print "Usage: khrem \n"; + print " Removes the entries in the .ssh/known_hosts file associated with this node.\n"; exit $exitcode; }; diff --git a/xCAT-SoftLayer/postscripts/configbond b/xCAT-SoftLayer/postscripts/configbond index 93162dc7a..537ed5df4 100755 --- a/xCAT-SoftLayer/postscripts/configbond +++ b/xCAT-SoftLayer/postscripts/configbond @@ -156,7 +156,15 @@ for ($i=0; $i < (scalar @nic_ips) ; $i++ ) { close FILE; # Configure slaves + my @output = `ip addr show 2>&1`; # to check for existance of the device later foreach my $dev (@devs) { + # as a convenience, make sure the device exists before adding it to the bond + if (!grep(m/^\d+:\s+$dev:/, @output)) { + system("logger -t xcat -p local4.err 'configbond: not configuring $dev because it does not exist.'"); + unlink("$dir/ifcfg-$dev"); # in case it was left over in the image we are cloning + next; + } + 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"; @@ -182,7 +190,9 @@ for ($i=0; $i < (scalar @nic_ips) ; $i++ ) { print FILE "STARTMODE=onboot\n"; print FILE "USERCONTROL=no\n"; my $devnum = 0; + my @output = `ip addr show 2>&1`; # to check for existance of the device later foreach my $dev (@devs) { + if (!grep(m/^\d+:\s+$dev:/, @output)) { next; } print FILE "BONDING_SLAVE_$devnum=$dev\n"; $devnum++; } @@ -190,6 +200,13 @@ for ($i=0; $i < (scalar @nic_ips) ; $i++ ) { # Configure slaves foreach my $dev (@devs) { + # as a convenience, make sure the device exists before adding it to the bond + if (!grep(m/^\d+:\s+$dev:/, @output)) { + system("logger -t xcat -p local4.err 'configbond: not configuring $dev because it does not exist.'"); + unlink("$dir/ifcfg-$dev"); # in case it was left over in the image we are cloning + next; + } + 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"; diff --git a/xCAT-SoftLayer/si-post-install/16all.updatenetwork b/xCAT-SoftLayer/si-post-install/16all.updatenetwork index e199dc4c5..a5b58d999 100755 --- a/xCAT-SoftLayer/si-post-install/16all.updatenetwork +++ b/xCAT-SoftLayer/si-post-install/16all.updatenetwork @@ -39,8 +39,15 @@ fi hostname $HOSTNAME bond=bond0 +# this is a softlayer assumption that the two devices on the private net will be eth0 and eth2 if [[ $DEVICE == "eth0" ]]; then - $DEVICE2=eth2 + DEVICE2=eth2 +elif [[ $DEVICE == "eth2" ]]; then + DEVICE2=eth0 +fi +ip addr show|grep -q -E "^[0-9]+:\s+$DEVICE2:" # make sure it exists on the system +if [[ $? == 0 ]]; then + DEVICE2EXISTS="yes" fi device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'` @@ -86,16 +93,18 @@ if [ -d "/etc/sysconfig/network-scripts/" ];then echo "SLAVE=yes" >> $str_cfg_file echo "USERCTL=no" >> $str_cfg_file - if [[ $DEVICE2 != "" ]]; then - # write ifcfg-eth0 - i="$DEVICE2" - str_cfg_file="$dir/ifcfg-$i" + i="$DEVICE2" + str_cfg_file="$dir/ifcfg-$i" + if [[ $DEVICE2EXISTS == "yes" ]]; then + # write ifcfg-eth2 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 + else + rm -f $str_cfg_file # in case it was left over in the image that was captured fi # write modprobe alias config @@ -139,7 +148,7 @@ elif [ -d "/etc/sysconfig/network/" ];then echo "BROADCAST=$BROADCAST" >> $str_cfg_file echo "USERCONTROL=no" >> $str_cfg_file echo "BONDING_SLAVE_0=$DEVICE" >> $str_cfg_file - if [[ $DEVICE2 != "" ]]; then + if [[ $DEVICE2EXISTS == "yes" ]]; then echo "BONDING_SLAVE_1=$DEVICE2" >> $str_cfg_file fi @@ -149,12 +158,14 @@ elif [ -d "/etc/sysconfig/network/" ];then echo "BOOTPROTO=none" > $str_cfg_file echo "STARTMODE=hotplug" >> $str_cfg_file - if [[ $DEVICE2 != "" ]]; then + i="$DEVICE2" + str_cfg_file="$dir/ifcfg-$i" + if [[ $DEVICE2EXISTS == "yes" ]]; then # write ifcfg-eth2 - i="$DEVICE2" - str_cfg_file="$dir/ifcfg-$i" echo "BOOTPROTO=none" > $str_cfg_file echo "STARTMODE=hotplug" >> $str_cfg_file + else + rm -f $str_cfg_file # in case it was left over in the image that was captured fi # write modprobe alias config diff --git a/xCAT-SoftLayer/xCAT-SoftLayer.spec b/xCAT-SoftLayer/xCAT-SoftLayer.spec index 3868e0a09..77aceab5d 100644 --- a/xCAT-SoftLayer/xCAT-SoftLayer.spec +++ b/xCAT-SoftLayer/xCAT-SoftLayer.spec @@ -17,6 +17,8 @@ BuildArch: noarch Requires: xCAT-server #Requires: xCAT-server >= %{epoch}:%(cat Version|cut -d. -f 1,2) +Requires: perl-ExtUtils-MakeMaker perl-CPAN perl-Test-Harness perl-SOAP-Lite + Provides: xCAT-SoftLayer = %{epoch}:%{version} %description