Changeset 547 for trunk


Ignore:
Timestamp:
11/08/12 17:56:36 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Clean up and move last-modified-change for master blocks to
IPDB.pm. See #34.

Location:
trunk/cgi-bin
Files:
2 edited

Legend:

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

    r545 r547  
    2626        %IPDBacl %aclmsg
    2727        &initIPDBGlobals &connectDB &finish &checkDBSanity
    28         &addMaster
     28        &addMaster &touchMaster
    2929        &listSummary &listMaster &listRBlock &listFree &listPool
    3030        &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
     
    4040                %IPDBacl %aclmsg
    4141                &initIPDBGlobals &connectDB &finish &checkDBSanity
    42                 &addMaster
     42                &addMaster &touchMaster
    4343                &listSummary &listMaster &listRBlock &listFree &listPool
    4444                &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
     
    301301  }
    302302} # end addMaster
     303
     304
     305## IPDB::touchMaster()
     306# Update last-changed timestamp on a master block.
     307sub touchMaster {
     308  my $dbh = shift;
     309  my $master = shift;
     310
     311  local $dbh->{AutoCommit} = 0;
     312  local $dbh->{RaiseError} = 1;
     313
     314  eval {
     315    $dbh->do("UPDATE masterblocks SET mtime=now() WHERE cidr = ?", undef, ($master));
     316    $dbh->commit;
     317  };
     318
     319  if ($@) {
     320    my $msg = $@;
     321    eval { $dbh->rollback; };
     322    return ('FAIL',$msg);
     323  }
     324  return ('OK','OK');
     325} # end touchMaster()
    303326
    304327
  • trunk/cgi-bin/admin.cgi

    r546 r547  
    229229} elsif ($webvar{action} eq 'touch') {
    230230
    231   $page->param(master => $webvar{whichmaster});
    232   $sth = $ip_dbh->prepare("update masterblocks set mtime=now() where cidr='$webvar{whichmaster}'");
    233   $sth->execute;
    234   if ($sth->err) {
    235     $page->param(errmsg => $sth->errstr);
    236   }
     231  my ($code,$msg) = touchMaster($ip_dbh, $webvar{whichmaster});
     232  $page->param(errmsg => $msg) if $code eq 'FAIL';
    237233
    238234} elsif ($webvar{action} eq 'listcust') {
Note: See TracChangeset for help on using the changeset viewer.