Closed alan-cugler closed 1 year ago
Kindly refer to the sample on how to get the tag from tag_id https://github.com/vmware/vsphere-automation-sdk-python/blob/master/samples/vsphere/tagging/tagging_workflow.py#L173 From tag association get the tag_id and pass it to the client.tagging.Tag.get(tag_id)
Here is a snippet which lists associations and tag names for each association
tag_model_ass = self.client.vcenter.tagging.Associations.list()
for association in tag_model_ass.associations:
tag_id = association.tag # tag_id
tag_obj = self.client.tagging.Tag.get(tag_id) # tag by tag_id
print(tag_obj.name)
Thanks Kunal
Is your feature request related to a problem? Please describe.
A vmware client is asking for their vCenter Tags associated to VMs to be imported to the grains system of Aria Automation Config (open-salt). This is a good fit for integration between the two pieces of technology. I attempted to achieve this by installing the vsphere-automation-sdk in the open-salt python environment. This did work and I was able to authenticate a session to vCenter!
However, I found I was able to extract the information of VM names and VM IDs, and I was able to get Tag URNs assigned to VM IDs. But there was no way to associate the Tag URNs to the human readable Tag names.
Demonstrated rest api solution
Describe the solution you'd like
I noticed in the REST api documentation there is a CIS api with tagging calls that have what is needed. As far as I could tell the python SDK doesnt have this wrapped. Can we add this please?
https://developer.vmware.com/apis/vsphere-automation/latest/cis/api/cis/tagging/tag/tag_id/get/
Describe alternatives you've considered
https://github.com/vmware/vsphere-automation-sdk-python/issues/360
Additional context