Changeset 866


Ignore:
Timestamp:
05/02/16 17:59:07 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

main.cgi:

  • Don't spew warnings and break the UI when retrieval of the zone list for a netblock fails

IPDB.pm, ipdb-rpc.cgi:

  • Fill out rpc_listPool stub in ipdb-rpc.cgi. The first likely consumer may not want the full UI dataset (with description and "deleteme" flag) so the core sub has been extended with an optional flag that defaults to on.

ipdb-rpc.cgi:

  • Correct argument validation in rpc_deleteBlock()
Location:
trunk/cgi-bin
Files:
3 edited

Legend:

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

    r862 r866  
    12161216  my $dbh = shift;
    12171217  my $pool = shift;
     1218  my $incdesc = shift;
     1219  $incdesc = 1 if !defined($incdesc);  # extra flag to include description and "deleteme" flag
    12181220
    12191221  my $sth = $dbh->prepare("SELECT ip,custid,available,description,type,id".
     
    12261228        custid => $custid,
    12271229        available => $available,
    1228         desc => $desc,
    1229         delme => $available eq 'n',
    12301230        parent => $pool,
    12311231        id => $id,
    12321232        );
     1233    if ($incdesc) {
     1234      $row{desc} = $desc;
     1235      $row{delme} = ($available eq 'n');
     1236    }
    12331237    push @poolips, \%row;
    12341238  }
  • trunk/cgi-bin/ipdb-rpc.cgi

    r852 r866  
    199199sub rpc_listAllocations {}
    200200sub rpc_listFree {}
    201 sub rpc_listPool {}
     201
     202
     203sub rpc_listPool {
     204  my %args = @_;
     205
     206  _commoncheck(\%args, 'y');
     207
     208  $args{include_desc} = 0 if !$args{include_desc};
     209
     210  # convert passed pool from CIDR to an ID, maybe
     211  if ($args{pool} !~ /^\d+$/) {
     212    die "Invalid pool argument" if $args{pool} !~ m{^\d+\.\d+\.\d+\.\d+/\d+$};
     213    die "VRF is required\n" if !$args{vrf};  # VRF name may not be empty
     214    ($pid) = $ip_dbh->selectrow_array("SELECT a.id FROM allocations a JOIN allocations m ON a.master_id=m.id".
     215        " WHERE a.cidr = ? AND m.vrf = ?", undef, $args{pool}, $args{vrf});
     216  }
     217
     218  return listPool($ip_dbh, $pid, $args{include_desc});
     219} # rpc_listPool()
     220
     221
    202222sub rpc_getMasterList {}
    203223sub rpc_getTypeList {}
     
    291311  _commoncheck(\%args, 'y');
    292312
    293   _validateInput(\%args);
     313  if (!$args{block}) {
     314    $args{block} = $args{cidr} if $args{cidr};
     315    die "Block/IP is required\n" if !$args{block};
     316  }
    294317
    295318  if ($args{block} =~ m{^(?:\d+\.){3}\d+(?:/32)?$}) {
  • trunk/cgi-bin/main.cgi

    r855 r866  
    474474  $page->param(maydel => $IPDBacl{$authuser} =~ /d/);
    475475
    476   my $plist = listPool($ip_dbh, $webvar{pool});
     476  my $plist = listPool($ip_dbh, $webvar{pool}, 1);
    477477  $page->param(poolips => $plist);
    478478} # end showPool
     
    11111111    my $revlist = getRevID($ip_dbh, user => $authuser, cidr => $blockinfo->{block},
    11121112        location => $blockinfo->{location});
    1113     $page->param(revlist => $revlist);
     1113    $page->param(revlist => $revlist) if $revlist;
    11141114
    11151115    my $cached;
Note: See TracChangeset for help on using the changeset viewer.