From 877ce12970b67f05202620e01be503b284e28572 Mon Sep 17 00:00:00 2001 From: Wilmar den Ouden Date: Wed, 10 Apr 2019 16:28:25 +0200 Subject: [PATCH] VMware: Rename results key to ansible_module_results (#55038) * Rename results key to ansible_module_results * Update to a better variable name * Update example and adds change to porting guide --- .../55038-rename-results-key-vmware-guest.yml | 2 ++ .../rst/porting_guides/porting_guide_2.8.rst | 3 ++ .../cloud/vmware/vmware_guest_snapshot.py | 32 ++++++++++++++++--- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/55038-rename-results-key-vmware-guest.yml diff --git a/changelogs/fragments/55038-rename-results-key-vmware-guest.yml b/changelogs/fragments/55038-rename-results-key-vmware-guest.yml new file mode 100644 index 00000000000..2387cc183a9 --- /dev/null +++ b/changelogs/fragments/55038-rename-results-key-vmware-guest.yml @@ -0,0 +1,2 @@ +bugfixes: + - The internal key `results` in vmware_guest_snapshot module return renamed to `snapshot_results`. diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.8.rst b/docs/docsite/rst/porting_guides/porting_guide_2.8.rst index 64307a08f63..475f70fb98b 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_2.8.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_2.8.rst @@ -304,6 +304,9 @@ Noteworthy module changes * ``vmware_vm_facts`` used to return dict of dict with virtual machine's facts. Ansible 2.8 and onwards will return list of dict with virtual machine's facts. Please see module ``vmware_vm_facts`` documentation for example. +* ``vmware_guest_snapshot`` module used to return ``results``. Since Ansible 2.8 and onwards ``results`` is a reserved keyword, it is replaced by ``snapshot_results``. + Please see module ``vmware_guest_snapshots`` documentation for example. + * The ``panos`` modules have been deprecated in favor of using the Palo Alto Networks `Ansible Galaxy role `_. Contributions to the role can be made `here `_. diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py b/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py index 320b8b62f24..f1ab82e1e6f 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py @@ -218,11 +218,35 @@ EXAMPLES = ''' ''' RETURN = """ -instance: - description: metadata about the new virtual machine snapshot +snapshot_results: + description: metadata about the virtual machine snapshots returned: always type: dict - sample: None + sample: { + "current_snapshot": { + "creation_time": "2019-04-09T14:40:26.617427+00:00", + "description": "Snapshot 4 example", + "id": 4, + "name": "snapshot4", + "state": "poweredOff" + }, + "snapshots": [ + { + "creation_time": "2019-04-09T14:38:24.667543+00:00", + "description": "Snapshot 3 example", + "id": 3, + "name": "snapshot3", + "state": "poweredOff" + }, + { + "creation_time": "2019-04-09T14:40:26.617427+00:00", + "description": "Snapshot 4 example", + "id": 4, + "name": "snapshot4", + "state": "poweredOff" + } + ] + } """ import time @@ -361,7 +385,7 @@ class PyVmomiHelper(PyVmomi): if task.info.state == 'error': result = {'changed': False, 'failed': True, 'msg': task.info.error.msg} else: - result = {'changed': True, 'failed': False, 'results': list_snapshots(vm)} + result = {'changed': True, 'failed': False, 'snapshot_results': list_snapshots(vm)} return result