Changeset 788 for trunk/cgi-bin/IPDB.pm


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.

File:
1 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    };
Note: See TracChangeset for help on using the changeset viewer.