Changeset 630 for trunk


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
Location:
trunk
Files:
2 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;
  • trunk/templates/listpool.tmpl

    r575 r630  
    3131<td>
    3232<TMPL_IF delme>
    33 <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;block=<TMPL_VAR NAME=ip>&amp;rdepth=<TMPL_VAR NAME=ipdepth>"><TMPL_VAR NAME=ip></a>
     33<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;id=<TMPL_VAR NAME=id>&amp;basetype=i"><TMPL_VAR NAME=ip></a>
    3434<TMPL_ELSE>
    35 <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=assign&amp;block=<TMPL_VAR NAME=ip>&amp;rdepth=<TMPL_VAR NAME=ipdepth>&amp;fbtype=i"><TMPL_VAR NAME=ip></a>
     35<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=assign&amp;block=<TMPL_VAR NAME=id>&amp;parent=<TMPL_VAR NAME=parent>&amp;fbtype=i"><TMPL_VAR NAME=ip></a>
    3636</TMPL_IF>
    3737</td>
     
    4040<td><TMPL_VAR NAME=desc></td>
    4141<TMPL_IF maydel><td><TMPL_IF delme>
    42 <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=delete&amp;block=<TMPL_VAR NAME=ip>&amp;rdepth=<TMPL_VAR NAME=ipdepth>&amp;alloctype=<TMPL_VAR NAME=type>">Unassign this IP</a>
     42<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=delete&amp;block=<TMPL_VAR NAME=id>&amp;basetype=i&amp;parent=<TMPL_VAR NAME=parent>">Unassign this IP</a>
    4343</TMPL_IF></td></TMPL_IF>
    4444</tr>
Note: See TracChangeset for help on using the changeset viewer.