Changeset 635 for trunk


Ignore:
Timestamp:
10/09/14 17:25:17 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix up consistency-check.pl; it was so stale it broke on the stable branch

File:
1 edited

Legend:

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

    r417 r635  
    1212use DBI;
    1313use NetAddr::IP;
     14use Data::Dumper;
    1415
    1516# don't remove!  required for GNU/FHS-ish install from tarball
     
    2526initIPDBGlobals($dbh);
    2627
     28## Do some new init things to account for IPDB.pm changes
     29my $tmp;
     30# get master blocks in an array
     31my @masterblocks;
     32$tmp = getMasterList($dbh);
     33foreach (@{$tmp}) {
     34  push @masterblocks, NetAddr::IP->new($_->{master});
     35}
     36
    2737print "Checking master containment...\n";
    2838
     
    3343$sth->execute;
    3444$flag = '';
     45my $i;
    3546ROUTED: while (@data = $sth->fetchrow_array) {
    3647  $cidr = new NetAddr::IP $data[0];
     
    3950  }
    4051  print "\n    $cidr not mastered";
     52  last if $i++>10;
    4153}
    4254print "$flag done.\n";
     
    114126  $prev = $master;
    115127  $sth = $dbh->prepare("(select network(cidr) as net, broadcast(cidr) as bcast ".
    116         "from allocations where cidr <<= '$master' and type not like '_c') ".
     128        "from allocations where cidr <<= '$master' and not (type like '_c' or type in ('rm','mm')) ) ".
    117129        "union (select network(cidr) as net, broadcast(cidr) as bcast ".
    118130        "from freeblocks where cidr <<= '$master' and not (routed='c')) order by net");
    119131  $sth->execute;
    120132
    121   while (@data = $sth->fetchrow_array) {
    122     $cur = new NetAddr::IP $data[0];
    123 
     133  while (my ($net,$bcast) = $sth->fetchrow_array) {
     134    my $prevn = $prev->broadcast->numeric + 1;
     135    $cur = new NetAddr::IP $net;
     136    if ($cur->numeric == $prevn) {
     137      $prev = $cur;
     138      next;
     139    }
     140#print "
     141##fixme:  the rest of this could probably be squashed down quite a bit
    124142    if ($master->numeric == $prev->numeric) {
    125143      # check if cur starts with master
     
    187205    $sth->execute;
    188206
    189   while (@data = $sth->fetchrow_array) {
    190     $cur = new NetAddr::IP $data[0];
     207print "(select network(cidr) as net, broadcast(cidr) as bcast ".
     208        "from allocations where cidr <<= '$container' and type like '_r')\n ".
     209        "union (select network(cidr) as net, broadcast(cidr) as bcast ".
     210        "from freeblocks where cidr <<= '$container' and not (routed='y' or routed='n')) ".
     211        "order by net" if $container =~ /10.10.20/;
     212
     213  while (my ($net,$bcast) = $sth->fetchrow_array) {
     214    my $prevn = $prev->broadcast->numeric + 1;
     215    $cur = new NetAddr::IP $net;
     216    if ($cur->numeric == $prevn) {
     217      $prev = $cur;
     218      next;
     219    }
    191220
    192221    if ($container->numeric == $prev->numeric) {
Note: See TracChangeset for help on using the changeset viewer.