From 7aca70b4b0b98077d8cfbefceebeed351bd4801c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Mon, 13 Jun 2016 08:27:27 +0200 Subject: [PATCH] cloudstack: simplify tag handling (#16188) Fixes tag support in projects. --- lib/ansible/module_utils/cloudstack.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index c9071b7e63..9eea9f8381 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -109,7 +109,6 @@ class AnsibleCloudStack(object): self.os_type = None self.hypervisor = None self.capabilities = None - self.tags = None def _connect(self): @@ -391,19 +390,9 @@ class AnsibleCloudStack(object): def get_tags(self, resource=None): - if not self.tags: - args = {} - args['projectid'] = self.get_project(key='id') - args['account'] = self.get_account(key='name') - args['domainid'] = self.get_domain(key='id') - args['resourceid'] = resource['id'] - response = self.cs.listTags(**args) - self.tags = response.get('tag', []) - existing_tags = [] - if self.tags: - for tag in self.tags: - existing_tags.append({'key': tag['key'], 'value': tag['value']}) + for tag in resource.get('tags',[]): + existing_tags.append({'key': tag['key'], 'value': tag['value']}) return existing_tags @@ -441,8 +430,7 @@ class AnsibleCloudStack(object): if tags is not None: 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) + resource['tags'] = tags return resource