mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudstack: add _get_by_key() to utils
Generic method to get the whole dict or just a singe value by key if found.
This commit is contained in:
parent
31520cdd17
commit
88540d3cdc
1 changed files with 8 additions and 0 deletions
|
@ -69,6 +69,14 @@ class AnsibleCloudStack:
|
||||||
self.cs = CloudStack(**read_config())
|
self.cs = CloudStack(**read_config())
|
||||||
|
|
||||||
|
|
||||||
|
def _get_by_key(self, key=None, my_dict={}):
|
||||||
|
if key:
|
||||||
|
if key in my_dict:
|
||||||
|
return my_dict[key]
|
||||||
|
self.module.fail_json(msg="Something went wrong: %s not found" % key)
|
||||||
|
return my_dict
|
||||||
|
|
||||||
|
|
||||||
def get_project_id(self):
|
def get_project_id(self):
|
||||||
if self.project_id:
|
if self.project_id:
|
||||||
return self.project_id
|
return self.project_id
|
||||||
|
|
Loading…
Reference in a new issue