diff options
author | Brenton Leanhardt <bleanhar@redhat.com> | 2016-02-08 16:48:24 -0500 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2016-02-11 13:28:08 -0500 |
commit | 4385281079a6023625720c06fb93d6d76d0092be (patch) | |
tree | e5dd12181d8d47c81c935e4ea854675e93ae9b42 /filter_plugins | |
parent | cfb19e24b7b93fd3b73201358d3f3ceb67840a05 (diff) | |
download | openshift-4385281079a6023625720c06fb93d6d76d0092be.tar.gz openshift-4385281079a6023625720c06fb93d6d76d0092be.tar.bz2 openshift-4385281079a6023625720c06fb93d6d76d0092be.tar.xz openshift-4385281079a6023625720c06fb93d6d76d0092be.zip |
Bug 1302970 - update script does not patch router if name is different from default
Diffstat (limited to 'filter_plugins')
-rw-r--r-- | filter_plugins/oo_filters.py | 28 |
1 files changed, 28 insertions, 0 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, } |