Changeset 720
- Timestamp:
- 05/07/15 15:17:05 (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r716 r720 29 29 &initIPDBGlobals &connectDB &finish &checkDBSanity 30 30 &addMaster &touchMaster 31 &listSummary &listSubs &listContainers &listAllocations &listF ree &listPool31 &listSummary &listSubs &listContainers &listAllocations &listForMerge &listFree &listPool 32 32 &getMasterList &getTypeList &getPoolSelect &findAllocateFrom 33 33 &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity … … 45 45 &initIPDBGlobals &connectDB &finish &checkDBSanity 46 46 &addMaster &touchMaster 47 &listSummary &listSubs &listContainers &listAllocations &listF ree &listPool47 &listSummary &listSubs &listContainers &listAllocations &listForMerge &listFree &listPool 48 48 &getMasterList &getTypeList &getPoolSelect &findAllocateFrom 49 49 &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity … … 810 810 811 811 812 ## IPDB::listForMerge() 813 # Get a list of blocks targetted in a proposed merge 814 sub listForMerge { 815 my $dbh = shift; 816 my $parent = shift; 817 my $newblock = shift; 818 my $btype = shift || 'a'; 819 $btype = 'a' if $btype !~/^[af]$/; 820 821 my $sql; 822 if ($btype eq 'a') { 823 my $ret = $dbh->selectall_arrayref(q( 824 SELECT a.cidr,a.id,t.dispname FROM allocations a 825 JOIN alloctypes t ON a.type=t.type 826 WHERE a.parent_id = ? AND a.cidr <<= ? 827 ORDER BY a.cidr 828 ), 829 { Slice => {} }, $parent, $newblock); 830 return $ret; 831 } else { 832 ##fixme: Not sure about the casting hackery in "SELECT ?::integer AS id", but it works as intended 833 my $ret = $dbh->selectall_arrayref(q( 834 SELECT cidr,id FROM freeblocks 835 WHERE parent_id IN (SELECT ?::integer AS id UNION 836 SELECT id FROM allocations WHERE parent_id = ? AND cidr <<= ? 837 ) AND cidr <<= ? 838 ORDER BY cidr 839 ), 840 { Slice => {} }, $parent, $parent, $newblock, $newblock) or print $dbh->errstr; 841 return $ret; 842 } 843 } # end listForMerge() 844 845 812 846 ## IPDB::listFree() 813 847 # Gets a list of free blocks in the requested parent/master and VRF instance in both CIDR and range notation -
trunk/cgi-bin/main.cgi
r717 r720 180 180 elsif($webvar{action} eq 'merge') { 181 181 prepMerge(); 182 } 183 elsif($webvar{action} eq 'confmerge') { 184 confMerge(); 182 185 } 183 186 elsif($webvar{action} eq 'delete') { … … 1225 1228 1226 1229 1230 # Show what will be merged, present warnings about data loss 1231 sub 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 1227 1278 # Delete an allocation. 1228 1279 sub remove {
Note:
See TracChangeset
for help on using the changeset viewer.