fusioninventory / FusionInventory

Open and follow issues about the project (agent, plugin for GSIT, website and documentation)
0 stars 0 forks source link

Retrieve VM Tags #34

Open conchaji opened 2 years ago

conchaji commented 2 years ago

Hi, is there a way to retreive VM Tags when quering VMware remote hosts?

Or of not, it is possible to add this funcionality?

Thanks

ddurieux commented 2 years ago

hi, need check on the VMware API to see if available (I think yes...)

conchaji commented 2 years ago

Hi ddurieux,

Once again thank you so much for your help!.

Unfortunately I am still in the infernal task of getting the vcenter tags.

I have used Data :: Dumper and placed different prints in the Host.pm file and in VMware.pm but I do not see the tags and I have doubts if it really does not bring them or is that I am not placing them correctly in the files.

I have put them in: /usr/share/fusioninventory/lib/FusionInventory/Agent/SOAP/VMware/Host.pm

sub getHostFullInfo { my ($ self, $ id) = @_; print Dumper ($ self);

sub getVirtualMachineList { my ($ self) = @; print Dumper ($ self);

/usr/share/fusioninventory/lib/FusionInventory/Agent/SOAP/VMware.pm

sub getHardwareInfo { my ($ self) = @_; print Dumper ($ self);

sub getVirtualMachines { my ($ self) = @_; print Dumper ($ self);

But according to VMware, the tags are not stored in the VMs or in the Hosts but in the vcenter itself, and I don't know where I should place the print to see ALL the response from the vCenter? Can you guide me on this? Where in the code should the print go to see ALL the output, not just the host or vm?

https://kb.vmware.com/s/article/2130130

With vSphere 6.0, vSphere tags are no longer stored in the Inventory Service database table as the source of truth. They are relocated to the vCenter Server's database (VCDB) table CIS_KV_Keystore and the VMware Directory Services (Lotus) Service Provider tagging. After the tag association is created, this information is then pulled into the Inventory Service database for display within the vSphere Web Client.

In power cli I can get them with: Get-VM -Tag

I see some python plugins query the CIS CLASS: https://cis.readthedocs.io/en/1.2.0/api/cis.html Or for Java: package "com.vmware.cis.tagging" , which provide the Interfaces and classes to create, read, update, delete Category and Tag.

There must be some way to get the vCenter tasks with Fusioninventory then, right?

Anyway, sorry for the bother and I hope someone can help me with some hints about this and if not, thank you so much anyway!

Thank you a lot.

conchaji commented 2 years ago

I think maybe the key is to add another sub in VMware.pm with the obj type="ManagedEntity"...

https://developer.vmware.com/apis/197/vsphere/doc/vim.ManagedEntity.html -> The set of tags associated with this managed entity

But not really sure.