Skip to content

Tree visualizations do not include all target objects #181

@jre3brg

Description

@jre3brg

Expected Behavior

Tree visualizations must include all target objects even they are at different levels

Current Behavior

The tree visualizations skip target objects if their level is greater than 2

Possible Solution

Instead of skip target object based on the level, skip object only if his parent is a Datacenter object type.

Possible implementation
library/Vspheredb/Web/OverviewTree.php

protected function getTree()
{
    $tree = [];
    $all = [];
    foreach ($this->fetchTree() as $item) {
        if ($this->typeFilter
            && (string) $item->parent_object_type === 'Datacenter'
            && $item->object_name !== $this->typeFilter) {
            continue;
        }
        $item->children = [];
        $all[$item->uuid] = $item;
        if ($item->parent_uuid === null) {
            $tree[$item->uuid] = $item;
        } else {
            $all[$item->parent_uuid]->children[$item->uuid] = $item;
        }
    }

    return $tree;
}
protected function fetchTree()
{
    $hostCnt = "SELECT COUNT(*) as cnt, parent_uuid"
        . " FROM object WHERE object_type = 'HostSystem'"
        . " GROUP BY parent_uuid";
    $vmCnt = "SELECT COUNT(*) as cnt, parent_uuid"
        . " FROM object WHERE object_type = 'VirtualMachine'"
        . " GROUP BY parent_uuid";
    $dsCnt = "SELECT COUNT(*) as cnt, parent_uuid"
        . " FROM object WHERE object_type = 'Datastore'"
        . " GROUP BY parent_uuid";
    $networkCnt = "SELECT COUNT(*) as cnt, parent_uuid"
        . " FROM object WHERE object_type = 'DistributedVirtualSwitch'"
        . " GROUP BY parent_uuid";
    $main = "SELECT * FROM object"
        . " WHERE object_type NOT IN ('VirtualMachine', 'HostSystem', 'Datastore')";

    $sql = "SELECT f.*, hc.cnt AS cnt_host, vc.cnt AS cnt_vm, dc.cnt AS cnt_ds, nc.cnt AS cnt_network,"
         . " (SELECT object_type FROM object where uuid = f.parent_uuid) as parent_object_type"
         . " FROM ($main) f"
         . " LEFT JOIN ($vmCnt) vc ON vc.parent_uuid = f.uuid"
         . " LEFT JOIN ($hostCnt) hc ON hc.parent_uuid = f.uuid"
         . " LEFT JOIN ($dsCnt) dc ON dc.parent_uuid = f.uuid"
         . " LEFT JOIN ($networkCnt) nc ON dc.parent_uuid = f.uuid"
         . " ORDER BY f.level ASC, f.object_name";

    return $this->db->getDbAdapter()->fetchAll($sql);
}

Steps to Reproduce (for bugs)

If vShpere path of the Host is for example (3 folders above Datacenter object)
Path > World > EMEA > Madrid > host > Cluster01

Your Environment

  • VMware vCenter®/ESXi™-Version: API Version | 6.7.3
  • Version/GIT-Hash of this module: 1.1.0
  • Icinga Web 2 version: 2.7.3
  • Operating System and version: RHEL7.8
  • Webserver, PHP versions: Apache/2.4.6, PHP 7.1.30

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions