Changeset 561
- Timestamp:
- 12/19/12 16:09:04 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r560 r561 27 27 &initIPDBGlobals &connectDB &finish &checkDBSanity 28 28 &addMaster &touchMaster 29 &listSummary &list Master &listRBlock&listFree &listPool29 &listSummary &listSubs &listFree &listPool 30 30 &getMasterList &getTypeList &getPoolSelect &findAllocateFrom 31 31 &ipParent &subParent &blockParent &getRoutedCity … … 41 41 &initIPDBGlobals &connectDB &finish &checkDBSanity 42 42 &addMaster &touchMaster 43 &listSummary &list Master &listRBlock&listFree &listPool43 &listSummary &listSubs &listFree &listPool 44 44 &getMasterList &getTypeList &getPoolSelect &findAllocateFrom 45 45 &ipParent &subParent &blockParent &getRoutedCity … … 359 359 return $mlist; 360 360 } # end listSummary() 361 362 363 ## IPDB::listSubs() 364 # Get list of subnets within a specified CIDR block, on a specified VRF. 365 # Returns an arrayref to a list of hashrefs containing the CIDR block, customer location or 366 # city it's routed to, block type, SWIP status, and description 367 sub listSubs { 368 my $dbh = shift; 369 my %args = @_; 370 371 # Just In Case 372 $args{vrf} = '' if !$args{vrf}; 373 $args{rdepth} = 1 if !$args{rdepth}; 374 375 # Snag the allocations for this block 376 my $sth = $dbh->prepare("SELECT cidr,city,type,custid,swip,description". 377 " FROM allocations WHERE parent = ? AND rdepth = ? ORDER BY cidr"); 378 $sth->execute($args{block},$args{rdepth}); 379 380 # hack hack hack 381 # set up to flag swip=y records if they don't actually have supporting data in the customers table 382 my $custsth = $dbh->prepare("SELECT count(*) FROM customers WHERE custid = ?"); 383 384 my @blocklist; 385 while (my ($cidr,$city,$type,$custid,$swip,$desc) = $sth->fetchrow_array()) { 386 $custsth->execute($custid); 387 my ($ncust) = $custsth->fetchrow_array(); 388 my %row = ( 389 block => $cidr, 390 city => $city, 391 type => $disp_alloctypes{$type}, 392 custid => $custid, 393 swip => ($swip eq 'y' ? 'Yes' : 'No'), 394 partswip => ($swip eq 'y' && $ncust == 0 ? 1 : 0), 395 desc => $desc, 396 hassubs => ($type eq 'rm' || $type =~ /.c/ ? 1 : 0), 397 ); 398 # $row{subblock} = ($type =~ /^.r$/); # hmf. wonder why these won't work in the hash declaration... 399 $row{listpool} = ($type =~ /^.[pd]$/); 400 push (@blocklist, \%row); 401 } 402 return \@blocklist; 403 } # end listSubs() 361 404 362 405
Note:
See TracChangeset
for help on using the changeset viewer.