Skip to content

Commit

Permalink
vmware_guest_info: Fix get tags API call (#406)
Browse files Browse the repository at this point in the history
vmware_guest_info: Fix get tags API call

Reviewed-by: https://github.com/apps/ansible-zuul
  • Loading branch information
Akasurde authored Sep 29, 2020
1 parent 34ef77f commit a92ccb0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/403_fix_vmware_guest_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- vmware_guest_info - Fix get tags API call (https://github.com/ansible-collections/community.vmware/issues/403).
3 changes: 2 additions & 1 deletion plugins/modules/vmware_guest_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,11 @@ def main():
" - https://code.vmware.com/web/sdk/60/vcloudsuite-python")

vm_rest_client = VmwareTag(module)
dynamic_obj = DynamicID(type='VirtualMachine', id=vm._moId)
instance.update(
tags=vm_rest_client.get_vm_tags(vm_rest_client.tag_service,
vm_rest_client.tag_association_svc,
vm_mid=vm._moId)
vm_mid=dynamic_obj)
)
module.exit_json(instance=instance)
except Exception as exc:
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@
that:
- tag_manager_ops.changed

- name: Get tags from a virtual machine
vmware_guest_info:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
name: "{{ vm_name }}"
register: r

- name: Check if tag information is available
assert:
that:
- not r.changed
- r['instance']['tags'] is defined
- "{{ Tag_Name[0] in r['instance']['tags'] }}"

- <<: *tag_assign
name: Add tags to a virtual machine again

Expand Down

0 comments on commit a92ccb0

Please sign in to comment.