Merge lp:~james-page/charms/trusty/cinder-ceph/lp1535062-stable into lp:~openstack-charmers-archive/charms/precise/cinder-ceph/trunk
- Trusty Tahr (14.04)
- lp1535062-stable
- Merge into trunk
Proposed by
James Page
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 40 | ||||
Proposed branch: | lp:~james-page/charms/trusty/cinder-ceph/lp1535062-stable | ||||
Merge into: | lp:~openstack-charmers-archive/charms/precise/cinder-ceph/trunk | ||||
Diff against target: |
572 lines (+286/-26) 7 files modified
hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+100/-1) hooks/charmhelpers/contrib/openstack/amulet/utils.py (+25/-3) hooks/charmhelpers/contrib/openstack/utils.py (+22/-17) hooks/charmhelpers/core/host.py (+12/-1) hooks/charmhelpers/core/hugepage.py (+2/-0) tests/charmhelpers/contrib/openstack/amulet/deployment.py (+100/-1) tests/charmhelpers/contrib/openstack/amulet/utils.py (+25/-3) |
||||
To merge this branch: | bzr merge lp:~james-page/charms/trusty/cinder-ceph/lp1535062-stable | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
charmers | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
uosci-testing-bot (uosci-testing-bot) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #16560 cinder-ceph for james-page mp283188
UNIT OK: passed
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #8927 cinder-ceph for james-page mp283188
AMULET OK: passed
Build: http://
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hooks/charmhelpers/contrib/openstack/amulet/deployment.py' |
2 | --- hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2015-10-22 13:19:37 +0000 |
3 | +++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-19 17:24:47 +0000 |
4 | @@ -14,12 +14,18 @@ |
5 | # You should have received a copy of the GNU Lesser General Public License |
6 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
7 | |
8 | +import logging |
9 | +import re |
10 | +import sys |
11 | import six |
12 | from collections import OrderedDict |
13 | from charmhelpers.contrib.amulet.deployment import ( |
14 | AmuletDeployment |
15 | ) |
16 | |
17 | +DEBUG = logging.DEBUG |
18 | +ERROR = logging.ERROR |
19 | + |
20 | |
21 | class OpenStackAmuletDeployment(AmuletDeployment): |
22 | """OpenStack amulet deployment. |
23 | @@ -28,9 +34,12 @@ |
24 | that is specifically for use by OpenStack charms. |
25 | """ |
26 | |
27 | - def __init__(self, series=None, openstack=None, source=None, stable=True): |
28 | + def __init__(self, series=None, openstack=None, source=None, |
29 | + stable=True, log_level=DEBUG): |
30 | """Initialize the deployment environment.""" |
31 | super(OpenStackAmuletDeployment, self).__init__(series) |
32 | + self.log = self.get_logger(level=log_level) |
33 | + self.log.info('OpenStackAmuletDeployment: init') |
34 | self.openstack = openstack |
35 | self.source = source |
36 | self.stable = stable |
37 | @@ -38,6 +47,22 @@ |
38 | # out. |
39 | self.current_next = "trusty" |
40 | |
41 | + def get_logger(self, name="deployment-logger", level=logging.DEBUG): |
42 | + """Get a logger object that will log to stdout.""" |
43 | + log = logging |
44 | + logger = log.getLogger(name) |
45 | + fmt = log.Formatter("%(asctime)s %(funcName)s " |
46 | + "%(levelname)s: %(message)s") |
47 | + |
48 | + handler = log.StreamHandler(stream=sys.stdout) |
49 | + handler.setLevel(level) |
50 | + handler.setFormatter(fmt) |
51 | + |
52 | + logger.addHandler(handler) |
53 | + logger.setLevel(level) |
54 | + |
55 | + return logger |
56 | + |
57 | def _determine_branch_locations(self, other_services): |
58 | """Determine the branch locations for the other services. |
59 | |
60 | @@ -45,6 +70,8 @@ |
61 | stable or next (dev) branch, and based on this, use the corresonding |
62 | stable or next branches for the other_services.""" |
63 | |
64 | + self.log.info('OpenStackAmuletDeployment: determine branch locations') |
65 | + |
66 | # Charms outside the lp:~openstack-charmers namespace |
67 | base_charms = ['mysql', 'mongodb', 'nrpe'] |
68 | |
69 | @@ -82,6 +109,8 @@ |
70 | |
71 | def _add_services(self, this_service, other_services): |
72 | """Add services to the deployment and set openstack-origin/source.""" |
73 | + self.log.info('OpenStackAmuletDeployment: adding services') |
74 | + |
75 | other_services = self._determine_branch_locations(other_services) |
76 | |
77 | super(OpenStackAmuletDeployment, self)._add_services(this_service, |
78 | @@ -111,9 +140,79 @@ |
79 | |
80 | def _configure_services(self, configs): |
81 | """Configure all of the services.""" |
82 | + self.log.info('OpenStackAmuletDeployment: configure services') |
83 | for service, config in six.iteritems(configs): |
84 | self.d.configure(service, config) |
85 | |
86 | + def _auto_wait_for_status(self, message=None, exclude_services=None, |
87 | + include_only=None, timeout=1800): |
88 | + """Wait for all units to have a specific extended status, except |
89 | + for any defined as excluded. Unless specified via message, any |
90 | + status containing any case of 'ready' will be considered a match. |
91 | + |
92 | + Examples of message usage: |
93 | + |
94 | + Wait for all unit status to CONTAIN any case of 'ready' or 'ok': |
95 | + message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE) |
96 | + |
97 | + Wait for all units to reach this status (exact match): |
98 | + message = re.compile('^Unit is ready and clustered$') |
99 | + |
100 | + Wait for all units to reach any one of these (exact match): |
101 | + message = re.compile('Unit is ready|OK|Ready') |
102 | + |
103 | + Wait for at least one unit to reach this status (exact match): |
104 | + message = {'ready'} |
105 | + |
106 | + See Amulet's sentry.wait_for_messages() for message usage detail. |
107 | + https://github.com/juju/amulet/blob/master/amulet/sentry.py |
108 | + |
109 | + :param message: Expected status match |
110 | + :param exclude_services: List of juju service names to ignore, |
111 | + not to be used in conjuction with include_only. |
112 | + :param include_only: List of juju service names to exclusively check, |
113 | + not to be used in conjuction with exclude_services. |
114 | + :param timeout: Maximum time in seconds to wait for status match |
115 | + :returns: None. Raises if timeout is hit. |
116 | + """ |
117 | + self.log.info('Waiting for extended status on units...') |
118 | + |
119 | + all_services = self.d.services.keys() |
120 | + |
121 | + if exclude_services and include_only: |
122 | + raise ValueError('exclude_services can not be used ' |
123 | + 'with include_only') |
124 | + |
125 | + if message: |
126 | + if isinstance(message, re._pattern_type): |
127 | + match = message.pattern |
128 | + else: |
129 | + match = message |
130 | + |
131 | + self.log.debug('Custom extended status wait match: ' |
132 | + '{}'.format(match)) |
133 | + else: |
134 | + self.log.debug('Default extended status wait match: contains ' |
135 | + 'READY (case-insensitive)') |
136 | + message = re.compile('.*ready.*', re.IGNORECASE) |
137 | + |
138 | + if exclude_services: |
139 | + self.log.debug('Excluding services from extended status match: ' |
140 | + '{}'.format(exclude_services)) |
141 | + else: |
142 | + exclude_services = [] |
143 | + |
144 | + if include_only: |
145 | + services = include_only |
146 | + else: |
147 | + services = list(set(all_services) - set(exclude_services)) |
148 | + |
149 | + self.log.debug('Waiting up to {}s for extended status on services: ' |
150 | + '{}'.format(timeout, services)) |
151 | + service_messages = {service: message for service in services} |
152 | + self.d.sentry.wait_for_messages(service_messages, timeout=timeout) |
153 | + self.log.info('OK') |
154 | + |
155 | def _get_openstack_release(self): |
156 | """Get openstack release. |
157 | |
158 | |
159 | === modified file 'hooks/charmhelpers/contrib/openstack/amulet/utils.py' |
160 | --- hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-22 13:19:37 +0000 |
161 | +++ hooks/charmhelpers/contrib/openstack/amulet/utils.py 2016-01-19 17:24:47 +0000 |
162 | @@ -18,6 +18,7 @@ |
163 | import json |
164 | import logging |
165 | import os |
166 | +import re |
167 | import six |
168 | import time |
169 | import urllib |
170 | @@ -604,7 +605,22 @@ |
171 | '{}'.format(sample_type, samples)) |
172 | return None |
173 | |
174 | -# rabbitmq/amqp specific helpers: |
175 | + # rabbitmq/amqp specific helpers: |
176 | + |
177 | + def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200): |
178 | + """Wait for rmq units extended status to show cluster readiness, |
179 | + after an optional initial sleep period. Initial sleep is likely |
180 | + necessary to be effective following a config change, as status |
181 | + message may not instantly update to non-ready.""" |
182 | + |
183 | + if init_sleep: |
184 | + time.sleep(init_sleep) |
185 | + |
186 | + message = re.compile('^Unit is ready and clustered$') |
187 | + deployment._auto_wait_for_status(message=message, |
188 | + timeout=timeout, |
189 | + include_only=['rabbitmq-server']) |
190 | + |
191 | def add_rmq_test_user(self, sentry_units, |
192 | username="testuser1", password="changeme"): |
193 | """Add a test user via the first rmq juju unit, check connection as |
194 | @@ -805,7 +821,10 @@ |
195 | if port: |
196 | config['ssl_port'] = port |
197 | |
198 | - deployment.configure('rabbitmq-server', config) |
199 | + deployment.d.configure('rabbitmq-server', config) |
200 | + |
201 | + # Wait for unit status |
202 | + self.rmq_wait_for_cluster(deployment) |
203 | |
204 | # Confirm |
205 | tries = 0 |
206 | @@ -832,7 +851,10 @@ |
207 | |
208 | # Disable RMQ SSL |
209 | config = {'ssl': 'off'} |
210 | - deployment.configure('rabbitmq-server', config) |
211 | + deployment.d.configure('rabbitmq-server', config) |
212 | + |
213 | + # Wait for unit status |
214 | + self.rmq_wait_for_cluster(deployment) |
215 | |
216 | # Confirm |
217 | tries = 0 |
218 | |
219 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' |
220 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-10-22 13:19:37 +0000 |
221 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-19 17:24:47 +0000 |
222 | @@ -121,36 +121,37 @@ |
223 | ('2.2.2', 'kilo'), |
224 | ('2.3.0', 'liberty'), |
225 | ('2.4.0', 'liberty'), |
226 | + ('2.5.0', 'liberty'), |
227 | ]) |
228 | |
229 | # >= Liberty version->codename mapping |
230 | PACKAGE_CODENAMES = { |
231 | 'nova-common': OrderedDict([ |
232 | - ('12.0.0', 'liberty'), |
233 | + ('12.0', 'liberty'), |
234 | ]), |
235 | 'neutron-common': OrderedDict([ |
236 | - ('7.0.0', 'liberty'), |
237 | + ('7.0', 'liberty'), |
238 | ]), |
239 | 'cinder-common': OrderedDict([ |
240 | - ('7.0.0', 'liberty'), |
241 | + ('7.0', 'liberty'), |
242 | ]), |
243 | 'keystone': OrderedDict([ |
244 | - ('8.0.0', 'liberty'), |
245 | + ('8.0', 'liberty'), |
246 | ]), |
247 | 'horizon-common': OrderedDict([ |
248 | - ('8.0.0', 'liberty'), |
249 | + ('8.0', 'liberty'), |
250 | ]), |
251 | 'ceilometer-common': OrderedDict([ |
252 | - ('5.0.0', 'liberty'), |
253 | + ('5.0', 'liberty'), |
254 | ]), |
255 | 'heat-common': OrderedDict([ |
256 | - ('5.0.0', 'liberty'), |
257 | + ('5.0', 'liberty'), |
258 | ]), |
259 | 'glance-common': OrderedDict([ |
260 | - ('11.0.0', 'liberty'), |
261 | + ('11.0', 'liberty'), |
262 | ]), |
263 | 'openstack-dashboard': OrderedDict([ |
264 | - ('8.0.0', 'liberty'), |
265 | + ('8.0', 'liberty'), |
266 | ]), |
267 | } |
268 | |
269 | @@ -237,7 +238,14 @@ |
270 | error_out(e) |
271 | |
272 | vers = apt.upstream_version(pkg.current_ver.ver_str) |
273 | - match = re.match('^(\d+)\.(\d+)\.(\d+)', vers) |
274 | + if 'swift' in pkg.name: |
275 | + # Fully x.y.z match for swift versions |
276 | + match = re.match('^(\d+)\.(\d+)\.(\d+)', vers) |
277 | + else: |
278 | + # x.y match only for 20XX.X |
279 | + # and ignore patch level for other packages |
280 | + match = re.match('^(\d+)\.(\d+)', vers) |
281 | + |
282 | if match: |
283 | vers = match.group(0) |
284 | |
285 | @@ -249,13 +257,8 @@ |
286 | # < Liberty co-ordinated project versions |
287 | try: |
288 | if 'swift' in pkg.name: |
289 | - swift_vers = vers[:5] |
290 | - if swift_vers not in SWIFT_CODENAMES: |
291 | - # Deal with 1.10.0 upward |
292 | - swift_vers = vers[:6] |
293 | - return SWIFT_CODENAMES[swift_vers] |
294 | + return SWIFT_CODENAMES[vers] |
295 | else: |
296 | - vers = vers[:6] |
297 | return OPENSTACK_CODENAMES[vers] |
298 | except KeyError: |
299 | if not fatal: |
300 | @@ -858,7 +861,9 @@ |
301 | if charm_state != 'active' and charm_state != 'unknown': |
302 | state = workload_state_compare(state, charm_state) |
303 | if message: |
304 | - message = "{} {}".format(message, charm_message) |
305 | + charm_message = charm_message.replace("Incomplete relations: ", |
306 | + "") |
307 | + message = "{}, {}".format(message, charm_message) |
308 | else: |
309 | message = charm_message |
310 | |
311 | |
312 | === modified file 'hooks/charmhelpers/core/host.py' |
313 | --- hooks/charmhelpers/core/host.py 2015-10-22 13:19:37 +0000 |
314 | +++ hooks/charmhelpers/core/host.py 2016-01-19 17:24:47 +0000 |
315 | @@ -566,7 +566,14 @@ |
316 | os.chdir(cur) |
317 | |
318 | |
319 | -def chownr(path, owner, group, follow_links=True): |
320 | +def chownr(path, owner, group, follow_links=True, chowntopdir=False): |
321 | + """ |
322 | + Recursively change user and group ownership of files and directories |
323 | + in given path. Doesn't chown path itself by default, only its children. |
324 | + |
325 | + :param bool follow_links: Also Chown links if True |
326 | + :param bool chowntopdir: Also chown path itself if True |
327 | + """ |
328 | uid = pwd.getpwnam(owner).pw_uid |
329 | gid = grp.getgrnam(group).gr_gid |
330 | if follow_links: |
331 | @@ -574,6 +581,10 @@ |
332 | else: |
333 | chown = os.lchown |
334 | |
335 | + if chowntopdir: |
336 | + broken_symlink = os.path.lexists(path) and not os.path.exists(path) |
337 | + if not broken_symlink: |
338 | + chown(path, uid, gid) |
339 | for root, dirs, files in os.walk(path): |
340 | for name in dirs + files: |
341 | full = os.path.join(root, name) |
342 | |
343 | === modified file 'hooks/charmhelpers/core/hugepage.py' |
344 | --- hooks/charmhelpers/core/hugepage.py 2015-10-22 13:19:37 +0000 |
345 | +++ hooks/charmhelpers/core/hugepage.py 2016-01-19 17:24:47 +0000 |
346 | @@ -46,6 +46,8 @@ |
347 | group_info = add_group(group) |
348 | gid = group_info.gr_gid |
349 | add_user_to_group(user, group) |
350 | + if max_map_count < 2 * nr_hugepages: |
351 | + max_map_count = 2 * nr_hugepages |
352 | sysctl_settings = { |
353 | 'vm.nr_hugepages': nr_hugepages, |
354 | 'vm.max_map_count': max_map_count, |
355 | |
356 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py' |
357 | --- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2015-10-22 13:19:37 +0000 |
358 | +++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-19 17:24:47 +0000 |
359 | @@ -14,12 +14,18 @@ |
360 | # You should have received a copy of the GNU Lesser General Public License |
361 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
362 | |
363 | +import logging |
364 | +import re |
365 | +import sys |
366 | import six |
367 | from collections import OrderedDict |
368 | from charmhelpers.contrib.amulet.deployment import ( |
369 | AmuletDeployment |
370 | ) |
371 | |
372 | +DEBUG = logging.DEBUG |
373 | +ERROR = logging.ERROR |
374 | + |
375 | |
376 | class OpenStackAmuletDeployment(AmuletDeployment): |
377 | """OpenStack amulet deployment. |
378 | @@ -28,9 +34,12 @@ |
379 | that is specifically for use by OpenStack charms. |
380 | """ |
381 | |
382 | - def __init__(self, series=None, openstack=None, source=None, stable=True): |
383 | + def __init__(self, series=None, openstack=None, source=None, |
384 | + stable=True, log_level=DEBUG): |
385 | """Initialize the deployment environment.""" |
386 | super(OpenStackAmuletDeployment, self).__init__(series) |
387 | + self.log = self.get_logger(level=log_level) |
388 | + self.log.info('OpenStackAmuletDeployment: init') |
389 | self.openstack = openstack |
390 | self.source = source |
391 | self.stable = stable |
392 | @@ -38,6 +47,22 @@ |
393 | # out. |
394 | self.current_next = "trusty" |
395 | |
396 | + def get_logger(self, name="deployment-logger", level=logging.DEBUG): |
397 | + """Get a logger object that will log to stdout.""" |
398 | + log = logging |
399 | + logger = log.getLogger(name) |
400 | + fmt = log.Formatter("%(asctime)s %(funcName)s " |
401 | + "%(levelname)s: %(message)s") |
402 | + |
403 | + handler = log.StreamHandler(stream=sys.stdout) |
404 | + handler.setLevel(level) |
405 | + handler.setFormatter(fmt) |
406 | + |
407 | + logger.addHandler(handler) |
408 | + logger.setLevel(level) |
409 | + |
410 | + return logger |
411 | + |
412 | def _determine_branch_locations(self, other_services): |
413 | """Determine the branch locations for the other services. |
414 | |
415 | @@ -45,6 +70,8 @@ |
416 | stable or next (dev) branch, and based on this, use the corresonding |
417 | stable or next branches for the other_services.""" |
418 | |
419 | + self.log.info('OpenStackAmuletDeployment: determine branch locations') |
420 | + |
421 | # Charms outside the lp:~openstack-charmers namespace |
422 | base_charms = ['mysql', 'mongodb', 'nrpe'] |
423 | |
424 | @@ -82,6 +109,8 @@ |
425 | |
426 | def _add_services(self, this_service, other_services): |
427 | """Add services to the deployment and set openstack-origin/source.""" |
428 | + self.log.info('OpenStackAmuletDeployment: adding services') |
429 | + |
430 | other_services = self._determine_branch_locations(other_services) |
431 | |
432 | super(OpenStackAmuletDeployment, self)._add_services(this_service, |
433 | @@ -111,9 +140,79 @@ |
434 | |
435 | def _configure_services(self, configs): |
436 | """Configure all of the services.""" |
437 | + self.log.info('OpenStackAmuletDeployment: configure services') |
438 | for service, config in six.iteritems(configs): |
439 | self.d.configure(service, config) |
440 | |
441 | + def _auto_wait_for_status(self, message=None, exclude_services=None, |
442 | + include_only=None, timeout=1800): |
443 | + """Wait for all units to have a specific extended status, except |
444 | + for any defined as excluded. Unless specified via message, any |
445 | + status containing any case of 'ready' will be considered a match. |
446 | + |
447 | + Examples of message usage: |
448 | + |
449 | + Wait for all unit status to CONTAIN any case of 'ready' or 'ok': |
450 | + message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE) |
451 | + |
452 | + Wait for all units to reach this status (exact match): |
453 | + message = re.compile('^Unit is ready and clustered$') |
454 | + |
455 | + Wait for all units to reach any one of these (exact match): |
456 | + message = re.compile('Unit is ready|OK|Ready') |
457 | + |
458 | + Wait for at least one unit to reach this status (exact match): |
459 | + message = {'ready'} |
460 | + |
461 | + See Amulet's sentry.wait_for_messages() for message usage detail. |
462 | + https://github.com/juju/amulet/blob/master/amulet/sentry.py |
463 | + |
464 | + :param message: Expected status match |
465 | + :param exclude_services: List of juju service names to ignore, |
466 | + not to be used in conjuction with include_only. |
467 | + :param include_only: List of juju service names to exclusively check, |
468 | + not to be used in conjuction with exclude_services. |
469 | + :param timeout: Maximum time in seconds to wait for status match |
470 | + :returns: None. Raises if timeout is hit. |
471 | + """ |
472 | + self.log.info('Waiting for extended status on units...') |
473 | + |
474 | + all_services = self.d.services.keys() |
475 | + |
476 | + if exclude_services and include_only: |
477 | + raise ValueError('exclude_services can not be used ' |
478 | + 'with include_only') |
479 | + |
480 | + if message: |
481 | + if isinstance(message, re._pattern_type): |
482 | + match = message.pattern |
483 | + else: |
484 | + match = message |
485 | + |
486 | + self.log.debug('Custom extended status wait match: ' |
487 | + '{}'.format(match)) |
488 | + else: |
489 | + self.log.debug('Default extended status wait match: contains ' |
490 | + 'READY (case-insensitive)') |
491 | + message = re.compile('.*ready.*', re.IGNORECASE) |
492 | + |
493 | + if exclude_services: |
494 | + self.log.debug('Excluding services from extended status match: ' |
495 | + '{}'.format(exclude_services)) |
496 | + else: |
497 | + exclude_services = [] |
498 | + |
499 | + if include_only: |
500 | + services = include_only |
501 | + else: |
502 | + services = list(set(all_services) - set(exclude_services)) |
503 | + |
504 | + self.log.debug('Waiting up to {}s for extended status on services: ' |
505 | + '{}'.format(timeout, services)) |
506 | + service_messages = {service: message for service in services} |
507 | + self.d.sentry.wait_for_messages(service_messages, timeout=timeout) |
508 | + self.log.info('OK') |
509 | + |
510 | def _get_openstack_release(self): |
511 | """Get openstack release. |
512 | |
513 | |
514 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/utils.py' |
515 | --- tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-22 13:19:37 +0000 |
516 | +++ tests/charmhelpers/contrib/openstack/amulet/utils.py 2016-01-19 17:24:47 +0000 |
517 | @@ -18,6 +18,7 @@ |
518 | import json |
519 | import logging |
520 | import os |
521 | +import re |
522 | import six |
523 | import time |
524 | import urllib |
525 | @@ -604,7 +605,22 @@ |
526 | '{}'.format(sample_type, samples)) |
527 | return None |
528 | |
529 | -# rabbitmq/amqp specific helpers: |
530 | + # rabbitmq/amqp specific helpers: |
531 | + |
532 | + def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200): |
533 | + """Wait for rmq units extended status to show cluster readiness, |
534 | + after an optional initial sleep period. Initial sleep is likely |
535 | + necessary to be effective following a config change, as status |
536 | + message may not instantly update to non-ready.""" |
537 | + |
538 | + if init_sleep: |
539 | + time.sleep(init_sleep) |
540 | + |
541 | + message = re.compile('^Unit is ready and clustered$') |
542 | + deployment._auto_wait_for_status(message=message, |
543 | + timeout=timeout, |
544 | + include_only=['rabbitmq-server']) |
545 | + |
546 | def add_rmq_test_user(self, sentry_units, |
547 | username="testuser1", password="changeme"): |
548 | """Add a test user via the first rmq juju unit, check connection as |
549 | @@ -805,7 +821,10 @@ |
550 | if port: |
551 | config['ssl_port'] = port |
552 | |
553 | - deployment.configure('rabbitmq-server', config) |
554 | + deployment.d.configure('rabbitmq-server', config) |
555 | + |
556 | + # Wait for unit status |
557 | + self.rmq_wait_for_cluster(deployment) |
558 | |
559 | # Confirm |
560 | tries = 0 |
561 | @@ -832,7 +851,10 @@ |
562 | |
563 | # Disable RMQ SSL |
564 | config = {'ssl': 'off'} |
565 | - deployment.configure('rabbitmq-server', config) |
566 | + deployment.d.configure('rabbitmq-server', config) |
567 | + |
568 | + # Wait for unit status |
569 | + self.rmq_wait_for_cluster(deployment) |
570 | |
571 | # Confirm |
572 | tries = 0 |
charm_lint_check #17720 cinder-ceph for james-page mp283188
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/17720/