Changeset 562 for trunk/cgi-bin
- Timestamp:
- 12/19/12 16:18:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r561 r562 472 472 473 473 ## IPDB::listFree() 474 # Gets a list of free blocks in the requested parent/master in both CIDR and range notation475 # Takes a parent/master and an optional "routed or unrouted" flag that defaults to unrouted.474 # Gets a list of free blocks in the requested parent/master and VRF instance in both CIDR and range notation 475 # Takes a parent/master and an optional VRF specifier that defaults to empty. 476 476 # Returns an arrayref to a list of hashrefs containing the CIDR and range-notation blocks 477 477 # Returns some extra flags in the hashrefs for routed blocks, since those can have several subtypes 478 478 sub listFree { 479 479 my $dbh = shift; 480 my $master = shift; 481 my $routed = shift || 'n'; 480 481 my %args = @_; 482 # Just In Case 483 $args{vrf} = '' if !$args{vrf}; 484 $args{rdepth} = 1 if !$args{rdepth}; 482 485 483 486 # do it this way so we can waste a little less time iterating 484 my $sth = $dbh->prepare("SELECT cidr ,routed FROM freeblocks WHERE cidr <<= ? AND".485 ($routed eq 'n' ? '' : 'NOT')." routed = 'n'ORDER BY cidr");486 $sth->execute($ master);487 my $sth = $dbh->prepare("SELECT cidr FROM freeblocks WHERE parent = ? AND rdepth = ? AND vrf = ? ". 488 "ORDER BY cidr"); 489 $sth->execute($args{master}, $args{rdepth}, $args{vrf}); 487 490 my @flist; 488 while (my ($cidr ,$rtype) = $sth->fetchrow_array()) {491 while (my ($cidr) = $sth->fetchrow_array()) { 489 492 $cidr = new NetAddr::IP $cidr; 490 493 my %row = ( … … 492 495 frange => $cidr->range, 493 496 ); 494 if ($routed eq 'y') {495 $row{subblock} = ($rtype ne 'y' && $rtype ne 'n');496 $row{fbtype} = $rtype;497 }498 497 push @flist, \%row; 499 498 }
Note:
See TracChangeset
for help on using the changeset viewer.