Ignore:
Timestamp:
08/14/25 13:35:51 (15 hours ago)
Author:
Kris Deugau
Message:

/branches/secondaryzones

Complete secondary zone update section

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/secondaryzones/DNSDB.pm

    r918 r920  
    46134613
    46144614
     4615## DNSDB::updateSecondaryDetails()
     4616# Update primary server and/or location/view of a secondary zone
     4617# Takes a hash with the zone ID, primary server string, and location
     4618# Returns a two-element list with a result code and message
     4619sub updateSecondaryDetails {
     4620  $errstr = '';
     4621  my $self = shift;
     4622  my $dbh = $self->{dbh};
     4623
     4624  my %secondary = @_;
     4625
     4626  my $oldsecondary = $self->getSecondaryDetails($secondary{id});
     4627
     4628  my $msg;
     4629  my %logdata;
     4630  $logdata{secondary_id} = $secondary{id};
     4631  $logdata{group_id} = $self->parentID(id => $secondary{id}, type => 'secondaryzone');
     4632  my $zone = $self->secondaryName($secondary{id});
     4633
     4634  # Allow transactions, and raise an exception on errors so we can catch it later.
     4635  # Use local to make sure these get "reset" properly on exiting this block
     4636  local $dbh->{AutoCommit} = 0;
     4637  local $dbh->{RaiseError} = 1;
     4638
     4639  eval {
     4640    my $sql = "UPDATE secondaryzones SET primaryserver=?, default_location=? WHERE secondary_id=?";
     4641    $dbh->do($sql, undef, ($secondary{primary}, $secondary{location}, $secondary{id}));
     4642    $msg = "Updated secondary zone $zone from (primary $oldsecondary->{primaryserver}, location ".
     4643        $self->getLoc($oldsecondary->{default_location})->{description}.") to (primary $secondary{primary}, ".
     4644        "location ".$self->getLoc($secondary{location})->{description}.")";
     4645    $logdata{entry} = $msg;
     4646    $self->_log(%logdata);
     4647    $dbh->commit;
     4648  };
     4649  if ($@) {
     4650    $msg = $@;
     4651    eval { $dbh->rollback; };
     4652    $logdata{entry} = "Error updating secondary zone settings: $msg";
     4653    if ($self->{log_failures}) {
     4654      $self->_log(%logdata);
     4655      $dbh->commit;
     4656    }
     4657    return ('FAIL', $msg);
     4658  } else {
     4659    return ('OK', $msg);
     4660  }
     4661
     4662} # end updateSecondaryDetails
     4663
     4664
    46154665## DNSDB::getRecLine()
    46164666# Return all data fields for a zone record in separate elements of a hash
Note: See TracChangeset for help on using the changeset viewer.