Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree visualizations do not include all target objects #181

Closed
jre3brg opened this issue Aug 28, 2020 · 2 comments
Closed

Tree visualizations do not include all target objects #181

jre3brg opened this issue Aug 28, 2020 · 2 comments
Assignees
Labels
Milestone

Comments

@jre3brg
Copy link

jre3brg commented Aug 28, 2020

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
@Thomas-Gelf Thomas-Gelf self-assigned this Sep 14, 2020
@Thomas-Gelf Thomas-Gelf added this to the v1.2.0 milestone Sep 14, 2020
@Thomas-Gelf
Copy link
Contributor

Thanks for reporting this and for explaining how to fix it. I'll push a fix with a slightly different query.

@kcahsalocin
Copy link

Hi,
I am struggeling this issue with the latest version.
In the riders "Virtual Machines", "Hosts" and "Datastores" everything is shown completely.
The problem is at the rider "Monitoring Rules". In here only those hosts, vm´s and datastores are displayed in the tree, which are not located i a folder at the vsphere.

As I see, the problem should be fixed now for almost 3 years.
Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants