From f0801879c77bcb1c03e1795ae34142b25ae5bf1d Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 30 Jun 2019 16:04:30 +0200 Subject: [PATCH] Rename xenserver_guest_facts -> xenserver_guest_info (#57032) * Rename xenserver_guest_facts -> xenserver_guest_info. * Add changelog. * Forgot one test. --- changelogs/fragments/57032-facts-info-rename.yaml | 2 ++ docs/docsite/rst/porting_guides/porting_guide_2.9.rst | 1 + .../modules/cloud/xenserver/_xenserver_guest_facts.py | 1 + ...enserver_guest_facts.py => xenserver_guest_info.py} | 9 ++++++--- test/units/modules/cloud/xenserver/conftest.py | 10 +++++----- ...ver_guest_facts.py => test_xenserver_guest_info.py} | 10 +++++----- 6 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 changelogs/fragments/57032-facts-info-rename.yaml create mode 120000 lib/ansible/modules/cloud/xenserver/_xenserver_guest_facts.py rename lib/ansible/modules/cloud/xenserver/{xenserver_guest_facts.py => xenserver_guest_info.py} (94%) rename test/units/modules/cloud/xenserver/{test_xenserver_guest_facts.py => test_xenserver_guest_info.py} (88%) diff --git a/changelogs/fragments/57032-facts-info-rename.yaml b/changelogs/fragments/57032-facts-info-rename.yaml new file mode 100644 index 0000000000..78349cd211 --- /dev/null +++ b/changelogs/fragments/57032-facts-info-rename.yaml @@ -0,0 +1,2 @@ +minor_changes: +- The ``xenserver_guest_facts`` module has been renamed to ``xenserver_guest_info``. diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst index 4aefc39f5e..9c25696b57 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst @@ -82,6 +82,7 @@ Noteworthy module changes * The ``memset_server_facts`` module was renamed to :ref:`memset_server_info `. * The ``one_image_facts`` module was renamed to :ref:`one_image_info `. * The ``ali_instance_facts`` module was renamed to :ref:`ali_instance_info `. +* The ``xenserver_guest_facts`` module was renamed to :ref:`xenserver_guest_info `. * The ``azure_rm_resourcegroup_facts`` module was renamed to :ref:`azure_rm_resourcegroup_info `. * The ``digital_ocean_account_facts`` module was renamed to :ref:`digital_ocean_account_info `. * The ``digital_ocean_certificate_facts`` module was renamed to :ref:`digital_ocean_certificate_info `. diff --git a/lib/ansible/modules/cloud/xenserver/_xenserver_guest_facts.py b/lib/ansible/modules/cloud/xenserver/_xenserver_guest_facts.py new file mode 120000 index 0000000000..e4f2c814ea --- /dev/null +++ b/lib/ansible/modules/cloud/xenserver/_xenserver_guest_facts.py @@ -0,0 +1 @@ +xenserver_guest_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/xenserver/xenserver_guest_facts.py b/lib/ansible/modules/cloud/xenserver/xenserver_guest_info.py similarity index 94% rename from lib/ansible/modules/cloud/xenserver/xenserver_guest_facts.py rename to lib/ansible/modules/cloud/xenserver/xenserver_guest_info.py index 811d4e3193..7cee1c6679 100644 --- a/lib/ansible/modules/cloud/xenserver/xenserver_guest_facts.py +++ b/lib/ansible/modules/cloud/xenserver/xenserver_guest_info.py @@ -13,8 +13,8 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', 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' @@ -30,6 +30,7 @@ notes: 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 @@ -53,7 +54,7 @@ extends_documentation_fragment: xenserver.documentation EXAMPLES = r''' - name: Gather facts - xenserver_guest_facts: + xenserver_guest_info: hostname: "{{ xenserver_hostname }}" username: "{{ xenserver_username }}" password: "{{ xenserver_password }}" @@ -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} diff --git a/test/units/modules/cloud/xenserver/conftest.py b/test/units/modules/cloud/xenserver/conftest.py index 5e46c39725..f93b6c60b4 100644 --- a/test/units/modules/cloud/xenserver/conftest.py +++ b/test/units/modules/cloud/xenserver/conftest.py @@ -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 diff --git a/test/units/modules/cloud/xenserver/test_xenserver_guest_facts.py b/test/units/modules/cloud/xenserver/test_xenserver_guest_info.py similarity index 88% rename from test/units/modules/cloud/xenserver/test_xenserver_guest_facts.py rename to test/units/modules/cloud/xenserver/test_xenserver_guest_info.py index 2208849e5c..b0db19673d 100644 --- a/test/units/modules/cloud/xenserver/test_xenserver_guest_facts.py +++ b/test/units/modules/cloud/xenserver/test_xenserver_guest_info.py @@ -46,16 +46,16 @@ testcase_module_params = { @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) @@ -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)