From 3410a855b0d4aab1e20c1f33a3d8b72dbdad2803 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Sun, 8 Nov 2015 20:23:06 +0100 Subject: [PATCH 1/2] cloudstack: use jop polling in tag handling, fixes outdated tags returned. In some cases the async job did not finish fast enough, causing returning an unexpeded result. --- lib/ansible/module_utils/cloudstack.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index e5eb73e9bd..dc25de678d 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -348,9 +348,10 @@ class AnsibleCloudStack(object): args['resourcetype'] = resource_type args['tags'] = tags if operation == "create": - self.cs.createTags(**args) + response = self.cs.createTags(**args) else: - self.cs.deleteTags(**args) + response = self.cs.deleteTags(**args) + self.poll_job(response) def _tags_that_should_exist_or_be_updated(self, resource, tags): From 1d59caed073eb92437cd63a0e22219334034ee12 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Sun, 8 Nov 2015 20:27:01 +0100 Subject: [PATCH 2/2] cloudstack: change order of tags handling, fixes update of tag value does not work --- lib/ansible/module_utils/cloudstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index dc25de678d..53d142847d 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -371,8 +371,8 @@ class AnsibleCloudStack(object): if 'tags' in resource: tags = self.module.params.get('tags') if tags is not None: - self._process_tags(resource, resource_type, self._tags_that_should_exist_or_be_updated(resource, tags)) self._process_tags(resource, resource_type, self._tags_that_should_not_exist(resource, tags), operation="delete") + self._process_tags(resource, resource_type, self._tags_that_should_exist_or_be_updated(resource, tags)) self.tags = None resource['tags'] = self.get_tags(resource) return resource