Changeset 595 for branches


Ignore:
Timestamp:
05/15/13 17:26:55 (11 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Hand-backport pieces of the allocate-from-routed-freeblock from /trunk
post-r553. Cherrypick merge not possible due to intermingled changes
relating to the database structure updates.
Includes a handful of harmless references to the new structure.
Will likely cause merge conflicts when the structure update is merged.

Location:
branches/stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/cgi-bin/IPDB.pm

    r594 r595  
    504504                                # really be specified in the call for clarity
    505505  my $tlist;
    506   if ($tgroup eq 'p') {
    507     # grouping 'p' - primary allocation types.  These include static IP pools (_d and _p),
    508     # dynamic-allocation ranges (_e), containers (_c), and the "miscellaneous" cn, in, and en types.
    509     $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder < 500 ".
    510         "AND type NOT LIKE '_i' AND type NOT LIKE '_r' ORDER BY listorder", { Slice => {} });
     506  if ($tgroup eq 'n') {
     507    # grouping 'n' - all netblock types.  These include routed blocks, containers (_c)
     508    # and contained (_r) types, dynamic-allocation ranges (_e), static IP pools (_d and _p),
     509    # and the "miscellaneous" cn, in, and en types.
     510    $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
     511        "AND type NOT LIKE '_i' ORDER BY listorder", { Slice => {} });
     512  } elsif ($tgroup eq 'p') {
     513    # grouping 'p' - primary allocation types.  As with 'n' above but without the _r contained types.
     514    $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
     515        "AND type NOT LIKE '_i' AND type NOT LIKE '_r' ORDER BY listorder", { Slice => {} });
    511516  } elsif ($tgroup eq 'c') {
    512517    # grouping 'c' - contained types.  These include all static IPs and all _r types.
    513518    $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
    514         " AND (type LIKE '_i' OR type LIKE '_r') ORDER BY listorder", { Slice => {} });
     519        " AND (type LIKE '_i' OR type LIKE '_r') ORDER BY listorder", { Slice => {} });
     520  } elsif ($tgroup eq 'i') {
     521    # grouping 'i' - static IP types.
     522    $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
     523        " AND type LIKE '_i' ORDER BY listorder", { Slice => {} });
    515524  } else {
    516525    # grouping 'a' - all standard allocation types.  This includes everything
    517526    # but mm (present only as a formality).  Make this the default.
    518527    $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
    519         " ORDER BY listorder", { Slice => {} });
     528        " ORDER BY listorder", { Slice => {} });
    520529  }
    521530  return $tlist;
  • branches/stable/cgi-bin/main.cgi

    r594 r595  
    238238  my $flist = listFree($ip_dbh, $webvar{block});
    239239  $page->param(unrouted => $flist);
     240  $page->param(mayadd => ($IPDBacl{$authuser} =~ /a/));
    240241} # showMaster
    241242
     
    312313  $page->param(rowa => 'row'.($webvar{block} eq '' ? 1 : 0));
    313314  $page->param(rowb => 'row'.($webvar{block} eq '' ? 0 : 1));
    314   $page->param(block => $webvar{block});        # fb-assign flag, if block is set, we're in fb-assign
    315   $page->param(iscontained => ($webvar{fbtype} && $webvar{fbtype} ne 'y'));
    316 
    317   # New special case- block to assign is specified
    318   if ($webvar{block} ne '') {
     315  $page->param(allocfrom => $webvar{block});    # fb-assign flag, if block is set, we're in fb-assign
     316
     317  if ($webvar{fbtype}) {
     318
     319    # Common case, according to reported usage.  Block to assign is specified.
    319320    my $block = new NetAddr::IP $webvar{block};
    320321
    321     # Handle contained freeblock allocation.
    322     # This is a little dangerous, as it's *theoretically* possible to
    323     # get fbtype='n' (aka a non-routed freeblock).  However, should
    324     # someone manage to get there, they get what they deserve.
    325     if ($webvar{fbtype} ne 'y') {
    326       # Snag the type of the container block from the database.
    327 ## hmm.  need a flag for parent class/type, sort of?
    328       my $pblock = subParent($ip_dbh, $webvar{block});
    329       my $ptype = $pblock->{type};
    330       $ptype =~ s/c$/r/;
    331       $page->param(fbdisptype => $list_alloctypes{$ptype});
    332       $page->param(type => $ptype);
     322    $webvar{fbtype} = '' if !$webvar{fbtype};
     323    if ($webvar{fbtype} eq 'i') {
     324      my $ipinfo = getBlockData($ip_dbh, $webvar{block}, 'i');
     325      my $pinfo = getBlockData($ip_dbh, $webvar{parent});
     326      $page->param(
     327        fbip => 1,
     328        block => $ipinfo->{block},
     329        fbdisptype => $list_alloctypes{$ipinfo->{type}},
     330        type => $ipinfo->{type},
     331        allocfrom => $pinfo->{block},
     332        );
     333    } elsif ($webvar{fbtype} eq 'n') {
     334      $page->param(
     335        fbrouted => 1,
     336        fbdisptype => $list_alloctypes{'rm'},
     337        type => 'rm',
     338        block => $block,
     339        );
    333340    } else {
    334341      # get "primary" alloctypes, since these are all that can correctly be assigned if we're in this branch
    335       my $tlist = getTypeList($ip_dbh, 'p');
     342      my $tlist = getTypeList($ip_dbh, 'n');
    336343      $tlist->[0]->{sel} = 1;
    337       $page->param(typelist => $tlist);
    338     }
     344      $page->param(typelist => $tlist, block => $block);
     345    }
     346
    339347  } else {
     348
     349    # Uncommon case, according to reported usage.  Block to assign needs to be found based on criteria.
    340350    my $mlist = getMasterList($ip_dbh, 'c');
    341351    $page->param(masterlist => $mlist);
    342352
    343353    my @pops;
    344     foreach my $pop (@poplist) {
     354    foreach my $pop (@citylist) {
    345355      my %row = (pop => $pop);
    346356      push (@pops, \%row);
     
    353363    $page->param(typelist => $tlist);
    354364  }
    355 
    356365  my @cities;
    357366  foreach my $city (@citylist) {
     
    400409
    401410    if ($webvar{fbassign} && $webvar{fbassign} eq 'y') {
     411      $cidr = new NetAddr::IP $webvar{block};
    402412      $alloc_from = new NetAddr::IP $webvar{allocfrom};
    403 ## possibly messy behaviour:  force the _from and block to be the network addr?
    404       $alloc_from = qq($alloc_from<input type=hidden name=alloc_from value="$alloc_from">);
    405       $cidr = new NetAddr::IP $webvar{block};
    406413      $webvar{maskbits} = $cidr->masklen;
    407414    } else { # done with direct freeblocks assignment
     
    440447
    441448# this chunk now specific to "guided" allocation;  freeblock-select can now slice-n-dice on its own.
    442       $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">);
     449      $alloc_from = "$cidr";
    443450      # If the block to be allocated is smaller than the one we found,
    444451      # figure out the "real" block to be allocated.
     
    452459      }
    453460    } # check for freeblocks assignment or IPDB-controlled assignment
    454 
    455     $alloc_from = "$cidr";
    456461
    457462  } # if ($webvar{alloctype} =~ /^.i$/)
  • branches/stable/templates/assign.tmpl

    r594 r595  
    11<div class="indent">
    2 <TMPL_IF block>
    3 <div class="tblsubtitle">
    4 Assign free <TMPL_IF iscontained><TMPL_VAR NAME=fbdisptype></TMPL_IF> block <TMPL_VAR NAME=block>
    5 </div>
    6 <TMPL_ELSE>
    7 <div class="tblsubtitle">Assign IPs</div>
    8 </TMPL_IF>
     2<div class="tblsubtitle">Assign IP<TMPL_UNLESS fbip>s</TMPL_UNLESS></div>
    93<br>
    104
     
    126<fieldset><legend class="noshow">&nbsp;</legend>
    137
    14 <TMPL_IF block>
    15 <input type="hidden" name="block" value="<TMPL_VAR NAME=block>">
     8<table class="regular" cellspacing="1" cellpadding="1">
     9
     10<TMPL_IF allocfrom>
     11<tr class="row0">
     12<TMPL_IF fbip>
     13<td>IP pool:</td>
     14<TMPL_ELSE>
     15<td>Free block selected:</td>
     16</TMPL_IF>
     17<td><TMPL_VAR NAME=allocfrom><input type="hidden" name="allocfrom" value="<TMPL_VAR NAME=allocfrom>">
     18<input type="hidden" name="parent" value="<TMPL_VAR NAME=parent>">
     19<input type="hidden" name="fbid" value="<TMPL_VAR NAME=fbid>">
     20</td>
     21</tr>
     22<tr class="row1">
     23<TMPL_IF fbip>
     24<td>IP:</td>
     25<td>
     26<TMPL_VAR NAME=block><input type="hidden" name="block" value="<TMPL_VAR NAME=block>">
    1627<input type="hidden" name="fbassign" value="y">
     28</td>
     29<TMPL_ELSE>
     30<td>Allocation:</td>
     31<td>
     32<input name="block" value="<TMPL_VAR NAME=block>">
     33<input type="hidden" name="fbassign" value="y">
     34</td>
    1735</TMPL_IF>
    18 
    19 <table class="regular" cellspacing="1" cellpadding="1">
     36</tr>
     37</TMPL_IF>
    2038
    2139<tr class="row0">
     
    3452<td>Allocation type:</td>
    3553<td>
    36 <TMPL_IF iscontained>
     54<TMPL_IF fbip>
     55<TMPL_VAR NAME=fbdisptype><input type="hidden" name="alloctype" value="<TMPL_VAR NAME=type>">
     56<TMPL_ELSE>
     57<TMPL_IF fbrouted>
    3758<TMPL_VAR NAME=fbdisptype><input type="hidden" name="alloctype" value="<TMPL_VAR NAME=type>">
    3859<TMPL_ELSE>
     
    4364<input type="button" value=" ? " onclick="helpAllocTypes()" class="regular">
    4465</TMPL_IF>
     66</TMPL_IF>
    4567</td>
    4668</tr>
    4769
    48 <TMPL_UNLESS block>
     70<TMPL_UNLESS allocfrom>
    4971<tr class="row0">
    5072<td>Subnet CIDR mask length:</td>
     
    5981
    6082<tr class="<TMPL_VAR NAME=rowb>">
    61 <td>Wifi tower/Fibre demarc</td>
     83<td>Layer-2/demarc node</td>
    6284<td>
    6385<select name="node">
     
    6688        <option value="<TMPL_VAR NAME=node_id>"><TMPL_VAR NAME=node_name></option></TMPL_LOOP>
    6789</select>
    68 &nbsp;<a href="javascript:popNotes('<TMPL_VAR NAME=webpath>/cgi-bin/newnode.cgi')">Add new location</a>
     90&nbsp;<a href="javascript:popNotes('<TMPL_VAR NAME=webpath>/cgi-bin/newnode.cgi')">Add new demarc node</a>
    6991</td>
    7092</tr>
    7193
    72 <TMPL_UNLESS block>
     94<TMPL_UNLESS allocfrom>
    7395<tr class="<TMPL_VAR NAME=rowa>">
    74 <td>Route from/through:</td>
     96<td>Limit to blocks in this location:</td>
    7597<td>
    7698<select name="pop">
     
    83105
    84106<tr class="<TMPL_VAR NAME=rowb>">
    85 <td>Route/allocate from this master:&nbsp;</td>
     107<td>Limit to blocks in this master:&nbsp;</td>
    86108<td>
    87109<select name="allocfrom">
    88110        <option selected="selected">-</option>
    89111<TMPL_LOOP NAME=masterlist>
    90         <option><TMPL_VAR NAME=master></option></TMPL_LOOP>
     112        <option value=<TMPL_VAR NAME=id>><TMPL_VAR NAME=master> (<TMPL_VAR NAME=vrf>)</option></TMPL_LOOP>
    91113</select>
    92114Allow automatic allocation from private IP ranges:<input type="checkbox" name="allowpriv"></td>
  • branches/stable/templates/showmaster.tmpl

    r594 r595  
    5454<TMPL_LOOP name=unrouted>
    5555<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
    56 <td><TMPL_VAR NAME=fblock></td>
     56<td><TMPL_IF mayadd><a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=assign&block=<TMPL_VAR NAME=fblock>&fbtype=n"><TMPL_VAR NAME=fblock><TMPL_ELSE><TMPL_VAR NAME=fblock></TMPL_IF></td>
    5757<td><TMPL_VAR NAME=frange></td>
    5858</tr>
Note: See TracChangeset for help on using the changeset viewer.