Changeset 634 for trunk/cgi-bin/IPDB.pm


Ignore:
Timestamp:
10/09/14 12:37:39 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Commit 8/mumble for work done intermittently over the past ~year.
See #5, comment 25:

  • Netblock update
File:
1 edited

Legend:

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

    r633 r634  
    11661166  return ('FAIL', 'Missing block to update') if !$args{block};
    11671167
     1168  # Spaces don't show up well in lots of places.  Make sure they don't get into the DB.
     1169  $args{custid} =~ s/^\s+//;
     1170  $args{custid} =~ s/\s+$//;
     1171
    11681172  # do it all in a transaction
    11691173  local $dbh->{AutoCommit} = 0;
     
    11791183  }
    11801184
     1185  my $binfo;
    11811186  my $updtable = 'allocations';
    1182   my $keyfield = 'cidr';
     1187  my $keyfield = 'id';
    11831188  if ($args{type} =~ /^(.)i$/) {
    11841189    $updtable = 'poolips';
    1185     $keyfield = 'ip';
     1190    $binfo = getBlockData($dbh, $args{block}, 'i');
    11861191  } else {
    11871192## fixme:  there's got to be a better way...
     1193    $binfo = getBlockData($dbh, $args{block});
    11881194    if ($args{swip}) {
    11891195      if ($args{swip} eq 'on' || $args{swip} eq '1' || $args{swip} eq 'y') {
     
    12031209  return ('FAIL', 'No fields to update') if !@fieldlist;
    12041210
    1205 #  push @vallist, $args{block}, $args{rdepth}, $args{vrf};
    1206   push @vallist, $args{block}, $args{rdepth};
     1211  push @vallist, $args{block};
    12071212  my $sql = "UPDATE $updtable SET ";
    12081213  $sql .= join " = ?, ", @fieldlist;
    1209 #  $sql .= " = ? WHERE $keyfield = ? AND rdepth = ? AND vrf = ?";
    1210   $sql .= " = ? WHERE $keyfield = ? AND rdepth = ? ";
     1214  $sql .= " = ? WHERE $keyfield = ?";
    12111215
    12121216  eval {
     
    12161220    if ($args{node}) {
    12171221      # done with delete/insert so we don't have to worry about funkyness updating a node ref that isn't there
    1218       $dbh->do("DELETE FROM noderef WHERE block = ?", undef, ($args{block}) );
    1219       $dbh->do("INSERT INTO noderef (block,node_id) VALUES (?,?)", undef, ($args{block}, $args{node}) );
     1222      $dbh->do("DELETE FROM noderef WHERE block = ?", undef, ($binfo->{block}) );
     1223      $dbh->do("INSERT INTO noderef (block,node_id) VALUES (?,?)", undef, ($binfo->{block}, $args{node}) )
     1224        if $args{node} ne '--';
    12201225    }
    12211226
     
    12281233  }
    12291234
    1230   _rpc('addOrUpdateRevRec', cidr => $args{block}, name => $args{rdns}, rpcuser => $args{user});
     1235  $binfo->{block} =~ s|/32$||;
     1236  _rpc('addOrUpdateRevRec', cidr => $binfo->{block}, name => $args{rdns}, rpcuser => $args{user});
    12311237  return ('OK','OK');
    12321238} # end updateBlock()
Note: See TracChangeset for help on using the changeset viewer.