Changeset 123


Ignore:
Timestamp:
09/09/11 17:38:52 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Fill out the remaining stubbed RPC calls; other subs from DNSDB

aren't as cleanly exposeable

Minor error-handling tweak in DNSDB.pm while retrieving a record line

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r121 r123  
    10781078        (($def eq 'def' or $def eq 'y') ? ',r.group_id FROM default_' : ',r.domain_id FROM ').
    10791079        "records r LEFT OUTER JOIN longrecs l ON r.longrec_id=l.longrec_id WHERE record_id=?";
    1080   my $ret = $dbh->selectrow_hashref($sql, undef, ($id) ) or warn $dbh->errstr;
     1080  my $ret = $dbh->selectrow_hashref($sql, undef, ($id) );
    10811081
    10821082  if ($dbh->err) {
    10831083    $errstr = $DBI::errstr;
     1084    return undef;
     1085  }
     1086
     1087  if (!$ret) {
     1088    $errstr = "No such record";
    10841089    return undef;
    10851090  }
  • trunk/dns-rpc.cgi

    r121 r123  
    3131        'dnsdb.delUser'         => \&delUser,
    3232        'dnsdb.getSOA'          => \&getSOA,
     33        'dnsdb.getRecLine'      => \&getRecLine,
     34        'dnsdb.getDomRecs'      => \&getDomRecs,
     35        'dnsdb.getRecCount'     => \&getRecCount,
     36        'dnsdb.addRec'          => \&addRec,
     37        'dnsdb.delRec'          => \&delRec,
     38        'dnsdb.domStatus'       => \&domStatus,
    3339
    3440        'dnsdb.getMethods'      => \&get_method_list
     
    237243  die "Missing remote username" if !$args{rpcuser};             # for logging
    238244  die "Missing remote system name" if !$args{rpcsystem};        # for logging
     245
     246  my $ret = DNSDB::getRecLine($dbh, $args{def}, $args{id});
     247
     248  die $DNSDB::errstr if !$ret;
     249
     250  return $ret;
    239251}
    240252
     
    245257  die "Missing remote username" if !$args{rpcuser};             # for logging
    246258  die "Missing remote system name" if !$args{rpcsystem};        # for logging
    247 }
    248 
    249 #sub getRecCount {
     259
     260#bleh
     261  $args{nrecs} = 'all' if !$args{nrecs};
     262  $args{nstart} = 0 if !$args{nstart};
     263## for order, need to map input to column names
     264  $args{order} = 'host' if !$args{order};
     265  $args{direction} = 'ASC' if !$args{direction};
     266
     267  my $ret = DNSDB::getDomRecs($dbh, $args{def}, $args{id}, $args{nrecs}, $args{nstart}, $args{order}, $args{direction});
     268
     269  die $DNSDB::errstr if !$ret;
     270
     271  return $ret;
     272}
     273
     274sub getRecCount {
     275  my %args = @_;
     276
     277  # Make sure we've got all the local bits we need
     278  die "Missing remote username" if !$args{rpcuser};             # for logging
     279  die "Missing remote system name" if !$args{rpcsystem};        # for logging
     280
     281  return DNSDB::getRecCount($dbh, $id);
     282}
    250283
    251284sub addRec {
     
    255288  die "Missing remote username" if !$args{rpcuser};             # for logging
    256289  die "Missing remote system name" if !$args{rpcsystem};        # for logging
     290
     291  # note dist, weight, port are not reequired on all types;  will be ignored if not needed.
     292  my ($code, $msg) = DNSDB::addRec($dbh, $args{def}, $args{domid}, $args{host}, $typemap{$args{type}},
     293        $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port});
     294
     295  die $msg if $code eq 'FAIL';
    257296}
    258297
     
    263302  die "Missing remote username" if !$args{rpcuser};             # for logging
    264303  die "Missing remote system name" if !$args{rpcsystem};        # for logging
     304
     305  # note dist, weight, port are not reequired on all types;  will be ignored if not needed.
     306  my ($code, $msg) = DNSDB::updateRec($dbh, $args{def}, $args{recid}, $args{host}, $typemap{$args{type}},
     307        $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port});
     308
     309  die $msg if $code eq 'FAIL';
    265310}
    266311
     
    271316  die "Missing remote username" if !$args{rpcuser};             # for logging
    272317  die "Missing remote system name" if !$args{rpcsystem};        # for logging
     318
     319  # note dist, weight, port are not reequired on all types;  will be ignored if not needed.
     320  my ($code, $msg) = DNSDB::delRec($dbh, $args{def}, $args{recid});
     321
     322  die $msg if $code eq 'FAIL';
    273323}
    274324
    275325#sub getParents {
    276 #sub domStatus {
     326
     327sub domStatus {
     328  my %args = @_;
     329
     330  # Make sure we've got all the local bits we need
     331  die "Missing remote username" if !$args{rpcuser};             # for logging
     332  die "Missing remote system name" if !$args{rpcsystem};        # for logging
     333
     334  my @arglist = ($dbh, $args{domid});
     335  push @arglist, $args{status} if defined($args{status});
     336
     337  my $status = DNSDB::domStatus(@arglist);
     338}
     339
    277340#sub importAXFR {
    278341#sub export {
Note: See TracChangeset for help on using the changeset viewer.