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
def tags(vm):
if hasattr(vm, 'childEntity'):
vmList = vm.childEntity
for c in vmList:
tags(c)
else:
print vm.name
for k in vm.tag:
print k
def main():
si = SmartConnect(host="<host>", user="<user>", pwd="<password>", port=<port>)
content = si.RetrieveContent()
datacenter = content.rootFolder.childEntity[0]
vmFolder = datacenter.vmFolder
vmList = vmFolder.childEntity
for vm in vmList:
tags(vm)
if __name__ == "__main__":
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?
Mathias
Did you ever find a resolution for this?
I'm looking for the same.
Thanks
is this not working :vSphere 5.5 Documentation Center
vSphere 5.5 Documentation Center
As per API reference, tag property is experimental.
Well, it should be possible with PowerCLI if you upgrade to 5.5, there are cmdlets Set-Tag, Get-Tag
And here is nice article about using them: Using vSphere tags powercli
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.
Ya this is pretty frustrating, I'm using yavijava 6 and have the same issue.
Did anyone found a soultion yet?
i am having the same issue.