From 9cdf977a6e7c7e7e4f5f295185a440c75b466364 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 13 Apr 2010 11:58:33 +0000 Subject: [PATCH] Add duplicated IP address in hosts table check in makedhcp -a. This could prevent duplicated entries in dhcp configuration file or lease file git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5755 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/dhcp.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 60ef5a183..44e945b71 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -707,6 +707,19 @@ sub process_request if ($req->{node}) { + my $ip_hash; + foreach my $node ( @{$req->{node}} ) { + my $hoststab = xCAT::Table->new('hosts'); + my $ent = $hoststab->getNodeAttribs( $node, ['ip'] ); + if ( $ent->{ip} ) { + if ( $ip_hash->{ $ent->{ip} } ) { + $callback->({error=>["Duplicated IP addresses in hosts table for following nodes: $node," . $ip_hash->{ $ent->{ip} }],errorcode=>[1]}); + return; + } + $ip_hash->{ $ent->{ip} } = $node; + } + } + @ARGV = @{$req->{arg}}; $statements = ""; GetOptions('s|statements=s' => \$statements);