Changeset 64


Ignore:
Timestamp:
11/12/04 12:37:17 (20 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Backported bugfixes and changes from /trunk r60:63

Location:
branches/stable/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/cgi-bin/consistency-check.pl

    r26 r64  
    6565print " done.\n";
    6666
    67 print "Done checking master containment.\n\nChecking block-alignment consistency:\n";
     67print "Done checking master containment.\n\nChecking pool containment:\n";
     68
     69$sth = $dbh->prepare("select pool,ip from poolips order by ip");
     70$sth->execute;
     71while (@data = $sth->fetchrow_array) {
     72  $pool = new NetAddr::IP $data[0];
     73  $ip = new NetAddr::IP $data[1];
     74  print "IP $ip listed with incorrect pool $pool\n"
     75    if !$pool->contains($ip);
     76}
     77$sth = $dbh->prepare("select distinct pool from poolips order by pool");
     78$sth->execute;
     79while (@data = $sth->fetchrow_array) {
     80  $sth2 = $dbh->prepare("select cidr from allocations where cidr='$data[0]'");
     81  $sth2->execute;
     82  print "Pool $data[0] does not exist in allocations table\n"
     83    if (($sth2->fetchrow_array)[0] eq '');
     84}
     85
     86print "Done checking pool containment.\n\nChecking block-alignment consistency:\n";
    6887
    6988# Block alignment consistency:  All allocated+free blocks within a master
  • branches/stable/cgi-bin/main.cgi

    r56 r64  
    119119    $sth = $ip_dbh->prepare("insert into masterblocks values ('$webvar{cidr}')");
    120120    $sth->execute;
    121 # Don't need this with RaiseError, but leave it for now.
    122 #    croak $sth->errstr if ($sth->errstr());
    123121
    124122# Unrouted blocks aren't associated with a city (yet).  We don't rely on this
     
    129127        $cidr->masklen.",'<NULL>','n')");
    130128    $sth->execute;
    131 # Don't need this with RaiseError, but leave it for now.
    132 #    croak $sth->errstr if ($sth->errstr());
    133129
    134130    # If we get here, everything is happy.  Commit changes.
     
    361357    # Fix up types from pools (which are single-char)
    362358    # Fixing the database would be...  painful.  :(
    363     if ($data[2] =~ /^[cdsm]$/) {
     359    if ($data[2] =~ /^[sdcmw]$/) {
    364360      $data[2] .= 'i';
    365361    }
     
    819815#  + Different flavours of netblock
    820816
    821   if ($webvar{alloctype} =~ /^[cdsm]i$/) {
     817  if ($webvar{alloctype} =~ /^[scdmw]i$/) {
    822818    my ($base,undef) = split //, $webvar{alloctype};    # split into individual chars
    823819    my $sql;
     
    999995# Allow transactions, and make errors much easier to catch.
    1000996# Much as I would like to error-track specifically on each ->execute,
    1001 # that's a LOT of code.  :/
    1002     $ip_dbh->{AutoCommit} = 0;
    1003     $ip_dbh->{RaiseError} = 1;
     997# that's a LOT of code, and some SQL blocks MUST be atomic at a
     998# multi-statement level.  :/
     999    local $ip_dbh->{AutoCommit} = 0;    # These need to be local so we don't
     1000    local $ip_dbh->{RaiseError} = 1;    # step on our toes by accident.
    10041001
    10051002    if ($webvar{fullcidr} eq $webvar{alloc_from}) {
     
    11341131    syslog "notice", "$full_alloc_types{$webvar{alloctype}} '$webvar{fullcidr}' successfully initialized by $authuser";
    11351132
    1136     # Turn off transactions and exception-on-error'ing
    1137     $ip_dbh->{AutoCommit} = 0;
    1138     $ip_dbh->{RaiseError} = 1;
    1139 
    11401133    print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was sucessfully added as type '$webvar{alloctype}' ($full_alloc_types{$webvar{alloctype}})</div></div>);
    11411134
Note: See TracChangeset for help on using the changeset viewer.