Changeset 788


Ignore:
Timestamp:
10/08/15 17:49:27 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Update IP assignment update and IP delete for backup data. See #52.

Location:
trunk
Files:
3 edited

Legend:

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

    r785 r788  
    18411841        my ($code,$rmsg) = initPool($dbh, "$newblock", $binfo->{type}, $binfo->{city}, 'normal', $args{block});
    18421842        die $rmsg if $code eq 'FAIL';
     1843      }
     1844    }
     1845
     1846    # check on the backup data first.  we may need to tweak the main update's parameters.
     1847    if (!defined($args{ignorebk})) {
     1848      if ($args{backupfields}) {
     1849        my @bkfields;
     1850        my @bkvals;
     1851        for my $bk (qw(brand model type src user vpass epass)) {
     1852          if ($binfo->{"bk$bk"} ne $args{"bk$bk"}) {
     1853            push @bkfields, "bk$bk = ?";
     1854            push @bkvals, $args{"bk$bk"};
     1855          }
     1856        }
     1857        $dbh->do("UPDATE backuplist SET ".join(',', @bkfields)." WHERE backup_id = ?",
     1858            undef, @bkvals, $binfo->{hasbk})
     1859            if @bkfields;
     1860##todo: keep historic changes for $timeperiod, by adding a backref ID field, and on updates adding a new backup
     1861# record instead of updating the existing one.  should probably check if new==old so we don't do needless updates
     1862# in that case...
     1863      } else {
     1864        if ($binfo->{hasbk}) {
     1865          # had backup data, no longer checked - delete backup entry
     1866          $dbh->do("DELETE FROM backuplist WHERE backup_id = ?", undef, $binfo->{hasbk});
     1867          $sql .= " = ?, backup_id";
     1868          push @vallist, 0;
     1869        }
    18431870      }
    18441871    }
     
    27402767      $msg = "Unable to deallocate $disp_alloctypes{$binfo->{type}} $cidr";
    27412768      $pinfo = getBlockData($dbh, $binfo->{parent_id}, 'b');
    2742 ##fixme: VRF and rdepth
    27432769      $dbh->do("UPDATE poolips SET custid = ?, available = 'y',".
    27442770        "city = (SELECT city FROM allocations WHERE id = ?),".
    2745         "description = '', notes = '', circuitid = '', vrf = ? WHERE id = ?", undef,
     2771        "description = '', notes = '', circuitid = '', vrf = ?, backup_id = 0".
     2772        " WHERE id = ?", undef,
    27462773        ($pinfo->{custid}, $binfo->{parent_id}, $pinfo->{vrf}, $id) );
     2774      $dbh->do("DELETE FROM backuplist WHERE backup_id = ?", undef, $binfo->{hasbk})
     2775          if $binfo->{hasbk};
    27472776      $dbh->commit;
    27482777    };
  • trunk/cgi-bin/main.cgi

    r787 r788  
    11161116        );
    11171117
     1118  # Check to see if user is allowed to do anything with sensitive data
     1119  if ($IPDBacl{$authuser} =~ /s/) {
     1120    $updargs{privdata} = $webvar{privdata};
     1121    for my $bkfield (qw(brand model type src user vpass epass port)) {
     1122      $updargs{"bk$bkfield"} = $webvar{"bk$bkfield"};
     1123    }
     1124    $updargs{backupfields} = $webvar{backupfields};
     1125  } else {
     1126    # If the user doesn't have permissions to monkey with NOC-things, pass
     1127    # a flag so we don't treat it as "backup data removed"
     1128    $updargs{ignorebk} = 1;
     1129  }
     1130
    11181131  # Semioptional values
    1119   $updargs{privdata} = $webvar{privdata} if $IPDBacl{$authuser} =~ /s/;
    11201132  $updargs{node} = $webvar{node} if $webvar{node};
    11211133
     
    11821194  $page->param(desc => $webvar{desc});
    11831195  $page->param(notes => $webvar{notes});
    1184   $page->param(privdata => $webvar{privdata})
    1185         if $IPDBacl{$authuser} =~ /s/;
     1196  if ($IPDBacl{$authuser} =~ /s/) {
     1197    $page->param(nocling  => 1);
     1198    $page->param(privdata => $webvar{privdata});
     1199    if ($binfo->{hasbk}) {
     1200      $page->param(hasbackup => $binfo->{hasbk});
     1201      for my $bkfield (qw(brand model type src user vpass epass port)) {
     1202        $page->param("bk$bkfield" => $binfo->{"bk$bkfield"});
     1203      }
     1204    }
     1205  }
    11861206
    11871207} # update()
  • trunk/templates/update.tmpl

    r687 r788  
    6161</tr>
    6262
    63 <TMPL_IF privdata>
     63<TMPL_IF nocling>
    6464<tr>
    6565<td valign="top">Restricted data:</td>
    6666<td><TMPL_VAR NAME=privdata></td>
     67</tr>
     68
     69<tr>
     70<td valign="top">Configuration backup:</td>
     71<td>
     72<TMPL_IF hasbackup>
     73Device will be backed up as below
     74<table><tr><td>Brand:</td><td><TMPL_VAR NAME=bkbrand></td></tr>
     75<tr><td>Model:</td><td><TMPL_VAR NAME=bkmodel></td></tr>
     76<tr><td>Access method:</td><td><TMPL_VAR NAME=bktype></td></tr>
     77<tr><td>Connect from:</td><td><TMPL_VAR NAME=bksrc></td></tr>
     78<tr><td>Username:</td><td><TMPL_VAR NAME=bkuser></td></tr>
     79<tr><td>VTY password:</td><td><TMPL_VAR NAME=bkvpass></td></tr>
     80<tr><td>Enable password:</td><td><TMPL_VAR NAME=bkepass></td></tr>
     81<tr><td>Port:</td><td><TMPL_VAR NAME=bkport></td></tr>
     82</table>
     83<TMPL_ELSE>
     84Device/assignment not flagged for backup
     85</TMPL_IF>
     86</td>
     87
    6788</tr>
    6889</TMPL_IF>
Note: See TracChangeset for help on using the changeset viewer.