Changeset 635 for trunk/cgi-bin
- Timestamp:
- 10/09/14 17:25:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/consistency-check.pl
r417 r635 12 12 use DBI; 13 13 use NetAddr::IP; 14 use Data::Dumper; 14 15 15 16 # don't remove! required for GNU/FHS-ish install from tarball … … 25 26 initIPDBGlobals($dbh); 26 27 28 ## Do some new init things to account for IPDB.pm changes 29 my $tmp; 30 # get master blocks in an array 31 my @masterblocks; 32 $tmp = getMasterList($dbh); 33 foreach (@{$tmp}) { 34 push @masterblocks, NetAddr::IP->new($_->{master}); 35 } 36 27 37 print "Checking master containment...\n"; 28 38 … … 33 43 $sth->execute; 34 44 $flag = ''; 45 my $i; 35 46 ROUTED: while (@data = $sth->fetchrow_array) { 36 47 $cidr = new NetAddr::IP $data[0]; … … 39 50 } 40 51 print "\n $cidr not mastered"; 52 last if $i++>10; 41 53 } 42 54 print "$flag done.\n"; … … 114 126 $prev = $master; 115 127 $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')) ) ". 117 129 "union (select network(cidr) as net, broadcast(cidr) as bcast ". 118 130 "from freeblocks where cidr <<= '$master' and not (routed='c')) order by net"); 119 131 $sth->execute; 120 132 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 124 142 if ($master->numeric == $prev->numeric) { 125 143 # check if cur starts with master … … 187 205 $sth->execute; 188 206 189 while (@data = $sth->fetchrow_array) { 190 $cur = new NetAddr::IP $data[0]; 207 print "(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 } 191 220 192 221 if ($container->numeric == $prev->numeric) {
Note:
See TracChangeset
for help on using the changeset viewer.