From bd743d0cb80ddf1226cfb7a3c7c4d33355978233 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 16 Jun 2010 18:47:53 +0000 Subject: [PATCH] -Avoid creating static bindings within dynamic range git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6488 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/dhcp.pm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index a5a82e037..9125f768b 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -37,6 +37,22 @@ my $iscsients; my $chainents; my $tftpdir = xCAT::Utils->getTftpDir(); my $dhcpconffile = $^O eq 'aix' ? '/etc/dhcpsd.cnf' : '/etc/dhcpd.conf'; +my %dynamicranges; #track dynamic ranges defined to see if a host that resolves is actually a dynamic address + +sub ipIsDynamic { + my $ip = shift; + $number = inet_aton($ip); + unless ($number) { # shouldn't be possible, but pessimistically presume it dynamically if so + return 1; + } + $number = unpack("N*",$number); + foreach (values %dynamicranges) { + if ($_->[0] <= $number and $_->[1] >= $number) { + return 1; + } + } + return 0; #it isn't in any of the dynamic ranges we are aware of +} sub handled_commands { @@ -315,7 +331,7 @@ sub addnode } else { - if ($ip) { + if ($ip and not ipIsDynamic($ip)) { print $omshell "set ip-address = $ip\n"; } if ($lstatements) @@ -1144,11 +1160,16 @@ sub addnet } if ($ent and $ent->{dynamicrange}) { + my $trange = $ent->{dynamicrange}; #temp range, the dollar sign makes it look strange + $trange =~ s/[,-]/ /g; + my $begin; + my $end; + ($begin,$end) = split / /,$trange; + %dynamicranges{$trange}=[unpack("N*",inet_aton($begin)),unpack("N*",inet_aton($end))]; unless ($ent->{dhcpserver} and xCAT::Utils->thishostisnot($ent->{dhcpserver})) { #If specific, only one dhcp server gets a dynamic range - $range = $ent->{dynamicrange}; - $range =~ s/[,-]/ /g; + $range = $trange; } } else