summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason DeTiberus <detiber@gmail.com>2016-04-25 17:45:04 -0400
committerJason DeTiberus <detiber@gmail.com>2016-04-25 17:45:04 -0400
commit7c6d0d70e2371bd9abb6feb4e6c098ae4ddb5143 (patch)
tree07949ccaf05a1a137ddcf5c481bbf72f056b2803
parent78129174976ee318ec79214f52ab8dd351138be5 (diff)
parent8e0b25974ff823301134fe132f980c3c4f5eeaba (diff)
downloadopenshift-7c6d0d70e2371bd9abb6feb4e6c098ae4ddb5143.tar.gz
openshift-7c6d0d70e2371bd9abb6feb4e6c098ae4ddb5143.tar.bz2
openshift-7c6d0d70e2371bd9abb6feb4e6c098ae4ddb5143.tar.xz
openshift-7c6d0d70e2371bd9abb6feb4e6c098ae4ddb5143.zip
Merge pull request #1799 from ibotty/port_filter_plugins_to_ansible_2
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 0f54d8a0a..b08670678 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