Changeset 738 for trunk/cgi-bin


Ignore:
Timestamp:
05/28/15 18:13:44 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Fill in merge-to-leaf. See #8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r737 r738  
    23802380    } elsif ($args{newtype} =~ /.[enr]/) {
    23812381      ## Leaf
    2382 
    2383     } # new type if()
     2382      # Merging to a leaf type of any kind is, pretty much be definition, scope == 'clearall'.
     2383      # keepall, mergepeer, and clearpeer all imply keeping suballocations, where leaf allocations
     2384      # by definition do not have suballocations.
     2385      # Snag the new parent info for the return list
     2386      push @retlist, {block => "$newblock", type => $disp_alloctypes{$args{newtype}}, id => $prime};
     2387      while (my ($peercidr, $peer_id, $peertype, $m_id) = $peersth->fetchrow_array) {
     2388        next if $peer_id == $prime;
     2389        # Push existing allocations down a level before deleting,
     2390        # so that when they're deleted the parent info is correct
     2391        $reparentsth->execute($prime, $binfo->{master_id}, $peer_id);
     2392        _deleteCascade($dbh, $peer_id, 0);
     2393        # Capture block for return
     2394        push @retlist, { block => $peercidr, mtype => $disp_alloctypes{$peertype} };
     2395      }
     2396      # Delete any subs of $prime as well
     2397      my $substh = $dbh->prepare("SELECT cidr,id FROM allocations WHERE parent_id = ?");
     2398      $substh->execute($prime);
     2399      while (my ($scidr, $s_id) = $substh->fetchrow_array) {
     2400        _deleteCascade($dbh, $s_id);
     2401      }
     2402      # Clean up lingering free blocks and pool IPs
     2403      $dbh->do("DELETE FROM freeblocks WHERE cidr <<= ? AND (parent_id = ? OR parent_id = ?)", undef,
     2404          $newblock, $binfo->{parent_id}, $prime);
     2405      $dbh->do("DELETE FROM poolips WHERE parent_id = ? AND ip <<= ? ", undef,
     2406          $prime, $newblock);
     2407
     2408    } # $args{newtype} if()
    23842409
    23852410    $dbh->commit;
Note: See TracChangeset for help on using the changeset viewer.