Skip to content

Commit

Permalink
CloudStack modules: rename _facts -> _info (ansible#61090)
Browse files Browse the repository at this point in the history
* Rename cloudstack _facts -> _info

* Add changelog.

* Fix errors due to overloaded get_result having different parameter names.

* Fix examples.

* Change debug tasks.

* Remove unneeded code.

* Change from rename -> deprecate+new module.

* Make cs_zone_info return a list.

* Make cs_instance_info return a list.

* Fix return value docs.

* Fix typo.

* Improve tests.

* Fix cs_zone_info.

* Linting.

* Fix alias/option switch.

* Fix version numbers.

* Extend docs.
  • Loading branch information
felixfontein authored and adharshsrivatsr committed Sep 3, 2019
1 parent b431932 commit 3426492
Show file tree
Hide file tree
Showing 20 changed files with 796 additions and 182 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/61090-cloudstack-facts-info.yaml
@@ -0,0 +1,3 @@
minor_changes:
- The ``cs_instance_facts`` module has been deprecated. Use ``cs_instance_info`` instead.
- The ``cs_zone_facts`` module has been deprecated. Use ``cs_zone_info`` instead.
4 changes: 4 additions & 0 deletions docs/docsite/rst/porting_guides/porting_guide_2.9.rst
Expand Up @@ -117,6 +117,10 @@ Deprecation notices

The following modules will be removed in Ansible 2.13. Please update update your playbooks accordingly.

* cs_instance_facts use :ref:`cs_instance_info <cs_instance_info_module>` instead.

* cs_zone_facts use :ref:`cs_zone_info <cs_zone_info_module>` instead.

* digital_ocean_sshkey_facts use :ref:`digital_ocean_sshkey_info <digital_ocean_sshkey_info_module>` instead.

* junos_interface use :ref:`junos_interfaces <junos_interfaces_module>` instead.
Expand Down
15 changes: 10 additions & 5 deletions lib/ansible/module_utils/cloudstack.py
Expand Up @@ -628,22 +628,27 @@ def poll_job(self, job=None, key=None):
time.sleep(2)
return job

def get_result(self, resource):
def update_result(self, resource, result=None):
if result is None:
result = dict()
if resource:
returns = self.common_returns.copy()
returns.update(self.returns)
for search_key, return_key in returns.items():
if search_key in resource:
self.result[return_key] = resource[search_key]
result[return_key] = resource[search_key]

# Bad bad API does not always return int when it should.
for search_key, return_key in self.returns_to_int.items():
if search_key in resource:
self.result[return_key] = int(resource[search_key])
result[return_key] = int(resource[search_key])

if 'tags' in resource:
self.result['tags'] = resource['tags']
return self.result
result['tags'] = resource['tags']
return result

def get_result(self, resource):
return self.update_result(resource, self.result)

def get_result_and_facts(self, facts_name, resource):
result = self.get_result(resource)
Expand Down
Expand Up @@ -9,7 +9,7 @@


ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'status': ['deprecated'],
'supported_by': 'community'}


Expand All @@ -19,6 +19,10 @@
short_description: Gathering facts from the API of instances from Apache CloudStack based clouds.
description:
- Gathering facts from the API of an instance.
deprecated:
removed_in: "2.13"
why: Transformed into an info module.
alternative: Use M(cs_instance_info) instead.
version_added: '2.1'
author: René Moser (@resmo)
options:
Expand Down
Expand Up @@ -5,7 +5,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'status': ['deprecated'],
'supported_by': 'community'}


Expand All @@ -16,6 +16,10 @@
description:
- Gathering facts from the API of a zone.
- Sets Ansible facts accessable by the key C(cloudstack_zone) and since version 2.6 also returns results.
deprecated:
removed_in: "2.13"
why: Transformed into an info module.
alternative: Use M(cs_zone_info) instead.
version_added: '2.1'
author: René Moser (@resmo)
options:
Expand Down

0 comments on commit 3426492

Please sign in to comment.