Skip to content

Commit

Permalink
VMware: Change return key results from VMware modules (#62161)
Browse files Browse the repository at this point in the history
Following module used internal results key as part of return json, this commit
changes this to appropriate values -
* vmware_datastore_maintenancemode.py
* vmware_host_kernel_manager.py
* vmware_host_ntp.py
* vmware_host_service_manager.py
* vmware_tag.py

Fixes: #62083

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
  • Loading branch information
Akasurde committed Sep 13, 2019
1 parent 041c52d commit 1c3effe
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
6 changes: 6 additions & 0 deletions changelogs/fragments/62083-vmware-internal_results.yml
@@ -0,0 +1,6 @@
minor_changes:
- vmware_datastore_maintenancemode now returns datastore_status instead of Ansible internal key results (https://github.com/ansible/ansible/issues/62083).
- vmware_host_kernel_manager now returns host_kernel_status instead of Ansible internal key results (https://github.com/ansible/ansible/issues/62083).
- vmware_host_ntp now returns host_ntp_status instead of Ansible internal key results (https://github.com/ansible/ansible/issues/62083).
- vmware_host_service_manager now returns host_service_status instead of Ansible internal key results (https://github.com/ansible/ansible/issues/62083).
- vmware_tag now returns tag_status instead of Ansible internal key results (https://github.com/ansible/ansible/issues/62083).
6 changes: 5 additions & 1 deletion docs/docsite/rst/porting_guides/porting_guide_2.10.rst
Expand Up @@ -57,7 +57,11 @@ No notable changes
Noteworthy module changes
-------------------------

No notable changes
* :ref:`vmware_datastore_maintenancemode <vmware_datastore_maintenancemode_module>` now returns ``datastore_status`` instead of Ansible internal key ``results``.
* :ref:`vmware_host_kernel_manager <vmware_host_kernel_manager_module>` now returns ``host_kernel_status`` instead of Ansible internal key ``results``.
* :ref:`vmware_host_ntp <vmware_host_ntp_module>` now returns ``host_ntp_status`` instead of Ansible internal key ``results``.
* :ref:`vmware_host_service_manager <vmware_host_service_manager_module>` now returns ``host_service_status`` instead of Ansible internal key ``results``.
* :ref:`vmware_tag <vmware_tag_module>` now returns ``tag_status`` instead of Ansible internal key ``results``.


Plugins
Expand Down
Expand Up @@ -98,11 +98,13 @@
'''

RETURN = '''
results:
datastore_status:
description: Action taken for datastore
returned: always
type: dict
sample:
sample: {
"ds_226_01": "Datastore 'ds_226_01' is already in maintenance mode."
}
'''

try:
Expand Down Expand Up @@ -189,7 +191,7 @@ def ensure(self):
changed = False
if any(change_datastore_list):
changed = True
self.module.exit_json(changed=changed, results=datastore_results)
self.module.exit_json(changed=changed, datastore_status=datastore_results)


def main():
Expand Down
Expand Up @@ -77,7 +77,7 @@
'''

RETURN = r'''
results:
host_kernel_status:
description:
- dict with information on what was changed, by ESXi host in scope.
returned: success
Expand Down Expand Up @@ -183,7 +183,7 @@ def check_host_configuration_state(self):
self.results[host.name]['changed'] = changed
self.results[host.name]['msg'] = msg

self.module.exit_json(changed=any(change_list), results=self.results)
self.module.exit_json(changed=any(change_list), host_kernel_status=self.results)


def main():
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/modules/cloud/vmware/vmware_host_ntp.py
Expand Up @@ -115,7 +115,7 @@
'''

RETURN = r'''
results:
host_ntp_status:
description: metadata about host system's NTP configuration
returned: always
type: dict
Expand Down Expand Up @@ -256,7 +256,7 @@ def check_host_state(self):

if any(change_list):
changed = True
self.module.exit_json(changed=changed, results=self.results)
self.module.exit_json(changed=changed, host_ntp_status=self.results)

def check_ntp_servers(self, host):
"""Check configured NTP servers"""
Expand Down
Expand Up @@ -182,7 +182,7 @@ def service_ctrl(self):

if any(host_service_state):
changed = True
self.module.exit_json(changed=changed, results=self.results)
self.module.exit_json(changed=changed, host_service_status=self.results)

def check_service_state(self, host, service_name):
host_service_system = host.configManager.serviceSystem
Expand Down
12 changes: 5 additions & 7 deletions lib/ansible/modules/cloud/vmware/vmware_tag.py
Expand Up @@ -99,7 +99,7 @@
'''

RETURN = r'''
results:
tag_status:
description: dictionary of tag metadata
returned: on success
type: dict
Expand Down Expand Up @@ -176,10 +176,9 @@ def state_create_tag(self):

if tag_id:
self.module.exit_json(changed=True,
results=dict(msg="Tag '%s' created." % tag_spec.name,
tag_id=tag_id))
tag_status=dict(msg="Tag '%s' created." % tag_spec.name, tag_id=tag_id))
self.module.exit_json(changed=False,
results=dict(msg="No tag created", tag_id=tag_id))
tag_status=dict(msg="No tag created", tag_id=tag_id))

def state_unchanged(self):
"""
Expand Down Expand Up @@ -210,7 +209,7 @@ def state_update_tag(self):
results['msg'] = 'Tag %s updated.' % self.tag_name
changed = True

self.module.exit_json(changed=changed, results=results)
self.module.exit_json(changed=changed, tag_status=results)

def state_delete_tag(self):
"""
Expand All @@ -223,8 +222,7 @@ def state_delete_tag(self):
except Error as error:
self.module.fail_json(msg="%s" % self.get_error_message(error))
self.module.exit_json(changed=True,
results=dict(msg="Tag '%s' deleted." % self.tag_name,
tag_id=tag_id))
tag_status=dict(msg="Tag '%s' deleted." % self.tag_name, tag_id=tag_id))

def check_tag_status(self):
"""
Expand Down

0 comments on commit 1c3effe

Please sign in to comment.