From 4dc3874176ccb3aff0e46c958e70509feabe7195 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 11 Oct 2017 16:16:40 +0200 Subject: [PATCH] cs_snapshot_policy: fix VM not found in non-default zone --- lib/ansible/module_utils/cloudstack.py | 4 ++-- lib/ansible/modules/cloud/cloudstack/cs_snapshot_policy.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index ad881caee5..49cbfc7e53 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -406,7 +406,7 @@ class AnsibleCloudStack(object): return self.vm_default_nic self.fail_json(msg="No default IP address of VM '%s' found" % self.module.params.get('vm')) - def get_vm(self, key=None): + def get_vm(self, key=None, filter_zone=True): if self.vm: return self._get_by_key(key, self.vm) @@ -418,7 +418,7 @@ class AnsibleCloudStack(object): 'account': self.get_account(key='name'), 'domainid': self.get_domain(key='id'), 'projectid': self.get_project(key='id'), - 'zoneid': self.get_zone(key='id'), + 'zoneid': self.get_zone(key='id') if filter_zone else None, } vms = self.query_api('listVirtualMachines', **args) if vms: diff --git a/lib/ansible/modules/cloud/cloudstack/cs_snapshot_policy.py b/lib/ansible/modules/cloud/cloudstack/cs_snapshot_policy.py index 9342183d98..924a6ea3bf 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_snapshot_policy.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_snapshot_policy.py @@ -222,7 +222,7 @@ class AnsibleCloudStackSnapshotPolicy(AnsibleCloudStack): 'account': self.get_account(key='name'), 'domainid': self.get_domain(key='id'), 'projectid': self.get_project(key='id'), - 'virtualmachineid': self.get_vm(key='id'), + 'virtualmachineid': self.get_vm(key='id', filter_zone=False), 'type': self.module.params.get('volume_type'), } volumes = self.query_api('listVolumes', **args)