Changeset 820 for trunk


Ignore:
Timestamp:
03/11/16 15:14:08 (8 years ago)
Author:
Kris Deugau
Message:

/trunk

Add "delete VRF" confirmation and action pages. Refine link from showvrf
template since a VRF is a completely different type of entity than a
netblock. See #54.

Location:
trunk
Files:
2 added
3 edited

Legend:

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

    r818 r820  
    2828        $errstr
    2929        &initIPDBGlobals &connectDB &finish &checkDBSanity
    30         &addVRF &getVRF &addMaster &touchMaster
     30        &addVRF &getVRF &deleteVRF &addMaster &touchMaster
    3131        &listVRF &listSummary &listSubs &listContainers &listAllocations &listForMerge &listFree &listPool
    3232        &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
     
    4444                $errstr
    4545                &initIPDBGlobals &connectDB &finish &checkDBSanity
    46                 &addVRF &getVRF &addMaster &touchMaster
     46                &addVRF &getVRF &deleteVRF &addMaster &touchMaster
    4747                &listVRF &listSummary &listSubs &listContainers &listAllocations &listForMerge &listFree &listPool
    4848                &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
     
    688688  return $dbh->selectrow_hashref("SELECT comment,location FROM vrfs WHERE vrf = ?", {Slice=>{}}, $vrf);
    689689} # end getVRF()
     690
     691
     692## IPDB::deleteVRF()
     693#
     694sub deleteVRF {
     695  my $dbh = shift;
     696  my $vrf = shift;
     697
     698  # Allow transactions, and raise an exception on errors so we can catch it later.
     699  # Use local to make sure these get "reset" properly on exiting this block
     700  local $dbh->{AutoCommit} = 0;
     701  local $dbh->{RaiseError} = 1;
     702
     703  eval {
     704    $dbh->do("DELETE FROM vrfs WHERE vrf = ?", undef, $vrf);
     705    $dbh->commit;
     706  };
     707  if ($@) {
     708    my $msg = $@;       # not much complexity here just yet.
     709    return ('FAIL',$msg);
     710  }
     711
     712  return ('OK','OK');
     713} # end deleteVRF()
    690714
    691715
  • trunk/cgi-bin/main.cgi

    r818 r820  
    148148
    149149  } # ACL check
     150
     151} elsif ($webvar{action} eq 'delvrf') {
     152  if ($IPDBacl{$authuser} !~ /s/) {
     153    $aclerr = 'delvrf';
     154  }
     155
     156  my $vrf = getVRF($ip_dbh, $webvar{vrf});
     157
     158  $page->param(vrf => $webvar{vrf});
     159  $page->param(vrfcomment => $vrf->{comment});
     160
     161} elsif ($webvar{action} eq 'finaldelvrf') {
     162  if ($IPDBacl{$authuser} !~ /s/) {
     163    $aclerr = 'finaldelvrf';
     164  }
     165
     166  my $vrf = getVRF($ip_dbh, $webvar{vrf});
     167  $page->param(vrf => $webvar{vrf});
     168  $page->param(vrfcomment => $vrf->{comment});
     169
     170  my ($code,$msg) = deleteVRF($ip_dbh, $webvar{vrf}, $authuser);
     171
     172  if ($code eq 'FAIL') {
     173    $page->param(failmsg => $msg);
     174  }
    150175
    151176} elsif ($webvar{action} eq 'addmaster') {
  • trunk/templates/showvrf.tmpl

    r818 r820  
    2929<form action="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi" method=POST>
    3030<fieldset><legend class="noshow">&nbsp;</legend>
    31 <input type=hidden name=action value="delete">
     31<input type=hidden name=action value="delvrf">
    3232<input type=hidden name=vrf value="<TMPL_VAR NAME=vrf>">
    3333<input type=submit value=" Remove this VRF ">
Note: See TracChangeset for help on using the changeset viewer.