Changeset 838 for trunk


Ignore:
Timestamp:
04/12/16 13:53:37 (8 years ago)
Author:
Kris Deugau
Message:

/trunk

Fill out rpc_updateBlock() stub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/ipdb-rpc.cgi

    r837 r838  
    252252# another internal sub;  mainly a sub to make allocateBlock() a lot smaller
    253253#sub rpc_initPool {}
    254 sub rpc_updateBlock {}
     254
     255
     256sub rpc_updateBlock {
     257  my %args = @_;
     258
     259  _commoncheck(\%args, 'y');
     260
     261  _validateInput(\%args);
     262
     263  # Allow caller to send a CIDR instead of the block ID.
     264  $args{origblock} = $args{block};
     265  if ($args{block} =~ m{^(?:\d+\.){3}\d+(?:/32)?$}) {
     266    # updating a static IP.  retrieve the IP ID based on either the parent or VRF.
     267    die "Pool ID or VRF is required\n" if !$args{parent} && !$args{vrf};
     268    ($args{block}) = $ip_dbh->selectrow_array(
     269       "SELECT id FROM poolips WHERE ip = ? AND ".($args{parent} ? "parent_id = ?" : "vrf = ?"),
     270       undef, $args{block}, ($args{parent} ? $args{parent} : $args{vrf}) );
     271  }
     272
     273  my $binfo = getBlockData($ip_dbh, $args{block}, $args{type});
     274
     275  # set assignIP_on_update to simplify some calling situations.  better to use allocateBlock if possible though.
     276  my ($code,$msg) = updateBlock($ip_dbh, %args, assignIP_on_update => 1);
     277
     278  if ($code eq 'FAIL') {
     279    syslog "err", "$args{rpcsystem}/$args{rpcuser} could not update block/IP ID $args{block}: '$msg'";
     280    die "$msg\n";
     281  }
     282
     283  syslog "notice", "$authuser updated $args{block}";
     284
     285  return $msg;
     286
     287} # rpc_updateBlock()
     288
     289
    255290sub rpc_deleteBlock {}
    256291sub rpc_getBlockData {}
Note: See TracChangeset for help on using the changeset viewer.