From ca88189bf765a1f519733706e299f45bd2dc3ccd Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Sat, 25 Apr 2015 18:31:58 +0200 Subject: [PATCH] cloudstack: add method to to get infos of API get_capabilities() allows you to get infos e.g. `cloudstackversion` to compare functionality of the API in your modules. --- lib/ansible/module_utils/cloudstack.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index 74afc79836..48f16a1399 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -50,6 +50,7 @@ class AnsibleCloudStack: self.vm = None self.os_type = None self.hypervisor = None + self.capabilities = None def _connect(self): @@ -235,6 +236,14 @@ class AnsibleCloudStack: self.module.fail_json(msg="Hypervisor '%s' not found" % hypervisor) + def get_capabilities(self, key=None): + if self.capabilities: + return self._get_by_key(key, self.capabilities) + capabilities = self.cs.listCapabilities() + self.capabilities = capabilities['capability'] + return self._get_by_key(key, self.capabilities) + + def _poll_job(self, job=None, key=None): if 'jobid' in job: while True: