Changeset 591 for trunk


Ignore:
Timestamp:
01/25/13 16:16:04 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

File off rough edges doing DNS updates for deleting allocations. See #1.

  • pass back and handle more subtle variations on WARN
  • add a watch comment noting some bizarre behaviour that could not be duplicated later.
  • more fully handle large allocations spanning multiple reverse zones (eg, /23 dynamic DSL spans 2 /24 reverse zones)
  • retrieve the DNS pattern from the parent in case of zone-spanning block deletes; the records in the zone can't be relied on to rebuild an "unused"-ish record in this case.

Should use dnsadmin:trunk/@r460 or higher for proper behaviour.

Location:
trunk
Files:
3 edited

Legend:

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

    r590 r591  
    254254sub addMaster {
    255255  my $dbh = shift;
     256        # warning!  during testing, this somehow generated a "Bad file descriptor" error.  O_o
    256257  my $cidr = new NetAddr::IP shift;
    257258  my %args = @_;
     
    12611262      eval { $dbh->rollback; };
    12621263      return ('FAIL', $msg);
     1264    }
     1265
     1266    # Have to handle potentially split reverse zones.  Assume they *are* split,
     1267    # since if we added them here, they would have been added split.
     1268# allow splitting reverse zones to be disabled, maybe, someday
     1269#if ($splitrevzones && !$cidr->{isv6}) {
     1270    my @zonelist;
     1271    if (1 && !$cidr->{isv6}) {
     1272      my $splitpoint = ($cidr->masklen <= 16 ? 16 : 24);        # hack pthui
     1273      @zonelist = $cidr->split($splitpoint);
    12631274    } else {
    1264 ##fixme:  RPC return code?
    1265       _rpc('delZone', zone => "$cidr", user => $user, revrec => 'y');
    1266       return ('OK',"OK");
    1267     }
     1275      @zonelist = ($cidr);
     1276    }
     1277    my @fails;
     1278    foreach my $subzone (@zonelist) {
     1279      if ($rpc_url && !_rpc('delZone', zone => "$subzone", revrec => 'y', user => $user, delforward => $delfwd) ) {
     1280        push @fails, ("$subzone" => $errstr);
     1281      }
     1282    }
     1283    if (@fails) {
     1284      return ('WARN',"Warning(s) deleting $cidr from reverse DNS:\n".join("\n", @fails));
     1285    }
     1286    return ('OK','OK');
    12681287
    12691288  } else { # end alloctype master block case
     
    12751294
    12761295    my $retcode = 'OK';
     1296    my ($ptype,$pcity,$ppatt);
    12771297
    12781298    eval {
     
    12891309
    12901310##fixme:  we could maybe eliminate a special case if we put masterblocks in the allocations table...?
    1291       my ($ptype,$pcity);
    12921311      if ($rdepth == 1) {
    12931312        # parent is a master block.
    12941313        $ptype = 'mm';
    12951314        $pcity = '<NULL>';
     1315        $ppatt = $dbh->selectrow_array("SELECT rdns FROM masterblocks WHERE cidr=?", undef, ($parent) );
    12961316      } else {
    12971317        # get that parent's details
    1298         ($ptype,$pcity) = $dbh->selectrow_array("SELECT type,city FROM allocations ".
     1318        ($ptype,$pcity,$ppatt) = $dbh->selectrow_array("SELECT type,city,rdns FROM allocations ".
    12991319                "WHERE cidr=? AND rdepth=?", undef, ($parent, $rdepth-1) );
    13001320      }
     
    13211341        $pcity = $tcity;
    13221342        ##fixme: hmm.  collect $rdepth into $goback here before vanishing?
    1323         $retcode = 'WARN';      # may be redundant
     1343        $retcode = 'WARNMERGE'; # may be redundant
    13241344        $goback = $tparent;
    13251345        # munge freeblock rdepth and parent to match true parent
     
    14351455    } else {
    14361456##fixme:  RPC return code?
    1437       _rpc('delByCIDR', cidr => "$cidr", user => $user, delforward => $delfwd, delsubs => 'y');
     1457      _rpc('delByCIDR', cidr => "$cidr", user => $user, delforward => $delfwd, delsubs => 'y', parpatt => $ppatt);
    14381458      return ($retcode, $goback);
    14391459    }
  • trunk/cgi-bin/main.cgi

    r590 r591  
    895895  $page->param(delparent => $blockinfo->{parent}) if $webvar{rdepth};
    896896  $page->param(prdepth => $webvar{rdepth});
    897   if ($code =~ /^WARN/) {
     897  if ($code =~ /^WARN(POOL|MERGE)/) {
    898898    my ($bp,$bd) = split /,/, $msg;
    899899    $page->param(bparent => $bp);
     
    901901    $page->param(mergeip => $code eq 'WARNPOOL');
    902902  }
    903 
     903  if ($code eq 'WARN') {
     904    $msg =~ s/\n/<br>\n/g;
     905    $page->param(genwarn => $msg);
     906  }
    904907  if ($code eq 'OK' || $code =~ /^WARN/) {
    905908    syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block} ".
  • trunk/templates/finaldelete.tmpl

    r577 r591  
    55<TMPL_ELSE>
    66<div class="heading">Success!  <TMPL_VAR NAME=block> deallocated.</div>
     7<TMPL_IF genwarn><br><div><TMPL_VAR NAME=genwarn></div></TMPL_IF>
    78<TMPL_IF bparent><br><div>
    89Warning: 
Note: See TracChangeset for help on using the changeset viewer.