Changeset 574 for trunk/cgi-bin
- Timestamp:
- 12/21/12 17:39:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r573 r574 843 843 if ($args{type} =~ /^.p$/) { 844 844 $msg = "Could not initialize IPs in new $disp_alloctypes{$args{type}} $args{cidr}"; 845 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "all" );845 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "all", $args{rdepth}+1); 846 846 die $rmsg if $code eq 'FAIL'; 847 847 } elsif ($args{type} =~ /^.d$/) { 848 848 $msg = "Could not initialize IPs in new $disp_alloctypes{$args{type}} $args{cidr}"; 849 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "normal" );849 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "normal", $args{rdepth}+1); 850 850 die $rmsg if $code eq 'FAIL'; 851 851 } … … 856 856 } 857 857 # end node hack 858 858 859 $dbh->commit; 859 860 }; # end of eval … … 920 921 if ($args{type} =~ /^.p$/) { 921 922 $msg = "Could not initialize IPs in new $disp_alloctypes{$args{type}} $args{cidr}"; 922 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "all" );923 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "all", $args{rdepth}+1); 923 924 die $rmsg if $code eq 'FAIL'; 924 925 } elsif ($args{type} =~ /^.d$/) { 925 926 $msg = "Could not initialize IPs in new $disp_alloctypes{$args{type}} $args{cidr}"; 926 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "normal" );927 my ($code,$rmsg) = initPool($dbh, $args{cidr}, $args{type}, $args{city}, "normal", $args{rdepth}+1); 927 928 die $rmsg if $code eq 'FAIL'; 928 929 } … … 959 960 # function and should ONLY EVER get called from allocateBlock() 960 961 sub initPool { 961 my ($dbh,undef,$type,$city,$class ) = @_;962 my ($dbh,undef,$type,$city,$class,$rdepth) = @_; 962 963 my $pool = new NetAddr::IP $_[1]; 964 965 # IPv6 does not lend itself to IP pools as supported 966 return ('FAIL',"Refusing to create IPv6 static IP pool") if $pool->{isv6}; 967 # IPv4 pools don't make much sense beyond even /24. Allow up to 4096-host footshooting anyway. 968 # NetAddr::IP won't allow more than a /16 (65k hosts). 969 return ('FAIL',"Refusing to create oversized static IP pool") if $pool->masklen <= 20; 963 970 964 971 ##fixme Need to just replace 2nd char of type with i rather than capturing 1st char of type … … 975 982 eval { 976 983 # have to insert all pool IPs into poolips table as "unallocated". 977 $sth = $dbh->prepare(" insert into poolips (pool,ip,custid,city,type)".978 " values ('$pool', ?, '$defcustid', ?, '$type')");984 $sth = $dbh->prepare("INSERT INTO poolips (pool,ip,custid,city,type,rdepth)". 985 " VALUES ('$pool', ?, '$defcustid', ?, '$type', $rdepth)"); 979 986 my @poolip_list = $pool->hostenum; 980 987 if ($class eq 'all') { # (DSL-ish block - *all* IPs available … … 994 1001 } 995 1002 } 1003 $dbh->commit; 996 1004 }; 997 1005 if ($@) { 998 $msg = $@ ." '".$sth->errstr."'";1006 $msg = $@; 999 1007 eval { $dbh->rollback; }; 1000 1008 return ('FAIL',$msg);
Note:
See TracChangeset
for help on using the changeset viewer.