I'm trying to read/edit tags associated with a virtual machine by using the vsphere sdk (with pyvmomi cause I prefer python, our VSphere has version 5.1). The vm object has a field "tag" which should contain the tag - but in fact it contains the custom attribute, not the tag.
A simple code excerpt:
from pyVim.connect import SmartConnect, Disconnect
if hasattr(vm, 'childEntity'):
vmList = vm.childEntity
for c in vmList:
for k in vm.tag:
si = SmartConnect(host="<host>", user="<user>", pwd="<password>", port=<port>)
content = si.RetrieveContent()
datacenter = content.rootFolder.childEntity
vmFolder = datacenter.vmFolder
vmList = vmFolder.childEntity
for vm in vmList:
if __name__ == "__main__":
This code prints the custom attributes of the VMs (which is a bit surprising because of the naming of fields like vm.tag), but I'm looking for the tags and categories. Where can I find this information?
is this not working :vSphere 5.5 Documentation Center
As per API reference, tag property is experimental.
Any update on this?
The SDK / pyvmomi are now at version 6.0. The Release Notes for SDK 6.0 mention new APIs for Tag management. I can't find any information about them though.
The use case I'm trying to address is for VMs to be classified via custom Attributes and/or Tags. I'm using a PropertyCollector / WaitForUpdatesEx(), and for common property types (e.g. 'summary.config.name') this works fine. Need to be able to do the same sort of thing with custom attributes and/or Tags, but so far have been unable to find any means of doing this.