summaryrefslogtreecommitdiffstats
path: root/filter_plugins
diff options
context:
space:
mode:
Diffstat (limited to 'filter_plugins')
-rw-r--r--filter_plugins/oo_filters.py28
-rw-r--r--filter_plugins/openshift_master.py27
2 files changed, 48 insertions, 7 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index 450101785..dcda14c63 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -670,6 +670,33 @@ class FilterModule(object):
return rpms_31
+ @staticmethod
+ def oo_pods_match_component(pods, deployment_type, component):
+ """ Filters a list of Pods and returns the ones matching the deployment_type and component
+ """
+ if not isinstance(pods, list):
+ raise errors.AnsibleFilterError("failed expects to filter on a list")
+ if not isinstance(deployment_type, basestring):
+ raise errors.AnsibleFilterError("failed expects deployment_type to be a string")
+ if not isinstance(component, basestring):
+ raise errors.AnsibleFilterError("failed expects component to be a string")
+
+ image_prefix = 'openshift/origin-'
+ if deployment_type in ['enterprise', 'online', 'openshift-enterprise']:
+ image_prefix = 'openshift3/ose-'
+ elif deployment_type == 'atomic-enterprise':
+ image_prefix = 'aep3_beta/aep-'
+
+ matching_pods = []
+ image_regex = image_prefix + component + r'.*'
+ for pod in pods:
+ for container in pod['spec']['containers']:
+ if re.search(image_regex, container['image']):
+ matching_pods.append(pod)
+ break # stop here, don't add a pod more than once
+
+ return matching_pods
+
def filters(self):
""" returns a mapping of filters to methods """
return {
@@ -696,4 +723,5 @@ class FilterModule(object):
"oo_persistent_volumes": self.oo_persistent_volumes,
"oo_persistent_volume_claims": self.oo_persistent_volume_claims,
"oo_31_rpm_rename_conversion": self.oo_31_rpm_rename_conversion,
+ "oo_pods_match_component": self.oo_pods_match_component,
}
diff --git a/filter_plugins/openshift_master.py b/filter_plugins/openshift_master.py
index 35a881a85..c41367f05 100644
--- a/filter_plugins/openshift_master.py
+++ b/filter_plugins/openshift_master.py
@@ -53,7 +53,20 @@ class IdentityProviderBase(object):
self.challenge = ansible_bool(self._idp.pop('challenge', False))
self.provider = dict(apiVersion=api_version, kind=self._idp.pop('kind'))
- self._required = [['mappingMethod', 'mapping_method']]
+ mm_keys = ('mappingMethod', 'mapping_method')
+ mapping_method = None
+ for key in mm_keys:
+ if key in self._idp:
+ mapping_method = self._idp[key]
+ if mapping_method is None:
+ mapping_method = self.get_default('mappingMethod')
+ self.mapping_method = mapping_method
+
+ valid_mapping_methods = ['add', 'claim', 'generate', 'lookup']
+ if self.mapping_method not in valid_mapping_methods:
+ raise errors.AnsibleFilterError("|failed unkown mapping method "
+ "for provider {0}".format(self.__class__.__name__))
+ self._required = []
self._optional = []
self._allow_additional = True
@@ -75,10 +88,7 @@ class IdentityProviderBase(object):
def validate(self):
''' validate an instance of this idp class '''
- valid_mapping_methods = ['add', 'claim', 'generate', 'lookup']
- if self.provider['mappingMethod'] not in valid_mapping_methods:
- raise errors.AnsibleFilterError("|failed unkown mapping method "
- "for provider {0}".format(self.__class__.__name__))
+ pass
@staticmethod
def get_default(key):
@@ -121,7 +131,8 @@ class IdentityProviderBase(object):
def to_dict(self):
''' translate this idp to a dictionary '''
return dict(name=self.name, challenge=self.challenge,
- login=self.login, provider=self.provider)
+ login=self.login, mappingMethod=self.mapping_method,
+ provider=self.provider)
class LDAPPasswordIdentityProvider(IdentityProviderBase):
@@ -436,7 +447,9 @@ class GitHubIdentityProvider(IdentityProviderOauthBase):
Raises:
AnsibleFilterError:
"""
- pass
+ def __init__(self, api_version, idp):
+ IdentityProviderOauthBase.__init__(self, api_version, idp)
+ self._optional += [['organizations']]
class FilterModule(object):