View Issue Details

IDProjectCategoryView StatusLast Update
1827RackTablesdefaultpublic2019-02-24 09:39
Reportertwielgos Assigned To 
PrioritynoneSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Summary1827: Feature request: Label generation from cable maps
DescriptionA feature I would like to see would be to output a CSV from cable maps so that they can be imported into popular label printer software from Panduit, Brother, Dymo, whoever.

An example would be a 4 column CSV with source hostname, local port, remote port, destination hostname

Doing this would allow me to rack and map cables in Racktables prior to physical installation of hardware. It would expand Racktables use as an architectural tool - not simply a documentation tool.
TagsNo tags attached.
Attached Files




2018-09-06 15:50

reporter   ~0003811

I have created a plugin that could respond to your needs.
Since I am working with version 0.21.1 which has a different plugin management, I have back-ported my plugin to be compatible with version 0.20.14, the current stable release (at the moment I no longer have a 0.20.14 environment for a complete test ... hope it works!)
Once installed (i.e. put the attached file in the 'plugins' directory of your installation, and set attributes and ownership as required), you should find a 'Cable labels' tab when displaying object information.
Feel free to use or modify it as needed.
cableMapLabelGeneration.php (1,871 bytes)   

global $tab, $ajaxhandler;
$tab['object']['csvmap'] = 'Cable labels';
registerTabHandler('object', 'csvmap', 'renderCSVmap');
$ajaxhandler['cablemap-report'] = 'cableMapAJAX';

function renderCSVmap ($object_id)
	// see renderPortsForObject() in interface.php
	$object = spotEntity ('object', $object_id);
	amplifyCell ($object);
	echo "<table class='widetable zebra' border=0 cellspacing=0 cellpadding=5 align='center'><tr><th>Source hostname</th><th>Local port</th><th>Remote port</th><th>Remote hostname</th></tr>";
	$lines = 0;
	foreach ($object['ports'] as $port)
		if ($port['remote_object_id'])
			echo "<tr><td>${object['name']}</td><td>${port['name']}</td><td>${port['remote_name']}</td><td>${port['remote_object_name']}</td></tr>";
	echo "</table>";
	echo "<p>";
	if ($lines > 0)
		echo "<form method=\"POST\" action=\"index.php?module=ajax&ac=cablemap-report&objid=${object_id}\" accept-charset=\"UTF-8\">";
		echo "<input type=\"submit\" name=\"csvmap\" value=\" Export CSV \" />";
		echo "</form><p>";
		echo "No data available";

function cableMapAJAX()
	$objid = 0;    
	if (isset($_REQUEST['objid']))
		$objid = $_REQUEST['objid'];
	$object = spotEntity ('object', $objid);
	amplifyCell ($object);
	echo 'Source hostname,Local port,Remote port,Remote hostname'."\n";
	foreach ($object['ports'] as $port)
		if ($port['remote_object_id'])
			echo $object['name'].','.$port['name'].','.$port['remote_name'].','.$port['remote_object_name']."\n";
	$csv = ob_get_clean();

	// write file (and size) to the browser
	header('Content-Type: text/csv; charset=utf-8');
	header(sprintf("Content-Disposition: attachment;filename=\"cablelabels-${object['name']}.csv\""));
	header('Cache-Control: max-age=0');
	header('Content-Length: '.strlen($csv));
	echo $csv;

cableMapLabelGeneration.php (1,871 bytes)   


2018-09-07 11:23

administrator   ~0003813

If you would like to commit this to the racktables-contribs repository, tell your GitHub username and you will have access.

Issue History

Date Modified Username Field Change
2018-06-21 17:37 twielgos New Issue
2018-09-06 15:50 albertoa File Added: cableMapLabelGeneration.php
2018-09-06 15:50 albertoa Note Added: 0003811
2018-09-07 11:23 infrastation Note Added: 0003813