- Timestamp:
- 05/20/15 14:11:36 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r723 r724 214 214 my $dbh = shift; 215 215 my $id = shift; 216 my $createfb = shift; # may be null at this point 216 217 217 218 my $binfo = getBlockData($dbh, $id); 219 220 # Decide if we're going to add a free block. 221 222 # Caller is normal block delete -> add freeblock under $binfo->{parent_id} -> pass nothing 223 # Caller is delete for merge to leaf -> do not add freeblock -> pass 0 224 # Caller is normal master delete -> do not add freeblock -> pass nothing 225 # Caller is merge master -> add freeblock under alternate parent -> pass parent ID 226 if ($binfo->{type} ne 'mm') { 227 # Deleting a non-master block 228 if (!defined($createfb)) { 229 # No createfb flag passed; assuming normal block delete. Add the freeblock 230 # under the parent of the block we're deleting. 231 $createfb = $binfo->{parent_id}; 232 #} else { 233 # Don't need to actually do anything here. The caller has given us an ID, 234 # which is either 0 (causing no free block) or (theoretically) a valid block 235 # ID to add the free block under. 236 } 237 #} else { 238 # Deleting a master block 239 # Don't need to actually do anything here. If the caller passed a parent ID, 240 # that parent will get the new free block. if the caller didn't pass anything, 241 # no free block will be added. 242 } 218 243 219 244 ##fixme: special-case master blocks up here and quickly delete based on master_id, … … 279 304 $dbh->do("DELETE FROM poolips WHERE parent_id IN ($b)", undef, (@dellist) ); 280 305 281 # Insert a new free block i n the target's parent, unless we just deleted a whole master block.282 if ($ binfo->{type} ne 'mm') {283 my $pinfo = getBlockData($dbh, $ binfo->{parent_id});306 # Insert a new free block if needed 307 if ($createfb) { 308 my $pinfo = getBlockData($dbh, $createfb); 284 309 my $pt = (split //, $pinfo->{type})[1]; 285 310 $dbh->do("INSERT INTO freeblocks (cidr,city,routed,parent_id,vrf,master_id) VALUES (?,?,?,?,?,?)", undef, 286 $binfo->{block}, $pinfo->{city}, $pt, $ binfo->{parent_id}, $pinfo->{vrf}, $binfo->{master_id});311 $binfo->{block}, $pinfo->{city}, $pt, $createfb, $pinfo->{vrf}, $binfo->{master_id}); 287 312 } 288 313 289 314 ##todo: and hey! bonus! we can return @dellist, or something (%cidrlist{@dellist}) 315 290 316 } # end _deleteCascade() 291 317
Note:
See TracChangeset
for help on using the changeset viewer.