Changeset 662


Ignore:
Timestamp:
12/30/14 12:15:07 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Remove obsolete listMaster() and listRBlock() subs

File:
1 edited

Legend:

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

    r661 r662  
    550550
    551551
    552 ## IPDB::listMaster()
    553 # Get list of routed blocks in the requested master
    554 # Returns an arrayref to a list of hashrefs containing the routed block, POP/city the block is routed to,
    555 # allocated count, free count, and largest free block masklength
    556 sub listMaster {
    557   my $dbh = shift;
    558   my $master = shift;
    559 
    560   my $rlist = $dbh->selectall_arrayref("SELECT cidr AS block,city FROM routed WHERE cidr <<= ? ORDER BY cidr",
    561         { Slice => {} }, ($master) );
    562 
    563   foreach (@{$rlist}) {
    564     my ($acnt) = $dbh->selectrow_array("SELECT count(*) FROM allocations WHERE cidr <<= ?", undef, ($$_{block}));
    565     $$_{nsubs} = $acnt;
    566     my ($fcnt) = $dbh->selectrow_array("SELECT count(*) FROM freeblocks WHERE cidr <<= ?".
    567         " AND (routed='y' OR routed='n')", undef, ($$_{block}));
    568     $$_{nfree} = $fcnt;
    569     my ($bigfree) = $dbh->selectrow_array("SELECT maskbits FROM freeblocks WHERE cidr <<= ?".
    570         " AND (routed='y' OR routed='n') ORDER BY maskbits LIMIT 1", undef, ($$_{block}));
    571 ##fixme:  should find a way to do this without having to HTMLize the <>
    572     $bigfree = "/$bigfree" if $bigfree;
    573     $bigfree = '<NONE>' if !$bigfree;
    574     $$_{lfree} = $bigfree;
    575   }
    576   return $rlist;
    577 } # end listMaster()
    578 
    579 
    580 ## IPDB::listRBlock()
    581 # Gets a list of free blocks in the requested parent/master in both CIDR and range notation
    582 # Takes a parent/master and an optional flag to look at routed or unrouted blocks, depending
    583 # on whether the master is a direct master or a routed block
    584 # Returns an arrayref to a list of hashrefs containing the CIDR and range-notation blocks
    585 sub listRBlock {
    586   my $dbh = shift;
    587   my $routed = shift;
    588 
    589   # Snag the allocations for this block
    590   my $sth = $dbh->prepare("SELECT cidr,city,type,custid,swip,description".
    591         " FROM allocations WHERE cidr <<= ? ORDER BY cidr");
    592   $sth->execute($routed);
    593 
    594   # hack hack hack
    595   # set up to flag swip=y records if they don't actually have supporting data in the customers table
    596   my $custsth = $dbh->prepare("SELECT count(*) FROM customers WHERE custid = ?");
    597 
    598   my @blocklist;
    599   while (my ($cidr,$city,$type,$custid,$swip,$desc) = $sth->fetchrow_array()) {
    600     $custsth->execute($custid);
    601     my ($ncust) = $custsth->fetchrow_array();
    602     my %row = (
    603         block => $cidr,
    604         city => $city,
    605         type => $disp_alloctypes{$type},
    606         custid => $custid,
    607         swip => ($swip eq 'y' ? 'Yes' : 'No'),
    608         partswip => ($swip eq 'y' && $ncust == 0 ? 1 : 0),
    609         desc => $desc
    610         );
    611     $row{subblock} = ($type =~ /^.r$/);         # hmf.  wonder why these won't work in the hash declaration...
    612     $row{listpool} = ($type =~ /^.[pd]$/);
    613     push (@blocklist, \%row);
    614   }
    615   return \@blocklist;
    616 } # end listRBlock()
    617 
    618 
    619552## IPDB::listFree()
    620553# 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.