Commit 1be5ffad authored by Mike Hibler's avatar Mike Hibler Committed by Leigh B Stoller
Browse files

Leigh's changes for DHCP on vnode hosts.

parent 56294cc5
...@@ -3369,26 +3369,21 @@ sub modDHCP($$$$$) ...@@ -3369,26 +3369,21 @@ sub modDHCP($$$$$)
$host = lc($host); $host = lc($host);
my $insubnet = 0; my $insubnet = 0;
my $inrange = 0; my $inrange = 0;
my $found = 0;
while (my $line = <OLD>) { while (my $line = <OLD>) {
if ($found) { if ($line =~ /^subnet\s*([\d\.]+)\s*netmask\s*([\d\.]+)/) {
;
} elsif ($line =~ /^subnet\s*([\d\.]+)\s*netmask\s*([\d\.]+)/) {
my $subnet = $1; my $subnet = $1;
my $submask = $2; my $submask = $2;
# #
# Is the IP we need to add, within this subnet? # Is the IP we need to add, within this subnet?
# #
$insubnet = 1 $insubnet = ((inet_ntoa(inet_aton($ip) &
if (inet_ntoa(inet_aton($ip) & inet_aton($submask)) eq $subnet) ? 1 : 0);
inet_aton($submask)) eq $subnet); } elsif ($line =~ /INSERT VNODES AFTER/) {
} elsif ($insubnet && $line =~ /INSERT VNODES AFTER/) {
$inrange = 1; $inrange = 1;
} elsif ($insubnet && $line =~ /INSERT VNODES BEFORE/) { } elsif ($line =~ /INSERT VNODES BEFORE/) {
$inrange = 0; $inrange = 0;
$found = 1; if ($insubnet && !$dorm) {
if (!$dorm) {
print NEW formatDHCP($host, $ip, $mac), "\n"; print NEW formatDHCP($host, $ip, $mac), "\n";
$changed = 1; $changed = 1;
} }
...@@ -3397,18 +3392,19 @@ sub modDHCP($$$$$) ...@@ -3397,18 +3392,19 @@ sub modDHCP($$$$$)
my $ohost = lc($3); my $ohost = lc($3);
my $oip = $2; my $oip = $2;
my $omac = lc($1); my $omac = lc($1);
if ($mac eq $omac) { #
if ($dorm) { # We skip (delete) any line with the same mac,ip,host, and
# skip this entry; don't mark found so we find all # add it back at the end. This is safe since we should never
$changed = 1; # reuse any of these across different VMs. This prevents
next; # problems where we get duplicate entries in the dhcpd.conf
} # file, say because of crashes or soft failures. This will
$found = 1; # result in a little more churning of the file, but its not
if ($host ne $ohost || $ip ne $oip) { # bad enough to worry about.
print NEW formatDHCP($host, $ip, $omac), "\n"; #
$changed = 1; if ($mac eq $omac || $host eq $ohost || $ip eq $oip) {
next; # skip this entry, mark as changed.
} $changed = 1;
next;
} }
} }
print NEW $line; print NEW $line;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment