Changeset 516 for trunk/DNSDB.pm


Ignore:
Timestamp:
05/24/13 16:58:49 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Tune up location/view handling on zone add. See #10.

Domains and revzones added with a location specified will actually use
that location. Documentation note: Zones specifying a location on
creation will only be visible to that location, because the SOA record
will be created with that location. A zone should be created with no
location set if records must be visible across multiple locations, or
publicly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r514 r516  
    18111811  my $state = shift;
    18121812  return ('FAIL',"Domain status must be specified\n") if !defined($state);
     1813  my $defloc = shift || '';
    18131814
    18141815  $state = 1 if $state =~ /^active$/;
     
    18381839  eval {
    18391840    # insert the domain...
    1840     $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef, ($domain, $group, $state));
     1841    $dbh->do("INSERT INTO domains (domain,group_id,status,default_location) VALUES (?,?,?,?)", undef,
     1842        ($domain, $group, $state, $defloc));
    18411843
    18421844    # get the ID...
     
    18491851    # ... and now we construct the standard records from the default set.  NB:  group should be variable.
    18501852    my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM default_records WHERE group_id=?");
    1851     my $sth_in = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,distance,weight,port,ttl)".
    1852         " VALUES ($dom_id,?,?,?,?,?,?,?)");
     1853    my $sth_in = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,distance,weight,port,ttl,location)".
     1854        " VALUES ($dom_id,?,?,?,?,?,?,?,?)");
    18531855    $sth->execute($group);
    1854     while (my ($host,$type,$val,$dist,$weight,$port,$ttl) = $sth->fetchrow_array()) {
     1856    while (my ($host, $type, $val, $dist, $weight, $port, $ttl) = $sth->fetchrow_array()) {
    18551857      $host =~ s/DOMAIN/$domain/g;
    18561858      $val =~ s/DOMAIN/$domain/g;
    1857       $sth_in->execute($host,$type,$val,$dist,$weight,$port,$ttl);
     1859      $sth_in->execute($host, $type, $val, $dist, $weight, $port, $ttl, $defloc);
    18581860      if ($typemap{$type} eq 'SOA') {
    18591861        my @tmp1 = split /:/, $host;
Note: See TracChangeset for help on using the changeset viewer.