blob: 06bc0796da138505db1e79f101e31c77bdcea83c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
def oo_filter_container_providers(results):
"""results - the result from posting the API calls for adding new
providers"""
all_results = []
for result in results:
if 'results' in result['json']:
# We got an OK response
r = result['json']['results'][0]
all_results.append("Provider '{}' - Added successfully".format(r['name']))
elif 'error' in result['json']:
# This was a problem
all_results.append("Provider '{}' - Failed to add. Message: {}".format(
result['item']['name'], result['json']['error']['message']))
return all_results
class FilterModule(object):
""" Custom ansible filter mapping """
# pylint: disable=no-self-use, too-few-public-methods
def filters(self):
""" returns a mapping of filters to methods """
return {
"oo_filter_container_providers": oo_filter_container_providers,
}
|