Changeset 23


Ignore:
Timestamp:
10/20/09 14:47:36 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint

  • basic group management functional
  • add readable failure messages on domain/group delete
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r22 r23  
    226226  local $dbh->{RaiseError} = 1;
    227227
     228  my $failmsg = '';
     229
    228230  # Wrap all the SQL in a transaction
    229231  eval {
    230232    my $sth = $dbh->prepare("delete from records where domain_id=?");
     233    $failmsg = "Failure removing domain records";
    231234    $sth->execute($domid);
    232235    $sth = $dbh->prepare("delete from domains where domain_id=?");
     236    $failmsg = "Failure removing domain";
    233237    $sth->execute($domid);
    234238
    235 #die "full of fail\n";
    236239    # once we get here, we should have suceeded.
    237 #    $dbh->commit;
     240    $dbh->commit;
    238241  }; # end eval
    239242
     
    241244    my $msg = $@;
    242245    eval { $dbh->rollback; };
    243     return ('FAIL',$msg);
     246    return ('FAIL',"$failmsg: $msg");
    244247  } else {
    245248    return ('OK','OK');
     
    340343
    341344##fixme:  locate "knowable" error conditions and deal with them before the eval
     345# ... or inside, whatever.
    342346# -> domains still exist in group
    343347# -> ...
     348  my $failmsg = '';
    344349
    345350  # Wrap all the SQL in a transaction
    346351  eval {
    347     my $sth = $dbh->prepare("delete from default_records where group_id=?");
     352    my $sth = $dbh->prepare("SELECT count(*) FROM domains WHERE group_id=?");
     353    $sth->execute($groupid);
     354    my ($domcnt) = $sth->fetchrow_array;
     355    $failmsg = "Can't remove group ".groupName($dbh,$groupid);
     356    die "$domcnt domains still in group\n" if $domcnt;
     357
     358    $sth = $dbh->prepare("delete from default_records where group_id=?");
     359    $failmsg = "Failed to delete default records for ".groupName($dbh,$groupid);
    348360    $sth->execute($groupid);
    349361    $sth = $dbh->prepare("delete from groups where group_id=?");
     362    $failmsg = "Failed to remove group ".groupName($dbh,$groupid);
    350363    $sth->execute($groupid);
    351364
    352 die "epic group fail FTW!\n";
    353365    # once we get here, we should have suceeded.
    354366    $dbh->commit;
     
    358370    my $msg = $@;
    359371    eval { $dbh->rollback; };
    360     return ('FAIL',$msg);
     372    return ('FAIL',"$failmsg: $msg");
    361373  } else {
    362374    return ('OK','OK');
     
    447459    $sql .= " records where domain_id=$id and type=$reverse_typemap{SOA}";
    448460  }
    449 #print "getSOA DEBUG: $sql<br>\n";
    450461  my $sth = $dbh->prepare($sql);
    451462  $sth->execute;
     
    649660  $sth->execute($id);
    650661
    651   return ('FAIL',$sth->errstr) if $sth->err;
     662  return ('FAIL',"Couldn't remove record: ".$sth->errstr) if $sth->err;
    652663
    653664  return ('OK','OK');
  • trunk/dns.cgi

    r22 r23  
    392392  if (!defined($webvar{del})) {
    393393    $page->param(del_getconf => 1);
    394     $page->param(groupname => groupName($dbh,$webvar{id}));
     394#    $page->param(groupname => groupName($dbh,$webvar{id}));
    395395# print some neato things?
    396396
     
    400400  } elsif ($webvar{del} eq 'ok') {
    401401    my ($code,$msg) = delGroup($dbh, $webvar{id});
     402push @debugbits, groupName($dbh, $webvar{id});
    402403    if ($code ne 'OK') {
    403404# need to find failure mode
     
    414415    changepage(page => "grpman");
    415416  }
    416 
     417  $page->param(delgroupname => groupName($dbh, $webvar{id}));
    417418}
    418419
     
    539540    $rec->{sid} = $webvar{sid};
    540541    $rec->{id} = $id;
     542    $rec->{distance} = 'n/a' unless ($rec->{type} eq 'MX' || $rec->{type} eq 'SRV');
     543    $rec->{weight} = 'n/a' unless ($rec->{type} eq 'SRV');
     544    $rec->{port} = 'n/a' unless ($rec->{type} eq 'SRV');
    541545    $row++;
    542546  }
    543547  $page->param(reclist => $foo2);
    544548}
     549
    545550
    546551# fill in record type list on add/update/edit record template
  • trunk/templates/delgrp.tmpl

    r22 r23  
    44
    55<td align="center">
    6 <h3>Are you really sure you want to delete group <TMPL_VAR NAME=groupname>?</h3>
     6<h3>Are you really sure you want to delete group <TMPL_VAR NAME=delgroupname>?</h3>
    77<a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delgrp&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> &nbsp; | &nbsp;
    88<a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delgrp&del=ok&id=<TMPL_VAR NAME=id>">confirm</a>
     
    1111<TMPL_ELSE>
    1212 <!-- <TMPL_IF del_failed>
    13   <div class='errmsg'>Error deleting group <TMPL_VAR NAME=groupname>: <TMPL_VAR NAME=errmsg></div>
     13  <div class='errmsg'>Error deleting group <TMPL_VAR NAME=delgroupname>: <TMPL_VAR NAME=errmsg></div>
    1414 </TMPL_IF> -->
    1515 <TMPL_INCLUDE NAME="grpman.tmpl">
  • trunk/templates/grpman.tmpl

    r22 r23  
    66
    77 <TMPL_IF del_failed>
    8   <div class='errmsg'>Error deleting group <TMPL_VAR NAME=groupname>: <TMPL_VAR NAME=errmsg></div>
     8  <div class='errmsg'>Error deleting group <TMPL_VAR NAME=delgroupname>: <TMPL_VAR NAME=errmsg></div>
    99 </TMPL_IF>
    1010
     
    3939<TMPL_LOOP name=grouptable>
    4040<tr class="row<TMPL_VAR name=bg>">
    41         <td><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=grpman&id=<TMPL_VAR NAME=groupid>"><TMPL_VAR NAME=groupname></a></td>
     41        <td><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=grpman&action=chgroup&group=<TMPL_VAR NAME=groupid>"><TMPL_VAR NAME=groupname></a></td>
    4242        <td width="5%" nowrap><TMPL_VAR name=pgroup></td>
    4343        <td width="5%" nowrap><TMPL_VAR name=nusers></td>
Note: See TracChangeset for help on using the changeset viewer.