View Issue Details

IDProjectCategoryView StatusLast Update
543RackTablesdefaultpublic2013-06-09 09:02
Reporteruser289Assigned Toandriyanov  
PrioritynormalSeverityfeatureReproducibilityN/A
Status assignedResolutionopen 
Summary543: Ability to hide reserved addresses in IPv4 Network
DescriptionWe have large sets of addresses within our networks that are not available for our use, so we set them as reserved. It would be nice to be able to hide the reserved addresses within a network. I've included a hackish patch that achieves it, but I think it should be a user interface check to allow for different views.
TagsNo tags attached.
Attached Files
interface.php.patch (4,573 bytes)   
Index: interface.php
===================================================================
--- interface.php	(revision 5010)
+++ interface.php	(working copy)
@@ -2519,8 +2519,14 @@
 	}
 
 	// pager
-	$maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE');
-	$address_count = $endip - $startip + 1;
+        $maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE');
+        $reservedips = 0;
+        for ($ip = $startip; $ip <= $endip; $ip++) :
+                $addr = $range['addrlist'][$ip];
+                if ( $addr['reserved'] == 'yes')
+                        $reservedips++;
+        endfor;
+        $address_count = $endip - $startip - $reservedips + 1;
 	$page = 0;
 	$rendered_pager = '';
 	if ($address_count > $maxperpage && $maxperpage > 0)
@@ -2553,51 +2559,54 @@
 			continue;
 		}
 		$addr = $range['addrlist'][$ip];
-		// render IP change history
-		$title = '';
-		$history_class = '';
-		if (isset ($addr['last_log']))
-		{
-			$title = ' title="' . htmlspecialchars ($addr['last_log']['user'] . ', ' . formatAge ($addr['last_log']['time']) , ENT_QUOTES) . '"';
-			$history_class = 'hover-history underline';
+		if ($addr['reserved'] != 'yes')
+                {
+			// render IP change history
+			$title = '';
+			$history_class = '';
+			if (isset ($addr['last_log']))
+			{
+				$title = ' title="' . htmlspecialchars ($addr['last_log']['user'] . ', ' . formatAge ($addr['last_log']['time']) , ENT_QUOTES) . '"';
+				$history_class = 'hover-history underline';
+			}
+			echo "<tr class='${addr['class']}'>";
+			echo "<td class=tdleft><a class='ancor $history_class' $title name='ip-$dottedquad' href='".makeHref(array('page'=>'ipaddress', 'ip'=>$addr['ip']))."'>${addr['ip']}</a></td>";
+			echo "<td class='${secondstyle} " .
+				(empty ($addr['allocs']) || !empty ($addr['name']) ? 'rsv-port' : '') .
+				"'><span class='rsvtext'>${addr['name']}</span></td><td class='${secondstyle}'>";
+			$delim = '';
+			if ( $addr['reserved'] == 'yes')
+			{
+				echo "<strong>RESERVED</strong> ";
+				$delim = '; ';
+			}
+			foreach ($addr['allocs'] as $ref)
+			{
+				echo $delim . $aac2[$ref['type']];
+				echo "<a href='".makeHref(array('page'=>'object', 'object_id'=>$ref['object_id'], 'tab' => 'default', 'hl_ipv4_addr'=>$addr['ip']))."'>";
+				echo $ref['name'] . (!strlen ($ref['name']) ? '' : '@');
+				echo "${ref['object_name']}</a>";
+				$delim = '; ';
+			}
+			if ($delim != '')
+				$delim = '<br>';
+			foreach ($addr['vslist'] as $vs_id)
+			{
+				$vs = spotEntity ('ipv4vs', $vs_id);
+				echo "${delim}<a href='".makeHref(array('page'=>'ipv4vs', 'vs_id'=>$vs['id']))."'>";
+				echo "${vs['name']}:${vs['vport']}/${vs['proto']}</a>&rarr;";
+				$delim = '<br>';
+			}
+			foreach ($addr['rsplist'] as $rsp_id)
+			{
+				$rsp = spotEntity ('ipv4rspool', $rsp_id);
+				echo "${delim}&rarr;<a href='".makeHref(array('page'=>'ipv4rspool', 'pool_id'=>$rsp['id']))."'>";
+				echo "${rsp['name']}</a>";
+				$delim = '<br>';
+			}
 		}
-		echo "<tr class='${addr['class']}'>";
-		echo "<td class=tdleft><a class='ancor $history_class' $title name='ip-$dottedquad' href='".makeHref(array('page'=>'ipaddress', 'ip'=>$addr['ip']))."'>${addr['ip']}</a></td>";
-		echo "<td class='${secondstyle} " .
-			(empty ($addr['allocs']) || !empty ($addr['name']) ? 'rsv-port' : '') .
-			"'><span class='rsvtext'>${addr['name']}</span></td><td class='${secondstyle}'>";
-		$delim = '';
-		if ( $addr['reserved'] == 'yes')
-		{
-			echo "<strong>RESERVED</strong> ";
-			$delim = '; ';
-		}
-		foreach ($addr['allocs'] as $ref)
-		{
-			echo $delim . $aac2[$ref['type']];
-			echo "<a href='".makeHref(array('page'=>'object', 'object_id'=>$ref['object_id'], 'tab' => 'default', 'hl_ipv4_addr'=>$addr['ip']))."'>";
-			echo $ref['name'] . (!strlen ($ref['name']) ? '' : '@');
-			echo "${ref['object_name']}</a>";
-			$delim = '; ';
-		}
-		if ($delim != '')
-			$delim = '<br>';
-		foreach ($addr['vslist'] as $vs_id)
-		{
-			$vs = spotEntity ('ipv4vs', $vs_id);
-			echo "${delim}<a href='".makeHref(array('page'=>'ipv4vs', 'vs_id'=>$vs['id']))."'>";
-			echo "${vs['name']}:${vs['vport']}/${vs['proto']}</a>&rarr;";
-			$delim = '<br>';
-		}
-		foreach ($addr['rsplist'] as $rsp_id)
-		{
-			$rsp = spotEntity ('ipv4rspool', $rsp_id);
-			echo "${delim}&rarr;<a href='".makeHref(array('page'=>'ipv4rspool', 'pool_id'=>$rsp['id']))."'>";
-			echo "${rsp['name']}</a>";
-			$delim = '<br>';
-		}
 		echo "</td></tr>\n";
-	endfor;
+		endfor;
 	// end of iteration
 	if (permitted (NULL, NULL, 'set_reserve_comment'))
 		addJS ('js/inplace-edit.js');
interface.php.patch (4,573 bytes)   

Activities

Issue History

Date Modified Username Field Change
2012-03-17 20:43 user289 New Issue
2012-03-17 20:43 user289 File Added: interface.php.patch
2013-06-09 09:02 andriyanov Assigned To => andriyanov
2013-06-09 09:02 andriyanov Status new => assigned