Changeset 686 for trunk/cgi-bin


Ignore:
Timestamp:
01/29/15 16:47:08 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Put a bit of polish on updating DNS records when updating containers
(particularly when the container is the master block). We don't want
to stomp downstream subs, so we only update free blocks. This may result
in new DNS "sub" blocks, but when things get deleted far enough up the
chain they all go away anyway.

File:
1 edited

Legend:

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

    r682 r686  
    13011301  }
    13021302
    1303   $binfo->{block} =~ s|/32$||;
    1304   _rpc('addOrUpdateRevRec', cidr => $binfo->{block}, name => $args{rdns}, rpcuser => $args{user});
    1305 
    1306   # and the per-IP set, if there is one.
    1307   _rpc('updateRevSet', %{$args{iprev}}, rpcuser => $args{user});
     1303  # In case of any container (mainly master block), only update freeblocks so we don't stomp subs
     1304  # (which would be the wrong thing in pretty much any case except "DELETE ALL EVARYTHING!!1!oneone!")
     1305  if ($binfo->{type} =~ '.[mc]') {
     1306    # Not using listFree() as it doesn't return quite all of the blocks wanted.
     1307    # Retrieve the immediate free blocks
     1308    my $sth = $dbh->prepare(q(
     1309        SELECT cidr FROM freeblocks WHERE parent_id = ?
     1310        UNION
     1311        SELECT cidr FROM freeblocks f WHERE
     1312                cidr = (SELECT cidr FROM allocations a WHERE f.cidr = a.cidr)
     1313                AND master_id = ?
     1314        ) );
     1315    $sth->execute($args{block}, $binfo->{master_id});
     1316    my %fbset;
     1317    while (my ($fb) = $sth->fetchrow_array) {
     1318      $fbset{"host_$fb"} = $args{rdns};
     1319    }
     1320    # We use this RPC call instead of multiple addOrUpdateRevRec calls, since we don't
     1321    # know how many records we'll be updating and more than 3-4 is far too slow.  This
     1322    # should be safe to call unconditionally.
     1323    # Requires dnsadmin >= r678
     1324    _rpc('updateRevSet', %fbset, rpcuser => $args{user});
     1325
     1326  } else {
     1327    $binfo->{block} =~ s|/32$||;
     1328    _rpc('addOrUpdateRevRec', cidr => $binfo->{block}, name => $args{rdns}, rpcuser => $args{user});
     1329
     1330    # and the per-IP set, if there is one.
     1331    _rpc('updateRevSet', %{$args{iprev}}, rpcuser => $args{user}) if keys (%{$args{iprev}});
     1332  }
    13081333
    13091334  return ('OK','OK');
Note: See TracChangeset for help on using the changeset viewer.