Skip to content

Commit

Permalink
renderVirtualResourcesSummary: add resource pool info to the cluster …
Browse files Browse the repository at this point in the history
…portlet (#915)
  • Loading branch information
adoom42 committed Oct 5, 2013
1 parent 04b469f commit 9911aaa
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 26 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
update: port link popup now has asset no search field (#949) by Thomas Uhde
update: searches now examine 'dictionary' attributes (#1003)
update: exclude some elements when printing to paper (#464)
update: add resource pool info to the Virtual Resources cluster portlet (#915)
new feature: port tracing (#333)
new feature: bulk selection and deslection of object rackspace checkboxes by Matthew Kelch
0.20.5 2013-06-23
Expand Down
71 changes: 47 additions & 24 deletions wwwroot/inc/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -1177,32 +1177,55 @@ function commitUnlinkEntitiesByLinkID ($link_id)
usePreparedDeleteBlade ('EntityLink', array ('id' => $link_id));
}

// The following functions return stats about VM-related info.
// TODO: simplify the queries
// return VM clusters and corresponding stats
// - number of hypervisors
// - number of resource pools
// - number of VMs whose parent is the cluster itself
// - number of VMs whose parent is one of the resource pools in the cluster
function getVMClusterSummary ()
{
$result = usePreparedSelectBlade
(
"SELECT O.id, O.name, " .
"(SELECT COUNT(*) FROM EntityLink EL " .
"LEFT JOIN Object O_H ON EL.child_entity_id = O_H.id " .
"LEFT JOIN AttributeValue AV ON O_H.id = AV.object_id " .
"WHERE EL.parent_entity_type = 'object' " .
"AND EL.child_entity_type = 'object' " .
"AND EL.parent_entity_id = O.id " .
"AND O_H.objtype_id = 4 " .
"AND AV.attr_id = 26 " .
"AND AV.uint_value = 1501) AS hypervisors, " .
"(SELECT COUNT(*) FROM EntityLink EL " .
"LEFT JOIN Object O_VM ON EL.child_entity_id = O_VM.id " .
"WHERE EL.parent_entity_type = 'object' " .
"AND EL.child_entity_type = 'object' " .
"AND EL.parent_entity_id = O.id " .
"AND O_VM.objtype_id = 1504) AS VMs " .
"FROM Object O " .
"WHERE O.objtype_id = 1505 " .
"ORDER BY O.name"
);
$query = <<<END
SELECT
O.id,
O.name,
(SELECT COUNT(*) FROM EntityLink EL
LEFT JOIN Object O_H ON EL.child_entity_id = O_H.id
LEFT JOIN AttributeValue AV ON O_H.id = AV.object_id
WHERE EL.parent_entity_type = 'object'
AND EL.child_entity_type = 'object'
AND EL.parent_entity_id = O.id
AND O_H.objtype_id = 4
AND AV.attr_id = 26
AND AV.uint_value = 1501) AS hypervisors,
(SELECT COUNT(*) FROM EntityLink EL
LEFT JOIN Object O_RP ON EL.child_entity_id = O_RP.id
WHERE EL.parent_entity_type = 'object'
AND EL.child_entity_type = 'object'
AND EL.parent_entity_id = O.id
AND O_RP.objtype_id = 1506) AS resource_pools,
(SELECT COUNT(*) FROM EntityLink EL
LEFT JOIN Object O_C_VM ON EL.child_entity_id = O_C_VM.id
WHERE EL.parent_entity_type = 'object'
AND EL.child_entity_type = 'object'
AND EL.parent_entity_id = O.id
AND O_C_VM.objtype_id = 1504) AS cluster_vms,
(SELECT COUNT(*) FROM EntityLink EL
LEFT JOIN Object O_RP_VM ON EL.child_entity_id = O_RP_VM.id
WHERE EL.parent_entity_type = 'object'
AND EL.child_entity_type = 'object'
AND EL.parent_entity_id IN
(SELECT child_entity_id FROM EntityLink EL
LEFT JOIN Object O_RP ON EL.child_entity_id = O_RP.id
WHERE EL.parent_entity_type = 'object'
AND EL.child_entity_type = 'object'
AND EL.parent_entity_id = O.id
AND O_RP.objtype_id = 1506)
AND O_RP_VM.objtype_id = 1504) AS resource_pool_vms
FROM Object O
WHERE O.objtype_id = 1505
ORDER BY O.name
END;
$result = usePreparedSelectBlade ($query);
return $result->fetchAll (PDO::FETCH_ASSOC);
}

Expand Down
8 changes: 6 additions & 2 deletions wwwroot/inc/interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8437,14 +8437,18 @@ function renderVirtualResourcesSummary ()
if (count($clusters) > 0)
{
echo "<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>\n";
echo "<tr><th>Cluster</th><th>Hypervisors</th><th>VMs</th></tr>\n";
echo "<tr><th>Cluster</th><th>Hypervisors</th><th>Resource Pools</th><th>Cluster VMs</th><th>RP VMs</th><th>Total VMs</th></tr>\n";
$order = 'odd';
foreach ($clusters as $cluster)
{
$total_vms = $cluster['cluster_vms'] + $cluster['resource_pool_vms'];
echo "<tr class=row_${order} valign=top>";
echo '<td class="tdleft">' . mkA ("<strong>${cluster['name']}</strong>", 'object', $cluster['id']) . '</td>';
echo "<td class='tdleft'>${cluster['hypervisors']}</td>";
echo "<td class='tdleft'>${cluster['VMs']}</td>";
echo "<td class='tdleft'>${cluster['resource_pools']}</td>";
echo "<td class='tdleft'>${cluster['cluster_vms']}</td>";
echo "<td class='tdleft'>${cluster['resource_pool_vms']}</td>";
echo "<td class='tdleft'>$total_vms</td>";
echo "</tr>\n";
$order = $nextorder[$order];
}
Expand Down

0 comments on commit 9911aaa

Please sign in to comment.