11 Commits

Author SHA1 Message Date
1a2fd2f436 routeop: for replace operator, convert dotted-decimal netmask to CIDR format 2014-07-10 11:34:09 +01:00
8d7cda14ab defect 4035 fix merge error in previous checkin to handle multiple servicenode entries 2014-07-09 12:09:42 +01:00
028cea62e1 defect 4035 handle multiple servicenode entries 2014-07-09 12:09:21 +01:00
ef9955b577 defect 4111: enhance the [routeop replace] to support redhat and sles. /etc/sysconfig/network-scripts/route-ifname is used for redhat to store the persistent route setting. The ip command is used to replace route command. 2014-07-04 00:35:03 +01:00
63168b5b12 support replace operation for routeop postscript. So far only supports the persistent route setting for sles. 2014-07-04 00:34:39 +01:00
94e5ed288d Change the default operator of setroute script to be replace from add. If you want to use add, run it as [setroute add] 2014-07-04 00:31:04 +01:00
1350a6faea correct xCATsn.spec to support apache2/httpd 2.4.x 2014-06-09 12:30:46 +01:00
372a6ab44a correct the build spec and script
Conflicts:
	xCAT/xCAT.spec
2014-06-09 12:29:42 +01:00
a2c2f2010a fix defect #4145 [DEV] /etc/httpd/conf.d/xcat.conf is missing after xcat upgrade
Conflicts:
	xCAT/xCAT.spec
2014-06-07 22:27:45 +01:00
9738889e22 Change version to 2.8.4ocf, so that it is distinct 2014-05-23 09:27:16 +01:00
4788142cab add per node consoleondemand 2014-05-23 09:27:03 +01:00
9 changed files with 535 additions and 103 deletions

View File

@ -1 +1 @@
2.8.4
2.8.4ocf

View File

@ -85,6 +85,7 @@ function makexcat {
cd `dirname $0`/$RPMNAME
tar --exclude .svn -czf $RPMROOT/SOURCES/license.tar.gz LICENSE.html
cp xcat.conf $RPMROOT/SOURCES
cp xcat.conf.apach24 $RPMROOT/SOURCES
cp xCATSN $RPMROOT/SOURCES
cd - >/dev/null
elif [ "$RPMNAME" = "xCAT-buildkit" ]; then

View File

@ -532,7 +532,7 @@ nodegroup => {
},
},
nodehm => {
cols => [qw(node power mgt cons termserver termport conserver serialport serialspeed serialflow getmac cmdmapping comments disable)],
cols => [qw(node power mgt cons termserver termport conserver serialport serialspeed serialflow getmac cmdmapping consoleondemand comments disable)],
keys => [qw(node)],
tablespace =>'XCATTBS16K',
table_desc => "Settings that control how each node's hardware is managed. Typically, an additional table that is specific to the hardware type of the node contains additional info. E.g. the ipmi, mp, and ppc tables.",
@ -549,6 +549,7 @@ nodehm => {
serialflow => "The flow control value of the serial port for this node. For SOL this is typically 'hard'.",
getmac => 'The method to use to get MAC address of the node with the getmac command. If not set, the mgt attribute will be used. Valid values: same as values for mgmt attribute.',
cmdmapping => 'The fully qualified name of the file that stores the mapping between PCM hardware management commands and xCAT/third-party hardware management commands for a particular type of hardware device. Only used by PCM.',
consoleondemand => 'This overrides the value from site.consoleondemand; (0=no, 1=yes). Default is the result from site.consoleondemand.',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
@ -1933,6 +1934,10 @@ my @nodeattrs = (
{attr_name => 'serialflow',
tabentry => 'nodehm.serialflow',
access_tabentry => 'nodehm.node=attr:node',
},
{attr_name => 'consoleondemand',
tabentry => 'nodehm.consoleondemand',
access_tabentry => 'nodehm.node=attr:node',
},
##################
# vpd table #

View File

@ -12,6 +12,7 @@ use strict;
use Data::Dumper;
my @cservers = qw(mrv cyclades);
my %termservers; #list of noted termservers
my $siteondemand; # The site value for consoleondemand
my $usage_string=
" makeconservercf [-d|--delete] noderange
@ -276,6 +277,10 @@ sub docfheaders {
my $site_entry = $entries[0];
if ( defined($site_entry) and $site_entry eq "yes" ) {
push @newheaders," options ondemand;\n";
$siteondemand=1;
}
else {
$siteondemand=0;
}
push @newheaders,"}\n";
@ -322,7 +327,7 @@ sub makeconservercf {
my $hmtab = xCAT::Table->new('nodehm');
my @cfgents1;# = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport']);
if (($nodes and @$nodes > 0) or $req->{noderange}->[0]) {
@cfgents1 = $hmtab->getNodesAttribs($nodes,['node','cons','serialport','mgt','conserver','termserver','termport']);
@cfgents1 = $hmtab->getNodesAttribs($nodes,['node','cons','serialport','mgt','conserver','termserver','termport','consoleondemand']);
# Adjust the data structure to make the result consistent with the getAllNodeAttribs() call we make if a noderange was not specified
my @tmpcfgents1;
foreach my $ent (@cfgents1)
@ -335,7 +340,7 @@ sub makeconservercf {
@cfgents1 = @tmpcfgents1
} else {
@cfgents1 = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport']);
@cfgents1 = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport','consoleondemand']);
}
@ -538,6 +543,14 @@ foreach my $node (sort keys %$cfgenthash) {
push @$content," exec $locerror".$::XCATROOT."/share/xcat/cons/".$cmeth." ".$node.";\n"
}
}
if (defined($cfgent->{consoleondemand})) {
if ($cfgent->{consoleondemand} && !$siteondemand ) {
push @$content," options ondemand;\n";
}
elsif (!$cfgent->{consoleondemand} && $siteondemand ) {
push @$content," options !ondemand;\n";
}
}
push @$content,"}\n";
push @$content,"#xCAT END $node CONS\n";
}

View File

@ -4,11 +4,13 @@
# This plugin is used to handle the command requests for Xeon Phi (mic) support
#
package xCAT_plugin::mic;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
use strict;
use Getopt::Long;
@ -613,6 +615,28 @@ sub rflash {
my @args = ("-s", "-v", "-e");
push @args, "$::XCATROOT/sbin/flashmic";
my $master = $request->{'_xcatdest'};
# in case there are multiple servicenode entries, assume the first entry
# is the master
($master) = split (/,/,$master);
# 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");
@ -913,6 +937,27 @@ sub nodeset {
my @args = ("-s", "-v", "-e");
push @args, "$::XCATROOT/sbin/configmic";
my $master = $request->{'_xcatdest'};
# in case there are multiple servicenode entries, assume the first entry
# is the master
($master) = split (/,/,$master);
# 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");

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# IBM(c) 2011EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------------------------------
@ -6,10 +6,26 @@
#=head2 routeop is called by makeroutes command and setuproutes postscript to
# setup a route on a node.
# The syntax is:
# routeop add/delete net mask gateway ifname
# routeop add/delete net mask gateway ifnamea #NOTE: the add/delete will be
# obsoleted, using 'replace' is recommended.
# routeop replace net mask gateway ifname #NOTE: it only works for sles so far
# net - IP of net like 192.168.1.0. The keyword
# 'default' is used to set the default route.
# mask - The length of the netmask (CIDR) like 8,16,24 OR
# the dotted-decimal format like 255.255.0.0
# gateway - The next hop. It could be set to 0.0.0.0 for omitting
# ifname - The interface to route to the next hop
#=head3 example
# routeop replace default 0 10.1.0.209 eth0
# routeop replace 50.1.0.0 16 10.1.0.210 eth0
# routeop replace 60.1.1.0 24 0.0.0.0 eth0
# routeop replace 70.1.1.0 24 10.1.0.211 #NOTE: this is NOT supported for redhat
#=cut
#-------------------------------------------------------------------------------
str_dir_name=`dirname $0`
. $str_dir_name/xcatlib.sh
op=$1
net=$2
@ -19,6 +35,25 @@ if [ -n "$5" ]; then
ifname=$5
fi
# use nummask to know whether the netmask format is 255.255.255.0 or CIDR (a number)
nummask=0
echo $mask | egrep "^[.0123456789]+$" > /dev/null
if [ $? -ne 0 ]; then
echo "Error: invalid format of netmask $mask."
exit 1
else
echo $mask | egrep "^[0123456789]+$" > /dev/null
if [ $? -eq 0 ]; then # only has digital
nummask=1 # the netmask is the length of network mask.
if [ $mask -ge 128 ]; then
echo "Error: invalid format of netmask $mask."
exit 1
fi
fi
fi
function debianpreconf(){
#create the config sub dir
if [ ! -d "/etc/network/interfaces.d" ];then
@ -143,6 +178,238 @@ route_exists()
echo $ret
}
# handle the route replace operation that adding the setting to configuration file
replace_persistent_route()
{
net=$1;
mask=$2;
gw=$3;
if [ -n "$4" ]; then
ifname=$4
fi
if [ "$(uname -s)" = "Linux" ]; then
#determine the os name
OS_name="something"
if [ -f /etc/redhat-release ]
then
OS_name="redhat" #it can be RedHatFerdora or CentOS
elif [ -f /etc/SuSE-release ]
then
OS_name="sles"
else
OS_name="debian"
fi
# The replace operation does not support debain so far
if [ "$OS_name" != "redhat" ] && [ "$OS_name" != "sles" ]; then
echo "Warning: replace operation only supports to add persistent route for sles and redhat by now."
return
fi
# set the destination of the route for searching in the route configuration file
if [ "$net" = "default" ]; then
routedest="default"
routedest1="default"
else
routedest="$net/$mask"
routedest1="$net\/$mask"
fi
case $OS_name in
sles)
filename="/etc/sysconfig/network/routes";
if echo $net | grep : 2>&1 1>/dev/null
then
# for ipv6
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$net/$mask :: - $ifname"
route1="$net\/$mask :: - $ifname";
else
route="$net/$mask $gw - -"
route1="$net\/$mask $gw - -";
fi
else
# for ipv4
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ "$net" = "default" ]; then
route="default - - $ifname";
route1="default - - $ifname";
else
route="$net/$mask - - $ifname";
route1="$net\/$mask - - $ifname";
fi
else
if [ "$net" = "default" ]; then
route="default $gw - $ifname";
route1="default $gw - $ifname";
else
route="$net/$mask $gw - $ifname";
route1="$net\/$mask $gw - $ifname";
fi
fi
fi
if [ -f $filename ]; then
egrep "^$routedest" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #route does not exist
echo $route >> $filename
echo "Persistent route \"$route\" has been added in $filename."
else
# replace it
sed -i -e "s/$routedest1.*/$route1/g" $filename
echo "Persistent route \"$route\" has been replaced in $filename."
fi
else
echo "$route" > $filename
echo "Persistent route \"$route\" has been added in $filename."
fi
;;
redhat)
#echo "rh/fedora/centos"
if [ -z "$ifname" ]; then
echo "Error: the device name is necessary to configure static route."
return
fi
if echo $net | grep : 2>&1 1>/dev/null
then
# ipv6
filename="/etc/sysconfig/network-scripts/route6-$ifname"
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$net/$mask dev $ifname"
route1="$net\/$mask dev $ifname"
else
route="$net/$mask via $gw"
route1="$net\/$mask via $gw"
fi
else
# ipv4
filename="/etc/sysconfig/network-scripts/route-$ifname"
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
route="$net/$mask dev $ifname"
route1="$net\/$mask dev $ifname"
else
route="$net/$mask via $gw"
route1="$net\/$mask via $gw"
fi
fi
if [ -f $filename ]; then
egrep "^$routedest" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #route does not exist
echo $route >> $filename
echo "Persistent route \"$route\" has been added in $filename."
else
# replace it
sed -i -e "s/$routedest1.*/$route1/g" $filename
echo "Persistent route \"$route\" has been replaced in $filename."
fi
else
echo "$route" > $filename
echo "Persistent route \"$route\" has been added in $filename."
fi
;;
debian)
debianpreconf
matchstr=""
v6flag=0
#on debian/ubuntu need the network device name
if [ ! $ifname ];then
ifname=`netstat -nr | grep "$net" | awk '{print $8}' | head -1`
fi
filename="/etc/network/interfaces.d/$ifname"
if [ ! -f $filename ];then
echo "auto $ifname" > $filename
echo "iface $ifname inet dhcp" >> $filename
fi
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
matchstr="$net/$mask gw $gw"
fi
v6flag=1
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
matchstr="net $net netmask $mask dev $ifname"
else
matchstr="net $net netmask $mask gw $gw"
fi
fi
grep "$matchstr" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ];then
foundflag=0
tempfile="/etc/network/interfaces.d/tmp"
while read LINE
do
echo $LINE | grep "iface" 2>&1 1>/dev/null
if [ $? -eq 0 -a $foundflag -eq 1 ];then
foundflag=0
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null
#this is the last line of the device
if [ $? -eq 0 ];then
foundflag=1
fi
echo $LINE >> $tempfile
done < $filename
#the insert place is the last line of the config file
if [ $foundflag -eq 1 ];then
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
mv -f $tempfile $filename
echo "Persistent route \"$matchstr\" added in $filename."
else
echo "Persisten route \"$match\" already exists in $filename"
fi
;;
esac
else #AIX
echo "Adding persistent route on AIX is not supported yet."
fi
}
# handle the route add operation that adding the setting to configuration file
add_persistent_route()
{
net=$1;
@ -168,6 +435,14 @@ add_persistent_route()
OS_name="debian"
fi
# The replace operation does not support redhat and debain so far
if [ "$op" = "replace" ]; then
if [ "$OS_name" = "redhat" -o "$OS_name" = "debain" ]; then
echo "Warning: replace operation only supports to add persistent route for sles by now."
return
fi
fi
case $OS_name in
sles)
#echo "sles"
@ -175,36 +450,56 @@ add_persistent_route()
filename="/etc/sysconfig/network/routes";
if echo $net | grep : 2>&1 1>/dev/null
then
if [ $gw_ip = "" -o $gw_ip = "::" ] ; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$net/$mask :: - $ifname"
route1="$net\/$mask :: - $ifname";
else
else
route="$net/$mask $gw - -"
route1="$net\/$mask $gw - -";
fi
fi
else
if [ $gw_ip = "" -o $gw_ip = "0.0.0.0" ] ; then
route="$net 0.0.0.0 $mask $ifname";
route1="$net 0.0.0.0 $mask $ifname";
else
route="$net $gw $mask $ifname";
route1="$net $gw $mask $ifname";
fi
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ $nummask -eq 1 ]; then
if [ "$net" = "default" ]; then
route="default - - $ifname";
route1="default - - $ifname";
else
route="$net/$mask - - $ifname";
route1="$net\/$mask - - $ifname";
fi
else
route="$net 0.0.0.0 $mask $ifname";
route1="$net 0.0.0.0 $mask $ifname";
fi
else
if [ $nummask -eq 1 ]; then
if [ "$net" = "default" ]; then
route="default $gw - $ifname";
route1="default $gw - $ifname";
else
route="$net/$mask $gw - $ifname";
route1="$net\/$mask $gw - $ifname";
fi
else
route="$net $gw $mask $ifname";
route1="$net $gw $mask $ifname";
fi
fi
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #route does not exist
grep "$xcat_config_start" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #no xCAT section
echo $xcat_config_start >> $filename
echo $route >> $filename
echo $xcat_config_end >> $filename
else
sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename
fi
echo "Persistent route \"$route\" added in $filename."
grep "$xcat_config_start" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #no xCAT section
echo $xcat_config_start >> $filename
echo $route >> $filename
echo $xcat_config_end >> $filename
else
sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename
fi
echo "Persistent route \"$route\" added in $filename."
else
echo "Persistent route \"$route\" already exists in $filename."
echo "Persistent route \"$route\" already exists in $filename."
fi
else
#echo "got here"
@ -232,18 +527,18 @@ add_persistent_route()
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
else
matchstr="$net/$mask gw $gw"
fi
v6flag=1
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
matchstr="net $net netmask $mask dev $ifname"
else
else
matchstr="net $net netmask $mask gw $gw"
fi
fi
fi
grep "$matchstr" $filename 2>&1 1>/dev/null
@ -256,21 +551,21 @@ add_persistent_route()
if [ $? -eq 0 -a $foundflag -eq 1 ];then
foundflag=0
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
fi
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
fi
echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null
@ -284,21 +579,21 @@ add_persistent_route()
#the insert place is the last line of the config file
if [ $foundflag -eq 1 ];then
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
fi
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
fi
mv -f $tempfile $filename
@ -313,7 +608,7 @@ add_persistent_route()
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$gw" = "" ] ; then
$gw = "::";
$gw = "::";
fi
filename="/etc/sysconfig/static-routes-ipv6";
route="$ifname $net/$mask $gw";
@ -324,10 +619,10 @@ add_persistent_route()
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
route="any net $net netmask $mask dev $ifname";
route1="any net $net netmask $mask dev $ifname";
else
else
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
fi
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -387,16 +682,16 @@ rm_persistent_route()
# ipv6 net
if echo $net | grep : 2>&1 1>/dev/null
then
if [ $gw = "" -o $gw = "::" ] ; then
if [ $gw = "" -o $gw = "::" ] ; then
route="$net/$mask :: - $ifname";
route1="$net\/$mask :: - $ifname";
else
else
route="$net/$mask $gw - -";
route1="$net\/$mask $gw - -";
fi
fi
else
if [ $gw = "" ] ; then
$gw = "0.0.0.0";
if [ $gw = "" ] ; then
$gw = "0.0.0.0";
fi
if [ -n "$ifname" ]; then
route="$net $gw $mask $ifname";
@ -431,18 +726,18 @@ rm_persistent_route()
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
if [ $gw = "" -o $gw = "::" ] ; then
if [ $gw = "" -o $gw = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
else
matchstr="$net/$mask gw $gw"
fi
fi
v6flag=1
else
if [ $gw = "" -o $gw = "0.0.0.0" ] ; then
if [ $gw = "" -o $gw = "0.0.0.0" ] ; then
matchstr="net $net netmask $mask dev $ifname"
else
else
matchstr="net $net netmask $mask gw $gw"
fi
fi
fi
grep "$matchstr" $filename
@ -463,10 +758,10 @@ rm_persistent_route()
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$ifname $net\/$mask ::"
route1="$ifname $net/$mask ::"
else
else
route="$ifname $net\/$mask $gw"
route1="$ifname $net/$mask $gw"
fi
fi
else
filename="/etc/sysconfig/static-routes";
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
@ -504,22 +799,22 @@ if [ "$op" = "add" ]; then
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
cmd="ip -6 route add $net/$mask dev $ifname"
else
else
cmd="ip -6 route add $net/$mask via $gw"
fi
fi
else
# AIX TODO
cmd="ip -6 route add $net/$mask via $gw"
fi
else
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
cmd="route add -net $net netmask $mask dev $ifname"
else
else
cmd="route add -net $net netmask $mask gw $gw"
fi
fi
else
cmd="route add -net $net -netmask $mask $gw"
fi
@ -553,22 +848,22 @@ elif [ "$op" = "delete" ]; then
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
cmd="ip -6 route delete $net/$mask dev $ifname"
else
else
cmd="ip -6 route delete $net/$mask via $gw"
fi
fi
else
# AIX TODO
cmd="ip -6 route delete $net/$mask via $gw"
fi
else
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
cmd="route delete -net $net netmask $mask dev $ifname"
else
else
cmd="route delete -net $net netmask $mask gw $gw"
fi
fi
else
cmd="route delete -net $net -netmask $mask $gw"
fi
@ -587,5 +882,57 @@ elif [ "$op" = "delete" ]; then
#remove the persistent route
rm_persistent_route $net $mask $gw $ifname
elif [ "$op" = "replace" ]; then
if [ $nummask -ne 1 ]; then
mask=$(v4mask2prefix $mask)
fi
if echo $net | grep : 2>&1 1>/dev/null
then # ipv6
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
if [ "$net" = "default" ]; then
cmd="ip -6 route replace default dev $ifname"
else
cmd="ip -6 route replace $net/$mask dev $ifname"
fi
else
if [ "$net" = "default" ]; then
cmd="ip -6 route replace default via $gw"
else
cmd="ip -6 route replace $net/$mask via $gw"
fi
fi
fi
else #ipv4
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ "$net" = "default" ]; then
cmd="ip route replace default dev $ifname"
else
cmd="ip route replace $net/$mask dev $ifname"
fi
else
if [ "$net" = "default" ]; then
cmd="ip route replace default via $gw"
else
cmd="ip route replace $net/$mask via $gw"
fi
fi
fi
fi
echo "Adding temporary route: $cmd"
result=`$cmd 2>&1`
code=$?
if [ $code -ne 0 ]; then
logger -t xCAT -p local4.err "Error: $cmd [error code=$code, result=$result]"
echo "Error: $cmd [error code=$code, result=$result]"
exit 1;
fi
#replace the persistent route
replace_persistent_route $net $mask $gw $ifname
fi
exit 0

View File

@ -2,8 +2,11 @@
# IBM(c) 2011 EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------------------------------
#=head1 setroute
#=head2 setrout command adds the routes to the node according to
#=head1 setroute [add]
# [add] - The operation to manipulate the route entry. It is optional.
# The default is 'replace' if ignoring it.
#
#=head2 setrout command replaces/adds the routes to the node according to
# what is specified in the xCAT tables.
# The route name for the node is defined in noderes.routenames.
# The route itself is defined in the routes table.
@ -14,6 +17,12 @@ if [ -z "$NODEROUTENAMES" ]; then
exit 0
fi
OP="replace"
if [ -n "$1" ] && [ "$1" = "add" ]; then
OP="add"
fi
for rn in `echo "$NODEROUTENAMES" | tr "," "\n"`
do
eval route_string=\$ROUTE_$rn
@ -34,7 +43,7 @@ do
mask=`echo $mask | awk -F'/' '{print $2}'`
fi
cmd="routeop add $net $mask $gw $ifname"
cmd="routeop $OP $net $mask $gw $ifname"
result=`$cmd 2>&1`
echo $result
done

View File

@ -116,6 +116,7 @@ fi
%install
mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig
mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d
mkdir -p $RPM_BUILD_ROOT/install/postscripts
@ -152,10 +153,9 @@ chmod 755 $RPM_BUILD_ROOT/install/postscripts/*
rm LICENSE.html
mkdir -p postscripts/hostkeys
cd -
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach22
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach24
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach22
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach24
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24
cp %{SOURCE5} $RPM_BUILD_ROOT/etc/xCATMN
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
@ -168,23 +168,15 @@ cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
elif [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
else
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/httpd/conf.d/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf
rm -rf /etc/apache2/conf.d/xcat.conf
cp /etc/apache2/conf.d/xcat.conf.apach22 /etc/apache2/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
fi
if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/apache2/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
fi
rm -rf /etc/apache2/conf.d/xcat.conf.apach22
rm -rf /etc/apache2/conf.d/xcat.conf.apach24
rm -rf /etc/httpd/conf.d/xcat.conf.apach22
rm -rf /etc/httpd/conf.d/xcat.conf.apach24
%endif
@ -220,11 +212,9 @@ exit 0
%files
%{prefix}
# one for sles, one for rhel. yes, it's ugly...
/etc/apache2/conf.d/xcat.conf.apach22
/etc/apache2/conf.d/xcat.conf.apach24
/etc/httpd/conf.d/xcat.conf.apach22
/etc/httpd/conf.d/xcat.conf.apach24
/etc/xcat/conf.orig/xcat.conf.apach24
/etc/httpd/conf.d/xcat.conf
/etc/apache2/conf.d/xcat.conf
/etc/xCATMN
/install/postscripts
/install/prescripts

View File

@ -15,6 +15,7 @@ Source1: xcat.conf
Source2: license.tar.gz
Source3: xCATSN
Source5: templates.tar.gz
Source6: xcat.conf.apach24
Provides: xCATsn = %{version}
Requires: xCAT-server xCAT-client perl-DBD-SQLite
@ -80,6 +81,7 @@ tar -xf license.tar
%install
%ifos linux
mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig
mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d/
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/
@ -87,6 +89,8 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf
cp %{SOURCE3} $RPM_BUILD_ROOT/etc/xCATSN
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach22
cp %{SOURCE6} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
@ -122,6 +126,23 @@ fi
%endif
%post
%ifos linux
#Apply the correct httpd/apache configuration file according to the httpd/apache version
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
fi
if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/apache2/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
fi
%endif
# create dir for the current pid and move the original ones from /tmp/xcat to /var/run/xcat
mkdir -p /var/run/xcat
if [ -r "/tmp/xcat/installservice.pid" ]; then
@ -161,7 +182,6 @@ if [ -e "/etc/redhat-release" ]; then
else # SuSE
apachedaemon='apache2'
fi
# start xcatd on linux
chkconfig $apachedaemon on
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
@ -199,6 +219,8 @@ fi
%{prefix}
# one for sles, one for rhel. yes, it's ugly...
%ifos linux
/etc/xcat/conf.orig/xcat.conf.apach24
/etc/xcat/conf.orig/xcat.conf.apach22
/etc/httpd/conf.d/xcat.conf
/etc/apache2/conf.d/xcat.conf
%endif