Changeset 696
- Timestamp:
- 02/13/15 17:35:24 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r695 r696 1240 1240 } 1241 1241 1242 # Dodge an edge case - pool where IPs have been "stolen" and turned into a netblock assignment. 1243 # We can't just "get all the current IPs, and add the missing ones", because some IPs are 1244 # legitimately missing (for stretchy values of "legitimately"). 1245 1246 my $pdata = getBlockData($dbh, $parent); 1247 my $pcidr = new NetAddr::IP $pdata->{block}; 1248 1249 if ($pcidr != $pool) { 1250 # enumerate the IPs from the *old* pool, flag them as "found", so we can iterate the entire 1251 # requested pool and still make sure we skip the IPs in the old pool - even if they've been 1252 # "stolen" by legacy netblocks. 1253 my @oldips = $pcidr->hostenum; 1254 # decide whether to start excluding existing IPs at the "gateway" or "gateway+1" 1255 my $ostart = ($pdata->{type} =~ /^.d$/ ? 1 : 0); 1256 for (my $i = $ostart; $i<= $#oldips; $i++) { 1257 $foundips{$oldips[$i]} = 1; 1258 } 1259 } 1260 1242 1261 # enumerate the hosts in the IP range - everything except the first (net) and last (bcast) IP 1243 1262 my @poolip_list = $pool->hostenum; … … 1246 1265 # (but the set won't be in oooorderrrrr! <pout>) 1247 1266 for (my $i=1; $i<=$#poolip_list; $i++) { 1248 $sth->execute($poolip_list[$i]->addr, $pcustid, $city, $type, $parent) unless $foundips{$poolip_list[$i]}; 1267 my $baseip = $poolip_list[$i]->addr; 1268 if ($baseip !~ /\.(?:0|255)$/ && !$foundips{$poolip_list[$i]}) { 1269 $sth->execute($baseip, $pcustid, $city, $type, $parent); 1270 } 1249 1271 } 1250 1272 … … 1255 1277 $sth->execute($pool->addr, $pcustid, $city, $type, $parent) unless $foundips{$pool->addr}; 1256 1278 } 1257 $sth->execute($poolip_list[0]->addr, $pcustid, $city, $type, $parent) unless $ poolip_list[0];1279 $sth->execute($poolip_list[0]->addr, $pcustid, $city, $type, $parent) unless $foundips{$poolip_list[0]}; 1258 1280 $pool--; 1259 1281 if ($pool->addr !~ /\.255$/) { # .255 can cause weirdness.
Note:
See TracChangeset
for help on using the changeset viewer.