View Issue Details

IDProjectCategoryView StatusLast Update
460RackTables802.1Q VLANspublic2012-12-27 09:49
Reporteruser167Assigned Toinfrastation  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version0.19.7 
Target Version0.20.1Fixed in Version0.20.1 
Summary460: Support static VLAN info per port
DescriptionWe needed a static info per port, which VLAN is untagged on that port.

The attached patch enables the user to enter a VLAN id and shows this vlan ID on the "view" page and on remote object views.
Additional InformationDEAR PEOPLE FROM THE FUTURE

This feature is implemented and its use is documented on this wiki page: http://wiki.racktables.org/index.php/8021Q#adding_and_removing_802.1Q_ports_offline
TagsNo tags attached.

Activities

2011-08-23 08:23

 

racktablesportvlaninfo.patch (7,570 bytes)   
### Eclipse Workspace Patch 1.0
#P racktables
Index: wwwroot/inc/database.php
===================================================================
--- wwwroot/inc/database.php	(Revision 234)
+++ wwwroot/inc/database.php	(Arbeitskopie)
@@ -518,7 +518,7 @@
 
 function getObjectPortsAndLinks ($object_id)
 {
-	$query = "SELECT id, name, label, l2address, iif_id, (SELECT iif_name FROM PortInnerInterface WHERE id = iif_id) AS iif_name, " .
+	$query = "SELECT id, name, label, l2address, vlan, iif_id, (SELECT iif_name FROM PortInnerInterface WHERE id = iif_id) AS iif_name, " .
 		"(SELECT name FROM RackObject WHERE Port.object_id = RackObject.id) AS object_name, " .
 		"type AS oif_id, (SELECT dict_value FROM Dictionary WHERE dict_key = type) AS oif_name, reservation_comment " .
 		"FROM Port WHERE object_id = ?";
@@ -531,6 +531,7 @@
 		$row['remote_id'] = NULL;
 		$row['remote_name'] = NULL;
 		$row['remote_object_id'] = NULL;
+        $row['remote_vlan'] = NULL;
 		$ret[] = $row;
 	}
 	unset ($result);
@@ -554,13 +555,14 @@
 		unset ($result);
 		if ($remote_id) // there's a remote end here
 		{
-			$query = "SELECT name, object_id FROM Port WHERE id = ?";
+			$query = "SELECT name, object_id, vlan FROM Port WHERE id = ?";
 			$result = usePreparedSelectBlade ($query, array ($remote_id));
 			if ($row = $result->fetch (PDO::FETCH_ASSOC))
 			{
 				$ret[$tmpkey]['remote_name'] = $row['name'];
 				$ret[$tmpkey]['remote_object_id'] = $row['object_id'];
 				$ret[$tmpkey]['cableid'] = $cable;
+                $ret[$tmpkey]['remote_vlan'] = $row['vlan'];
 			}
 			$ret[$tmpkey]['remote_id'] = $remote_id;
 			unset ($result);
@@ -1066,7 +1068,7 @@
 	return $ret;
 }
 
-function commitAddPort ($object_id = 0, $port_name, $port_type_id, $port_label, $port_l2address)
+function commitAddPort ($object_id = 0, $port_name, $port_type_id, $port_label, $port_l2address, $port_vlan)
 {
 	$db_l2address = l2addressForDatabase ($port_l2address);
 	global $dbxlink;
@@ -1102,6 +1104,7 @@
 			'iif_id' => $iif_id,
 			'type' => $oif_id,
 			'l2address' => ($db_l2address === '') ? NULL : $db_l2address,
+			'vlan' => $port_vlan
 		)
 	);
 	$dbxlink->exec ('UNLOCK TABLES');
@@ -1110,7 +1113,7 @@
 // The fifth argument may be either explicit 'NULL' or some (already quoted by the upper layer)
 // string value. In case it is omitted, we just assign it its current value.
 // It would be nice to simplify this semantics later.
-function commitUpdatePort ($object_id, $port_id, $port_name, $port_type_id, $port_label, $port_l2address, $port_reservation_comment)
+function commitUpdatePort ($object_id, $port_id, $port_name, $port_type_id, $port_label, $port_l2address, $port_reservation_comment, $port_vlan)
 {
 	$db_l2address = l2addressForDatabase ($port_l2address);
 	global $dbxlink;
@@ -1133,6 +1136,7 @@
 			'label' => $port_label,
 			'reservation_comment' => mb_strlen ($port_reservation_comment) ? $port_reservation_comment : NULL,
 			'l2address' => ($db_l2address === '') ? NULL : $db_l2address,
+			'vlan' => $port_vlan,
 		),
 		array
 		(
Index: wwwroot/inc/ophandlers.php
===================================================================
--- wwwroot/inc/ophandlers.php	(Revision 234)
+++ wwwroot/inc/ophandlers.php	(Arbeitskopie)
@@ -602,7 +602,8 @@
 		trim ($_REQUEST['port_name']),
 		$_REQUEST['port_type_id'],
 		trim ($_REQUEST['port_label']),
-		trim ($_REQUEST['port_l2address'])
+		trim ($_REQUEST['port_l2address']),
+		trim ($_REQUEST['port_vlan'])
 	);
 	return buildRedirectURL (__FUNCTION__, 'OK', array ($_REQUEST['port_name']));
 }
@@ -616,7 +617,7 @@
 	assertStringArg ('reservation_comment', TRUE);
 	genericAssertion ('l2address', 'l2address0');
 	genericAssertion ('name', 'string');
-	commitUpdatePort ($sic['object_id'], $sic['port_id'], $sic['name'], $sic['port_type_id'], $sic['label'], $sic['l2address'], $sic['reservation_comment']);
+	commitUpdatePort ($sic['object_id'], $sic['port_id'], $sic['name'], $sic['port_type_id'], $sic['label'], $sic['l2address'], $sic['reservation_comment'], $sic['vlan']);
 	return buildRedirectURL (__FUNCTION__, 'OK', array ($_REQUEST['name']));
 }
 
Index: wwwroot/inc/interface.php
===================================================================
--- wwwroot/inc/interface.php	(Revision 234)
+++ wwwroot/inc/interface.php	(Arbeitskopie)
@@ -788,6 +788,7 @@
 		echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>";
 		echo '<tr><th class=tdleft>Local name</th><th class=tdleft>Visible label</th>';
 		echo '<th class=tdleft>Interface</th><th class=tdleft>L2 address</th>';
+        echo '<th class=tdleft>VLAN</th>';        
 		echo '<th class=tdcenter colspan=2>Remote object and port</th>';
 		echo '<th class=tdleft>Cable ID</th></tr>';
 		foreach ($info['ports'] as $port)
@@ -799,12 +800,17 @@
 			echo "><td class='tdleft' NOWRAP><a name='port-${port['id']}' class='ancor interactive-portname nolink $a_class'>${port['name']}</a></td>";
 			echo "<td class=tdleft>${port['label']}</td>";
 			echo "<td class=tdleft>" . formatPortIIFOIF ($port) . "</td><td class=tdleft><tt>${port['l2address']}</tt></td>";
+            echo "<td class=tdleft>${port['vlan']}</td>";
 			if ($port['remote_object_id'])
 			{
 				$remote_object = spotEntity ('object', $port['remote_object_id']);
 				echo "<td class=tdleft><a href='".makeHref(array('page'=>'object', 'object_id'=>$port['remote_object_id'], 'hl_port_id'=>$port['remote_id']))."'>${remote_object['dname']}</a></td>";
 				echo "<td class=tdleft>${port['remote_name']}</td>";
-				echo "<td class='tdleft rsvtext'>${port['cableid']}</td>";
+				echo "<td class='tdleft rsvtext'>${port['cableid']}";                
+				if ($port['remote_vlan'] != NULL) {
+				    echo " VLAN " . $port['remote_vlan'];
+                }
+				echo "</td>";
 			}
 			else
 				echo implode ('', formatPortReservation ($port)) . '<td></td>';
@@ -1066,7 +1072,8 @@
 		echo "<td><input type=text name=port_label tabindex=101></td><td>";
 		printNiftySelect (getNewPortTypeOptions(), array ('name' => 'port_type_id', 'tabindex' => 102), $prefs['selected']);
 		echo "<td><input type=text name=port_l2address tabindex=103 size=18 maxlength=24></td>\n";
-		echo "<td colspan=3>&nbsp;</td><td>";
+        echo "<td><input type=text name=port_vlan tabindex=104 size=5 maxlength=200></td>\n";
+		echo "<td colspan=2>&nbsp;</td><td>";
 		printImageHREF ('add', 'add a port', TRUE, 104);
 		echo "</td></tr></form>";
 	}
@@ -1095,7 +1102,7 @@
 	}
 	
 	echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
-	echo "<tr><th>&nbsp;</th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>L2 address</th>";
+	echo "<tr><th>&nbsp;</th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>L2 address</th><th class=tdleft>VLAN</th>";
 	echo "<th class=tdcenter colspan=2>Cable, Remote object and port</th><th class=tdcenter>(Un)link or (un)reserve</th><th>&nbsp;</th></tr>\n";
 	if (getConfigVar ('ADDNEW_AT_TOP') == 'yes')
 		printNewItemTR ($prefs);
@@ -1140,6 +1147,7 @@
 		// 18 is enough to fit 6-byte MAC address in its longest form,
 		// while 24 should be Ok for WWN
 		echo "<td><input type=text name=l2address value='${port['l2address']}' size=18 maxlength=24></td>\n";
+        echo "<td><input type=text name=vlan value='${port['vlan']}' size=5 maxlength=24></td>\n";
 		if ($port['remote_object_id'])
 		{
 			$remote_object = spotEntity ('object', $port['remote_object_id']);
racktablesportvlaninfo.patch (7,570 bytes)   
infrastation

infrastation

2011-08-23 15:02

administrator   ~0000399

I may be missing something, but you seem to implement the functionality, which is already implemented. This information is stored by means of 802.1Q feature.

user167

2011-08-23 19:18

  ~0000402

But how? I didn't see any field to enter the vlan id.
infrastation

infrastation

2011-08-24 15:23

administrator   ~0000406

The current implementation assumes, that VLAN configuration is pulled from live devices. After that it can be edited and pushed back. If this is not the case in your environment, I may consider a request for off-line management of 802.1Q data, it has been discussed before.

user263

2011-11-12 20:41

  ~0000476

Last edited: 2011-11-12 20:42

I would like to add to this isuse; we really do like Racktables, but as an administration tool only. Meaning that racktables doesn't have access to any device (our switches aren't supported anyways by racktables).

As such, it would be highly appreciated if there would be an option to just statically specify what port was assigned to what vlan etc.

infrastation

infrastation

2011-11-16 12:51

administrator   ~0000480

Dennis, could you develop another patch? The code to change port VLAN information already exist, you would need to implement a form, which would create such records. You would need to use function add8021QPort(), you can figure its input arguments out from the code.

From user's point of view it would look like an additional portlet on "802.1Q ports" tab, which would offer a multiple-choice SELECT filled with Ethernet-only ports of the current device. As a possible way to implement it, the ports would be put into VLAN1, access mode.
infrastation

infrastation

2012-04-16 10:01

administrator   ~0000647

I will work on this issue. A good implementation should allow both adding 802.1Q function to existing Ethernet ports and removing it. Also, this direct editing form should be available based on a RackCode trigger.
infrastation

infrastation

2012-09-17 10:10

administrator   ~0000797

ta-da!!!

Issue History

Date Modified Username Field Change
2011-08-23 08:23 user167 New Issue
2011-08-23 08:23 user167 Status new => assigned
2011-08-23 08:23 user167 Assigned To => infrastation
2011-08-23 08:23 user167 File Added: racktablesportvlaninfo.patch
2011-08-23 15:02 infrastation Note Added: 0000399
2011-08-23 19:18 user167 Note Added: 0000402
2011-08-24 15:23 infrastation Note Added: 0000406
2011-11-12 20:41 user263 Note Added: 0000476
2011-11-12 20:42 user263 Note Edited: 0000476
2011-11-16 12:51 infrastation Note Added: 0000480
2012-01-07 11:47 infrastation Assigned To infrastation =>
2012-01-07 11:47 infrastation Status assigned => acknowledged
2012-04-15 16:48 infrastation Status acknowledged => assigned
2012-04-15 16:48 infrastation Assigned To => infrastation
2012-04-16 10:01 infrastation Note Added: 0000647
2012-09-15 21:42 infrastation Target Version => 0.20.1
2012-09-17 10:10 infrastation Note Added: 0000797
2012-09-17 10:10 infrastation Status assigned => closed
2012-09-17 10:10 infrastation Resolution open => fixed
2012-09-17 10:10 infrastation Fixed in Version => 0.20.1
2012-12-27 09:49 infrastation Additional Information Updated