From 982f411251957bcfe43fbfd45c9da478a83d5407 Mon Sep 17 00:00:00 2001 From: ligc Date: Wed, 18 Sep 2013 07:54:40 +0800 Subject: [PATCH] fix bug 3745: makehosts -d to delete otherinterfaces hosts --- xCAT-server/lib/xcat/plugins/hosts.pm | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) mode change 100644 => 100755 xCAT-server/lib/xcat/plugins/hosts.pm diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm old mode 100644 new mode 100755 index c17b48584..661dcf507 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -203,6 +203,32 @@ sub addotherinterfaces } } +sub delotherinterfaces +{ + my $node = shift; + my $otherinterfaces = shift; + my $domain = shift; + + my @itf_pairs = split(/,/, $otherinterfaces); + foreach (@itf_pairs) + { + my ($itf, $ip); + if ($_ =~ /!/) { + ($itf, $ip) = split(/!/, $_); + } else { + ($itf, $ip) = split(/:/, $_); + } + if ($ip && xCAT::NetworkUtils->isIpaddr($ip)) + { + if ($itf =~ /^-/) + { + $itf = $node . $itf; + } + delnode $itf, $ip, '', $domain; + } + } +} + sub add_hosts_content { my %args = @_; my $nodelist = $args{nodelist}; @@ -245,6 +271,10 @@ sub add_hosts_content { if ($DELNODE) { delnode $nodename, $ip, $ref->{hostnames}, $domain; + if (defined($ref->{otherinterfaces})) + { + delotherinterfaces $nodename, $ref->{otherinterfaces}, $domain; + } } else {