Changeset 630 for trunk/cgi-bin


Ignore:
Timestamp:
10/08/14 17:31:48 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Commit 5/mumble for work done intermittently over the past ~year.
See #5, comment 25:

  • Update free blocks lister IPDB::listFree()
  • Update IP pool lister IPDB::listPool() and IP pool template page
File:
1 edited

Legend:

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

    r629 r630  
    590590## IPDB::listFree()
    591591# Gets a list of free blocks in the requested parent/master and VRF instance in both CIDR and range notation
    592 # Takes a parent/master and an optional VRF specifier that defaults to empty.
     592# Takes a parent/master ID and an optional VRF specifier that defaults to empty.
    593593# Returns an arrayref to a list of hashrefs containing the CIDR and range-notation blocks
    594594# Returns some extra flags in the hashrefs for routed blocks, since those can have several subtypes
     
    599599  # Just In Case
    600600  $args{vrf} = '' if !$args{vrf};
    601   $args{rdepth} = 1 if !$args{rdepth};
    602 
    603   # do it this way so we can waste a little less time iterating
    604 #  my $sth = $dbh->prepare("SELECT cidr FROM freeblocks WHERE parent = ? AND rdepth = ? AND vrf = ? ".
    605   my $sth = $dbh->prepare("SELECT cidr FROM freeblocks WHERE parent = ? AND rdepth = ? ".
    606         "ORDER BY cidr");
    607 #  $sth->execute($args{master}, $args{rdepth}, $args{vrf});
    608   $sth->execute($args{master}, $args{rdepth});
     601
     602  my $sth = $dbh->prepare("SELECT cidr,id FROM freeblocks WHERE parent_id = ? ORDER BY cidr");
     603#  $sth->execute($args{parent}, $args{vrf});
     604  $sth->execute($args{parent});
    609605  my @flist;
    610   while (my ($cidr) = $sth->fetchrow_array()) {
     606  while (my ($cidr,$id) = $sth->fetchrow_array()) {
    611607    $cidr = new NetAddr::IP $cidr;
    612608    my %row = (
    613609        fblock => "$cidr",
    614610        frange => $cidr->range,
     611        fbid => $id,
     612        fbparent => $args{parent},
    615613        );
    616614    push @flist, \%row;
     
    626624  my $pool = shift;
    627625
    628   my $sth = $dbh->prepare("SELECT ip,custid,available,description,type,rdepth".
    629         " FROM poolips WHERE pool = ? ORDER BY ip");
     626  my $sth = $dbh->prepare("SELECT ip,custid,available,description,type,id".
     627        " FROM poolips WHERE parent_id = ? ORDER BY ip");
    630628  $sth->execute($pool);
    631629  my @poolips;
    632   while (my ($ip,$custid,$available,$desc,$type,$rdepth) = $sth->fetchrow_array) {
     630  while (my ($ip,$custid,$available,$desc,$type,$id) = $sth->fetchrow_array) {
    633631    my %row = (
    634632        ip => $ip,
     
    637635        desc => $desc,
    638636        delme => $available eq 'n',
    639         ipdepth => $rdepth,
     637        parent => $pool,
     638        id => $id,
    640639        );
    641640    push @poolips, \%row;
Note: See TracChangeset for help on using the changeset viewer.