26 Commits

Author SHA1 Message Date
2ddfd8c17d Merge branch '2.8.3-ocf' of gitlab.ocf.co.uk:aali/xcat-core into 2.8.3-ocf 2014-04-23 11:17:02 +01:00
9ac4bde2ed defect #4061: fix DSHCLI.pm for append in hierarchy 2014-04-23 11:15:29 +01:00
8bd63d7f04 defect 4061 2014-04-15 20:25:44 +01:00
bf0f8dc26e defect #4061: fix DSHCLI.pm for merge in hierarchy 2014-04-11 14:52:45 +01:00
f049a9844d Merge branch '2.8.3-ocf' of gitlab.ocf.co.uk:aali/xcat-core into 2.8.3-ocf 2014-04-11 08:49:42 +01:00
354596f545 Update version to 2.8.3ocf 2014-04-11 08:48:58 +01:00
036e8d3618 defect 4049 broadcast updatenode -g if sharedtftp=0 2014-04-10 18:18:54 +01:00
c410124610 fix for a typo in confignics, caused ib configuration problems 2014-04-09 19:01:18 +01:00
0fe8154a19 fix bug 3971, trim othernames variable 2014-04-09 18:53:48 +01:00
c547796400 defect 4050 2014-04-09 18:06:30 +01:00
2727f04b4f defect 4049 change Postage.pm to call my_if_facing if xcatmaster attr not set 2014-04-09 18:05:57 +01:00
2c34e7a632 fix for bug 4002, configib replaces /etc/sysctl.conf 2014-04-09 17:59:03 +01:00
d3a5b1c5fd add vlan support to configeth 2014-04-09 17:58:36 +01:00
23013c30bb fix bug #4027, replace chop with chomp 2014-04-09 17:36:16 +01:00
ba9e8cb2e0 add nichostnameprefixes to @nodeattrs 2014-04-09 17:35:00 +01:00
f724708689 first commit for prefix hostname feature 2014-04-09 17:34:51 +01:00
4b2274ea26 fix bug 3971, trim othernames variable 2014-04-09 17:34:39 +01:00
90076cd6c1 change comment on path of where the gpfs_updates directory is placed 2014-04-09 17:33:17 +01:00
e577d6e80e update Template.pm, so that the partitionfile is grabbed from the master using wget 2014-04-09 17:33:08 +01:00
fe7beabb89 add per node consoleondemand 2014-04-09 17:32:37 +01:00
43f5eb623c fix ipv6 0.0.0.0 to ::, the equivalent ip 2014-04-09 17:31:42 +01:00
ce21f38cf7 add ifname to arguments for checkConfig_Sles 2014-04-09 17:31:26 +01:00
96b884e5e7 update routeop with device based routing 2014-04-09 17:31:18 +01:00
437bc8e95e update route.pm, and start work on routeop 2014-04-09 17:31:07 +01:00
0a7e140cc8 defect 4033: fix device based routing in makeroutes 2014-04-09 17:30:53 +01:00
e2b85da515 fix gpfs_updates to use MASTER instead of SITEMASTER for hierarchical situations 2014-04-09 10:44:47 +01:00
17 changed files with 430 additions and 123 deletions

View File

@ -1 +1 @@
2.8.3
2.8.3ocf

View File

@ -4972,7 +4972,8 @@ sub parse_rsync_input_file_on_MN
$::process_line = 0;
my $destfileisdir;
my $clause=0;
my $addmergescript =0;
my $addappendscript =0;
open(INPUTFILE, "< $input_file") || die "File $input_file does not exist\n";
while (my $line = <INPUTFILE>)
{
@ -5013,12 +5014,16 @@ sub parse_rsync_input_file_on_MN
# this triggers the running of the appendscript
$::appendscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
}
# add the append script to the sync
my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
my $appendscriptline = "$appscript -> $appscript";
$syncappendscript=1; # syncing the xdcpappend.sh script
&build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript);
}
if ($addappendscript == 0) { # only add once
my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
my $appendscriptline = "$appscript -> $appscript";
$syncappendscript=1; # syncing the xdcpappend.sh script
&build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript);
$addappendscript=1;
}
} # end APPEND clause
if ($clause =~ /MERGE:/) {
# location of the base merge script
# for MERGE we have to sync the mergescript and the
@ -5030,12 +5035,16 @@ sub parse_rsync_input_file_on_MN
# this triggers the running of the mergescript
$::mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
}
# add the merge script to the sync
my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
my $mergescriptline = "$mergescript -> $mergescript";
$syncmergescript=1; # syncing the xdcpmerge.sh script
&build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript);
}
if ($addmergescript == 0) { # only add once
my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
my $mergescriptline = "$mergescript -> $mergescript";
$syncmergescript=1; # syncing the xdcpmerge.sh script
&build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript);
$addmergescript=1;
}
} # end MERGE clause
}
} else { # not processing EXECUTE, EXECUTEALWAYS or APPEND
@ -5199,6 +5208,7 @@ sub build_append_rsync
push @::appendlines,$line;
}
my $src_file = $1; # append file left of arror
my $orig_src_file = $1; # append file left of arror
# it will be sync'd to $nodesyncfiledir/$append_file
my $dest_file = $nodesyncfiledir;
$dest_file .= $src_file;
@ -5227,7 +5237,7 @@ sub build_append_rsync
# to pick up files from /var/xcat/syncfiles...
if ($onServiceNode == 1) {
my $newsrcfile = $syncdir; # add SN syndir on front
$newsrcfile .= $src_file;
$newsrcfile .= $orig_src_file;
$src_file=$newsrcfile;
}
# destination file name
@ -5311,6 +5321,7 @@ sub build_merge_rsync
push @::mergelines,$line;
}
my $src_file = $1; # merge file left of arror
my $orig_src_file = $1;
# it will be sync'd to $nodesyncfiledir/$merge_file
my $dest_file = $nodesyncfiledir;
$dest_file .= $src_file;
@ -5339,7 +5350,7 @@ sub build_merge_rsync
# to pick up files from /var/xcat/syncfiles...
if ($onServiceNode == 1) {
my $newsrcfile = $syncdir; # add SN syndir on front
$newsrcfile .= $src_file;
$newsrcfile .= $orig_src_file;
$src_file=$newsrcfile;
}
# destination file name

View File

@ -265,6 +265,7 @@ sub rackformat_to_numricformat{
values are attributes of a specific nic, like:
type : nic type
hostnamesuffix: hostname suffix
hostnameprefix: hostname prefix
customscript: custom script for this nic
network: network name for this nic
ip: ip address of this nic.
@ -276,7 +277,7 @@ sub get_nodes_nic_attrs{
my $nodes = shift;
my $nicstab = xCAT::Table->new( 'nics');
my $entry = $nicstab->getNodesAttribs($nodes, ['nictypes', 'nichostnamesuffixes', 'niccustomscripts', 'nicnetworks', 'nicips']);
my $entry = $nicstab->getNodesAttribs($nodes, ['nictypes', 'nichostnamesuffixes', 'nichostnameprefixes', 'niccustomscripts', 'nicnetworks', 'nicips']);
my %nicsattrs;
my @nicattrslist;
@ -308,6 +309,20 @@ sub get_nodes_nic_attrs{
}
}
if($entry->{$node}->[0]->{'nichostnameprefixes'}){
@nicattrslist = split(",", $entry->{$node}->[0]->{'nichostnameprefixes'});
foreach (@nicattrslist){
my @nicattrs;
if ($_ =~ /!/) {
@nicattrs = split("!", $_);
} else {
@nicattrs = split(":", $_);
}
$nicsattrs{$node}{$nicattrs[0]}{'hostnameprefix'} = $nicattrs[1];
}
}
if($entry->{$node}->[0]->{'niccustomscripts'}){
@nicattrslist = split(",", $entry->{$node}->[0]->{'niccustomscripts'});
foreach (@nicattrslist){

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.",
},
@ -1279,7 +1280,7 @@ firmware => {
},
nics => {
cols => [qw(node nicips nichostnamesuffixes nictypes niccustomscripts nicnetworks nicaliases comments disable)],
cols => [qw(node nicips nichostnamesuffixes nichostnameprefixes nictypes niccustomscripts nicnetworks nicaliases comments disable)],
keys => [qw(node)],
tablespace =>'XCATTBS16K',
table_desc => 'Stores NIC details.',
@ -1297,6 +1298,13 @@ nics => {
<nic1>!<ext1>|<ext2>,<nic2>!<ext1>|<ext2>,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6.
The xCAT object definition commands support to use nichostnamesuffixes.<nicname> as the sub attributes.
Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention',
nichostnameprefixes => 'Comma-separated list of hostname prefixes per NIC.
If only one ip address is associated with each NIC:
<nic1>!<ext1>,<nic2>!<ext2>,..., for example, eth0!eth0-,ib0!ib-
If multiple ip addresses are associcated with each NIC:
<nic1>!<ext1>|<ext2>,<nic2>!<ext1>|<ext2>,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-.
The xCAT object definition commands support to use nichostnameprefixes.<nicname> as the sub attributes.
Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention',
nictypes => 'Comma-separated list of NIC types per NIC. <nic1>!<type1>,<nic2>!<type2>, e.g. eth0!Ethernet,ib0!Infiniband. The xCAT object definition commands support to use nictypes.<nicname> as the sub attributes.',
niccustomscripts => 'Comma-separated list of custom scripts per NIC. <nic1>!<script1>,<nic2>!<script2>, e.g. eth0!configeth eth0, ib0!configib ib0. The xCAT object definition commands support to use niccustomscripts.<nicname> as the sub attribute
.',
@ -1816,6 +1824,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 #
@ -2177,6 +2189,10 @@ my @nodeattrs = (
tabentry => 'nics.nichostnamesuffixes',
access_tabentry => 'nics.node=attr:node',
},
{attr_name => 'nichostnameprefixes',
tabentry => 'nics.nichostnameprefixes',
access_tabentry => 'nics.node=attr:node',
},
{attr_name => 'nictypes',
tabentry => 'nics.nictypes',
access_tabentry => 'nics.node=attr:node',

View File

@ -14,7 +14,7 @@
# postscript (stateful install) or with the otherpkgs processing of
# genimage (stateless/statelite install). This script will install any
# gpfs update rpms that exist on the xCAT management node in the
# /install/post/gpfs_updates directory.
# /install/post/otherpkgs/gpfs_updates directory.
# This is necessary because the GPFS updates can ONLY be installed
# after the base rpms have been installed, and the update rpms cannot
# exist in any rpm repositories used by xCAT otherpkgs processing
@ -41,8 +41,8 @@ if [ $OS != "AIX" ]; then
mkdir -p /tmp/gpfs_updates
rm -f -R /tmp/gpfs_updates/*
cd /tmp/gpfs_updates
# wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=3 ftp://$SITEMASTER/$UPDATES_DIR/*.rpm 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=4 --reject "index.html*" --no-parent http://$SITEMASTER$INSTALL_DIR/$UPDATES_DIR/ 2> /tmp/wget.log
# wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=3 ftp://$MASTER/$UPDATES_DIR/*.rpm 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=4 --reject "index.html*" --no-parent http://$MASTER$INSTALL_DIR/$UPDATES_DIR/ 2> /tmp/wget.log
if [ -n "`ls *.rpm 2> /dev/null`" ] ; then
rpm -Uvh *.rpm
fi

View File

@ -1192,7 +1192,9 @@ sub collect_all_attribs_for_tables_in_template
$::GLOBAL_TAB_HASH{$tabname}{$node}{$attrib} = $ent->{$node}->[0]->{$attrib};
#for noderes.xcatmaster
if ($tabname =~ /^noderes$/ && $attrib =~ /^xcatmaster$/ && ! exists($::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster}))
if ($tabname =~ /^noderes$/ && $attrib =~ /^xcatmaster$/ &&
( ! exists($::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster}) ||
$::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster} == "" ) )
{
my $value;
$value = xCAT::NetworkUtils->my_ip_facing($node);

View File

@ -271,7 +271,7 @@ sub subvars {
my $tempstr = "%include /tmp/partitionfile\n";
$inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/;
#modify the content in the file, and write into %pre part
$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent = "wget http://$master/$partitionfile -O /tmp/partscript\n";
$partcontent .= "chmod 755 /tmp/partscript\n";
$partcontent .= "/tmp/partscript\n";
#replace the #XCA_PARTITION_SCRIPT#
@ -281,7 +281,7 @@ sub subvars {
elsif ($inc =~ /<!-- XCAT-PARTITION-START -->/){
my $tempstr = "<drive><device>XCATPARTITIONTEMP</device></drive>";
$inc =~ s/<!-- XCAT-PARTITION-START -->[\s\S]*<!-- XCAT-PARTITION-END -->/$tempstr/;
$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent = "wget http://$master/$partitionfile -O /tmp/partscript\n";
$partcontent .= "chmod 755 /tmp/partscript\n";
$partcontent .= "/tmp/partscript\n";
$inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/;

View File

@ -538,7 +538,7 @@ sub processArgs
# --nics is the equivalent of -i nicips,nichostnamesuffixes...
if ($::opt_nics) {
$::opt_i="nicips,nichostnamesuffixes,nictypes,niccustomscripts,nicnetworks,nicaliases";
$::opt_i="nicips,nichostnamesuffixes,nihostnameprefixes,nictypes,niccustomscripts,nicnetworks,nicaliases";
}
# -i and -s cannot be used together

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

@ -122,6 +122,10 @@ sub build_line
my $othernames = shift;
my @o_names = ();
my @n_names = ();
# Trim spaces from the beginning and end from $othernames
$othernames =~ s/^\s+|\s+$//g;
if (defined $othernames)
{
# the "hostnames" attribute can be a list delimited by
@ -564,6 +568,7 @@ sub donics
$node,
[
'nicips', 'nichostnamesuffixes',
'nichostnameprefixes',
'nicnetworks', 'nicaliases'
]
);
@ -609,6 +614,7 @@ sub donics
}
my @nicandsufx = split(',', $et->{'nichostnamesuffixes'});
my @nicandprfx = split(',', $et->{'nichostnameprefixes'});
foreach (@nicandsufx)
{
@ -630,12 +636,32 @@ sub donics
$nich->{$nicname}->{nicsufx}->[0] = $nicsufx;
}
}
foreach (@nicandprfx)
{
my ($nicname, $nicprfx);
if ($_ =~ /!/) {
($nicname, $nicprfx) = split('!', $_);
} else {
($nicname, $nicprfx) = split(':', $_);
}
if ( $nicprfx =~ /\|/) {
my @prfs = split( /\|/, $nicprfx);
my $index=0;
foreach my $prf (@prfs) {
$nich->{$nicname}->{nicprfx}->[$index] = $prf;
$index++;
}
} else {
$nich->{$nicname}->{nicprfx}->[0] = $nicprfx;
}
}
# see if we need to fill in a default suffix
# nich has all the valid nics - ie. that have IPs provided!
foreach my $nic (keys %{$nich}) {
for (my $i = 0; $i < $nicindex{$nic}; $i++ ){
if (!$nich->{$nic}->{nicsufx}->[$i]) {
if (!$nich->{$nic}->{nicsufx}->[$i] && !$nich->{$nic}->{nicprfx}->[$i]) {
# then we have no suffix at all for this
# so set a default
$nich->{$nic}->{nicsufx}->[$i] = "-$nic";
@ -706,6 +732,7 @@ sub donics
my $nicip = $nich->{$nic}->{nicip}->[$i];
my $nicsuffix = $nich->{$nic}->{nicsufx}->[$i];
my $nicprefix = $nich->{$nic}->{nicprfx}->[$i];
my $nicnetworks = $nich->{$nic}->{netwrk}->[$i];
my $nicaliases = $nich->{$nic}->{nicaliases}->[$i];
@ -714,7 +741,7 @@ sub donics
}
# construct hostname for nic
my $nichostname = "$shorthost$nicsuffix";
my $nichostname = "$nicprefix$shorthost$nicsuffix";
# get domain from network def provided by nic attr
my $nt = $nettab->getAttribs({ netname => "$nicnetworks"}, 'domain');

View File

@ -239,7 +239,7 @@ sub add_known_host
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return 1;
}
chop($output[0]);
chomp($output[0]);
my ($hostname,$ip_address) = xCAT::NetworkUtils->gethostnameandip($node);
if (!$hostname || !$ip_address)
{

View File

@ -449,7 +449,7 @@ sub process_makeroutes {
delete_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $route_hash->{ifname});
}
else {
set_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name,$route_hash->{ifname});
set_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $route_hash->{ifname});
}
}
}
@ -526,6 +526,7 @@ sub route_exists {
my $mask = shift;
my $gw_ip = shift;
my $gw=shift;
my $ifname = shift;
my $islinux=xCAT::Utils->isLinux();
@ -557,7 +558,8 @@ sub route_exists {
my $net1=$a[0];
my $mask1=$a[2];
my $gw1=$a[1];
if (($net1 eq $net) && ($mask1 eq $mask) && (($gw1 eq $gw) || ($gw1 eq $gw_ip))) {
my $ifname1=$a[7];
if (($net1 eq $net) && ($mask1 eq $mask) && (($gw1 eq $gw) || ($gw1 eq $gw_ip) || ($ifname1 eq $ifname))) {
return 1;
}
}
@ -602,19 +604,27 @@ sub set_route {
#print "set_route get called\n";
my $result;
if (!route_exists($net, $mask, $gw_ip, $gw)) {
if (!route_exists($net, $mask, $gw_ip, $gw, $ifname)) {
#set temporay route
my $cmd;
# ipv6 network
if ($net =~ /:/) {
if (xCAT::Utils->isLinux()) {
$cmd="ip -6 route add $net/$mask via $gw_ip";
if ( $gw_ip == "" || $gw_ip == "::" ) {
$cmd="ip -6 route add $net/$mask dev $ifname";
} else {
$cmd="ip -6 route add $net/$mask via $gw_ip";
}
} else {
# AIX TODO
}
} else {
if (xCAT::Utils->isLinux()) {
$cmd="route add -net $net netmask $mask gw $gw_ip";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$cmd="route add -net $net netmask $mask dev $ifname";
} else {
$cmd="route add -net $net netmask $mask gw $gw_ip";
}
} else {
$cmd="route add -net $net -netmask $mask $gw_ip";
}
@ -676,18 +686,26 @@ sub delete_route {
#print "delete_route get called\n";
my $result;
if (route_exists($net, $mask, $gw_ip, $gw)) {
if (route_exists($net, $mask, $gw_ip, $gw, $ifname)) {
#delete route temporarily
my $cmd;
if ($net =~ /:/) {
if (xCAT::Utils->isLinux()) {
$cmd = "ip -6 route delete $net/$mask via $gw_ip";
if ( $gw_ip == "" || $gw_ip == "::" ) {
$cmd = "ip -6 route delete $net/$mask dev $ifname";
} else {
$cmd = "ip -6 route delete $net/$mask via $gw_ip";
}
} else {
# AIX TODO
}
} else {
if (xCAT::Utils->isLinux()) {
$cmd="route delete -net $net netmask $mask gw $gw_ip";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$cmd="route delete -net $net netmask $mask dev $ifname";
} else {
$cmd="route delete -net $net netmask $mask gw $gw_ip";
}
} else {
$cmd="route delete -net $net -netmask $mask $gw_ip";
}
@ -827,14 +845,22 @@ sub addPersistentRoute_Sles {
#print "old output=" . join("\n", @output) . "\n";
my $hasConfiged=0;
if (@output && (@output > 0)) {
$hasConfiged=checkConfig_Sles($net, $mask, $gw_ip, $gw, \@output);
$hasConfiged=checkConfig_Sles($net, $mask, $gw_ip, $gw, $ifname, \@output);
}
#print "hasConfiged=$hasConfiged\n";
my $new_config;
if ($net =~ /:/) {
$new_config = "$net/$mask $gw_ip - -\n";
if ( $gw_ip == "" || $gw_ip == "::" ) {
$new_config = "$net/$mask :: - $ifname\n";
} else {
$new_config = "$net/$mask $gw_ip - -\n";
}
} else {
$new_config="$net $gw_ip $mask $ifname\n";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$new_config="$net 0.0.0.0 $mask $ifname\n";
} else {
$new_config="$net $gw_ip $mask $ifname\n";
}
}
if (!$hasConfiged) {
push(@output, $new_config);
@ -872,7 +898,7 @@ sub deletePersistentRoute_Sles {
my @new_output=();
my $bigfound=0;
foreach my $tmp_conf (@output) {
my $found = checkConfig_Sles($net, $mask, $gw_ip, $gw, [$tmp_conf]);
my $found = checkConfig_Sles($net, $mask, $gw_ip, $gw, $ifname, [$tmp_conf]);
if (!$found) {
push(@new_output, $tmp_conf);
} else {
@ -909,13 +935,18 @@ sub checkConfig_Sles {
my $mask = shift;
my $gw_ip = shift;
my $gw=shift;
my $ifname=shift;
my $output=shift;
# Format:
# DESTINATION GATEWAY NETMASK INTERFACE
# DESTINATION/PREFIXLEN GATEWAY - INTERFACE
# ipv4 format: 192.168.0.0 207.68.156.51 255.255.0.0 eth1
# ipv6 format: fd59::/64 fd57:faaf:e1ab:336:21a:64ff:fe01:1 - -
foreach my $line (@$output) {
my @a=split(' ', $line);
my ($net1,$mask1,$gw1);
my ($net1,$mask1,$gw1,$ifname1);
if ($net =~ /:/) {
if (@a>0) {
my $ipv6net = $a[0];
@ -925,6 +956,10 @@ sub checkConfig_Sles {
$gw1=$a[1];
if ($gw1 eq '-') { $gw1=$gw_ip; }
}
if (@a>3) {
$ifname1=$a[3];
if ($ifname1 eq '-') { $ifname1=$ifname;}
}
} else {
if (@a>0) {
@ -939,10 +974,14 @@ sub checkConfig_Sles {
$mask1=$a[2];
if ($mask1 eq '-') { $mask1=$mask;}
}
if (@a>3) {
$ifname1=$a[3];
if ($ifname1 eq '-') { $ifname1=$ifname;}
}
}
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip))) {
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip ifname=$ifname1\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip) || ($ifname1 && $ifname1 eq $ifname))) {
return 1;
}
}
@ -972,7 +1011,7 @@ sub addPersistentRoute_RH {
#print "old output=" . join("\n", @output) . "\n";
my $hasConfiged=0;
if (@output && (@output > 0)) {
$hasConfiged=checkConfig_RH($net, $mask, $gw_ip, $gw, \@output);
$hasConfiged=checkConfig_RH($net, $mask, $gw_ip, $gw, $ifname, \@output);
}
#print "hasConfiged=$hasConfiged\n";
my $new_config;
@ -987,7 +1026,11 @@ sub addPersistentRoute_RH {
$new_config="$ifname $net/$mask $gw_ip";
} else {
$new_config="any net $net netmask $mask gw $gw_ip $ifname\n";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$new_config="any net $net netmask $mask dev $ifname\n";
} else {
$new_config="any net $net netmask $mask gw $gw_ip\n";
}
}
if (!$hasConfiged) {
push(@output, $new_config);
@ -1031,7 +1074,7 @@ sub deletePersistentRoute_RH {
my @new_output=();
my $bigfound=0;
foreach my $tmp_conf (@output) {
my $found = checkConfig_RH($net, $mask, $gw_ip, $gw, [$tmp_conf]);
my $found = checkConfig_RH($net, $mask, $gw_ip, $gw, $ifname, [$tmp_conf]);
if (!$found) {
push(@new_output, $tmp_conf);
} else {
@ -1065,14 +1108,16 @@ sub checkConfig_RH {
my $mask = shift;
my $gw_ip = shift;
my $gw=shift;
my $ifname=shift;
my $output=shift;
foreach my $line (@$output) {
my @a=split(' ', $line);
#The format is: any net 172.16.0.0 netmask 255.240.0.0 gw 192.168.0.1 eth0
# ipv6 format: eth1 fd60::/64 fd57::214:5eff:fe15:1
my ($net1,$mask1,$gw1);
my ($net1,$mask1,$gw1,$ifname1);
if ($net =~ /:/) {
$ifname1 = $a[0];
if (@a>1) {
my $ipv6net = $a[1];
($net1,$mask1) = split("/",$ipv6net);
@ -1090,13 +1135,18 @@ sub checkConfig_RH {
if ($mask1 eq '-') { $mask1=$mask;}
}
if (@a>6) {
$gw1=$a[6];
if ($gw1 eq '-') { $gw1=$gw_ip; }
if ( $a[5] eq 'dev' ) {
$ifname1=$a[6];
if ($ifname1 eq '-') { $ifname1=$ifname;}
} else {
$gw1=$a[6];
if ($gw1 eq '-') { $gw1=$gw_ip; }
}
}
}
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip))) {
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip ifname=$ifname1,ifname\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip) || ($ifname1 && $ifname1 eq $ifname))) {
return 1;
}
}
@ -1120,12 +1170,21 @@ sub addPersistentRoute_Debian{
#ipv6
if ( $net =~ /:/){
$cmd = "grep \"$net/$mask gw $gw_ip\" $conf_file";
$route_conf = " up route -A inet6 add $net/$mask gw $gw_ip \n down route -A inet6 del $net/$mask gw $gw_ip \n";
if ( $gw_ip == "" || $gw_ip == "::" ) {
$cmd = "grep \"$net/$mask dev $ifname\" $conf_file";
$route_conf = " up route -A inet6 add $net/$mask dev $ifname \n down route -A inet6 del $net/$mask dev $ifname \n";
} else {
$cmd = "grep \"$net/$mask gw $gw_ip\" $conf_file";
$route_conf = " up route -A inet6 add $net/$mask gw $gw_ip \n down route -A inet6 del $net/$mask gw $gw_ip \n";
}
}
else { #ipv4
$cmd = "grep \"-net $net netmask $mask gw $gw_ip\" $conf_file";
$route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip \n";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$route_conf = " up route add -net $net netmask $mask dev $ifname \n down route del -net $net netmask $mask dev $ifname \n";
} else {
$route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip\n";
}
}
#fine the corresponding config in the config file
@ -1183,10 +1242,18 @@ sub deletePersistentRoute_Debian{
preParse_Debian();
#ipv6
if ( $net =~ /:/){
$match = "$net/$mask gw $gw_ip";
if ( $gw_ip == "" || $gw_ip == "::" ) {
$match = "$net/$mask dev $ifname";
} else {
$match = "$net/$mask gw $gw_ip";
}
}
else {
$match = "net $net netmask $mask gw $gw_ip";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$match = "net $net netmask $mask dev $ifname";
} else {
$match = "net $net netmask $mask gw $gw_ip";
}
}
open(FH, "<", $conf_file);

View File

@ -14,6 +14,7 @@ use xCAT::Schema;
use Data::Dumper;
use xCAT::Utils;
use xCAT::SvrUtils;
use xCAT::Scope;
use xCAT::Usage;
use Storable qw(dclone);
use xCAT::TableUtils;
@ -188,6 +189,7 @@ sub preprocess_updatenode
my @requests = ();
my $installdir = xCAT::TableUtils->getInstallDir();
my $localhost = hostname();
# subroutine to display the usage
sub updatenode_usage
@ -251,20 +253,40 @@ sub preprocess_updatenode
$callback->($rsp);
return;
}
# Just generate mypostscripts file and get out
# preprocess generate mypostscripts files (-g) for hierarchy
# if no sharedtftp then we need to broadcast this updatenode -g to all service nodes inorder
# to be able to support service node pools
#
if ($::GENMYPOST)
{
# precreatemypostscript has to be yes/1 or do nothing
my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts");
if ($entries[0] ) {
$entries[0] =~ tr/a-z/A-Z/;
if ($entries[0] =~ /^(1|YES)$/ ) {
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files";
$callback->($rsp);
# now check if sharedtftp = 0, if it is we need to broadcast to all the servicenode
# if there are service nodes
my @entries = xCAT::TableUtils->get_site_attribute("sharedtftp");
my $t_entry = $entries[0];
if ( defined($t_entry) and ($t_entry eq "0" or $t_entry eq "no" or $t_entry eq "NO")) {
# see if there are any servicenodes. If so then run updatenode -g on all of them
my @SN;
my @CN;
my $nodes = $request->{node};
xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN);
if (@CN >0 ) { # if compute nodes broadcast to all servicenodes
return xCAT::Scope->get_broadcast_scope($request,@_);
}
} else { # sharedtftp=yes, just run on MN
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files on $localhost";
$callback->($rsp);
return 0;
}
} else { # not valid unless precreatemypostscripts enabled
my $rsp = {};
$rsp->{error}->[0] =
@ -273,7 +295,7 @@ sub preprocess_updatenode
$callback->($rsp);
return ;
}
} else { # not in the site table
} else { # precreatemypostscripts not in the site table
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
@ -281,8 +303,9 @@ sub preprocess_updatenode
$callback->($rsp);
return ;
}
return 0;
}
} # end GENMYPOST
# -c must work with -S for AIX node
if ($::CMDLINE && !$::SWMAINTENANCE)
@ -967,27 +990,6 @@ sub updatenode
}
#create each /tftpboot/mypostscript/mypostscript.<nodename> for each node
# This first removes the old one if precreatemypostscripts =0 or undefined
# call create files but no tmp files
my $notmpfiles=1;
my $nofiles=0;
#my $nofiles=1;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
# convert the hashes back to the way they were passed in
my $flatreq = xCAT::InstUtils->restore_request($request, $callback);
my $imgdefs;
my $updates;
if ($flatreq->{imagedef})
{
$imgdefs = $flatreq->{imagedef};
}
if ($flatreq->{updateinfo})
{
$updates = $flatreq->{updateinfo};
}
# get the NIM primary server name
my $nimprime = xCAT::InstUtils->getnimprime();
chomp $nimprime;
@ -1000,6 +1002,7 @@ sub updatenode
'A|updateallsw' => \$::ALLSW,
'c|cmdlineonly' => \$::CMDLINE,
'd=s' => \$::ALTSRC,
'g|genmypost' => \$::GENMYPOST,
'h|help' => \$::HELP,
'v|version' => \$::VERSION,
'V|verbose' => \$::VERBOSE,
@ -1042,6 +1045,60 @@ sub updatenode
$::attrres{$attr} = $value;
}
}
# Just generate mypostscripts file and get out
if ($::GENMYPOST)
{
my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts");
if ($entries[0] ) {
$entries[0] =~ tr/a-z/A-Z/;
if ($entries[0] =~ /^(1|YES)$/ ) {
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files on $localhostname";
$callback->($rsp);
} else { # not valid unless precreatemypostscripts enabled
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
$rsp->{errorcode}->[0] =1;
$callback->($rsp);
return ;
}
} else { # not in the site table
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
$rsp->{errorcode}->[0] =1;
$callback->($rsp);
return ;
}
return 0;
}
#create each /tftpboot/mypostscript/mypostscript.<nodename> for each node
# This first removes the old one if precreatemypostscripts =0 or undefined
# call create files but no tmp files
my $notmpfiles=1;
my $nofiles=0;
#my $nofiles=1;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
# convert the hashes back to the way they were passed in
my $flatreq = xCAT::InstUtils->restore_request($request, $callback);
my $imgdefs;
my $updates;
if ($flatreq->{imagedef})
{
$imgdefs = $flatreq->{imagedef};
}
if ($flatreq->{updateinfo})
{
$updates = $flatreq->{updateinfo};
}
# if not just using the -k flag, then set all nodes to syncing in
# nodelist updatestatus for the other updatenode options
if (!($::SECURITY)) {

View File

@ -27,6 +27,9 @@ function configipv4(){
echo "NETWORK_${num_v4num}=${str_v4net}" >> $str_conf_file
echo "LABEL_${num_v4num}=${num_v4num}" >> $str_conf_file
fi
if [[ ${str_if_name} == eth[0-9]*.[0-9]* ]]; then
echo "VLAN=yes" >> $str_conf_file
fi
#debian ubuntu
elif [ "$str_os_type" = "debian" ];then
str_conf_file="/etc/network/interfaces.d/${str_if_name}"
@ -40,6 +43,10 @@ function configipv4(){
echo " address ${str_v4ip}" >> $str_conf_file
echo " netmask ${str_v4mask}" >> $str_conf_file
echo " network ${str_v4net}" >> $str_conf_file
if [[ ${str_if_name} == eth[0-9]*.[0-9]* ]]; then
parent_device=`echo ${str_if_name} | sed -e 's/\(eth[0-9]*\)\.[0-9]*/\1/g'`
echo " vlan-raw-device ${parent_device}" >> $str_conf_file
fi
else
# Write the info to the ifcfg file for redhat
str_conf_file=""
@ -56,6 +63,9 @@ function configipv4(){
echo "IPADDR=${str_v4ip}" >> $str_conf_file
echo "NETMASK=${str_v4mask}" >> $str_conf_file
echo "ONBOOT=yes" >> $str_conf_file
if [[ ${str_if_name} == eth[0-9]*.[0-9]* ]]; then
echo "VLAN=yes" >> $str_conf_file
fi
fi
}

View File

@ -286,9 +286,9 @@ do
if [ -f /etc/sysctl.conf ]
then
TMP1=`sed "/net.ipv4.conf.$nic.arp_filter=1/d" /etc/sysctl.conf 2>&1 1>/dev/null`
TMP1=`sed "/net.ipv4.conf.$nic.arp_filter=1/d" /etc/sysctl.conf`
echo "$TMP1" > /etc/sysctl.conf
TMP2=`sed "/net.ipv4.conf.$nic.arp_ignore=1/d" /etc/sysctl.conf 2>&1 1>/dev/null`
TMP2=`sed "/net.ipv4.conf.$nic.arp_ignore=1/d" /etc/sysctl.conf`
echo "$TMP2" > /etc/sysctl.conf
cfg="net.ipv4.conf.$nic.arp_filter=1"
grep "$cfg" /etc/sysctl.conf 2>&1 1>/dev/null

View File

@ -278,7 +278,7 @@ do
else
if [ `echo $key | grep -E '(eth|en)[0-9]+'` ];then
str_nic_type="ethernet"
elif [ `echo $KEY | grep -E 'ib[0-9]+'` ];then
elif [ `echo $key | grep -E 'ib[0-9]+'` ];then
str_nic_type="infiniband"
else
logger -t xcat -p local4.info "confignics: unknown nic type for $key: $str_value ."

View File

@ -107,7 +107,8 @@ route_exists()
net1=`echo $x|cut -d',' -f1`
gw1=`echo $x|cut -d',' -f2`
mask1=`echo $x|cut -d',' -f3`
if [ "$net" = "$net1" ] && [ "$mask" = "$mask1" ] && [ "$gw" = "$gw1" ]; then
ifname1=`echo $x|cut -d',' -f8`
if [ "$net" = "$net1" ] && [ "$mask" = "$mask1" ] && [ "$gw" = "$gw1" ] && [ "$ifname" = "$ifname1" ]; then
ret=1
break
fi
@ -174,11 +175,21 @@ add_persistent_route()
filename="/etc/sysconfig/network/routes";
if echo $net | grep : 2>&1 1>/dev/null
then
route="$net/$mask $gw - -"
route1="$net\/$mask $gw - -";
if [ $gw_ip = "" -o $gw_ip = "::" ] ; then
route="$net/$mask :: - $ifname"
route1="$net\/$mask :: - $ifname";
else
route="$net/$mask $gw - -"
route1="$net\/$mask $gw - -";
fi
else
route="$net $gw $mask $ifname";
route1="$net $gw $mask $ifname";
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
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -221,10 +232,18 @@ add_persistent_route()
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
matchstr="$net/$mask gw $gw"
if [ "$gw" = "" -o "$gw" = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
matchstr="$net/$mask gw $gw"
fi
v6flag=1
else
matchstr="net $net netmask $mask gw $gw"
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
@ -237,11 +256,21 @@ add_persistent_route()
if [ $? -eq 0 -a $foundflag -eq 1 ];then
foundflag=0
if [ $v6flag -eq 1 ];then
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
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
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
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
@ -255,11 +284,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
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
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
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
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
@ -273,14 +312,22 @@ add_persistent_route()
# ipv6 net
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$gw" = "" ] ; then
$gw = "::";
fi
filename="/etc/sysconfig/static-routes-ipv6";
route="$ifname $net/$mask $gw";
# $net/mask does not work with sed cmd
route1="$ifname $net\/$mask $gw";
else
filename="/etc/sysconfig/static-routes";
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
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
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -340,15 +387,23 @@ rm_persistent_route()
# ipv6 net
if echo $net | grep : 2>&1 1>/dev/null
then
route="$net/$mask $gw - -";
route1="$net\/$mask $gw - -";
if [ $gw = "" -o $gw = "::" ] ; then
route="$net/$mask :: - $ifname";
route1="$net\/$mask :: - $ifname";
else
route="$net/$mask $gw - -";
route1="$net\/$mask $gw - -";
fi
else
if [ $gw = "" ] ; then
$gw = "0.0.0.0";
fi
if [ -n "$ifname" ]; then
route="$net $gw $mask $ifname";
route1="$net $gw $mask $ifname";
else
route="$net $gw $mask";
route1="$net $gw $mask";
route="$net $gw $mask -";
route1="$net $gw $mask -";
fi
fi
if [ -f $filename ]; then
@ -376,10 +431,18 @@ rm_persistent_route()
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
matchstr="$net/$mask gw $gw"
if [ $gw = "" -o $gw = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
matchstr="$net/$mask gw $gw"
fi
v6flag=1
else
matchstr="net $net netmask $mask gw $gw"
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
@ -397,12 +460,22 @@ rm_persistent_route()
then
filename="/etc/sysconfig/static-routes-ipv6";
# $net/$mask does not work with sed
route="$ifname $net\/$mask $gw"
route1="$ifname $net/$mask $gw"
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$ifname $net\/$mask ::"
route1="$ifname $net/$mask ::"
else
route="$ifname $net\/$mask $gw"
route1="$ifname $net/$mask $gw"
fi
else
filename="/etc/sysconfig/static-routes";
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
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
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -431,14 +504,22 @@ if [ "$op" = "add" ]; then
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$(uname -s)" = "Linux" ]; then
cmd="ip -6 route add $net/$mask via $gw"
if [ "$gw" = "" -o "$gw" = "::" ] ; then
cmd="ip -6 route add $net/$mask dev $ifname"
else
cmd="ip -6 route add $net/$mask via $gw"
fi
else
# AIX TODO
cmd="ip -6 route add $net/$mask via $gw"
fi
else
if [ "$(uname -s)" = "Linux" ]; then
cmd="route add -net $net netmask $mask gw $gw"
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
cmd="route add -net $net netmask $mask dev $ifname"
else
cmd="route add -net $net netmask $mask gw $gw"
fi
else
cmd="route add -net $net -netmask $mask $gw"
fi
@ -472,14 +553,22 @@ elif [ "$op" = "delete" ]; then
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$(uname -s)" = "Linux" ]; then
cmd="ip -6 route delete $net/$mask via $gw"
if [ "$gw" = "" -o "$gw" = "::" ] ; then
cmd="ip -6 route delete $net/$mask dev $ifname"
else
cmd="ip -6 route delete $net/$mask via $gw"
fi
else
# AIX TODO
cmd="ip -6 route delete $net/$mask via $gw"
fi
else
if [ "$(uname -s)" = "Linux" ]; then
cmd="route delete -net $net netmask $mask gw $gw"
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
cmd="route delete -net $net netmask $mask dev $ifname"
else
cmd="route delete -net $net netmask $mask gw $gw"
fi
else
cmd="route delete -net $net -netmask $mask $gw"
fi