Changeset 705 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
02/25/15 18:09:13 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

  • Complete internal handling for "shrink block". See #7 (more or less).
  • Add "breadcrumb" navigation fragments to split/shrink prep and do pages
  • Add link to pool IP list on edit and split/shrink prep pages
  • Shave off some useless code showing the split results
  • Catch the theoretically impossible case of "no subact value" on submitting split/shrink form

Still need to add calls to monkey rDNS on split/shrink changes

File:
1 edited

Legend:

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

    r702 r705  
    875875  $utilbar->param(breadcrumb => \@rcrumbs);
    876876
     877  # Show link to IP list for pools
     878  $page->param(ispool => 1) if $blockinfo->{type} =~ /^.[dp]$/;
     879
    877880  # Clean up extra whitespace on alloc type.  Mainly a legacy-data cleanup.
    878881  $blockinfo->{type} =~ s/\s//;
     
    10921095  my $blockinfo = getBlockData($ip_dbh, $webvar{block});
    10931096
     1097  # Tree navigation
     1098  my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
     1099  my @rcrumbs = reverse (@$crumbs);
     1100  $utilbar->param(breadcrumb => \@rcrumbs);
     1101
    10941102  if ($blockinfo->{type} =~ /^.i$/) {
    10951103    $page->param(err => "Can't split a single IP allocation");
     
    11101118  if ($blockinfo->{type} =~ /^.d$/) {
    11111119    # Non-PPP pools
     1120    $page->param(ispool => 1);
    11121121    if ($oldmask+2 >= $block->bits) {
    11131122      $page->param(err => "Can't split a standard netblock pool any further");
     
    11171126    $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits-2;
    11181127  } elsif ($blockinfo->{type} =~ /.p/) {
     1128    $page->param(ispool => 1);
    11191129    # Allow splitting PPP pools down to v4 /31
    11201130    $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits-1;
     
    11441154  my $blockinfo = getBlockData($ip_dbh, $webvar{block});
    11451155
     1156  # Tree navigation
     1157  my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
     1158  my @rcrumbs = reverse (@$crumbs);
     1159  $utilbar->param(breadcrumb => \@rcrumbs);
     1160
    11461161  if ($blockinfo->{type} =~ /^.i$/) {
    11471162    $page->param(err => "Can't split a single IP allocation");
     
    11511166  if ($webvar{subact} eq 'split') {
    11521167    $page->param(issplit => 1);
    1153     my $binfo = getBlockData($ip_dbh, $webvar{block});
    1154     $page->param(cidr => $binfo->{block});
    1155     my $block = new NetAddr::IP $binfo->{block};
     1168    my $block = new NetAddr::IP $blockinfo->{block};
    11561169    my $newblocks = splitBlock($ip_dbh, $webvar{block}, 'b', $webvar{split});
    11571170    if ($newblocks) {
    11581171      $page->param(newblocks => $newblocks);
    1159       # and the backlink to the parent container
    1160       my $pinfo = getBlockData($ip_dbh, $binfo->{parent_id});
    1161       $page->param(backid => $binfo->{parent_id});
    1162       $page->param(backblock => $pinfo->{block});
    11631172    } else {
    11641173      $page->param(err => $IPDB::errstr);
    11651174    }
    11661175
     1176  } elsif ($webvar{subact} eq 'shrink') {
     1177    $page->param(nid => $webvar{block});
     1178    $page->param(newblock => $webvar{shrink});
     1179    my $newfree = shrinkBlock($ip_dbh, $webvar{block}, $webvar{shrink});
     1180    if ($newfree) {
     1181      $page->param(newfb => $newfree);
     1182    } else {
     1183      $page->param(err => $IPDB::errstr);
     1184    }
     1185
    11671186  } else {
    1168     # Shrink
    1169   }
     1187    # Your llama is on fire.
     1188    $page->param(err => "Missing form field that shouldn't be missing.");
     1189    return;
     1190  }
     1191
     1192  # common bits
     1193  $page->param(cidr => $blockinfo->{block});
     1194  # and the backlink to the parent container
     1195  my $pinfo = getBlockData($ip_dbh, $blockinfo->{parent_id});
     1196  $page->param(backid => $blockinfo->{parent_id});
     1197  $page->param(backblock => $pinfo->{block});
    11701198} # doSplit()
    11711199
Note: See TracChangeset for help on using the changeset viewer.