vmware/pyvmomi-community-samples

Is there a MO for Host and Host PG similar to DV-PG?

Open

#652 aperta il 10 ago 2020

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Python (914 fork)batch import
help wanted

Metriche repository

Star
 (972 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Hello, I wanted to get the attributes of the Distributed -PG (DPG) and a regular Host PG. For a DPG, i cache the Managed Object (MO) of the top-level Distributed Switch and each of its (DPG). Something like this:

    container = self.si_obj.content.viewManager.CreateContainerView(
        si_obj.content.rootFolder, [vim.DistributedVirtualSwitch],
        True)
    for dvs_obj in container.view: **// Gives the DVS object**
        dvs_pgs = dvs_obj.portgroup 
        for dvpg in dvs_pgs: **// Each dvps refers to the DV-PG’s objects in the DVS**
            pg_dict.update({dvpg.name: dvpg})

I am using the cached objects above to get the attributes like VLAN, vnic and other network attributes. Even, when the network attributes are updated in vSphere, i am able to get the latest values when i re-read the object’s attributes.

But, for host PG, i don’t see a similar MO. When, i do something like below:

    container = self.si_obj.content.viewManager.CreateContainerView(
        self.si_obj.content.rootFolder, [vim.HostSystem],
        True)
    for host_obj in container.view:
        host_pgs = host_obj.config.network.portgroup
        for hostpg in host_pgs: **// host PG is not a MO**
            pg_dict.update({hostpg.spec.name: hostpg})

‘hostpg’ above seems to be a big structure, which will not get updated dynamically when any of the PG parameters in a host changes. Accessing each attribute seems to be really slow. Is there a MO for a host PG as well similar to DV-PG? Am i missing something?

Thanks, KP

Guida contributor