Merge lp:~billy-olsen/charms/trusty/glance/public-endpoint-host into lp:~openstack-charmers-archive/charms/trusty/glance/next
- Trusty Tahr (14.04)
- public-endpoint-host
- Merge into next
Proposed by
Billy Olsen
Status: | Merged |
---|---|
Merged at revision: | 119 |
Proposed branch: | lp:~billy-olsen/charms/trusty/glance/public-endpoint-host |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/glance/next |
Diff against target: |
761 lines (+321/-87) 9 files modified
config.yaml (+10/-0) hooks/charmhelpers/contrib/hahelpers/cluster.py (+25/-0) hooks/charmhelpers/contrib/openstack/ip.py (+49/-44) hooks/charmhelpers/contrib/openstack/neutron.py (+10/-5) hooks/charmhelpers/core/hookenv.py (+147/-10) hooks/charmhelpers/core/host.py (+1/-1) hooks/charmhelpers/core/services/base.py (+32/-11) hooks/charmhelpers/fetch/__init__.py (+1/-1) unit_tests/test_glance_relations.py (+46/-15) |
To merge this branch: | bzr merge lp:~billy-olsen/charms/trusty/glance/public-endpoint-host |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Corey Bryant (community) | Approve | ||
Review via email: mp+261009@code.launchpad.net |
Commit message
Description of the change
Provides a config option which allows the user to specify the public hostname used to advertise to keystone when creating endpoints.
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4727 glance-next for billy-olsen mp261009
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4453 glance-next for billy-olsen mp261009
AMULET OK: passed
Build: http://
- 121. By Billy Olsen
-
c-h sync
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #5071 glance-next for billy-olsen mp261009
LINT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4750 glance-next for billy-olsen mp261009
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4478 glance-next for billy-olsen mp261009
AMULET OK: passed
Build: http://
Revision history for this message
Corey Bryant (corey.bryant) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'config.yaml' | |||
2 | --- config.yaml 2015-04-01 16:48:59 +0000 | |||
3 | +++ config.yaml 2015-06-04 23:12:46 +0000 | |||
4 | @@ -176,6 +176,16 @@ | |||
5 | 176 | 192.168.0.0/24) | 176 | 192.168.0.0/24) |
6 | 177 | . | 177 | . |
7 | 178 | This network will be used for public endpoints. | 178 | This network will be used for public endpoints. |
8 | 179 | os-public-hostname: | ||
9 | 180 | type: string | ||
10 | 181 | default: | ||
11 | 182 | description: | | ||
12 | 183 | The hostname or address of the public endpoints created for glance | ||
13 | 184 | in the keystone identity provider. | ||
14 | 185 | . | ||
15 | 186 | This value will be used for public endpoints. For example, an | ||
16 | 187 | os-public-hostname set to 'glance.example.com' with ssl enabled will | ||
17 | 188 | create a public endpoint for glance of https://glance.example.com:9292/ | ||
18 | 179 | prefer-ipv6: | 189 | prefer-ipv6: |
19 | 180 | type: boolean | 190 | type: boolean |
20 | 181 | default: False | 191 | default: False |
21 | 182 | 192 | ||
22 | === modified file 'hooks/charmhelpers/contrib/hahelpers/cluster.py' | |||
23 | --- hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-03-20 17:15:02 +0000 | |||
24 | +++ hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-06-04 23:12:46 +0000 | |||
25 | @@ -52,6 +52,8 @@ | |||
26 | 52 | bool_from_string, | 52 | bool_from_string, |
27 | 53 | ) | 53 | ) |
28 | 54 | 54 | ||
29 | 55 | DC_RESOURCE_NAME = 'DC' | ||
30 | 56 | |||
31 | 55 | 57 | ||
32 | 56 | class HAIncompleteConfig(Exception): | 58 | class HAIncompleteConfig(Exception): |
33 | 57 | pass | 59 | pass |
34 | @@ -95,6 +97,27 @@ | |||
35 | 95 | return False | 97 | return False |
36 | 96 | 98 | ||
37 | 97 | 99 | ||
38 | 100 | def is_crm_dc(): | ||
39 | 101 | """ | ||
40 | 102 | Determine leadership by querying the pacemaker Designated Controller | ||
41 | 103 | """ | ||
42 | 104 | cmd = ['crm', 'status'] | ||
43 | 105 | try: | ||
44 | 106 | status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) | ||
45 | 107 | if not isinstance(status, six.text_type): | ||
46 | 108 | status = six.text_type(status, "utf-8") | ||
47 | 109 | except subprocess.CalledProcessError: | ||
48 | 110 | return False | ||
49 | 111 | current_dc = '' | ||
50 | 112 | for line in status.split('\n'): | ||
51 | 113 | if line.startswith('Current DC'): | ||
52 | 114 | # Current DC: juju-lytrusty-machine-2 (168108163) - partition with quorum | ||
53 | 115 | current_dc = line.split(':')[1].split()[0] | ||
54 | 116 | if current_dc == get_unit_hostname(): | ||
55 | 117 | return True | ||
56 | 118 | return False | ||
57 | 119 | |||
58 | 120 | |||
59 | 98 | @retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound) | 121 | @retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound) |
60 | 99 | def is_crm_leader(resource, retry=False): | 122 | def is_crm_leader(resource, retry=False): |
61 | 100 | """ | 123 | """ |
62 | @@ -104,6 +127,8 @@ | |||
63 | 104 | We allow this operation to be retried to avoid the possibility of getting a | 127 | We allow this operation to be retried to avoid the possibility of getting a |
64 | 105 | false negative. See LP #1396246 for more info. | 128 | false negative. See LP #1396246 for more info. |
65 | 106 | """ | 129 | """ |
66 | 130 | if resource == DC_RESOURCE_NAME: | ||
67 | 131 | return is_crm_dc() | ||
68 | 107 | cmd = ['crm', 'resource', 'show', resource] | 132 | cmd = ['crm', 'resource', 'show', resource] |
69 | 108 | try: | 133 | try: |
70 | 109 | status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) | 134 | status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) |
71 | 110 | 135 | ||
72 | === modified file 'hooks/charmhelpers/contrib/openstack/ip.py' | |||
73 | --- hooks/charmhelpers/contrib/openstack/ip.py 2015-03-20 17:15:02 +0000 | |||
74 | +++ hooks/charmhelpers/contrib/openstack/ip.py 2015-06-04 23:12:46 +0000 | |||
75 | @@ -17,6 +17,7 @@ | |||
76 | 17 | from charmhelpers.core.hookenv import ( | 17 | from charmhelpers.core.hookenv import ( |
77 | 18 | config, | 18 | config, |
78 | 19 | unit_get, | 19 | unit_get, |
79 | 20 | service_name, | ||
80 | 20 | ) | 21 | ) |
81 | 21 | from charmhelpers.contrib.network.ip import ( | 22 | from charmhelpers.contrib.network.ip import ( |
82 | 22 | get_address_in_network, | 23 | get_address_in_network, |
83 | @@ -26,8 +27,6 @@ | |||
84 | 26 | ) | 27 | ) |
85 | 27 | from charmhelpers.contrib.hahelpers.cluster import is_clustered | 28 | from charmhelpers.contrib.hahelpers.cluster import is_clustered |
86 | 28 | 29 | ||
87 | 29 | from functools import partial | ||
88 | 30 | |||
89 | 31 | PUBLIC = 'public' | 30 | PUBLIC = 'public' |
90 | 32 | INTERNAL = 'int' | 31 | INTERNAL = 'int' |
91 | 33 | ADMIN = 'admin' | 32 | ADMIN = 'admin' |
92 | @@ -35,15 +34,18 @@ | |||
93 | 35 | ADDRESS_MAP = { | 34 | ADDRESS_MAP = { |
94 | 36 | PUBLIC: { | 35 | PUBLIC: { |
95 | 37 | 'config': 'os-public-network', | 36 | 'config': 'os-public-network', |
97 | 38 | 'fallback': 'public-address' | 37 | 'fallback': 'public-address', |
98 | 38 | 'override': 'os-public-hostname', | ||
99 | 39 | }, | 39 | }, |
100 | 40 | INTERNAL: { | 40 | INTERNAL: { |
101 | 41 | 'config': 'os-internal-network', | 41 | 'config': 'os-internal-network', |
103 | 42 | 'fallback': 'private-address' | 42 | 'fallback': 'private-address', |
104 | 43 | 'override': 'os-internal-hostname', | ||
105 | 43 | }, | 44 | }, |
106 | 44 | ADMIN: { | 45 | ADMIN: { |
107 | 45 | 'config': 'os-admin-network', | 46 | 'config': 'os-admin-network', |
109 | 46 | 'fallback': 'private-address' | 47 | 'fallback': 'private-address', |
110 | 48 | 'override': 'os-admin-hostname', | ||
111 | 47 | } | 49 | } |
112 | 48 | } | 50 | } |
113 | 49 | 51 | ||
114 | @@ -57,15 +59,50 @@ | |||
115 | 57 | :param endpoint_type: str endpoint type to resolve. | 59 | :param endpoint_type: str endpoint type to resolve. |
116 | 58 | :param returns: str base URL for services on the current service unit. | 60 | :param returns: str base URL for services on the current service unit. |
117 | 59 | """ | 61 | """ |
121 | 60 | scheme = 'http' | 62 | scheme = _get_scheme(configs) |
122 | 61 | if 'https' in configs.complete_contexts(): | 63 | |
120 | 62 | scheme = 'https' | ||
123 | 63 | address = resolve_address(endpoint_type) | 64 | address = resolve_address(endpoint_type) |
124 | 64 | if is_ipv6(address): | 65 | if is_ipv6(address): |
125 | 65 | address = "[{}]".format(address) | 66 | address = "[{}]".format(address) |
126 | 67 | |||
127 | 66 | return '%s://%s' % (scheme, address) | 68 | return '%s://%s' % (scheme, address) |
128 | 67 | 69 | ||
129 | 68 | 70 | ||
130 | 71 | def _get_scheme(configs): | ||
131 | 72 | """Returns the scheme to use for the url (either http or https) | ||
132 | 73 | depending upon whether https is in the configs value. | ||
133 | 74 | |||
134 | 75 | :param configs: OSTemplateRenderer config templating object to inspect | ||
135 | 76 | for a complete https context. | ||
136 | 77 | :returns: either 'http' or 'https' depending on whether https is | ||
137 | 78 | configured within the configs context. | ||
138 | 79 | """ | ||
139 | 80 | scheme = 'http' | ||
140 | 81 | if configs and 'https' in configs.complete_contexts(): | ||
141 | 82 | scheme = 'https' | ||
142 | 83 | return scheme | ||
143 | 84 | |||
144 | 85 | |||
145 | 86 | def _get_address_override(endpoint_type=PUBLIC): | ||
146 | 87 | """Returns any address overrides that the user has defined based on the | ||
147 | 88 | endpoint type. | ||
148 | 89 | |||
149 | 90 | Note: this function allows for the service name to be inserted into the | ||
150 | 91 | address if the user specifies {service_name}.somehost.org. | ||
151 | 92 | |||
152 | 93 | :param endpoint_type: the type of endpoint to retrieve the override | ||
153 | 94 | value for. | ||
154 | 95 | :returns: any endpoint address or hostname that the user has overridden | ||
155 | 96 | or None if an override is not present. | ||
156 | 97 | """ | ||
157 | 98 | override_key = ADDRESS_MAP[endpoint_type]['override'] | ||
158 | 99 | addr_override = config(override_key) | ||
159 | 100 | if not addr_override: | ||
160 | 101 | return None | ||
161 | 102 | else: | ||
162 | 103 | return addr_override.format(service_name=service_name()) | ||
163 | 104 | |||
164 | 105 | |||
165 | 69 | def resolve_address(endpoint_type=PUBLIC): | 106 | def resolve_address(endpoint_type=PUBLIC): |
166 | 70 | """Return unit address depending on net config. | 107 | """Return unit address depending on net config. |
167 | 71 | 108 | ||
168 | @@ -77,7 +114,10 @@ | |||
169 | 77 | 114 | ||
170 | 78 | :param endpoint_type: Network endpoing type | 115 | :param endpoint_type: Network endpoing type |
171 | 79 | """ | 116 | """ |
173 | 80 | resolved_address = None | 117 | resolved_address = _get_address_override(endpoint_type) |
174 | 118 | if resolved_address: | ||
175 | 119 | return resolved_address | ||
176 | 120 | |||
177 | 81 | vips = config('vip') | 121 | vips = config('vip') |
178 | 82 | if vips: | 122 | if vips: |
179 | 83 | vips = vips.split() | 123 | vips = vips.split() |
180 | @@ -109,38 +149,3 @@ | |||
181 | 109 | "clustered=%s)" % (net_type, clustered)) | 149 | "clustered=%s)" % (net_type, clustered)) |
182 | 110 | 150 | ||
183 | 111 | return resolved_address | 151 | return resolved_address |
184 | 112 | |||
185 | 113 | |||
186 | 114 | def endpoint_url(configs, url_template, port, endpoint_type=PUBLIC, | ||
187 | 115 | override=None): | ||
188 | 116 | """Returns the correct endpoint URL to advertise to Keystone. | ||
189 | 117 | |||
190 | 118 | This method provides the correct endpoint URL which should be advertised to | ||
191 | 119 | the keystone charm for endpoint creation. This method allows for the url to | ||
192 | 120 | be overridden to force a keystone endpoint to have specific URL for any of | ||
193 | 121 | the defined scopes (admin, internal, public). | ||
194 | 122 | |||
195 | 123 | :param configs: OSTemplateRenderer config templating object to inspect | ||
196 | 124 | for a complete https context. | ||
197 | 125 | :param url_template: str format string for creating the url template. Only | ||
198 | 126 | two values will be passed - the scheme+hostname | ||
199 | 127 | returned by the canonical_url and the port. | ||
200 | 128 | :param endpoint_type: str endpoint type to resolve. | ||
201 | 129 | :param override: str the name of the config option which overrides the | ||
202 | 130 | endpoint URL defined by the charm itself. None will | ||
203 | 131 | disable any overrides (default). | ||
204 | 132 | """ | ||
205 | 133 | if override: | ||
206 | 134 | # Return any user-defined overrides for the keystone endpoint URL. | ||
207 | 135 | user_value = config(override) | ||
208 | 136 | if user_value: | ||
209 | 137 | return user_value.strip() | ||
210 | 138 | |||
211 | 139 | return url_template % (canonical_url(configs, endpoint_type), port) | ||
212 | 140 | |||
213 | 141 | |||
214 | 142 | public_endpoint = partial(endpoint_url, endpoint_type=PUBLIC) | ||
215 | 143 | |||
216 | 144 | internal_endpoint = partial(endpoint_url, endpoint_type=INTERNAL) | ||
217 | 145 | |||
218 | 146 | admin_endpoint = partial(endpoint_url, endpoint_type=ADMIN) | ||
219 | 147 | 152 | ||
220 | === modified file 'hooks/charmhelpers/contrib/openstack/neutron.py' | |||
221 | --- hooks/charmhelpers/contrib/openstack/neutron.py 2015-04-16 19:53:49 +0000 | |||
222 | +++ hooks/charmhelpers/contrib/openstack/neutron.py 2015-06-04 23:12:46 +0000 | |||
223 | @@ -256,11 +256,14 @@ | |||
224 | 256 | def parse_mappings(mappings): | 256 | def parse_mappings(mappings): |
225 | 257 | parsed = {} | 257 | parsed = {} |
226 | 258 | if mappings: | 258 | if mappings: |
228 | 259 | mappings = mappings.split(' ') | 259 | mappings = mappings.split() |
229 | 260 | for m in mappings: | 260 | for m in mappings: |
230 | 261 | p = m.partition(':') | 261 | p = m.partition(':') |
233 | 262 | if p[1] == ':': | 262 | key = p[0].strip() |
234 | 263 | parsed[p[0].strip()] = p[2].strip() | 263 | if p[1]: |
235 | 264 | parsed[key] = p[2].strip() | ||
236 | 265 | else: | ||
237 | 266 | parsed[key] = '' | ||
238 | 264 | 267 | ||
239 | 265 | return parsed | 268 | return parsed |
240 | 266 | 269 | ||
241 | @@ -283,13 +286,13 @@ | |||
242 | 283 | Returns dict of the form {bridge:port}. | 286 | Returns dict of the form {bridge:port}. |
243 | 284 | """ | 287 | """ |
244 | 285 | _mappings = parse_mappings(mappings) | 288 | _mappings = parse_mappings(mappings) |
246 | 286 | if not _mappings: | 289 | if not _mappings or list(_mappings.values()) == ['']: |
247 | 287 | if not mappings: | 290 | if not mappings: |
248 | 288 | return {} | 291 | return {} |
249 | 289 | 292 | ||
250 | 290 | # For backwards-compatibility we need to support port-only provided in | 293 | # For backwards-compatibility we need to support port-only provided in |
251 | 291 | # config. | 294 | # config. |
253 | 292 | _mappings = {default_bridge: mappings.split(' ')[0]} | 295 | _mappings = {default_bridge: mappings.split()[0]} |
254 | 293 | 296 | ||
255 | 294 | bridges = _mappings.keys() | 297 | bridges = _mappings.keys() |
256 | 295 | ports = _mappings.values() | 298 | ports = _mappings.values() |
257 | @@ -309,6 +312,8 @@ | |||
258 | 309 | 312 | ||
259 | 310 | Mappings must be a space-delimited list of provider:start:end mappings. | 313 | Mappings must be a space-delimited list of provider:start:end mappings. |
260 | 311 | 314 | ||
261 | 315 | The start:end range is optional and may be omitted. | ||
262 | 316 | |||
263 | 312 | Returns dict of the form {provider: (start, end)}. | 317 | Returns dict of the form {provider: (start, end)}. |
264 | 313 | """ | 318 | """ |
265 | 314 | _mappings = parse_mappings(mappings) | 319 | _mappings = parse_mappings(mappings) |
266 | 315 | 320 | ||
267 | === modified file 'hooks/charmhelpers/core/hookenv.py' | |||
268 | --- hooks/charmhelpers/core/hookenv.py 2015-04-16 19:53:49 +0000 | |||
269 | +++ hooks/charmhelpers/core/hookenv.py 2015-06-04 23:12:46 +0000 | |||
270 | @@ -21,12 +21,14 @@ | |||
271 | 21 | # Charm Helpers Developers <juju@lists.ubuntu.com> | 21 | # Charm Helpers Developers <juju@lists.ubuntu.com> |
272 | 22 | 22 | ||
273 | 23 | from __future__ import print_function | 23 | from __future__ import print_function |
274 | 24 | from functools import wraps | ||
275 | 24 | import os | 25 | import os |
276 | 25 | import json | 26 | import json |
277 | 26 | import yaml | 27 | import yaml |
278 | 27 | import subprocess | 28 | import subprocess |
279 | 28 | import sys | 29 | import sys |
280 | 29 | import errno | 30 | import errno |
281 | 31 | import tempfile | ||
282 | 30 | from subprocess import CalledProcessError | 32 | from subprocess import CalledProcessError |
283 | 31 | 33 | ||
284 | 32 | import six | 34 | import six |
285 | @@ -58,15 +60,17 @@ | |||
286 | 58 | 60 | ||
287 | 59 | will cache the result of unit_get + 'test' for future calls. | 61 | will cache the result of unit_get + 'test' for future calls. |
288 | 60 | """ | 62 | """ |
289 | 63 | @wraps(func) | ||
290 | 61 | def wrapper(*args, **kwargs): | 64 | def wrapper(*args, **kwargs): |
291 | 62 | global cache | 65 | global cache |
292 | 63 | key = str((func, args, kwargs)) | 66 | key = str((func, args, kwargs)) |
293 | 64 | try: | 67 | try: |
294 | 65 | return cache[key] | 68 | return cache[key] |
295 | 66 | except KeyError: | 69 | except KeyError: |
299 | 67 | res = func(*args, **kwargs) | 70 | pass # Drop out of the exception handler scope. |
300 | 68 | cache[key] = res | 71 | res = func(*args, **kwargs) |
301 | 69 | return res | 72 | cache[key] = res |
302 | 73 | return res | ||
303 | 70 | return wrapper | 74 | return wrapper |
304 | 71 | 75 | ||
305 | 72 | 76 | ||
306 | @@ -178,7 +182,7 @@ | |||
307 | 178 | 182 | ||
308 | 179 | def remote_unit(): | 183 | def remote_unit(): |
309 | 180 | """The remote unit for the current relation hook""" | 184 | """The remote unit for the current relation hook""" |
311 | 181 | return os.environ['JUJU_REMOTE_UNIT'] | 185 | return os.environ.get('JUJU_REMOTE_UNIT', None) |
312 | 182 | 186 | ||
313 | 183 | 187 | ||
314 | 184 | def service_name(): | 188 | def service_name(): |
315 | @@ -250,6 +254,12 @@ | |||
316 | 250 | except KeyError: | 254 | except KeyError: |
317 | 251 | return (self._prev_dict or {})[key] | 255 | return (self._prev_dict or {})[key] |
318 | 252 | 256 | ||
319 | 257 | def get(self, key, default=None): | ||
320 | 258 | try: | ||
321 | 259 | return self[key] | ||
322 | 260 | except KeyError: | ||
323 | 261 | return default | ||
324 | 262 | |||
325 | 253 | def keys(self): | 263 | def keys(self): |
326 | 254 | prev_keys = [] | 264 | prev_keys = [] |
327 | 255 | if self._prev_dict is not None: | 265 | if self._prev_dict is not None: |
328 | @@ -353,18 +363,49 @@ | |||
329 | 353 | """Set relation information for the current unit""" | 363 | """Set relation information for the current unit""" |
330 | 354 | relation_settings = relation_settings if relation_settings else {} | 364 | relation_settings = relation_settings if relation_settings else {} |
331 | 355 | relation_cmd_line = ['relation-set'] | 365 | relation_cmd_line = ['relation-set'] |
332 | 366 | accepts_file = "--file" in subprocess.check_output( | ||
333 | 367 | relation_cmd_line + ["--help"], universal_newlines=True) | ||
334 | 356 | if relation_id is not None: | 368 | if relation_id is not None: |
335 | 357 | relation_cmd_line.extend(('-r', relation_id)) | 369 | relation_cmd_line.extend(('-r', relation_id)) |
342 | 358 | for k, v in (list(relation_settings.items()) + list(kwargs.items())): | 370 | settings = relation_settings.copy() |
343 | 359 | if v is None: | 371 | settings.update(kwargs) |
344 | 360 | relation_cmd_line.append('{}='.format(k)) | 372 | for key, value in settings.items(): |
345 | 361 | else: | 373 | # Force value to be a string: it always should, but some call |
346 | 362 | relation_cmd_line.append('{}={}'.format(k, v)) | 374 | # sites pass in things like dicts or numbers. |
347 | 363 | subprocess.check_call(relation_cmd_line) | 375 | if value is not None: |
348 | 376 | settings[key] = "{}".format(value) | ||
349 | 377 | if accepts_file: | ||
350 | 378 | # --file was introduced in Juju 1.23.2. Use it by default if | ||
351 | 379 | # available, since otherwise we'll break if the relation data is | ||
352 | 380 | # too big. Ideally we should tell relation-set to read the data from | ||
353 | 381 | # stdin, but that feature is broken in 1.23.2: Bug #1454678. | ||
354 | 382 | with tempfile.NamedTemporaryFile(delete=False) as settings_file: | ||
355 | 383 | settings_file.write(yaml.safe_dump(settings).encode("utf-8")) | ||
356 | 384 | subprocess.check_call( | ||
357 | 385 | relation_cmd_line + ["--file", settings_file.name]) | ||
358 | 386 | os.remove(settings_file.name) | ||
359 | 387 | else: | ||
360 | 388 | for key, value in settings.items(): | ||
361 | 389 | if value is None: | ||
362 | 390 | relation_cmd_line.append('{}='.format(key)) | ||
363 | 391 | else: | ||
364 | 392 | relation_cmd_line.append('{}={}'.format(key, value)) | ||
365 | 393 | subprocess.check_call(relation_cmd_line) | ||
366 | 364 | # Flush cache of any relation-gets for local unit | 394 | # Flush cache of any relation-gets for local unit |
367 | 365 | flush(local_unit()) | 395 | flush(local_unit()) |
368 | 366 | 396 | ||
369 | 367 | 397 | ||
370 | 398 | def relation_clear(r_id=None): | ||
371 | 399 | ''' Clears any relation data already set on relation r_id ''' | ||
372 | 400 | settings = relation_get(rid=r_id, | ||
373 | 401 | unit=local_unit()) | ||
374 | 402 | for setting in settings: | ||
375 | 403 | if setting not in ['public-address', 'private-address']: | ||
376 | 404 | settings[setting] = None | ||
377 | 405 | relation_set(relation_id=r_id, | ||
378 | 406 | **settings) | ||
379 | 407 | |||
380 | 408 | |||
381 | 368 | @cached | 409 | @cached |
382 | 369 | def relation_ids(reltype=None): | 410 | def relation_ids(reltype=None): |
383 | 370 | """A list of relation_ids""" | 411 | """A list of relation_ids""" |
384 | @@ -509,6 +550,11 @@ | |||
385 | 509 | return None | 550 | return None |
386 | 510 | 551 | ||
387 | 511 | 552 | ||
388 | 553 | def unit_public_ip(): | ||
389 | 554 | """Get this unit's public IP address""" | ||
390 | 555 | return unit_get('public-address') | ||
391 | 556 | |||
392 | 557 | |||
393 | 512 | def unit_private_ip(): | 558 | def unit_private_ip(): |
394 | 513 | """Get this unit's private IP address""" | 559 | """Get this unit's private IP address""" |
395 | 514 | return unit_get('private-address') | 560 | return unit_get('private-address') |
396 | @@ -605,3 +651,94 @@ | |||
397 | 605 | 651 | ||
398 | 606 | The results set by action_set are preserved.""" | 652 | The results set by action_set are preserved.""" |
399 | 607 | subprocess.check_call(['action-fail', message]) | 653 | subprocess.check_call(['action-fail', message]) |
400 | 654 | |||
401 | 655 | |||
402 | 656 | def status_set(workload_state, message): | ||
403 | 657 | """Set the workload state with a message | ||
404 | 658 | |||
405 | 659 | Use status-set to set the workload state with a message which is visible | ||
406 | 660 | to the user via juju status. If the status-set command is not found then | ||
407 | 661 | assume this is juju < 1.23 and juju-log the message unstead. | ||
408 | 662 | |||
409 | 663 | workload_state -- valid juju workload state. | ||
410 | 664 | message -- status update message | ||
411 | 665 | """ | ||
412 | 666 | valid_states = ['maintenance', 'blocked', 'waiting', 'active'] | ||
413 | 667 | if workload_state not in valid_states: | ||
414 | 668 | raise ValueError( | ||
415 | 669 | '{!r} is not a valid workload state'.format(workload_state) | ||
416 | 670 | ) | ||
417 | 671 | cmd = ['status-set', workload_state, message] | ||
418 | 672 | try: | ||
419 | 673 | ret = subprocess.call(cmd) | ||
420 | 674 | if ret == 0: | ||
421 | 675 | return | ||
422 | 676 | except OSError as e: | ||
423 | 677 | if e.errno != errno.ENOENT: | ||
424 | 678 | raise | ||
425 | 679 | log_message = 'status-set failed: {} {}'.format(workload_state, | ||
426 | 680 | message) | ||
427 | 681 | log(log_message, level='INFO') | ||
428 | 682 | |||
429 | 683 | |||
430 | 684 | def status_get(): | ||
431 | 685 | """Retrieve the previously set juju workload state | ||
432 | 686 | |||
433 | 687 | If the status-set command is not found then assume this is juju < 1.23 and | ||
434 | 688 | return 'unknown' | ||
435 | 689 | """ | ||
436 | 690 | cmd = ['status-get'] | ||
437 | 691 | try: | ||
438 | 692 | raw_status = subprocess.check_output(cmd, universal_newlines=True) | ||
439 | 693 | status = raw_status.rstrip() | ||
440 | 694 | return status | ||
441 | 695 | except OSError as e: | ||
442 | 696 | if e.errno == errno.ENOENT: | ||
443 | 697 | return 'unknown' | ||
444 | 698 | else: | ||
445 | 699 | raise | ||
446 | 700 | |||
447 | 701 | |||
448 | 702 | def translate_exc(from_exc, to_exc): | ||
449 | 703 | def inner_translate_exc1(f): | ||
450 | 704 | def inner_translate_exc2(*args, **kwargs): | ||
451 | 705 | try: | ||
452 | 706 | return f(*args, **kwargs) | ||
453 | 707 | except from_exc: | ||
454 | 708 | raise to_exc | ||
455 | 709 | |||
456 | 710 | return inner_translate_exc2 | ||
457 | 711 | |||
458 | 712 | return inner_translate_exc1 | ||
459 | 713 | |||
460 | 714 | |||
461 | 715 | @translate_exc(from_exc=OSError, to_exc=NotImplementedError) | ||
462 | 716 | def is_leader(): | ||
463 | 717 | """Does the current unit hold the juju leadership | ||
464 | 718 | |||
465 | 719 | Uses juju to determine whether the current unit is the leader of its peers | ||
466 | 720 | """ | ||
467 | 721 | cmd = ['is-leader', '--format=json'] | ||
468 | 722 | return json.loads(subprocess.check_output(cmd).decode('UTF-8')) | ||
469 | 723 | |||
470 | 724 | |||
471 | 725 | @translate_exc(from_exc=OSError, to_exc=NotImplementedError) | ||
472 | 726 | def leader_get(attribute=None): | ||
473 | 727 | """Juju leader get value(s)""" | ||
474 | 728 | cmd = ['leader-get', '--format=json'] + [attribute or '-'] | ||
475 | 729 | return json.loads(subprocess.check_output(cmd).decode('UTF-8')) | ||
476 | 730 | |||
477 | 731 | |||
478 | 732 | @translate_exc(from_exc=OSError, to_exc=NotImplementedError) | ||
479 | 733 | def leader_set(settings=None, **kwargs): | ||
480 | 734 | """Juju leader set value(s)""" | ||
481 | 735 | log("Juju leader-set '%s'" % (settings), level=DEBUG) | ||
482 | 736 | cmd = ['leader-set'] | ||
483 | 737 | settings = settings or {} | ||
484 | 738 | settings.update(kwargs) | ||
485 | 739 | for k, v in settings.iteritems(): | ||
486 | 740 | if v is None: | ||
487 | 741 | cmd.append('{}='.format(k)) | ||
488 | 742 | else: | ||
489 | 743 | cmd.append('{}={}'.format(k, v)) | ||
490 | 744 | subprocess.check_call(cmd) | ||
491 | 608 | 745 | ||
492 | === modified file 'hooks/charmhelpers/core/host.py' | |||
493 | --- hooks/charmhelpers/core/host.py 2015-03-20 17:15:02 +0000 | |||
494 | +++ hooks/charmhelpers/core/host.py 2015-06-04 23:12:46 +0000 | |||
495 | @@ -90,7 +90,7 @@ | |||
496 | 90 | ['service', service_name, 'status'], | 90 | ['service', service_name, 'status'], |
497 | 91 | stderr=subprocess.STDOUT).decode('UTF-8') | 91 | stderr=subprocess.STDOUT).decode('UTF-8') |
498 | 92 | except subprocess.CalledProcessError as e: | 92 | except subprocess.CalledProcessError as e: |
500 | 93 | return 'unrecognized service' not in e.output | 93 | return b'unrecognized service' not in e.output |
501 | 94 | else: | 94 | else: |
502 | 95 | return True | 95 | return True |
503 | 96 | 96 | ||
504 | 97 | 97 | ||
505 | === modified file 'hooks/charmhelpers/core/services/base.py' | |||
506 | --- hooks/charmhelpers/core/services/base.py 2015-03-20 17:15:02 +0000 | |||
507 | +++ hooks/charmhelpers/core/services/base.py 2015-06-04 23:12:46 +0000 | |||
508 | @@ -15,9 +15,9 @@ | |||
509 | 15 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
510 | 16 | 16 | ||
511 | 17 | import os | 17 | import os |
512 | 18 | import re | ||
513 | 19 | import json | 18 | import json |
515 | 20 | from collections import Iterable | 19 | from inspect import getargspec |
516 | 20 | from collections import Iterable, OrderedDict | ||
517 | 21 | 21 | ||
518 | 22 | from charmhelpers.core import host | 22 | from charmhelpers.core import host |
519 | 23 | from charmhelpers.core import hookenv | 23 | from charmhelpers.core import hookenv |
520 | @@ -119,7 +119,7 @@ | |||
521 | 119 | """ | 119 | """ |
522 | 120 | self._ready_file = os.path.join(hookenv.charm_dir(), 'READY-SERVICES.json') | 120 | self._ready_file = os.path.join(hookenv.charm_dir(), 'READY-SERVICES.json') |
523 | 121 | self._ready = None | 121 | self._ready = None |
525 | 122 | self.services = {} | 122 | self.services = OrderedDict() |
526 | 123 | for service in services or []: | 123 | for service in services or []: |
527 | 124 | service_name = service['service'] | 124 | service_name = service['service'] |
528 | 125 | self.services[service_name] = service | 125 | self.services[service_name] = service |
529 | @@ -132,8 +132,8 @@ | |||
530 | 132 | if hook_name == 'stop': | 132 | if hook_name == 'stop': |
531 | 133 | self.stop_services() | 133 | self.stop_services() |
532 | 134 | else: | 134 | else: |
533 | 135 | self.reconfigure_services() | ||
534 | 135 | self.provide_data() | 136 | self.provide_data() |
535 | 136 | self.reconfigure_services() | ||
536 | 137 | cfg = hookenv.config() | 137 | cfg = hookenv.config() |
537 | 138 | if cfg.implicit_save: | 138 | if cfg.implicit_save: |
538 | 139 | cfg.save() | 139 | cfg.save() |
539 | @@ -145,15 +145,36 @@ | |||
540 | 145 | A provider must have a `name` attribute, which indicates which relation | 145 | A provider must have a `name` attribute, which indicates which relation |
541 | 146 | to set data on, and a `provide_data()` method, which returns a dict of | 146 | to set data on, and a `provide_data()` method, which returns a dict of |
542 | 147 | data to set. | 147 | data to set. |
543 | 148 | |||
544 | 149 | The `provide_data()` method can optionally accept two parameters: | ||
545 | 150 | |||
546 | 151 | * ``remote_service`` The name of the remote service that the data will | ||
547 | 152 | be provided to. The `provide_data()` method will be called once | ||
548 | 153 | for each connected service (not unit). This allows the method to | ||
549 | 154 | tailor its data to the given service. | ||
550 | 155 | * ``service_ready`` Whether or not the service definition had all of | ||
551 | 156 | its requirements met, and thus the ``data_ready`` callbacks run. | ||
552 | 157 | |||
553 | 158 | Note that the ``provided_data`` methods are now called **after** the | ||
554 | 159 | ``data_ready`` callbacks are run. This gives the ``data_ready`` callbacks | ||
555 | 160 | a chance to generate any data necessary for the providing to the remote | ||
556 | 161 | services. | ||
557 | 148 | """ | 162 | """ |
560 | 149 | hook_name = hookenv.hook_name() | 163 | for service_name, service in self.services.items(): |
561 | 150 | for service in self.services.values(): | 164 | service_ready = self.is_ready(service_name) |
562 | 151 | for provider in service.get('provided_data', []): | 165 | for provider in service.get('provided_data', []): |
568 | 152 | if re.match(r'{}-relation-(joined|changed)'.format(provider.name), hook_name): | 166 | for relid in hookenv.relation_ids(provider.name): |
569 | 153 | data = provider.provide_data() | 167 | units = hookenv.related_units(relid) |
570 | 154 | _ready = provider._is_ready(data) if hasattr(provider, '_is_ready') else data | 168 | if not units: |
571 | 155 | if _ready: | 169 | continue |
572 | 156 | hookenv.relation_set(None, data) | 170 | remote_service = units[0].split('/')[0] |
573 | 171 | argspec = getargspec(provider.provide_data) | ||
574 | 172 | if len(argspec.args) > 1: | ||
575 | 173 | data = provider.provide_data(remote_service, service_ready) | ||
576 | 174 | else: | ||
577 | 175 | data = provider.provide_data() | ||
578 | 176 | if data: | ||
579 | 177 | hookenv.relation_set(relid, data) | ||
580 | 157 | 178 | ||
581 | 158 | def reconfigure_services(self, *service_names): | 179 | def reconfigure_services(self, *service_names): |
582 | 159 | """ | 180 | """ |
583 | 160 | 181 | ||
584 | === modified file 'hooks/charmhelpers/fetch/__init__.py' | |||
585 | --- hooks/charmhelpers/fetch/__init__.py 2015-05-01 14:56:06 +0000 | |||
586 | +++ hooks/charmhelpers/fetch/__init__.py 2015-06-04 23:12:46 +0000 | |||
587 | @@ -158,7 +158,7 @@ | |||
588 | 158 | 158 | ||
589 | 159 | def apt_cache(in_memory=True): | 159 | def apt_cache(in_memory=True): |
590 | 160 | """Build and return an apt cache""" | 160 | """Build and return an apt cache""" |
592 | 161 | import apt_pkg | 161 | from apt import apt_pkg |
593 | 162 | apt_pkg.init() | 162 | apt_pkg.init() |
594 | 163 | if in_memory: | 163 | if in_memory: |
595 | 164 | apt_pkg.config.set("Dir::Cache::pkgcache", "") | 164 | apt_pkg.config.set("Dir::Cache::pkgcache", "") |
596 | 165 | 165 | ||
597 | === modified file 'unit_tests/test_glance_relations.py' | |||
598 | --- unit_tests/test_glance_relations.py 2015-05-12 19:46:43 +0000 | |||
599 | +++ unit_tests/test_glance_relations.py 2015-06-04 23:12:46 +0000 | |||
600 | @@ -24,7 +24,6 @@ | |||
601 | 24 | TO_PATCH = [ | 24 | TO_PATCH = [ |
602 | 25 | # charmhelpers.core.hookenv | 25 | # charmhelpers.core.hookenv |
603 | 26 | 'Hooks', | 26 | 'Hooks', |
604 | 27 | 'canonical_url', | ||
605 | 28 | 'config', | 27 | 'config', |
606 | 29 | 'juju_log', | 28 | 'juju_log', |
607 | 30 | 'is_relation_made', | 29 | 'is_relation_made', |
608 | @@ -320,8 +319,9 @@ | |||
609 | 320 | ) | 319 | ) |
610 | 321 | self.migrate_database.assert_called_with() | 320 | self.migrate_database.assert_called_with() |
611 | 322 | 321 | ||
614 | 323 | def test_image_service_joined_leader(self): | 322 | @patch.object(relations, 'canonical_url') |
615 | 324 | self.canonical_url.return_value = 'http://glancehost' | 323 | def test_image_service_joined_leader(self, _canonical_url): |
616 | 324 | _canonical_url.return_value = 'http://glancehost' | ||
617 | 325 | relations.image_service_joined() | 325 | relations.image_service_joined() |
618 | 326 | args = { | 326 | args = { |
619 | 327 | 'glance-api-server': 'http://glancehost:9292', | 327 | 'glance-api-server': 'http://glancehost:9292', |
620 | @@ -329,8 +329,9 @@ | |||
621 | 329 | } | 329 | } |
622 | 330 | self.relation_set.assert_called_with(**args) | 330 | self.relation_set.assert_called_with(**args) |
623 | 331 | 331 | ||
626 | 332 | def test_image_service_joined_specified_interface(self): | 332 | @patch.object(relations, 'canonical_url') |
627 | 333 | self.canonical_url.return_value = 'http://glancehost' | 333 | def test_image_service_joined_specified_interface(self, _canonical_url): |
628 | 334 | _canonical_url.return_value = 'http://glancehost' | ||
629 | 334 | relations.image_service_joined(relation_id='image-service:1') | 335 | relations.image_service_joined(relation_id='image-service:1') |
630 | 335 | args = { | 336 | args = { |
631 | 336 | 'glance-api-server': 'http://glancehost:9292', | 337 | 'glance-api-server': 'http://glancehost:9292', |
632 | @@ -417,10 +418,12 @@ | |||
633 | 417 | for c in [call('/etc/glance/glance.conf')]: | 418 | for c in [call('/etc/glance/glance.conf')]: |
634 | 418 | self.assertNotIn(c, configs.write.call_args_list) | 419 | self.assertNotIn(c, configs.write.call_args_list) |
635 | 419 | 420 | ||
636 | 421 | @patch("charmhelpers.core.host.service") | ||
637 | 420 | @patch("glance_relations.relation_get", autospec=True) | 422 | @patch("glance_relations.relation_get", autospec=True) |
638 | 421 | @patch.object(relations, 'CONFIGS') | 423 | @patch.object(relations, 'CONFIGS') |
639 | 422 | def test_ceph_changed_with_key_and_relation_data(self, configs, | 424 | def test_ceph_changed_with_key_and_relation_data(self, configs, |
641 | 423 | mock_relation_get): | 425 | mock_relation_get, |
642 | 426 | mock_service): | ||
643 | 424 | configs.complete_contexts = MagicMock() | 427 | configs.complete_contexts = MagicMock() |
644 | 425 | configs.complete_contexts.return_value = ['ceph'] | 428 | configs.complete_contexts.return_value = ['ceph'] |
645 | 426 | configs.write = MagicMock() | 429 | configs.write = MagicMock() |
646 | @@ -439,8 +442,9 @@ | |||
647 | 439 | self.delete_keyring.assert_called_with(service='glance') | 442 | self.delete_keyring.assert_called_with(service='glance') |
648 | 440 | self.assertTrue(configs.write_all.called) | 443 | self.assertTrue(configs.write_all.called) |
649 | 441 | 444 | ||
652 | 442 | def test_keystone_joined(self): | 445 | @patch.object(relations, 'canonical_url') |
653 | 443 | self.canonical_url.return_value = 'http://glancehost' | 446 | def test_keystone_joined(self, _canonical_url): |
654 | 447 | _canonical_url.return_value = 'http://glancehost' | ||
655 | 444 | relations.keystone_joined() | 448 | relations.keystone_joined() |
656 | 445 | ex = { | 449 | ex = { |
657 | 446 | 'region': 'RegionOne', | 450 | 'region': 'RegionOne', |
658 | @@ -452,8 +456,9 @@ | |||
659 | 452 | } | 456 | } |
660 | 453 | self.relation_set.assert_called_with(**ex) | 457 | self.relation_set.assert_called_with(**ex) |
661 | 454 | 458 | ||
664 | 455 | def test_keystone_joined_with_relation_id(self): | 459 | @patch.object(relations, 'canonical_url') |
665 | 456 | self.canonical_url.return_value = 'http://glancehost' | 460 | def test_keystone_joined_with_relation_id(self, _canonical_url): |
666 | 461 | _canonical_url.return_value = 'http://glancehost' | ||
667 | 457 | relations.keystone_joined(relation_id='identity-service:0') | 462 | relations.keystone_joined(relation_id='identity-service:0') |
668 | 458 | ex = { | 463 | ex = { |
669 | 459 | 'region': 'RegionOne', | 464 | 'region': 'RegionOne', |
670 | @@ -465,6 +470,26 @@ | |||
671 | 465 | } | 470 | } |
672 | 466 | self.relation_set.assert_called_with(**ex) | 471 | self.relation_set.assert_called_with(**ex) |
673 | 467 | 472 | ||
674 | 473 | @patch('charmhelpers.contrib.openstack.ip.is_clustered') | ||
675 | 474 | @patch('charmhelpers.contrib.openstack.ip.unit_get') | ||
676 | 475 | @patch('charmhelpers.contrib.openstack.ip.config') | ||
677 | 476 | def test_keystone_joined_public_endpoint(self, _config, _unit_get, | ||
678 | 477 | _is_clustered): | ||
679 | 478 | _unit_get.return_value = 'glancehost' | ||
680 | 479 | _is_clustered.return_value = False | ||
681 | 480 | self.test_config.set('os-public-hostname', 'glance.example.com') | ||
682 | 481 | _config.side_effect = self.test_config.get | ||
683 | 482 | relations.keystone_joined() | ||
684 | 483 | ex = { | ||
685 | 484 | 'region': 'RegionOne', | ||
686 | 485 | 'public_url': 'http://glance.example.com:9292', | ||
687 | 486 | 'admin_url': 'http://glancehost:9292', | ||
688 | 487 | 'service': 'glance', | ||
689 | 488 | 'internal_url': 'http://glancehost:9292', | ||
690 | 489 | 'relation_id': None, | ||
691 | 490 | } | ||
692 | 491 | self.relation_set.assert_called_with(**ex) | ||
693 | 492 | |||
694 | 468 | @patch.object(relations, 'CONFIGS') | 493 | @patch.object(relations, 'CONFIGS') |
695 | 469 | def test_keystone_changes_incomplete(self, configs): | 494 | def test_keystone_changes_incomplete(self, configs): |
696 | 470 | configs.complete_contexts.return_value = [] | 495 | configs.complete_contexts.return_value = [] |
697 | @@ -570,9 +595,11 @@ | |||
698 | 570 | call('/etc/haproxy/haproxy.cfg')], | 595 | call('/etc/haproxy/haproxy.cfg')], |
699 | 571 | configs.write.call_args_list) | 596 | configs.write.call_args_list) |
700 | 572 | 597 | ||
701 | 598 | @patch.object(relations, 'canonical_url') | ||
702 | 573 | @patch.object(relations, 'relation_set') | 599 | @patch.object(relations, 'relation_set') |
703 | 574 | @patch.object(relations, 'CONFIGS') | 600 | @patch.object(relations, 'CONFIGS') |
705 | 575 | def test_cluster_changed_with_ipv6(self, configs, relation_set): | 601 | def test_cluster_changed_with_ipv6(self, configs, relation_set, |
706 | 602 | _canonical_url): | ||
707 | 576 | self.test_config.set('prefer-ipv6', True) | 603 | self.test_config.set('prefer-ipv6', True) |
708 | 577 | configs.complete_contexts = MagicMock() | 604 | configs.complete_contexts = MagicMock() |
709 | 578 | configs.complete_contexts.return_value = ['cluster'] | 605 | configs.complete_contexts.return_value = ['cluster'] |
710 | @@ -683,10 +710,11 @@ | |||
711 | 683 | 'ha_changed: hacluster subordinate is not fully clustered.' | 710 | 'ha_changed: hacluster subordinate is not fully clustered.' |
712 | 684 | ) | 711 | ) |
713 | 685 | 712 | ||
714 | 713 | @patch.object(relations, 'canonical_url') | ||
715 | 686 | @patch.object(relations, 'keystone_joined') | 714 | @patch.object(relations, 'keystone_joined') |
716 | 687 | @patch.object(relations, 'CONFIGS') | 715 | @patch.object(relations, 'CONFIGS') |
717 | 688 | def test_configure_https_enable_with_identity_service( | 716 | def test_configure_https_enable_with_identity_service( |
719 | 689 | self, configs, keystone_joined): | 717 | self, configs, keystone_joined, _canonical_url): |
720 | 690 | configs.complete_contexts = MagicMock() | 718 | configs.complete_contexts = MagicMock() |
721 | 691 | configs.complete_contexts.return_value = ['https'] | 719 | configs.complete_contexts.return_value = ['https'] |
722 | 692 | configs.write = MagicMock() | 720 | configs.write = MagicMock() |
723 | @@ -697,10 +725,11 @@ | |||
724 | 697 | self.check_call.assert_called_has_calls(calls) | 725 | self.check_call.assert_called_has_calls(calls) |
725 | 698 | keystone_joined.assert_called_with(relation_id='identity-service:0') | 726 | keystone_joined.assert_called_with(relation_id='identity-service:0') |
726 | 699 | 727 | ||
727 | 728 | @patch.object(relations, 'canonical_url') | ||
728 | 700 | @patch.object(relations, 'keystone_joined') | 729 | @patch.object(relations, 'keystone_joined') |
729 | 701 | @patch.object(relations, 'CONFIGS') | 730 | @patch.object(relations, 'CONFIGS') |
730 | 702 | def test_configure_https_disable_with_keystone_joined( | 731 | def test_configure_https_disable_with_keystone_joined( |
732 | 703 | self, configs, keystone_joined): | 732 | self, configs, keystone_joined, _canonical_url): |
733 | 704 | configs.complete_contexts = MagicMock() | 733 | configs.complete_contexts = MagicMock() |
734 | 705 | configs.complete_contexts.return_value = [''] | 734 | configs.complete_contexts.return_value = [''] |
735 | 706 | configs.write = MagicMock() | 735 | configs.write = MagicMock() |
736 | @@ -711,10 +740,11 @@ | |||
737 | 711 | self.check_call.assert_called_has_calls(calls) | 740 | self.check_call.assert_called_has_calls(calls) |
738 | 712 | keystone_joined.assert_called_with(relation_id='identity-service:0') | 741 | keystone_joined.assert_called_with(relation_id='identity-service:0') |
739 | 713 | 742 | ||
740 | 743 | @patch.object(relations, 'canonical_url') | ||
741 | 714 | @patch.object(relations, 'image_service_joined') | 744 | @patch.object(relations, 'image_service_joined') |
742 | 715 | @patch.object(relations, 'CONFIGS') | 745 | @patch.object(relations, 'CONFIGS') |
743 | 716 | def test_configure_https_enable_with_image_service( | 746 | def test_configure_https_enable_with_image_service( |
745 | 717 | self, configs, image_service_joined): | 747 | self, configs, image_service_joined, _canonical_url): |
746 | 718 | configs.complete_contexts = MagicMock() | 748 | configs.complete_contexts = MagicMock() |
747 | 719 | configs.complete_contexts.return_value = ['https'] | 749 | configs.complete_contexts.return_value = ['https'] |
748 | 720 | configs.write = MagicMock() | 750 | configs.write = MagicMock() |
749 | @@ -725,10 +755,11 @@ | |||
750 | 725 | self.check_call.assert_called_has_calls(calls) | 755 | self.check_call.assert_called_has_calls(calls) |
751 | 726 | image_service_joined.assert_called_with(relation_id='image-service:0') | 756 | image_service_joined.assert_called_with(relation_id='image-service:0') |
752 | 727 | 757 | ||
753 | 758 | @patch.object(relations, 'canonical_url') | ||
754 | 728 | @patch.object(relations, 'image_service_joined') | 759 | @patch.object(relations, 'image_service_joined') |
755 | 729 | @patch.object(relations, 'CONFIGS') | 760 | @patch.object(relations, 'CONFIGS') |
756 | 730 | def test_configure_https_disable_with_image_service( | 761 | def test_configure_https_disable_with_image_service( |
758 | 731 | self, configs, image_service_joined): | 762 | self, configs, image_service_joined, _canonical_url): |
759 | 732 | configs.complete_contexts = MagicMock() | 763 | configs.complete_contexts = MagicMock() |
760 | 733 | configs.complete_contexts.return_value = [''] | 764 | configs.complete_contexts.return_value = [''] |
761 | 734 | configs.write = MagicMock() | 765 | configs.write = MagicMock() |
charm_lint_check #5047 glance-next for billy-olsen mp261009
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/5047/