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

This commit is contained in:
mellor 2014-05-14 11:00:57 -04:00
commit 0c668d1cf0
41 changed files with 1509 additions and 245 deletions

View File

@ -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

View File

@ -643,16 +643,11 @@ sub get_nic_ip
{
my $nic;
my %iphash;
my $cmd = "ifconfig -a";
my $result = `$cmd`;
my $mode = "MULTICAST";
my $payingattention=0;
my $interface;
my $keepcurrentiface;
#############################################
# Error running command
#############################################
if ( !$result ) {
return undef;
}
if (xCAT::Utils->isAIX()) {
##############################################################
@ -664,6 +659,14 @@ sub get_nic_ip
# en1: ...
#
##############################################################
my $cmd = "ifconfig -a";
my $result = `$cmd`;
#############################################
# Error running command
#############################################
if ( !$result ) {
return undef;
}
my @adapter = split /(\w+\d+):\s+flags=/, $result;
foreach ( @adapter ) {
if ($_ =~ /^(en\d)/) {
@ -683,44 +686,39 @@ sub get_nic_ip
}
}
}
else {
##############################################################
# Should look like this for Linux:
# eth0 Link encap:Ethernet HWaddr 00:02:55:7B:06:30
# inet addr:9.114.154.193 Bcast:9.114.154.223
# inet6 addr: fe80::202:55ff:fe7b:630/64 Scope:Link
# UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
# RX packets:1280982 errors:0 dropped:0 overruns:0 frame:0
# TX packets:3535776 errors:0 dropped:0 overruns:0 carrier:0
# collisions:0 txqueuelen:1000
# RX bytes:343489371 (327.5 MiB) TX bytes:870969610 (830.6 MiB)
# Base address:0x2600 Memory:fbfe0000-fc0000080
#
# eth1 ...
# Redhat7
#eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
# inet 10.1.0.178 netmask 255.255.0.0 broadcast 10.1.255.255
#
##############################################################
my @adapter= split /\n{2,}/, $result;
foreach ( @adapter ) {
if ( !($_ =~ /LOOPBACK/ ) and
$_ =~ /UP( |,|>)/ and
$_ =~ /$mode/ ) {
my @ip = split /\n/;
for my $ent ( @ip ) {
if ($ent =~ /^(eth\d|ib\d|hf\d)\s+/) {
$nic = $1;
}
if ($ent =~ /^(eth\d:|ib\d:|hf\d:)\s+/) {
$nic = $1;
}
$ent=~ s/addr://; # works for Redhat7 also
if ( $ent =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) {
$iphash{$nic} = $1;
next;
}
else { # linux
my @ipoutput = `ip addr`;
#############################################
# Error running command
#############################################
if ( !@ipoutput ) {
return undef;
}
foreach my $line (@ipoutput) {
if ($line =~ /^\d/) { # new interface, new context..
if ($interface and not $keepcurrentiface) {
#don't bother reporting unusable nics
delete $iphash{$interface};
}
$keepcurrentiface=0;
if ( !($line =~ /LOOPBACK/ ) and
$line =~ /UP( |,|>)/ and
$line =~ /$mode/ ) {
$payingattention=1;
$line =~ /^([^:]*): ([^:]*):/;
$interface=$2;
} else {
$payingattention=0;
next;
}
}
unless ($payingattention) { next; }
if ($line =~ /inet/) {
$keepcurrentiface=1;
}
if ( $line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) {
$iphash{$interface} = $1;
}
}
}
@ -1593,7 +1591,7 @@ sub thishostisnot
#-----------------------------------------------------------------------------
=head3 gethost_ips (AIX and Linux)
Will use ifconfig to determine all possible ip addresses for the
Will use ifconfig or ip addr to determine all possible ip addresses for the
host it is running on and then gethostbyaddr to get all possible hostnames
input:
@ -1608,52 +1606,57 @@ sub gethost_ips
my ($class) = @_;
my $cmd;
my @ipaddress;
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet\"";
if (xCAT::Utils->isLinux()) {
$cmd = "ip addr ";
$cmd = $cmd . "| grep \"inet\"";
} else { # AIX
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet\"";
}
my @result = xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
foreach my $addr (@result)
{
if (xCAT::Utils->isLinux()) {
foreach (@result)
{
my @ip;
if (xCAT::Utils->isLinux())
if (/inet6/)
{
if ($addr =~ /inet6/)
#TODO, Linux ipv6
}
else
{
my @ents = split(/\s+/);
my $ip = $ents[2];
$ip =~ s/\/.*//;
$ip =~ s/\%.*//;
push @ipaddress, $ip;
}
}
} else { #AIX
foreach my $addr (@result)
{
if ($addr =~ /inet6/)
{
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
my $v6ip = $1;
my $v6mask = $2;
if ($v6ip)
{
#TODO, Linux ipv6
}
else
{
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
#@ip = split(":", $addr1);
#push @ipaddress, $ip[1];
$addr1 =~ s/.*://;
push @ipaddress, $addr1;
push @ipaddress, $v6ip;
}
}
else
{ #AIX
if ($addr =~ /inet6/)
{
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
my $v6ip = $1;
my $v6mask = $2;
if ($v6ip)
{
push @ipaddress, $v6ip;
}
}
else
{
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
push @ipaddress, $addr1;
}
{
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
push @ipaddress, $addr1;
}
}
}
my @names = @ipaddress;
foreach my $ipaddr (@names)
@ -1844,100 +1847,6 @@ sub validate_ip
return([0]);
}
#-------------------------------------------------------------------------------
=head3 getFacingIP
Gets the ip address of the adapter of the localhost that is facing the
the given node.
Assume it is the same as my_ip_facing...
Arguments:
The name of the node that is facing the localhost.
Returns:
The ip address of the adapter that faces the node.
=cut
#-------------------------------------------------------------------------------
sub getFacingIP
{
my ($class, $node) = @_;
my $ip;
my $cmd;
my @ipaddress;
my $nodeip = inet_ntoa(inet_aton($node));
unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/)
{
return 0; #Not supporting IPv6 here IPV6TODO
}
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet \"";
my @result = xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
# split node address
my ($n1, $n2, $n3, $n4) = split('\.', $nodeip);
foreach my $addr (@result)
{
my $ip;
my $mask;
if (xCAT::Utils->isLinux())
{
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
if ((!$addr1) || (!$Mask)) { next; }
my @ips = split(":", $addr1);
my @masks = split(":", $Mask);
$ip = $ips[1];
$mask = $masks[1];
}
else
{ #AIX
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
if ((!$addr1) && (!$mask1)) { next; }
$ip = $addr1;
$mask1 =~ s/0x//;
$mask =
`printf "%d.%d.%d.%d" \$(echo "$mask1" | sed 's/../0x& /g')`;
}
if ($ip && $mask)
{
# split interface IP
my ($h1, $h2, $h3, $h4) = split('\.', $ip);
# split mask
my ($m1, $m2, $m3, $m4) = split('\.', $mask);
# AND this interface IP with the netmask of the network
my $a1 = ((int $h1) & (int $m1));
my $a2 = ((int $h2) & (int $m2));
my $a3 = ((int $h3) & (int $m3));
my $a4 = ((int $h4) & (int $m4));
# AND node IP with the netmask of the network
my $b1 = ((int $n1) & (int $m1));
my $b2 = ((int $n2) & (int $m2));
my $b3 = ((int $n3) & (int $m3));
my $b4 = ((int $n4) & (int $m4));
if (($b1 == $a1) && ($b2 == $a2) && ($b3 == $a3) && ($b4 == $a4))
{
return $ip;
}
}
}
xCAT::MsgUtils->message("S", "Cannot find master for the node $node\n");
return 0;
}
#-------------------------------------------------------------------------------

View File

@ -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

View File

@ -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

View File

@ -207,7 +207,7 @@ sub modifyAutoinstFiles {
# Copy softlayer specific systemimager post-install scripts to the systemimager location.
# These cause si to use static ip and insert a wait into the bring up of the network.
sub copySyscloneFiles {
my $cmd = "cp -f /opt/xcat/share/xcat/sysclone/post-install/* /install/sysclone/scripts/post-install";
my $cmd = "cp -f /opt/xcat/share/xcat/sysclone/post-install/16all.updatenetwork /install/sysclone/scripts/post-install";
print "Copying SoftLayer-specific post scripts to the SystemImager post-install directory.\n";
runcmd($cmd);
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -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

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

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

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");
}
}
}
@ -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");
}
}

View File

@ -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})
{

View File

@ -742,6 +742,12 @@ sub copycd
$darch = "x86_64";
} elsif (/BuildBranch=win7_rtm/){
$distname = "win7";
} elsif (/BuildBranch=winblue_rtm/){
if (-r $mntpath . "/sources/background_svr.bmp") {
if (! -r $mntpath . "/sources/EI.CFG") {
$distname = "win2012r2";
}
}
} elsif (/BuildBranch=win8_rtm/){
if (-r $mntpath . "/sources/background_cli.bmp") {
$distname = "win8";

View File

@ -2,6 +2,7 @@
#cmdline
lang en_US
#KICKSTARTNET#
#
# Where's the source?

View File

@ -3,6 +3,7 @@
#cmdline
lang en_US
#KICKSTARTNET#
#
# Where's the source?

View File

@ -2,6 +2,8 @@
# Setup hostname
#
echo "post scripts" >/root/post.log
export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic#
if [ "$PRINIC" == "mac" ]
then

View File

@ -1,5 +1,5 @@
#!/bin/sh
export MANAGEDADDRESSMODE="#XCATVAR:MANAGEDADDRESSMODE#"
export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE#
cd /etc/sysconfig/network

View File

@ -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 <<EOF
#!/usr/bin/python

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,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

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
}
@ -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;
}
}

503
xCAT-test/restapitest Executable file
View File

@ -0,0 +1,503 @@
#!/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;
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} = 1;
}
return \%hash;
}
}
}
############################
# check curl running code #
############################
sub check_errcode
{
if(!open (ERRLOG, "</tmp/err.log")) {
log_me("can't open err.log in tmp");
return 1;
}
my $num;
while (<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 (<OUTPUT>) {
$res .= $_;
}
close OUTPUT;
my $expects = transf_hash(parse_json($data)); # one entry
my $actuals = transf_hash(parse_json($res)); # serval entries
print_debug("expected result is:\n");
print_debug($expects);
print_debug("testcase run result is \n");
print_debug($actuals);
my $flag = 0;
my %flaghash;
my $expect = $$expects[0]; # $expect = ANY:ANY:x86_64
my @expectvalue = split /:/, $expect; #@expectvalue = ANY, ANY, x86_64
$flag = 0;
foreach my $expval (@expectvalue) { # $expval = ANY
foreach my $actual (@$actuals) { # $actual = nodetype:arch:x86_64
if($flaghash{$actual} eq "none"){
next;
}
my @actualvalue = split /:/, $actual; # @actualvalue = nodetype, arch, x86_64
print_debug("begin to compare $expval and $actualvalue[$flag]");
if(($expval eq $actualvalue[$flag]) or ($expval eq "ANY")) { #ANY =~ nodetype
$flaghash{$actual} = "eq";
} elsif (($expval =~ $actualvalue[$flag]) or ($expval eq "ANY")) {
$flaghash{$actual} = "match";
} else {
$flaghash{$actual} = "none";
}
print_debug(", compare result is $flaghash{$actual}\n");
}
$flag++;
}
print_debug("search result is \n");
print_debug(\%flaghash);
if ($opterator eq "!="){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "eq") {
print_debug("compare result: failed\n");
return 1; # fail
}
}
print_debug("compare result: succeed\n");
return 0; #succeed
}
if ($opterator eq "=="){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "eq") {
print_debug("compare result: succeed\n");
return 0; # succeed
}
}
print_debug("compare result: failed\n");
return 1; #fail
}
if ($opterator eq "=~"){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "match") {
print_debug("compare result: succeed\n");
return 0; # succeed
}
}
print_debug("compare result: failed\n");
return 1; #fail
}
if ($opterator eq "!=~"){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "match") {
print_debug("compare result: failed\n");
return 1; # fail
}
}
print_debug("compare result: succeed\n");
return 0; #succeed
}
}
####################################
# help to transfer hash into array #
####################################
sub find_key
{
my $input = shift;
my $en = shift;
my $ou = shift;
if( ref($input) =~ "HASH") {
foreach my $val (keys %$input) {
my $tmp = $$en; # keey head
$$en .= "$val:";
my $t1 = find_key($$input{$val}, $en, $ou);
if ($$en == ""){
$$en = $tmp; #restore head
}
}
} else {
$$en .= $input;
push @$ou, $$en;
$$en = ""; # clear entry;
}
}
############################
# transfer hash into array #
############################
sub transf_hash
{
my $input = shift;
my $entry;
my @array;
find_key($input, \$entry, \@array);
return \@array;
}

View File

@ -39,6 +39,7 @@ pod2html pods/man1/xcattest.1.pod > share/doc/man1/xcattest.1.html
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
mkdir -p $RPM_BUILD_ROOT/%{prefix}/sbin
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools/autotest
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
@ -46,6 +47,9 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
cp xcattest $RPM_BUILD_ROOT/%{prefix}/bin
chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
cp restapitest $RPM_BUILD_ROOT/%{prefix}/sbin
chmod 755 $RPM_BUILD_ROOT/%{prefix}/sbin/*
# These were built dynamically in the build phase
cp share/man/man1/* $RPM_BUILD_ROOT/%{prefix}/share/man/man1
chmod 444 $RPM_BUILD_ROOT/%{prefix}/share/man/man1/*

View File

@ -25,10 +25,10 @@ my $string1 = undef;
if (
!GetOptions("h|?" => \$needhelp,
"f=s" => \$configfile,
"b=s" => \$bundle_list,
"t=s" => \$case_list,
"c=s" => \$cmd_list,
"l" => \$needshow,
"b=s" => \$bundle_list,
"t=s" => \$case_list,
"c=s" => \$cmd_list,
"l" => \$needshow,
"restore"=>\$restore)
)
{
@ -221,7 +221,7 @@ sub getConfig
}
}
}
if(exists $config{object}){
foreach my $type (keys %{$config{object}}){
foreach my $name (keys %{$config{object}{$type}}){
@ -344,7 +344,7 @@ sub init
log_this("No compute node defined,can't get ARCH of compute node");
} else {
$config{var}{ARCH} = getnodeattr($config{var}{CN},"arch");
if($config{var}{ARCH} =~ /ppc/){
if($config{var}{ARCH} =~ /ppc/){
$config{var}{ARCH} = 'ppc';
}elsif($config{var}{ARCH}=~/86/){
$config{var}{ARCH} = 'x86';
@ -432,7 +432,7 @@ sub loadcase
my $j = -1;
my $z = 0;
my $skip = 0;
my @caserange = ();
my @rightcase = ();
my @notrightcase = ();
@ -452,7 +452,7 @@ sub loadcase
}
}
if($case_list){
@caserange = split /,/, $case_list;
@caserange = split /,/, $case_list;
}
foreach $file (@files){
if(!open(FILE, "<$file")){
@ -498,13 +498,13 @@ sub loadcase
$cases[$i]->{os}=$string1;
}
if($cases[$i]->{os} !~ /$config{var}{OS}/){
push(@notrightcase, $cases[$i]->{name});
pop(@rightcase);
$skip = 1;
}
}elsif($line =~ /^arch\s*:\s*(\w[\w\,]+)/){
next if $skip;
$cases[$i]->{arch}=$1;
@ -631,7 +631,7 @@ sub getfunc
$func = $1;
$parameter = $2;
@para = split /\s*,\s*/, trim($parameter);
if($func eq "GETNODEATTR"){
if($func eq "GETNODEATTR"){
$value= getnodeattr(@para);
if($value eq "Unknown"){
$value = '';
@ -669,9 +669,9 @@ sub runcase
my $time1=gmtime $now1;
log_this("------START:$$case{name}::Time:$time1------");
push @record, "------START:$$case{name}::Time:$time1------";
push @record, "FILENAME:$$case{filename}";
push @record, "FILENAME:$$case{filename}";
foreach my $cmd (@{$$case{cmd}}){
$cmd = getfunc($cmd);
$cmd = getfunc($cmd);
#by
my $runstart=timelocal(localtime());
@ -684,10 +684,10 @@ sub runcase
my $diffduration=$runstop-$runstart;
log_this("\n[$cmd] Running Time:$diffduration sec");
push(@record,("\n[$cmd] Running Time:$diffduration sec"));
log_this("RETURN: rc = $rc","OUTPUT:",@output);
push(@record,("RETURN rc = $rc","OUTPUT:",@output));
foreach my $check (@{$$case{check}->[$j]}){
if($failed){
@ -766,7 +766,17 @@ sub runcase
}
}
foreach my $cmdcheck (@{$$case{cmdcheck}->[$j]}){
&runcmd($cmdcheck);
if($cmdcheck) {
&runcmd($cmdcheck);
$rc = $::RUNCMD_RC;
if($rc == 1) {
log_this("CMDCHECK:output $cmdcheck\t[Failed]");
push(@record, "CHECK:output $cmdcheck\t[Failed]");
} elsif ($rc == 0) {
log_this("CMDCHECK:output $cmdcheck\t[Pass]");
push(@record, "CHECK:output $cmdcheck\t[Pass]");
}
}
}
$j = $j + 1;
}
@ -798,6 +808,7 @@ sub runcmd
if ($?)
{
$rc = $? ;
$rc = $rc >> 8;
$::RUNCMD_RC = $rc;
}
chomp(@$outref);
@ -835,3 +846,5 @@ sub getreport
close(FD);
close(STDOUT);
}

View File

@ -5,4 +5,5 @@ install/prescripts
install/kdump
opt/xcat/share/xcat
etc/apache2/conf.d
etc/apache2/conf-enabled
opt/xcat/share/doc/packages/xCAT

View File

@ -1,5 +1,5 @@
xcat.conf etc/apache2/conf.d/
xcat.conf.apach24 etc/apache2/conf.d/
xcat.conf.apach24 etc/apache2/conf-enabled
LICENSE.html opt/xcat/share/doc/packages/xCAT
postscripts/* install/postscripts/
prescripts/* install/prescripts/

View File

@ -40,12 +40,9 @@ case "$1" in
else
xcatconfig -i -d -s
fi
ver=$(cat /etc/issue |awk '{print $2}')
num=${ver%.*}
file="xcat.conf.apach24"
if [ $num -gt 12 ];then
mv /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf-enabled/
fi
# [ -e /etc/apache2/conf-enabled/xcat.conf ] && rm /etc/apache2/conf-enabled/xcat.conf
# mv /etc/apache2/conf-enabled/xcat.conf.apach24 /etc/apache2/conf-enabled/xcat.conf
/etc/init.d/apache2 restart
;;

View File

@ -335,7 +335,8 @@ elif [ "$1" = "-s" ];then
if [ -n "$MACADDRESS" ];then
str_inst_mac=$MACADDRESS
else
str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'`
#str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'`
str_inst_mac=`ip link show $netdev | grep ether | awk '{print $2}'`
fi
if [ -z "$str_inst_ip" -o -z "$str_inst_mask" ];then

View File

@ -1,4 +1,4 @@
#!/bin/sh
PREFIXMASK#!/bin/sh
# pmatch determines if 1st argument string is matched by 2nd argument pattern
pmatch ()
@ -9,6 +9,18 @@ pmatch ()
return 1 # non-zero return code means string not matched by pattern
}
# converts netmask CIDR fromat to x.x.x.x mask value
maskfromprefix ()
{
prefixlen=$1
maskval=$((0xffffffff>>(32-prefixlen)<<(32-prefixlen)))
mask1=$((maskval >> 24))
mask2=$((maskval >> 16 & 0xff))
mask3=$((maskval >> 8 & 0xff))
mask4=$((maskval & 0xff))
echo $mask1.$mask2.$mask3.$mask4
NETMASK=$mask1.$mask2.$mask3.$mask4
}
network_ipv4calc ()
{
@ -56,9 +68,12 @@ else
echo "GATEWAY=$defgw" >> /etc/sysconfig/network
fi
fi
for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep -v -- --|grep -v lo`; do
IPADDR=`ifconfig $nic |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}'`
NETMASK=`ifconfig $nic |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'`
for nic in `ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://`; do
IPADDRMASK=`ip addr show dev $nic | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1`
IPADDR=`echo $IPADDRMASK | awk -F'/' '{print $1}'`
PREFIXMASK=`echo $IPADDRMASK | awk -F'/' '{print $2}'`
# converts to x.x.x.x mask value
maskfromprefix $PREFIXMASK
if ( pmatch $OSVER "ubuntu*" )
then
NETWORK=`network_ipv4calc $IPADDR $NETMASK`
@ -69,7 +84,7 @@ for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep
else
gateway_line=""
fi
# add info to interfaces file on ubuntu, TBD does unbuntu change to systemd, this will not exist
cat >>/etc/network/interfaces <<EOF
auto $nic
iface $nic inet static
@ -81,12 +96,14 @@ iface $nic inet static
EOF
# not ubuntu
else
if [ -f ${NICFILEPRE}${nic} ]
then
NICFILE=${NICFILEPRE}${nic}
else
mac=`ifconfig $nic|grep HWaddr|awk '{print $5}'|tr "[A-Z]" "[a-z]"`
#mac=`ifconfig $nic|grep HWaddr|awk '{print $5}'|tr "[A-Z]" "[a-z]"`
mac=`ip link show $nic | grep ether | awk '{print $2}'`
NICFILE=${NICFILEPRE}eth-id-${mac}
fi
sed -i s/BOOTPROTO=dhcp/BOOTPROTO=static/ $NICFILE

0
xCAT/postscripts/setupesx Normal file → Executable file
View File

View File

@ -10,7 +10,7 @@
# Change these two parameters according to your requirements
$::NFSRETRIES = 3;
$::NFSTIMEO = 10;
$::NFSTIMEO = 50;
# Candidate commands: mount, df, lsfs, nfs4cl showfs
# Only the mount command could list all file systems

View File

@ -11,7 +11,8 @@ hostname $HOSTNAME
#write the config files, the device name may change after reboot
#so use the dhcp for all interface
device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'`
#device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'`
device_names=`ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://`
str_cfg_file=''
if [ -d "/etc/sysconfig/network-scripts/" ];then
#redhat