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


Ignore:
Timestamp:
05/07/15 15:17:05 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Second page in merge sequence; show main allocations and free blocks
that would be affected by the merge, along with reminders as
appropriate about data that may be lost with the combination of merge
scope and target type selected for the new allocation.
See #8.

File:
1 edited

Legend:

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

    r717 r720  
    180180elsif($webvar{action} eq 'merge') {
    181181  prepMerge();
     182}
     183elsif($webvar{action} eq 'confmerge') {
     184  confMerge();
    182185}
    183186elsif($webvar{action} eq 'delete') {
     
    12251228
    12261229
     1230# Show what will be merged, present warnings about data loss
     1231sub confMerge {
     1232  if (!$webvar{newmask} || $webvar{newmask} !~ /^\d+$/) {
     1233    $page->param(err => 'New netmask required');
     1234    return;
     1235  }
     1236
     1237  $page->param(block => $webvar{block});
     1238  my $binfo = getBlockData($ip_dbh, $webvar{block});
     1239  my $pinfo = getBlockData($ip_dbh, $binfo->{parent_id});
     1240  my $minfo = getBlockData($ip_dbh, $binfo->{master_id});
     1241  my $block = new NetAddr::IP $binfo->{block};
     1242
     1243  # Tree navigation
     1244  my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
     1245  my @rcrumbs = reverse (@$crumbs);
     1246  $utilbar->param(breadcrumb => \@rcrumbs);
     1247
     1248  $page->param(oldblock => $binfo->{block});
     1249  $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
     1250  $page->param(ismaster => $binfo->{type} eq 'mm');
     1251  $page->param(iscontainer => $webvar{alloctype} eq 'rm' || $webvar{alloctype} =~ /.c/);
     1252  $page->param(ispool => $webvar{alloctype} =~ /.[dp]/);
     1253  $page->param(isleaf => $webvar{alloctype} =~ /.[enr]/);
     1254  $page->param(newtype => $webvar{alloctype});
     1255  $page->param(newdisptype => $disp_alloctypes{$webvar{alloctype}});
     1256  my $newblock = new NetAddr::IP $block->addr."/$webvar{newmask}";
     1257  $newblock = $newblock->network;
     1258  $page->param(newmask => $webvar{newmask});
     1259  $page->param(newblock => "$newblock");
     1260
     1261  # get list of allocations and freeblocks to be merged
     1262  my $malloc_list = listForMerge($ip_dbh, $binfo->{parent_id}, $newblock, 'a');
     1263  $page->param(mergealloc => $malloc_list);
     1264  my $fb_list = listForMerge($ip_dbh, $binfo->{parent_id}, $newblock, 'f');
     1265  $page->param(mergefree => $fb_list);
     1266
     1267  # scope
     1268  my %merge_friendly = (
     1269        keepall   => "Keep mergeable allocations as suballocations of new block",
     1270        mergepeer => "Make suballocations of mergeable allocations direct children of new block",
     1271        clearpeer => "Keep only suballocations of $binfo->{block}",
     1272        clearall  => "Clear all suballocations"
     1273    );
     1274  $page->param(scope => $merge_friendly{$webvar{mscope}});
     1275} # confMerge()
     1276
     1277
    12271278# Delete an allocation.
    12281279sub remove {
Note: See TracChangeset for help on using the changeset viewer.