Skip to content

Commit

Permalink
Rename xenserver_guest_facts -> xenserver_guest_info (ansible#57032)
Browse files Browse the repository at this point in the history
* Rename xenserver_guest_facts -> xenserver_guest_info.

* Add changelog.

* Forgot one test.
  • Loading branch information
felixfontein authored and ansibot committed Jun 30, 2019
1 parent 2401154 commit f080187
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/57032-facts-info-rename.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- The ``xenserver_guest_facts`` module has been renamed to ``xenserver_guest_info``.
1 change: 1 addition & 0 deletions docs/docsite/rst/porting_guides/porting_guide_2.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Noteworthy module changes
* The ``memset_server_facts`` module was renamed to :ref:`memset_server_info <memset_server_info_module>`.
* The ``one_image_facts`` module was renamed to :ref:`one_image_info <one_image_info_module>`.
* The ``ali_instance_facts`` module was renamed to :ref:`ali_instance_info <ali_instance_info_module>`.
* The ``xenserver_guest_facts`` module was renamed to :ref:`xenserver_guest_info <xenserver_guest_info_module>`.
* The ``azure_rm_resourcegroup_facts`` module was renamed to :ref:`azure_rm_resourcegroup_info <azure_rm_resourcegroup_info_module>`.
* The ``digital_ocean_account_facts`` module was renamed to :ref:`digital_ocean_account_info <digital_ocean_account_info_module>`.
* The ``digital_ocean_certificate_facts`` module was renamed to :ref:`digital_ocean_certificate_info <digital_ocean_certificate_info_module>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

DOCUMENTATION = r'''
---
module: xenserver_guest_facts
short_description: Gathers facts for virtual machines running on Citrix XenServer host or pool
module: xenserver_guest_info
short_description: Gathers information for virtual machines running on Citrix XenServer host or pool
description: >
This module can be used to gather essential VM facts.
version_added: '2.8'
Expand All @@ -30,6 +30,7 @@
accessing XenServer host in trusted environment or use C(https://) scheme explicitly.'
- 'To use C(https://) scheme for C(hostname) you have to either import host certificate to your OS certificate store or use C(validate_certs: no)
which requires XenAPI library from XenServer 7.2 SDK or newer and Python 2.7.9 or newer.'
- This module was called C(xenserver_guest_facts) before Ansible 2.9. The usage did not change.
requirements:
- python >= 2.6
- XenAPI
Expand All @@ -53,7 +54,7 @@

EXAMPLES = r'''
- name: Gather facts
xenserver_guest_facts:
xenserver_guest_info:
hostname: "{{ xenserver_hostname }}"
username: "{{ xenserver_username }}"
password: "{{ xenserver_password }}"
Expand Down Expand Up @@ -205,6 +206,8 @@ def main():
['name', 'uuid'],
],
)
if module._name == 'xenserver_guest_facts':
module.deprecate("The 'xenserver_guest_facts' module has been renamed to 'xenserver_guest_info'", version='2.13')

result = {'failed': False, 'changed': False}

Expand Down
10 changes: 5 additions & 5 deletions test/units/modules/cloud/xenserver/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ def XenAPI():


@pytest.fixture
def xenserver_guest_facts(XenAPI):
"""Imports and returns xenserver_guest_facts module."""
def xenserver_guest_info(XenAPI):
"""Imports and returns xenserver_guest_info module."""

# Since we are wrapping fake XenAPI module inside a fixture, all modules
# that depend on it have to be imported inside a test function. To make
# this easier to handle and remove some code repetition, we wrap the import
# of xenserver_guest_facts module with a fixture.
from ansible.modules.cloud.xenserver import xenserver_guest_facts
# of xenserver_guest_info module with a fixture.
from ansible.modules.cloud.xenserver import xenserver_guest_info

return xenserver_guest_facts
return xenserver_guest_info


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@


@pytest.mark.parametrize('patch_ansible_module', testcase_module_params['params'], ids=testcase_module_params['ids'], indirect=True)
def test_xenserver_guest_facts(mocker, capfd, XenAPI, xenserver_guest_facts):
def test_xenserver_guest_info(mocker, capfd, XenAPI, xenserver_guest_info):
"""
Tests regular module invocation including parsing and propagation of
module params and module output.
"""
fake_vm_facts = {"fake-vm-fact": True}

mocker.patch('ansible.modules.cloud.xenserver.xenserver_guest_facts.get_object_ref', return_value=None)
mocker.patch('ansible.modules.cloud.xenserver.xenserver_guest_facts.gather_vm_params', return_value=None)
mocker.patch('ansible.modules.cloud.xenserver.xenserver_guest_facts.gather_vm_facts', return_value=fake_vm_facts)
mocker.patch('ansible.modules.cloud.xenserver.xenserver_guest_info.get_object_ref', return_value=None)
mocker.patch('ansible.modules.cloud.xenserver.xenserver_guest_info.gather_vm_params', return_value=None)
mocker.patch('ansible.modules.cloud.xenserver.xenserver_guest_info.gather_vm_facts', return_value=fake_vm_facts)

mocked_xenapi = mocker.patch.object(XenAPI.Session, 'xenapi', create=True)

Expand All @@ -69,7 +69,7 @@ def test_xenserver_guest_facts(mocker, capfd, XenAPI, xenserver_guest_facts):
mocker.patch('ansible.module_utils.xenserver.get_xenserver_version', return_value=[7, 2, 0])

with pytest.raises(SystemExit):
xenserver_guest_facts.main()
xenserver_guest_info.main()

out, err = capfd.readouterr()
result = json.loads(out)
Expand Down

0 comments on commit f080187

Please sign in to comment.