summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Florek <tob@butter.sh>2016-04-06 12:58:15 +0200
committerTobias Florek <tob@butter.sh>2016-04-25 22:59:51 +0200
commit8e0b25974ff823301134fe132f980c3c4f5eeaba (patch)
tree8347aaa30c79f62e88d21c66980af40238da7b8b
parent04b52454275572f9d09e76c6ce46bdd60aa46c72 (diff)
downloadopenshift-8e0b25974ff823301134fe132f980c3c4f5eeaba.tar.gz
openshift-8e0b25974ff823301134fe132f980c3c4f5eeaba.tar.bz2
openshift-8e0b25974ff823301134fe132f980c3c4f5eeaba.tar.xz
openshift-8e0b25974ff823301134fe132f980c3c4f5eeaba.zip
port filter_plugins to ansible2
-rw-r--r--filter_plugins/oo_filters.py9
-rw-r--r--filter_plugins/openshift_master.py6
2 files changed, 10 insertions, 5 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index 3da4562ac..c0f246d88 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -6,6 +6,7 @@ Custom filters for use in openshift-ansible
"""
from ansible import errors
+from collections import Mapping
from operator import itemgetter
import OpenSSL.crypto
import os
@@ -128,14 +129,14 @@ class FilterModule(object):
returns [1, 3]
"""
- if not isinstance(data, dict):
- raise errors.AnsibleFilterError("|failed expects to filter on a dict")
+ if not isinstance(data, Mapping):
+ raise errors.AnsibleFilterError("|failed expects to filter on a dict or object")
if not isinstance(keys, list):
raise errors.AnsibleFilterError("|failed expects first param is a list")
# Gather up the values for the list of keys passed in
- retval = [data[key] for key in keys if data.has_key(key)]
+ retval = [data[key] for key in keys if key in data]
return retval
@@ -299,7 +300,7 @@ class FilterModule(object):
raise errors.AnsibleFilterError("|failed expects filter_attr is a str or unicode")
# Gather up the values for the list of keys passed in
- return [x for x in data if x.has_key(filter_attr) and x[filter_attr]]
+ return [x for x in data if filter_attr in x and x[filter_attr]]
@staticmethod
def oo_oc_nodes_matching_selector(nodes, selector):
diff --git a/filter_plugins/openshift_master.py b/filter_plugins/openshift_master.py
index 34d9aef75..dc12eb24b 100644
--- a/filter_plugins/openshift_master.py
+++ b/filter_plugins/openshift_master.py
@@ -9,8 +9,12 @@ import sys
import yaml
from ansible import errors
-from ansible.runner.filter_plugins.core import bool as ansible_bool
+# pylint: disable=no-name-in-module,import-error
+try:
+ from ansible.runner.filter_plugins.core import bool as ansible_bool
+except ImportError:
+ from ansible.plugins.filter.core import bool as ansible_bool
class IdentityProviderBase(object):
""" IdentityProviderBase