diff options
author | Scott Dodson <sdodson@redhat.com> | 2016-08-25 09:33:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-25 09:33:21 -0400 |
commit | d08a872a0392c100e86eed41f5d5372d226538c0 (patch) | |
tree | 14286133d094e90882258506cf34d25ada484f37 /filter_plugins | |
parent | 0af3d7cd96e4584c2d1301d84c1f02234a8cfdb5 (diff) | |
parent | 3f2d71a1bfb589778733dd8eb0ccd6b1dac31d79 (diff) | |
download | openshift-d08a872a0392c100e86eed41f5d5372d226538c0.tar.gz openshift-d08a872a0392c100e86eed41f5d5372d226538c0.tar.bz2 openshift-d08a872a0392c100e86eed41f5d5372d226538c0.tar.xz openshift-d08a872a0392c100e86eed41f5d5372d226538c0.zip |
Merge pull request #2052 from sdodson/metrics
Metrics improvements
Diffstat (limited to 'filter_plugins')
-rw-r--r-- | filter_plugins/oo_filters.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index b57bc0afa..a4dceb679 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -17,6 +17,7 @@ import re import json import yaml from ansible.utils.unicode import to_unicode +from urlparse import urlparse # Disabling too-many-public-methods, since filter methods are necessarily # public @@ -709,7 +710,7 @@ class FilterModule(object): fsType=filesystem, volumeID=volume_id))) persistent_volumes.append(persistent_volume) - elif kind != 'object': + elif not (kind == 'object' or kind == 'dynamic'): msg = "|failed invalid storage kind '{0}' for component '{1}'".format( kind, component) @@ -733,7 +734,8 @@ class FilterModule(object): if 'storage' in hostvars['openshift']['hosted'][component]: kind = hostvars['openshift']['hosted'][component]['storage']['kind'] create_pv = hostvars['openshift']['hosted'][component]['storage']['create_pv'] - if kind != None and create_pv: + create_pvc = hostvars['openshift']['hosted'][component]['storage']['create_pvc'] + if kind != None and create_pv and create_pvc: volume = hostvars['openshift']['hosted'][component]['storage']['volume']['name'] size = hostvars['openshift']['hosted'][component]['storage']['volume']['size'] access_modes = hostvars['openshift']['hosted'][component]['storage']['access_modes'] @@ -829,6 +831,22 @@ class FilterModule(object): return version + @staticmethod + def oo_hostname_from_url(url): + """ Returns the hostname contained in a URL + + Ex: https://ose3-master.example.com/v1/api -> ose3-master.example.com + """ + if not isinstance(url, basestring): + raise errors.AnsibleFilterError("|failed expects a string or unicode") + parse_result = urlparse(url) + if parse_result.netloc != '': + return parse_result.netloc + else: + # netloc wasn't parsed, assume url was missing scheme and path + return parse_result.path + + def filters(self): """ returns a mapping of filters to methods """ return { @@ -859,5 +877,6 @@ class FilterModule(object): "oo_get_hosts_from_hostvars": self.oo_get_hosts_from_hostvars, "oo_image_tag_to_rpm_version": self.oo_image_tag_to_rpm_version, "oo_merge_dicts": self.oo_merge_dicts, + "oo_hostname_from_url": self.oo_hostname_from_url, "oo_merge_hostvars": self.oo_merge_hostvars, } |