move VRFs to routing. Merge /vrf/ and /vrfs/. make menubar track selection.

git-svn-id: http://www.observium.org/svn/observer/trunk@2195 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-04-28 14:20:17 +00:00
parent d7c2b7602c
commit 66f6125c14
5 changed files with 181 additions and 151 deletions

View File

@ -153,8 +153,6 @@ if ($config['enable_billing']) { echo('<li><a href="bills/"><img src="images/16/
if ($config['enable_pseudowires']) { echo('<li><a href="pseudowires/"><img src="images/16/arrow_switch.png" border="0" align="absmiddle" /> Pseudowires</a></li>'); $ifbreak = 1; }
if ($config['enable_vrfs']) { echo('<li><a href="vrfs/"><img src="images/16/layers.png" border="0" align="absmiddle" /> VRFs</a></li>'); $ifbreak = 1; }
?>
<?php
@ -281,6 +279,8 @@ if ($_SESSION['userlevel'] >= '5')
<table><tr><td>
<ul>');
if ($config['enable_vrfs']) { echo('<li><a href="routing/vrfs/"><img src="images/16/layers.png" border="0" align="absmiddle" /> VRFs</a></li> <li><hr width=140></li> '); }
## BGP Sessions
if ($_SESSION['userlevel'] >= '5' && (isset($config['enable_bgp']) && $config['enable_bgp']))
{

View File

@ -18,6 +18,21 @@ print_optionbar_start('', '');
echo('<a href="routing/bgp/all/'.$graphs.'/">BGP</a>');
if ($_GET['opta'] == "bgp") { echo("</span>"); }
echo(" | ");
## Start OSPF Menu -- FIXME only show if BGP enabled?
if ($_GET['opta'] == "ospf") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/ospf/all/'.$graphs.'/">OSPF</a>');
if ($_GET['opta'] == "ospf") { echo("</span>"); }
echo(" | ");
## Start VRF Menu -- FIXME only show if BGP enabled?
if ($_GET['opta'] == "vrf") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/all/'.$graphs.'/">VRF</a>');
if ($_GET['opta'] == "vrf") { echo("</span>"); }
print_optionbar_end('', '');
@ -25,6 +40,7 @@ switch ($_GET['opta'])
{
case 'overview':
case 'bgp':
case 'vrf':
include('pages/routing/'.$_GET['opta'].'.inc.php');
break;
default:

View File

@ -0,0 +1,163 @@
<?php
if ($_SESSION['userlevel'] >= '5') {
if(!isset($_GET['optb'])) { $_GET['optb'] = "all"; }
if(!isset($_GET['optc'])) { $_GET['optc'] = "basic"; }
print_optionbar_start();
echo('<span style="font-weight: bold;">VRF</span> &#187; ');
if ($_GET['opta'] == "vrf" && $_GET['optb'] == "all") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/all/'.$_GET['optc'].'/">All</a>');
if ($_GET['opta'] == "vrf" && $_GET['optb'] == "all") { echo("</span>"); }
echo(' | ');
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "basic") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/'.$_GET['optb'].'/basic/">Basic</a>');
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "basic") { echo("</span>"); }
echo(" | ");
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "details") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/'.$_GET['optb'].'/details/">Details</a>');
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "details") { echo("</span>"); }
echo(" | Graphs: ( ");
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "bits") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/'.$_GET['optb'].'/bits/">Bits</a>');
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "bits") { echo("</span>"); }
echo(" | ");
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "upkts") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/'.$_GET['optb'].'/upkts/">Packets</a>');
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "upkts") { echo("</span>"); }
echo(" | ");
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "nupkts") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/'.$_GET['optb'].'/nupkts/">NU Packets</a>');
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "nupkts") { echo("</span>"); }
echo(" | ");
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "errors") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/vrf/'.$_GET['optb'].'/errors/">Errors</a>');
if ($_GET['opta'] == "vrf" && $_GET['optc'] == "errors") { echo("</span>"); }
echo(" )");
print_optionbar_end();
if($_GET['optb'] == "all" ) {
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
$vrf_query = mysql_query("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`");
while ($vrf = mysql_fetch_assoc($vrf_query))
{
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=240><a class=list-large href='routing/vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/".$_GET['optc']."/'>" . $vrf['vrf_name'] . "</a><br /><span class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</span></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
#echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("<td><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
while ($device = mysql_fetch_assoc($devices))
{
if (!is_integer($i/2))
{
if (!is_integer($x/2)) { $dev_colour = $list_colour_a_a; } else { $dev_colour = $list_colour_a_b; }
} else {
if (!is_integer($x/2)) { $dev_colour = $list_colour_b_b; } else { $dev_colour = $list_colour_b_a; }
}
echo("<tr bgcolor='$dev_colour'><td width=150>".generate_device_link($device, shorthost($device['hostname'])));
if ($device['vrf_name'] != $vrf['vrf_name']) { echo("<a href='#' onmouseover=\" return overlib('Expected Name : ".$vrf['vrf_name']."<br />Configured : ".$device['vrf_name']."', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>"); }
echo("</td><td>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
while ($port = mysql_fetch_assoc($ports))
{
$port = array_merge ($device, $port);
switch ($_GET['optc'])
{
case 'bits':
case 'pkts':
case 'nupkts':
case 'errors':
$port['width'] = "130";
$port['height'] = "30";
$port['from'] = $day;
$port['to'] = $now;
$port['bg'] = "#".$bg;
$port['graph_type'] = "port_".$_GET['optc'];
echo("<div style='display: block; padding: 3px; margin: 3px; min-width: 135px; max-width:135px; min-height:75px; max-height:75px;
text-align: center; float: left; background-color: ".$list_colour_b_b.";'>
<div style='font-weight: bold;'>".makeshortif($port['ifDescr'])."</div>");
generate_port_thumbnail($port);
echo("<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 22, '')."</div>
</div>");
break;
default:
echo($seperator.generate_port_link($port,makeshortif($port['ifDescr'])));
$seperator = ", ";
break;
}
}
echo("</td></tr>");
$x++;
} // End While
echo("</table></td>");
$i++;
}
echo("</table></div>");
} else {
echo("<div style='background: $list_colour_b; padding: 10px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$vrf_query = mysql_query("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = '".$_GET['optb']."'");
$vrf = mysql_fetch_assoc($vrf_query);
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=200 class=list-large><a href='routing/vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/".$_GET['optc']."/'>" . $vrf['vrf_name'] . "</a></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("</table></div>");
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
while ($device = mysql_fetch_assoc($devices))
{
$hostname = $device['hostname'];
#if (!is_integer($x/2)) { $device_colour = $list_colour_a; } else { $device_colour = $list_colour_b; }
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
include("includes/device-header.inc.php");
echo("</table>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
echo("<table cellspacing=0 cellpadding=7>");
$i=1;
while ($interface = mysql_fetch_assoc($ports))
{
if (!is_integer($x/2))
{
if (is_integer($i/2)) { $int_colour = $list_colour_a_a; } else { $int_colour = $list_colour_a_b; }
} else {
if (is_integer($i/2)) { $int_colour = $list_colour_b_b; } else { $int_colour = $list_colour_b_a; }
}
include("includes/print-interface.inc.php");
$i++;
}
$x++;
echo("</table>");
echo("<div style='height: 10px;'></div>");
}
}
} else {
include("includes/error-no-perm.inc.php");
} ## End Permission if
?>

View File

@ -1,68 +0,0 @@
<?php
echo("
<div style='width: 100%; text-align: right; padding-bottom: 10px; clear: both; display:block; height:20px;'>
<a href='vrf/" . $_GET['id'] . "/'>Basic</a> |
<a href='vrf/" . $_GET['id'] . "/details/'>Details</a> | Graphs:
<a href='vrf/" . $_GET['id'] . "/graphs/bits/'>Bits</a> |
<a href='vrf/" . $_GET['id'] . "/graphs/pkts/'>Packets</a> |
<a href='vrf/" . $_GET['id'] . "/graphs/nupkts/'>NU Packets</a> |
<a href='vrf/" . $_GET['id'] . "/graphs/errors/'>Errors</a>
</div>");
if ($_GET['opta'] == 'graphs')
{
if ($_GET['optb'])
{
$graph_type = $_GET['optb'];
} else {
$graph_type = "bits";
}
$dographs = 1;
}
if ($_GET['opta'] == "details" )
{
$port_details = 1;
}
echo("<div style='background: $list_colour_b; padding: 10px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$vrf_query = mysql_query("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = '".$_GET['id']."'");
$vrf = mysql_fetch_assoc($vrf_query);
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=200 class=list-large><a href='vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/'>" . $vrf['vrf_name'] . "</a></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("</table></div>");
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
while ($device = mysql_fetch_assoc($devices))
{
$hostname = $device['hostname'];
#if (!is_integer($x/2)) { $device_colour = $list_colour_a; } else { $device_colour = $list_colour_b; }
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
include("includes/device-header.inc.php");
echo("</table>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
echo("<table cellspacing=0 cellpadding=7>");
$i=1;
while ($interface = mysql_fetch_assoc($ports))
{
if (!is_integer($x/2))
{
if (is_integer($i/2)) { $int_colour = $list_colour_a_a; } else { $int_colour = $list_colour_a_b; }
} else {
if (is_integer($i/2)) { $int_colour = $list_colour_b_b; } else { $int_colour = $list_colour_b_a; }
}
include("includes/print-interface.inc.php");
$i++;
}
$x++;
echo("</table>");
echo("<div style='height: 10px;'></div>");
}
?>

View File

@ -1,81 +0,0 @@
<?php
if ($_SESSION['userlevel'] >= '5')
{
print_optionbar_start();
echo("
<a href='".$config['base_url']. "/vrfs/'>Basic</a> | Graphs :
<a href='".$config['base_url']. "/vrfs/bits/'>Bits</a> |
<a href='".$config['base_url']. "/vrfs/upkts/'>Packets</a> |
<a href='".$config['base_url']. "/vrfs/nupkts/'>NU Packets</a> |
<a href='".$config['base_url']. "/vrfs/errors/'>Errors</a>
");
print_optionbar_end();
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
$vrf_query = mysql_query("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`");
while ($vrf = mysql_fetch_assoc($vrf_query))
{
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=240><a class=list-large href='vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/'>" . $vrf['vrf_name'] . "</a><br /><span class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</span></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
#echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("<td><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
while ($device = mysql_fetch_assoc($devices))
{
if (!is_integer($i/2))
{
if (!is_integer($x/2)) { $dev_colour = $list_colour_a_a; } else { $dev_colour = $list_colour_a_b; }
} else {
if (!is_integer($x/2)) { $dev_colour = $list_colour_b_b; } else { $dev_colour = $list_colour_b_a; }
}
echo("<tr bgcolor='$dev_colour'><td width=150>".generate_device_link($device, shorthost($device['hostname'])));
if ($device['vrf_name'] != $vrf['vrf_name']) { echo("<a href='#' onmouseover=\" return overlib('Expected Name : ".$vrf['vrf_name']."<br />Configured : ".$device['vrf_name']."', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>"); }
echo("</td><td>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
while ($port = mysql_fetch_assoc($ports))
{
$port = array_merge ($device, $port);
if ($_GET['opta'])
{
$port['width'] = "130";
$port['height'] = "30";
$port['from'] = $day;
$port['to'] = $now;
$port['bg'] = "#".$bg;
$port['graph_type'] = "port_".$_GET['opta'];
echo("<div style='display: block; padding: 3px; margin: 3px; min-width: 135px; max-width:135px; min-height:75px; max-height:75px;
text-align: center; float: left; background-color: ".$list_colour_b_b.";'>
<div style='font-weight: bold;'>".makeshortif($port['ifDescr'])."</div>");
generate_port_thumbnail($port);
echo("<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 22, '')."</div>
</div>");
} else {
echo($seperator.generate_port_link($port,makeshortif($port['ifDescr'])));
$seperator = ", ";
}
}
echo("</td></tr>");
$x++;
} // End While
echo("</table></td>");
$i++;
}
echo("</table></div>");
} else {
include("includes/error-no-perm.inc.php");
} ## End Permission if
?>