View Issue Details

IDProjectCategoryView StatusLast Update
432RackTablesVMs/containerspublic2013-05-04 20:55
Reporteruser225Assigned Toadoom42  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.19.10 
Target Version0.19.11Fixed in Version0.19.11 
Summary432: Objects placed in container are displayed without rack allocation information
DescriptionWhen trying to add a blade chassis and blade servers to my racktables installation I stumbled across the following.

I added a container (Object type Server Chassis) and a couple of objects (Object type Server) to that container. The objects that are allocated to the container all show up as unmounted in the Objects overview page and when clicking on such an object their rackspace allocation show up as empty.

IMHO, the "correct" behavior would be to :

a) Show them as mounted in the same physical location as their container in the Objects overview page.

b) Show each objects rackspace allocation to be the same as the physical location of the container on the object details page.
 
TagsNo tags attached.

Relationships

has duplicate 535 closedadoom42 When creating a VM Object and connecting to a container, the listing in Object page -shows unmounted, which is incorrect. 
related to 825 closedadoom42 Objects placed in container are displayed without rack allocation information 

Activities

2011-12-06 15:18

 

RT-containerRackspace.diff (2,526 bytes)   
--- database.php.orig	2011-12-06 16:10:14.778269389 +0100
+++ database.php	2011-12-06 16:10:39.476389681 +0100
@@ -17,7 +17,10 @@
 			'label' => 'label',
 			'asset_no' => 'asset_no',
 			'objtype_id' => 'objtype_id',
-			'rack_id' => '(select rack_id from RackSpace where object_id = id order by rack_id asc limit 1)',
+		//	'rack_id' => '(select rack_id from RackSpace where object_id = id order by rack_id asc limit 1)',
+			'rack_id' => '(select rack_id from RackSpace 
+					left join EntityLink on RackSpace.object_id = EntityLink.parent_entity_id
+					 where RackSpace.object_id = RackObject.id or EntityLink.child_entity_id = RackObject.id order by rack_id asc limit 1)',
 			'Rack_name' => '(select name from Rack where id = rack_id)',
 			'row_id' => '(select row_id from Rack where id = rack_id)',
 			'Row_name' => '(select name from RackRow where id = row_id)',
@@ -1050,7 +1053,10 @@
 
 function getResidentRacksData ($object_id = 0, $fetch_rackdata = TRUE)
 {
-	$result = usePreparedSelectBlade ('SELECT DISTINCT rack_id FROM RackSpace WHERE object_id = ? ORDER BY rack_id', array ($object_id));
+	//$result = usePreparedSelectBlade ('SELECT DISTINCT rack_id FROM RackSpace WHERE object_id = ? ORDER BY rack_id', array ($object_id));
+	$result = usePreparedSelectBlade ('SELECT DISTINCT rack_id FROM RackSpace 
+						JOIN EntityLink on RackSpace.object_id = EntityLink.parent_entity_id
+						WHERE object_id = ? or EntityLink.child_entity_id = ? ORDER BY rack_id', array ($object_id, $object_id));
 	$rows = $result->fetchAll (PDO::FETCH_NUM);
 	unset ($result);
 	$ret = array();
--- functions.php.orig	2011-12-06 16:10:23.275243445 +0100
+++ functions.php	2011-12-06 16:10:44.173679141 +0100
@@ -602,12 +602,24 @@
 // This function highlights specified object (and removes previous highlight).
 function highlightObject (&$rackData, $object_id)
 {
+
+	/* highlight also parent Objects */
+	$parents = getEntityRelatives ('parents', 'object', $object_id);
+	
+	$parent_ids[] = array();
+
+	foreach ($parents as $parent) {
+		$parent_ids[] = $parent['entity_id'];
+	}
+
 	for ($unit_no = $rackData['height']; $unit_no > 0; $unit_no--)
 		for ($locidx = 0; $locidx < 3; $locidx++)
 			if
 			(
 				$rackData[$unit_no][$locidx]['state'] == 'T' and
-				$rackData[$unit_no][$locidx]['object_id'] == $object_id
+				($rackData[$unit_no][$locidx]['object_id'] == $object_id or
+				in_array($rackData[$unit_no][$locidx]['object_id'],$parent_ids) )
+
 			)
 				$rackData[$unit_no][$locidx]['hl'] = 'h';
 			else
RT-containerRackspace.diff (2,526 bytes)   
racktabler

racktabler

2011-12-06 15:20

reporter   ~0000486

Last edited: 2011-12-06 15:25

RT-containerRackspace.diff is how i display physical location in the Objects overview page and the object details page.

Changes database.php and functions.php.

I don't know if it breaks something, till now it works quite well.

Patch is against 0.19.10

2011-12-07 08:13

 

RT-containerRackspace_corrected.diff (2,531 bytes)   
--- database.php.orig	2011-12-06 16:10:14.778269389 +0100
+++ database.php	2011-12-06 16:10:39.476389681 +0100
@@ -17,7 +17,10 @@
 			'label' => 'label',
 			'asset_no' => 'asset_no',
 			'objtype_id' => 'objtype_id',
-			'rack_id' => '(select rack_id from RackSpace where object_id = id order by rack_id asc limit 1)',
+		//	'rack_id' => '(select rack_id from RackSpace where object_id = id order by rack_id asc limit 1)',
+			'rack_id' => '(select rack_id from RackSpace 
+					left join EntityLink on RackSpace.object_id = EntityLink.parent_entity_id
+					 where RackSpace.object_id = RackObject.id or EntityLink.child_entity_id = RackObject.id order by rack_id asc limit 1)',
 			'Rack_name' => '(select name from Rack where id = rack_id)',
 			'row_id' => '(select row_id from Rack where id = rack_id)',
 			'Row_name' => '(select name from RackRow where id = row_id)',
@@ -1050,7 +1053,10 @@
 
 function getResidentRacksData ($object_id = 0, $fetch_rackdata = TRUE)
 {
-	$result = usePreparedSelectBlade ('SELECT DISTINCT rack_id FROM RackSpace WHERE object_id = ? ORDER BY rack_id', array ($object_id));
+	//$result = usePreparedSelectBlade ('SELECT DISTINCT rack_id FROM RackSpace WHERE object_id = ? ORDER BY rack_id', array ($object_id));
+	$result = usePreparedSelectBlade ('SELECT DISTINCT rack_id FROM RackSpace 
+						left JOIN EntityLink on RackSpace.object_id = EntityLink.parent_entity_id
+						WHERE object_id = ? or EntityLink.child_entity_id = ? ORDER BY rack_id', array ($object_id, $object_id));
 	$rows = $result->fetchAll (PDO::FETCH_NUM);
 	unset ($result);
 	$ret = array();
--- functions.php.orig	2011-12-06 16:10:23.275243445 +0100
+++ functions.php	2011-12-06 16:10:44.173679141 +0100
@@ -602,12 +602,24 @@
 // This function highlights specified object (and removes previous highlight).
 function highlightObject (&$rackData, $object_id)
 {
+
+	/* highlight also parent Objects */
+	$parents = getEntityRelatives ('parents', 'object', $object_id);
+	
+	$parent_ids[] = array();
+
+	foreach ($parents as $parent) {
+		$parent_ids[] = $parent['entity_id'];
+	}
+
 	for ($unit_no = $rackData['height']; $unit_no > 0; $unit_no--)
 		for ($locidx = 0; $locidx < 3; $locidx++)
 			if
 			(
 				$rackData[$unit_no][$locidx]['state'] == 'T' and
-				$rackData[$unit_no][$locidx]['object_id'] == $object_id
+				($rackData[$unit_no][$locidx]['object_id'] == $object_id or
+				in_array($rackData[$unit_no][$locidx]['object_id'],$parent_ids) )
+
 			)
 				$rackData[$unit_no][$locidx]['hl'] = 'h';
 			else
racktabler

racktabler

2011-12-07 08:15

reporter   ~0000487

RT-containerRackspace_corrected.diff with missing "left join" in getResidentRacksData

Again against 0.19.10
adoom42

adoom42

2011-12-31 01:14

administrator   ~0000492

Thanks for the patch. It will be included in 0.19.11.

Issue History

Date Modified Username Field Change
2011-06-06 06:19 user225 New Issue
2011-06-06 06:19 user225 Status new => assigned
2011-06-06 06:19 user225 Assigned To => adoom42
2011-12-06 15:18 racktabler File Added: RT-containerRackspace.diff
2011-12-06 15:20 racktabler Note Added: 0000486
2011-12-06 15:25 racktabler Note Edited: 0000486
2011-12-07 08:13 racktabler File Added: RT-containerRackspace_corrected.diff
2011-12-07 08:15 racktabler Note Added: 0000487
2011-12-31 01:14 adoom42 Note Added: 0000492
2011-12-31 01:14 adoom42 Status assigned => closed
2011-12-31 01:14 adoom42 Resolution open => fixed
2011-12-31 01:14 adoom42 Product Version 0.19.4 => 0.19.10
2011-12-31 01:14 adoom42 Fixed in Version => 0.19.11
2011-12-31 01:14 adoom42 Target Version => 0.19.11
2012-03-01 15:45 adoom42 Relationship added has duplicate 535
2013-05-04 20:55 adoom42 Relationship added related to 825