Changeset 768 for trunk/cgi-bin


Ignore:
Timestamp:
08/24/15 18:17:49 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

  • Fix getPoolSelect to return the pool ID
  • Catch some log-noise-inducing messiness in allocateBlock() on guided allocation of a static IP
File:
1 edited

Legend:

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

    r764 r768  
    11781178
    11791179  my $plist = $dbh->selectall_arrayref( q(
    1180         SELECT count(*) AS poolfree,p.pool AS poolblock, a.city AS poolcit
     1180        SELECT a.id as poolid,count(*) AS poolfree,a.cidr AS poolblock, a.city AS poolcit
    11811181        FROM poolips p
    11821182        JOIN allocations a ON p.parent_id=a.id
    11831183        WHERE p.available='y' AND a.city = ? AND p.type LIKE ?
    1184         GROUP BY p.pool,a.city
     1184        GROUP BY a.id,a.cidr,a.city
     1185        ORDER BY a.cidr
    11851186        ),
    11861187        { Slice => {} }, ($pcity, $ptype) );
     
    13811382  my %args = @_;
    13821383
    1383   $args{cidr} = new NetAddr::IP $args{cidr};
     1384  if ($args{cidr} eq 'Single static IP') {
     1385    $args{cidr} = '';
     1386  } else {
     1387    $args{cidr} = new NetAddr::IP $args{cidr};
     1388  }
    13841389
    13851390  $args{desc} = '' if !$args{desc};
     
    13931398  # Could arguably allow this for eg /120 allocations, but end users who get a single v4 IP are
    13941399  # usually given a v6 /64, and most v6 addressing schemes need at least half that address space
    1395   if ($args{cidr}->{isv6} && $args{rdns} =~ /\%/) {
     1400  if ($args{cidr} && $args{cidr}->{isv6} && $args{rdns} =~ /\%/) {
    13961401    return ('FAIL','Reverse DNS template patterns are not supported for IPv6 allocations');
    13971402  }
     
    14261431          if $isavail eq 'n';
    14271432      } else {  # IP not specified, take first available
    1428         ($args{cidr}) = $dbh->selectrow_array("SELECT ip FROM poolips WHERE pool=? AND available='y' ORDER BY ip",
    1429                 undef, ($args{alloc_from}) );
     1433        ($args{cidr}) = $dbh->selectrow_array("SELECT ip FROM poolips WHERE parent_id=? AND available='y' ORDER BY ip",
     1434                undef, ($args{parent}) );
    14301435      }
    14311436      $dbh->do("UPDATE poolips SET custid = ?, city = ?,available='n', description = ?, notes = ?, ".
Note: See TracChangeset for help on using the changeset viewer.