Changeset 21


Ignore:
Timestamp:
10/25/04 17:38:02 (20 years ago)
Author:
Kris Deugau
Message:

Added support for directly assigning blocks listed as "free"

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r20 r21  
    694694    my $cidr = new NetAddr::IP $data[0];
    695695    if ($master->contains($cidr)) {
    696       my @row = ("$cidr", $cidr->range);
     696      my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>",
     697        $cidr->range);
    697698      printRow(\@row, 'color1') if ($count%2 == 0);
    698699      printRow(\@row, 'color2') if ($count%2 != 0);
     
    766767  printHeader('');
    767768
    768   open HTML, "../assign.html"
     769  my $html;
     770
     771  # New special case- block to assign is specified
     772  if ($webvar{block} ne '') {
     773    open HTML, "../fb-assign.html"
     774        or croak "Could not open fb-assign.html: $!";
     775    $html = join('',<HTML>);
     776    close HTML;
     777    my $block = new NetAddr::IP $webvar{block};
     778    $html =~ s|\$\$BLOCK\$\$|$block|g;
     779    $html =~ s|\$\$MASKBITS\$\$|$block->masklen|;
     780  } else {
     781    open HTML, "../assign.html"
    769782        or croak "Could not open assign.html: $!";
    770   my $html = join('',<HTML>);
    771   close(HTML);
     783    $html = join('',<HTML>);
     784    close HTML;
     785  }
    772786
    773787  print $html;
     
    830844
    831845  } else { # end show pool options
    832     if (!$webvar{maskbits}) {
    833       printAndExit("Please specify a CIDR mask length.");
    834     }
    835     my $sql;
    836     my $city;
    837     my $failmsg;
    838     if ($webvar{alloctype} eq 'rr') {
    839       $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
    840         " order by maskbits desc";
    841       $failmsg = "No suitable free block found.<br>\nWe do not have a free".
    842         " routeable block of that size.<br>\nYou will have to either route".
    843         " a set of smaller netblocks or a single smaller netblock.";
    844     } else {
    845       if ($webvar{alloctype} =~ /^[sd]p$/) {
    846         if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
    847           printAndExit("You must chose Sudbury or North Bay for DSL pools."); }
    848         if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; }
    849         $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    850           " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller".
    851           " block size for the pool.";
     846
     847    if ($webvar{fbassign} eq 'y') {
     848      $cidr = new NetAddr::IP $webvar{block};
     849      $webvar{maskbits} = $cidr->masklen;
     850    } else { # done with direct freeblocks assignment
     851
     852      if (!$webvar{maskbits}) {
     853        printAndExit("Please specify a CIDR mask length.");
     854      }
     855      my $sql;
     856      my $city;
     857      my $failmsg;
     858      if ($webvar{alloctype} eq 'rr') {
     859        $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
     860          " order by maskbits desc";
     861        $failmsg = "No suitable free block found.<br>\nWe do not have a free".
     862          " routeable block of that size.<br>\nYou will have to either route".
     863          " a set of smaller netblocks or a single smaller netblock.";
    852864      } else {
    853         $city = $webvar{pop};
    854         $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    855           " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or".
    856           " chose a smaller blocksize.";
    857       }
    858       $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    859         " and routed='y' order by cidr,maskbits desc";
    860     }
    861     $sth = $ip_dbh->prepare($sql);
    862     $sth->execute;
    863     my @data = $sth->fetchrow_array();
    864     if ($data[0] eq "") {
    865       printAndExit($failmsg);
    866     }
    867 
    868     $cidr = new NetAddr::IP $data[0];
     865        if ($webvar{alloctype} =~ /^[sd]p$/) {
     866          if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
     867            printAndExit("You must chose Sudbury or North Bay for DSL pools."); }
     868          if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; }
     869          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
     870            " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller".
     871            " block size for the pool.";
     872        } else {
     873          $city = $webvar{pop};
     874          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
     875            " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or".
     876            " chose a smaller blocksize.";
     877        }
     878        $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
     879          " and routed='y' order by cidr,maskbits desc";
     880      }
     881      $sth = $ip_dbh->prepare($sql);
     882      $sth->execute;
     883      my @data = $sth->fetchrow_array();
     884      if ($data[0] eq "") {
     885        printAndExit($failmsg);
     886      }
     887      $cidr = new NetAddr::IP $data[0];
     888    } # check for freeblocks assignment or IPDB-controlled assignment
     889
    869890    $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">);
    870891
Note: See TracChangeset for help on using the changeset viewer.