Changeset 720 for trunk/cgi-bin/IPDB.pm


Ignore:
Timestamp:
05/07/15 15:17:05 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Second page in merge sequence; show main allocations and free blocks
that would be affected by the merge, along with reminders as
appropriate about data that may be lost with the combination of merge
scope and target type selected for the new allocation.
See #8.

File:
1 edited

Legend:

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

    r716 r720  
    2929        &initIPDBGlobals &connectDB &finish &checkDBSanity
    3030        &addMaster &touchMaster
    31         &listSummary &listSubs &listContainers &listAllocations &listFree &listPool
     31        &listSummary &listSubs &listContainers &listAllocations &listForMerge &listFree &listPool
    3232        &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    3333        &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity
     
    4545                &initIPDBGlobals &connectDB &finish &checkDBSanity
    4646                &addMaster &touchMaster
    47                 &listSummary &listSubs &listContainers &listAllocations &listFree &listPool
     47                &listSummary &listSubs &listContainers &listAllocations &listForMerge &listFree &listPool
    4848                &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    4949                &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity
     
    810810
    811811
     812## IPDB::listForMerge()
     813# Get a list of blocks targetted in a proposed merge
     814sub listForMerge {
     815  my $dbh = shift;
     816  my $parent = shift;
     817  my $newblock = shift;
     818  my $btype = shift || 'a';
     819  $btype = 'a' if $btype !~/^[af]$/;
     820
     821  my $sql;
     822  if ($btype eq 'a') {
     823    my $ret = $dbh->selectall_arrayref(q(
     824        SELECT a.cidr,a.id,t.dispname FROM allocations a
     825        JOIN alloctypes t ON a.type=t.type
     826        WHERE a.parent_id = ? AND a.cidr <<= ?
     827        ORDER BY a.cidr
     828        ),
     829        { Slice => {} }, $parent, $newblock);
     830    return $ret;
     831  } else {
     832##fixme:  Not sure about the casting hackery in "SELECT ?::integer AS id", but it works as intended
     833    my $ret = $dbh->selectall_arrayref(q(
     834        SELECT cidr,id FROM freeblocks
     835        WHERE parent_id IN (SELECT ?::integer AS id UNION
     836                SELECT id FROM allocations WHERE parent_id = ? AND cidr <<= ?
     837        ) AND cidr <<= ?
     838        ORDER BY cidr
     839        ),
     840        { Slice => {} }, $parent, $parent, $newblock, $newblock) or print $dbh->errstr;
     841    return $ret;
     842  }
     843} # end listForMerge()
     844
     845
    812846## IPDB::listFree()
    813847# Gets a list of free blocks in the requested parent/master and VRF instance in both CIDR and range notation
Note: See TracChangeset for help on using the changeset viewer.