Browse Source

Removal of netloc filters

The ansible urlsplit filter added in 2.4 means that maintaining the
filters netloc, netloc_no_port and netorigin should no longer be
necessary.
All usages of these filters within other openstack repos have been
updated to use urlsplit and merged.

Change-Id: Ief1ec06e205bae7ec114fe0b9bd7d9c4973383dd
Closes-Bug: #1820830
changes/26/655126/2
Georgina 1 month ago
parent
commit
6482c25017

+ 0
- 27
doc/source/filters.rst View File

@@ -80,33 +80,6 @@ user after removing any duplicates found within the second list.
80 80
    {{ ['a', 'b'] | filtered_list(['b', 'c']) }}
81 81
    # => [ "a" ]
82 82
 
83
-netloc
84
-~~~~~~
85
-This filter will return the netloc from a given URL.
86
-
87
-.. code-block:: yaml
88
-
89
-    {{ 'https://172.29.236.100:5000/v3/auth/tokens' | netloc }}
90
-    # => "172.29.236.100:5000"
91
-
92
-netloc_no_port
93
-~~~~~~~~~~~~~~
94
-This filter will return the netloc, without a port, from a given URL.
95
-
96
-.. code-block:: yaml
97
-
98
-    {{ 'https://172.29.236.100:5000/v3/auth/tokens' | netloc_no_port }}
99
-    # => "172.29.236.100"
100
-
101
-netorigin
102
-~~~~~~~~~
103
-This filter will return the scheme and netloc from a given URL.
104
-
105
-.. code-block:: yaml
106
-
107
-    {{ 'https://172.29.236.100:5000/v3/auth/tokens' | netorigin }}
108
-    # => "https://172.29.236.100:5000"
109
-
110 83
 pip_constraint_update
111 84
 ~~~~~~~~~~~~~~~~~~~~~
112 85
 This filter will return a merged list from a given list of pip packages and a

+ 0
- 65
filter/osa-filters.py View File

@@ -152,68 +152,6 @@ def bit_length_power_of_2(value):
152 152
     """
153 153
     return 2**(int(value)-1).bit_length()
154 154
 
155
-
156
-def get_netloc(url):
157
-    """Return the netloc from a URL.
158
-
159
-    If the input value is not a value URL the method will raise an Ansible
160
-    filter exception.
161
-
162
-    :param url: the URL to parse
163
-    :type url: ``str``
164
-    :returns: ``str``
165
-    """
166
-    try:
167
-        netloc = urlparse(url).netloc
168
-    except Exception as exp:
169
-        raise errors.AnsibleFilterError(
170
-            'Failed to return the netloc of: "%s"' % str(exp)
171
-        )
172
-    else:
173
-        return netloc
174
-
175
-
176
-def get_netloc_no_port(url):
177
-    """Return the netloc without a port from a URL.
178
-
179
-    If the input value is not a value URL the method will raise an Ansible
180
-    filter exception.
181
-
182
-    :param url: the URL to parse
183
-    :type url: ``str``
184
-    :returns: ``str``
185
-    """
186
-    try:
187
-        hostname = urlparse(url).hostname
188
-    except Exception as exp:
189
-        raise errors.AnsibleFilterError(
190
-            'Failed to return the hostname of: "%s"' % str(exp)
191
-        )
192
-    else:
193
-        return hostname
194
-
195
-def get_netorigin(url):
196
-    """Return the netloc from a URL.
197
-
198
-    If the input value is not a value URL the method will raise an Ansible
199
-    filter exception.
200
-
201
-    :param url: the URL to parse
202
-    :type url: ``str``
203
-    :returns: ``str``
204
-    """
205
-    try:
206
-        parsed_url = urlparse(url)
207
-        netloc = parsed_url.netloc
208
-        scheme = parsed_url.scheme
209
-    except Exception as exp:
210
-        raise errors.AnsibleFilterError(
211
-            'Failed to return the netorigin of: "%s"' % str(exp)
212
-        )
213
-    else:
214
-        return '%s://%s' % (scheme, netloc)
215
-
216
-
217 155
 def string_2_int(string):
218 156
     """Return the an integer from a string.
219 157
 
@@ -331,9 +269,6 @@ class FilterModule(object):
331 269
     def filters():
332 270
         return {
333 271
             'bit_length_power_of_2': bit_length_power_of_2,
334
-            'netloc': get_netloc,
335
-            'netloc_no_port': get_netloc_no_port,
336
-            'netorigin': get_netorigin,
337 272
             'string_2_int': string_2_int,
338 273
             'pip_requirement_names': pip_requirement_names,
339 274
             'pip_constraint_update': pip_constraint_update,

+ 6
- 0
releasenotes/notes/remove-netloc-filters-072744382314d578.yaml View File

@@ -0,0 +1,6 @@
1
+---
2
+deprecations:
3
+  - |
4
+    Removal of the netloc, netloc_no_port and netorigin filters.
5
+    Please use the urlsplit filter instead.
6
+    All usages of the deprecated filters in openstack repos have been updated.

+ 0
- 14
tests/test-filters.yml View File

@@ -26,20 +26,6 @@
26 26
           - "{{ 1024 | bit_length_power_of_2 }} == 1024"
27 27
           - "{{ 9600 | bit_length_power_of_2 }} == 16384"
28 28
 
29
-    - name: Set net filter facts
30
-      set_fact:
31
-         url_netloc: "{{ 'http://review.openstack.org:29418/something' | netloc }}"
32
-         url_netloc_no_port: "{{ 'http://review.openstack.org:29418/something' | netloc_no_port }}"
33
-         url_netloc_no_port_with_auth: "{{ 'http://user:secrete@review.openstack.org:29418/something' | netloc_no_port }}"
34
-         url_netorigin: "{{ 'http://review.openstack.org:29418/something' | netorigin }}"
35
-    - name: Validate net filters
36
-      assert:
37
-        that:
38
-          - "url_netloc == 'review.openstack.org:29418'"
39
-          - "url_netloc_no_port == 'review.openstack.org'"
40
-          - "url_netloc_no_port_with_auth == 'review.openstack.org'"
41
-          - "url_netorigin == 'http://review.openstack.org:29418'"
42
-
43 29
     - name: Validate string_2_int filter
44 30
       assert:
45 31
         that:

Loading…
Cancel
Save