From dd678197d3195f4ad18ce3186eb0e72210466842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ne=C4=8Das?= Date: Mon, 17 Jun 2019 22:01:47 +0200 Subject: [PATCH] Ovirt host facts fix (#57793) * ovirt host facts fix (#57790) * add changelog --- changelogs/fragments/57790-ovirt_host_facts_fix.yml | 2 ++ lib/ansible/modules/cloud/ovirt/ovirt_host_facts.py | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/57790-ovirt_host_facts_fix.yml diff --git a/changelogs/fragments/57790-ovirt_host_facts_fix.yml b/changelogs/fragments/57790-ovirt_host_facts_fix.yml new file mode 100644 index 00000000000..a03a38cd699 --- /dev/null +++ b/changelogs/fragments/57790-ovirt_host_facts_fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - Don't return nested information in ovirt_host_facts when fetch_nested is false diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_host_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_host_facts.py index 2da2e9ba280..474f0cf82b4 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_host_facts.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_host_facts.py @@ -79,11 +79,11 @@ from ansible.module_utils.ovirt import ( ) -def get_filtered_hosts(cluster_version, hosts): +def get_filtered_hosts(cluster_version, hosts, connection): # Filtering by cluster version returns only those which have same cluster version as input filtered_hosts = [] for host in hosts: - cluster = host.cluster + cluster = connection.follow_link(host.cluster) cluster_version_host = str(cluster.version.major) + '.' + str(cluster.version.minor) if cluster_version_host == cluster_version: filtered_hosts.append(host) @@ -106,12 +106,11 @@ def main(): hosts_service = connection.system_service().hosts_service() hosts = hosts_service.list( search=module.params['pattern'], - all_content=module.params['all_content'], - follow='cluster', + all_content=module.params['all_content'] ) cluster_version = module.params.get('cluster_version') if cluster_version is not None: - hosts = get_filtered_hosts(cluster_version, hosts) + hosts = get_filtered_hosts(cluster_version, hosts, connection) module.exit_json( changed=False, ansible_facts=dict(