Skip to content

Commit d5d03c0

Browse files
sanity fix
1 parent 7bedacf commit d5d03c0

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

plugins/lookup/api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
- name: List all Virtual Machines from the API
3737
set_fact:
3838
virtual_machines: "{{ lookup('ngine_io.cloudstack.api', 'listVirtualMachines') }}"
39-
39+
4040
- name: List specific Virtual Machines from the API
4141
set_fact:
4242
virtual_machines: "{{ lookup('ngine_io.cloudstack.api', 'listVirtualMachines', query_params={ 'name': 'myvmname' }) }}"
@@ -57,6 +57,7 @@
5757

5858
from ..module_utils.cloudstack_api import AnsibleCloudStackAPI
5959

60+
6061
class LookupModule(LookupBase):
6162
display = Display()
6263

@@ -69,19 +70,20 @@ def warn_callback(self, warning):
6970
def run(self, terms, variables=None, **kwargs):
7071
if len(terms) != 1:
7172
raise AnsibleError('You must pass exactly one endpoint to query')
72-
73+
7374
self.set_options(direct=kwargs)
74-
75+
7576
module = AnsibleCloudStackAPI(argument_spec={}, direct_params=kwargs, error_callback=self.handle_error, warn_callback=self.warn_callback)
7677

7778
args = {}
7879
if self.get_option('query_params'):
7980
args.update(self.get_option('query_params', {}))
80-
81+
8182
res = module.query_api(terms[0], **args)
8283

8384
if res is None:
8485
return []
8586
if type(res) is list:
8687
return res
88+
8789
return [res]

plugins/module_utils/cloudstack_api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AnsibleCloudStackAPI(AnsibleModule):
4343
)
4444

4545
def __init__(self, argument_spec=None, direct_params=None, error_callback=None, warn_callback=None, **kwargs):
46-
46+
4747
if not HAS_LIB_CS:
4848
self.fail_json(msg=missing_required_lib('cs'), exception=CS_IMP_ERR)
4949

@@ -54,7 +54,7 @@ def __init__(self, argument_spec=None, direct_params=None, error_callback=None,
5454

5555
self.error_callback = error_callback
5656
self.warn_callback = warn_callback
57-
57+
5858
self._cs = None
5959
self.result = {}
6060

@@ -63,15 +63,14 @@ def __init__(self, argument_spec=None, direct_params=None, error_callback=None,
6363
if param in direct_params:
6464
setattr(self, param, direct_params[param])
6565
else:
66-
setattr(self, param, value)
66+
setattr(self, param, value)
6767
else:
6868
super(AnsibleCloudStackAPI, self).__init__(argument_spec=full_argspec, **kwargs)
6969

7070
# Perform some basic validation
7171
if not re.match('^https{0,1}://', self.api_url):
7272
self.api_url = "https://{0}".format(self.api_url)
7373

74-
7574
def fail_json(self, **kwargs):
7675
if self.error_callback:
7776
self.error_callback(**kwargs)
@@ -110,7 +109,7 @@ def get_api_config(self):
110109
return api_config
111110

112111
def query_api(self, command, **args):
113-
112+
114113
try:
115114
res = getattr(self.cs, command)(**args)
116115

0 commit comments

Comments
 (0)