mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #11398 from resmo/for-ansible
cloudstack: fixes and updates
This commit is contained in:
commit
af49944ab2
2 changed files with 24 additions and 6 deletions
|
@ -77,6 +77,14 @@ class AnsibleCloudStack:
|
|||
else:
|
||||
self.cs = CloudStack(**read_config())
|
||||
|
||||
|
||||
def get_or_fallback(self, key=None, fallback_key=None):
|
||||
value = self.module.params.get(key)
|
||||
if not value:
|
||||
value = self.module.params.get(fallback_key)
|
||||
return value
|
||||
|
||||
|
||||
# TODO: for backward compatibility only, remove if not used anymore
|
||||
def _has_changed(self, want_dict, current_dict, only_keys=None):
|
||||
return self.has_changed(want_dict=want_dict, current_dict=current_dict, only_keys=only_keys)
|
||||
|
@ -266,11 +274,12 @@ class AnsibleCloudStack:
|
|||
return None
|
||||
|
||||
args = {}
|
||||
args['name'] = domain
|
||||
args['listall'] = True
|
||||
domains = self.cs.listDomains(**args)
|
||||
if domains:
|
||||
self.domain = domains['domain'][0]
|
||||
for d in domains['domain']:
|
||||
if d['path'].lower() in [ domain.lower(), "root/" + domain.lower(), "root" + domain.lower() ]:
|
||||
self.domain = d
|
||||
return self._get_by_key(key, self.domain)
|
||||
self.module.fail_json(msg="Domain '%s' not found" % domain)
|
||||
|
||||
|
|
|
@ -77,6 +77,14 @@ class AnsibleCloudStack:
|
|||
else:
|
||||
self.cs = CloudStack(**read_config())
|
||||
|
||||
|
||||
def get_or_fallback(self, key=None, fallback_key=None):
|
||||
value = self.module.params.get(key)
|
||||
if not value:
|
||||
value = self.module.params.get(fallback_key)
|
||||
return value
|
||||
|
||||
|
||||
# TODO: for backward compatibility only, remove if not used anymore
|
||||
def _has_changed(self, want_dict, current_dict, only_keys=None):
|
||||
return self.has_changed(want_dict=want_dict, current_dict=current_dict, only_keys=only_keys)
|
||||
|
@ -266,11 +274,12 @@ class AnsibleCloudStack:
|
|||
return None
|
||||
|
||||
args = {}
|
||||
args['name'] = domain
|
||||
args['listall'] = True
|
||||
domains = self.cs.listDomains(**args)
|
||||
if domains:
|
||||
self.domain = domains['domain'][0]
|
||||
for d in domains['domain']:
|
||||
if d['path'].lower() in [ domain.lower(), "root/" + domain.lower(), "root" + domain.lower() ]:
|
||||
self.domain = d
|
||||
return self._get_by_key(key, self.domain)
|
||||
self.module.fail_json(msg="Domain '%s' not found" % domain)
|
||||
|
||||
|
|
Loading…
Reference in a new issue