- Timestamp:
- 11/12/04 12:37:17 (20 years ago)
- Location:
- branches/stable/cgi-bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/consistency-check.pl
r26 r64 65 65 print " done.\n"; 66 66 67 print "Done checking master containment.\n\nChecking block-alignment consistency:\n"; 67 print "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; 71 while (@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; 79 while (@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 86 print "Done checking pool containment.\n\nChecking block-alignment consistency:\n"; 68 87 69 88 # Block alignment consistency: All allocated+free blocks within a master -
branches/stable/cgi-bin/main.cgi
r56 r64 119 119 $sth = $ip_dbh->prepare("insert into masterblocks values ('$webvar{cidr}')"); 120 120 $sth->execute; 121 # Don't need this with RaiseError, but leave it for now.122 # croak $sth->errstr if ($sth->errstr());123 121 124 122 # Unrouted blocks aren't associated with a city (yet). We don't rely on this … … 129 127 $cidr->masklen.",'<NULL>','n')"); 130 128 $sth->execute; 131 # Don't need this with RaiseError, but leave it for now.132 # croak $sth->errstr if ($sth->errstr());133 129 134 130 # If we get here, everything is happy. Commit changes. … … 361 357 # Fix up types from pools (which are single-char) 362 358 # Fixing the database would be... painful. :( 363 if ($data[2] =~ /^[ cdsm]$/) {359 if ($data[2] =~ /^[sdcmw]$/) { 364 360 $data[2] .= 'i'; 365 361 } … … 819 815 # + Different flavours of netblock 820 816 821 if ($webvar{alloctype} =~ /^[ cdsm]i$/) {817 if ($webvar{alloctype} =~ /^[scdmw]i$/) { 822 818 my ($base,undef) = split //, $webvar{alloctype}; # split into individual chars 823 819 my $sql; … … 999 995 # Allow transactions, and make errors much easier to catch. 1000 996 # 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. 1004 1001 1005 1002 if ($webvar{fullcidr} eq $webvar{alloc_from}) { … … 1134 1131 syslog "notice", "$full_alloc_types{$webvar{alloctype}} '$webvar{fullcidr}' successfully initialized by $authuser"; 1135 1132 1136 # Turn off transactions and exception-on-error'ing1137 $ip_dbh->{AutoCommit} = 0;1138 $ip_dbh->{RaiseError} = 1;1139 1140 1133 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>); 1141 1134
Note:
See TracChangeset
for help on using the changeset viewer.