Changeset 754 for trunk


Ignore:
Timestamp:
07/03/15 16:35:36 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

rDNS call management wrapup. See #41, #1.

Wrap almost all existing RPC calls in suitable barriers so we don't try
to make changes for IP blocks not in dnsadmin:

  • Add new allocation (any type - note, may not handle edge case of a multizone block well or at all)
  • Allocation update
  • Split block
  • Shrink block
  • Delete allocation (arguably this could be done unconditionally)

Note an exception to skipping rDNS changes when deleting a master block.

Fix a minor logic bug in getBlockRDNS; return the cached value and leave
the cached flag set if nothing was retrieved. This seems marginally less
wrong than retrieving nothing and unsetting the flag.

File:
1 edited

Legend:

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

    r753 r754  
    14441444      return ('FAIL', $msg);
    14451445    } else {
    1446       _rpc('addOrUpdateRevRec', cidr => "$args{cidr}", name => $args{rdns}, rpcuser => $args{user});
     1446      # Snag the pool info
     1447      my $pinfo = getBlockData($args{parent});
     1448      # Only try to update rDNS when the pool is flagged as "rDNS available"
     1449      if ($binfo->{revavail} || $binfo->{revpartial}) {
     1450        _rpc('addOrUpdateRevRec', cidr => "$args{cidr}", name => $args{rdns}, rpcuser => $args{user});
     1451      }
    14471452      return ('OK', $args{cidr});
    14481453    }
     
    15841589    } # end fullcidr != alloc_from
    15851590
    1586     # now we do the DNS dance for netblocks, if we have an RPC server to do it with and a pattern to use.
    1587     _rpc('addOrUpdateRevRec', cidr => "$args{cidr}", name => $args{rdns}, rpcuser => $args{user})
    1588       if $args{rdns};
    1589 
    1590     # and the per-IP set, if there is one.
    1591     _rpc('updateRevSet', %{$args{iprev}}, rpcuser => $args{user});
     1591    # Snag the parent info
     1592    my $pinfo = getBlockData($fbparent);
     1593    # Only try to update rDNS when the pool is flagged as "rDNS available"
     1594    if ($binfo->{revavail} || $binfo->{revpartial}) {
     1595      # now we do the DNS dance for netblocks, if we have an RPC server to do it with and a pattern to use.
     1596      _rpc('addOrUpdateRevRec', cidr => "$args{cidr}", name => $args{rdns}, rpcuser => $args{user})
     1597        if $args{rdns};
     1598
     1599      # and the per-IP set, if there is one.
     1600      _rpc('updateRevSet', %{$args{iprev}}, rpcuser => $args{user});
     1601    }
    15921602
    15931603    return ('OK', 'OK');
     
    17911801    return ('FAIL', $msg);
    17921802  }
     1803
     1804  # Do RPC rDNS call, if available.
     1805  # Snag the parent info
     1806  my $pinfo = getBlockData($args{parent});
     1807  # Return early if rDNS flag(s) are not set
     1808  return ('OK','OK') unless ($pinfo->{revavail} || $pinfo->{revpartial});
    17931809
    17941810  # In case of any container (mainly master block), only update freeblocks so we don't stomp subs
     
    19842000    return;
    19852001  }
    1986 ##fixme:  RPC return code?
    1987 # particularly useful in this case as there may be arbitrary combinations of pass, warn, fail
    1988 # results from each of the update and add(s), which could get the user to prod dnsadmin to see what exploded
    1989   my $foo = _rpc('splitTemplate', cidr => $binfo->{block}, newmask => $args{newmask}, rpcuser => $args{user});
     2002
     2003  # Only try to update rDNS when the original block is flagged as "rDNS available"
     2004  _rpc('splitTemplate', cidr => $binfo->{block}, newmask => $args{newmask}, rpcuser => $args{user});
     2005      if ($binfo->{revavail} || $binfo->{revpartial});
    19902006
    19912007  return \@ret;
     
    21142130    return;
    21152131  }
     2132
     2133  # Only try to update rDNS when the original block is flagged as "rDNS available"
     2134  _rpc('resizeTemplate', oldcidr => $binfo->{block}, newcidr => $newblock->network, rpcuser => $args{user});
     2135      if ($binfo->{revavail} || $binfo->{revpartial});
    21162136
    21172137  return \@ret;
     
    26352655    # Note that we still need some additional code in the odd case
    26362656    # of a netblock-aligned contiguous group of static IPs
     2657    my $pinfo;
    26372658
    26382659    eval {
    26392660      $msg = "Unable to deallocate $disp_alloctypes{$binfo->{type}} $cidr";
    2640       my $pinfo = getBlockData($dbh, $binfo->{parent_id}, 'b');
     2661      $pinfo = getBlockData($dbh, $binfo->{parent_id}, 'b');
    26412662##fixme: VRF and rdepth
    26422663      $dbh->do("UPDATE poolips SET custid = ?, available = 'y',".
     
    26502671      eval { $dbh->rollback; };
    26512672      return ('FAIL',$msg);
    2652     } else {
     2673    }
     2674
    26532675##fixme:  RPC return code?
    2654       _rpc('delByCIDR', cidr => "$cidr", user => $user, delforward => $delfwd, rpcuser => $user);
    2655       return ('OK',"OK");
    2656     }
     2676    _rpc('delByCIDR', cidr => "$cidr", user => $user, delforward => $delfwd, rpcuser => $user)
     2677        if ($pinfo->{revavail} || $pinfo->{revpartial});
     2678
     2679    return ('OK',"OK");
    26572680
    26582681  } elsif ($binfo->{type} eq 'mm') { # end alloctype =~ /.i/
     
    26852708    my @fails;
    26862709    foreach my $subzone (@zonelist) {
     2710      # We don't wrap this call tighter, since there isn't an inherent allocation to check for rDNS-ability.
    26872711      if ($rpc_url && !_rpc('delZone', zone => "$subzone", revrec => 'y', rpcuser => $user, delforward => $delfwd) ) {
    26882712        push @fails, ("$subzone" => $errstr);
     
    28782902      eval { $dbh->rollback; };
    28792903      return ('FAIL', $msg);
    2880     } else {
     2904    }
     2905
    28812906##fixme:  RPC return code?
    2882       _rpc('delByCIDR', cidr => "$cidr", rpcuser => $user, delforward => $delfwd, delsubs => 'y', parpatt => $ppatt);
    2883       return ($retcode, $goback);
    2884     }
     2907    _rpc('delByCIDR', cidr => "$cidr", rpcuser => $user, delforward => $delfwd, delsubs => 'y', parpatt => $ppatt)
     2908        if ($binfo->{revavail} || $binfo->{revpartial});
     2909
     2910    return ($retcode, $goback);
    28852911
    28862912  } # end alloctype != netblock
     
    29813007
    29823008    my $remote_rdns = _rpc('getRevPattern', %rpcargs);
    2983     $rdns = $remote_rdns if $remote_rdns;
    2984     $cached = 0;
     3009    if ($remote_rdns) {
     3010      $rdns = $remote_rdns;
     3011      $cached = 0;
     3012    }
    29853013  }
    29863014
Note: See TracChangeset for help on using the changeset viewer.