Merge lp:~james-page/charms/trusty/ceilometer/lp1531102-trunk into lp:~openstack-charmers-archive/charms/trusty/ceilometer/trunk

Proposed by James Page
Status: Merged
Merged at revision: 91
Proposed branch: lp:~james-page/charms/trusty/ceilometer/lp1531102-trunk
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceilometer/trunk
Diff against target: 533 lines (+207/-39)
6 files modified
charmhelpers/contrib/openstack/amulet/deployment.py (+67/-8)
charmhelpers/contrib/openstack/amulet/utils.py (+25/-3)
charmhelpers/contrib/openstack/utils.py (+21/-17)
charmhelpers/core/hugepage.py (+2/-0)
tests/charmhelpers/contrib/openstack/amulet/deployment.py (+67/-8)
tests/charmhelpers/contrib/openstack/amulet/utils.py (+25/-3)
To merge this branch: bzr merge lp:~james-page/charms/trusty/ceilometer/lp1531102-trunk
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+281870@code.launchpad.net

Commit message

Resync helpers

Description of the change

Resync stable charm helpers to resolve liberty point release issues.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #16738 ceilometer for james-page mp281870
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/16738/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #8568 ceilometer for james-page mp281870
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8568/

Revision history for this message
Liam Young (gnuoy) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/openstack/amulet/deployment.py'
--- charmhelpers/contrib/openstack/amulet/deployment.py 2015-10-22 13:17:02 +0000
+++ charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-07 14:29:51 +0000
@@ -14,13 +14,18 @@
14# You should have received a copy of the GNU Lesser General Public License14# You should have received a copy of the GNU Lesser General Public License
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/>.
1616
17import logging
17import re18import re
19import sys
18import six20import six
19from collections import OrderedDict21from collections import OrderedDict
20from charmhelpers.contrib.amulet.deployment import (22from charmhelpers.contrib.amulet.deployment import (
21 AmuletDeployment23 AmuletDeployment
22)24)
2325
26DEBUG = logging.DEBUG
27ERROR = logging.ERROR
28
2429
25class OpenStackAmuletDeployment(AmuletDeployment):30class OpenStackAmuletDeployment(AmuletDeployment):
26 """OpenStack amulet deployment.31 """OpenStack amulet deployment.
@@ -29,9 +34,12 @@
29 that is specifically for use by OpenStack charms.34 that is specifically for use by OpenStack charms.
30 """35 """
3136
32 def __init__(self, series=None, openstack=None, source=None, stable=True):37 def __init__(self, series=None, openstack=None, source=None,
38 stable=True, log_level=DEBUG):
33 """Initialize the deployment environment."""39 """Initialize the deployment environment."""
34 super(OpenStackAmuletDeployment, self).__init__(series)40 super(OpenStackAmuletDeployment, self).__init__(series)
41 self.log = self.get_logger(level=log_level)
42 self.log.info('OpenStackAmuletDeployment: init')
35 self.openstack = openstack43 self.openstack = openstack
36 self.source = source44 self.source = source
37 self.stable = stable45 self.stable = stable
@@ -39,6 +47,22 @@
39 # out.47 # out.
40 self.current_next = "trusty"48 self.current_next = "trusty"
4149
50 def get_logger(self, name="deployment-logger", level=logging.DEBUG):
51 """Get a logger object that will log to stdout."""
52 log = logging
53 logger = log.getLogger(name)
54 fmt = log.Formatter("%(asctime)s %(funcName)s "
55 "%(levelname)s: %(message)s")
56
57 handler = log.StreamHandler(stream=sys.stdout)
58 handler.setLevel(level)
59 handler.setFormatter(fmt)
60
61 logger.addHandler(handler)
62 logger.setLevel(level)
63
64 return logger
65
42 def _determine_branch_locations(self, other_services):66 def _determine_branch_locations(self, other_services):
43 """Determine the branch locations for the other services.67 """Determine the branch locations for the other services.
4468
@@ -46,6 +70,8 @@
46 stable or next (dev) branch, and based on this, use the corresonding70 stable or next (dev) branch, and based on this, use the corresonding
47 stable or next branches for the other_services."""71 stable or next branches for the other_services."""
4872
73 self.log.info('OpenStackAmuletDeployment: determine branch locations')
74
49 # Charms outside the lp:~openstack-charmers namespace75 # Charms outside the lp:~openstack-charmers namespace
50 base_charms = ['mysql', 'mongodb', 'nrpe']76 base_charms = ['mysql', 'mongodb', 'nrpe']
5177
@@ -83,6 +109,8 @@
83109
84 def _add_services(self, this_service, other_services):110 def _add_services(self, this_service, other_services):
85 """Add services to the deployment and set openstack-origin/source."""111 """Add services to the deployment and set openstack-origin/source."""
112 self.log.info('OpenStackAmuletDeployment: adding services')
113
86 other_services = self._determine_branch_locations(other_services)114 other_services = self._determine_branch_locations(other_services)
87115
88 super(OpenStackAmuletDeployment, self)._add_services(this_service,116 super(OpenStackAmuletDeployment, self)._add_services(this_service,
@@ -112,11 +140,12 @@
112140
113 def _configure_services(self, configs):141 def _configure_services(self, configs):
114 """Configure all of the services."""142 """Configure all of the services."""
143 self.log.info('OpenStackAmuletDeployment: configure services')
115 for service, config in six.iteritems(configs):144 for service, config in six.iteritems(configs):
116 self.d.configure(service, config)145 self.d.configure(service, config)
117146
118 def _auto_wait_for_status(self, message=None, exclude_services=None,147 def _auto_wait_for_status(self, message=None, exclude_services=None,
119 timeout=1800):148 include_only=None, timeout=1800):
120 """Wait for all units to have a specific extended status, except149 """Wait for all units to have a specific extended status, except
121 for any defined as excluded. Unless specified via message, any150 for any defined as excluded. Unless specified via message, any
122 status containing any case of 'ready' will be considered a match.151 status containing any case of 'ready' will be considered a match.
@@ -127,7 +156,7 @@
127 message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE)156 message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE)
128157
129 Wait for all units to reach this status (exact match):158 Wait for all units to reach this status (exact match):
130 message = 'Unit is ready'159 message = re.compile('^Unit is ready and clustered$')
131160
132 Wait for all units to reach any one of these (exact match):161 Wait for all units to reach any one of these (exact match):
133 message = re.compile('Unit is ready|OK|Ready')162 message = re.compile('Unit is ready|OK|Ready')
@@ -139,20 +168,50 @@
139 https://github.com/juju/amulet/blob/master/amulet/sentry.py168 https://github.com/juju/amulet/blob/master/amulet/sentry.py
140169
141 :param message: Expected status match170 :param message: Expected status match
142 :param exclude_services: List of juju service names to ignore171 :param exclude_services: List of juju service names to ignore,
172 not to be used in conjuction with include_only.
173 :param include_only: List of juju service names to exclusively check,
174 not to be used in conjuction with exclude_services.
143 :param timeout: Maximum time in seconds to wait for status match175 :param timeout: Maximum time in seconds to wait for status match
144 :returns: None. Raises if timeout is hit.176 :returns: None. Raises if timeout is hit.
145 """177 """
146178 self.log.info('Waiting for extended status on units...')
147 if not message:179
180 all_services = self.d.services.keys()
181
182 if exclude_services and include_only:
183 raise ValueError('exclude_services can not be used '
184 'with include_only')
185
186 if message:
187 if isinstance(message, re._pattern_type):
188 match = message.pattern
189 else:
190 match = message
191
192 self.log.debug('Custom extended status wait match: '
193 '{}'.format(match))
194 else:
195 self.log.debug('Default extended status wait match: contains '
196 'READY (case-insensitive)')
148 message = re.compile('.*ready.*', re.IGNORECASE)197 message = re.compile('.*ready.*', re.IGNORECASE)
149198
150 if not exclude_services:199 if exclude_services:
200 self.log.debug('Excluding services from extended status match: '
201 '{}'.format(exclude_services))
202 else:
151 exclude_services = []203 exclude_services = []
152204
153 services = list(set(self.d.services.keys()) - set(exclude_services))205 if include_only:
206 services = include_only
207 else:
208 services = list(set(all_services) - set(exclude_services))
209
210 self.log.debug('Waiting up to {}s for extended status on services: '
211 '{}'.format(timeout, services))
154 service_messages = {service: message for service in services}212 service_messages = {service: message for service in services}
155 self.d.sentry.wait_for_messages(service_messages, timeout=timeout)213 self.d.sentry.wait_for_messages(service_messages, timeout=timeout)
214 self.log.info('OK')
156215
157 def _get_openstack_release(self):216 def _get_openstack_release(self):
158 """Get openstack release.217 """Get openstack release.
159218
=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
--- charmhelpers/contrib/openstack/amulet/utils.py 2015-10-22 13:17:02 +0000
+++ charmhelpers/contrib/openstack/amulet/utils.py 2016-01-07 14:29:51 +0000
@@ -18,6 +18,7 @@
18import json18import json
19import logging19import logging
20import os20import os
21import re
21import six22import six
22import time23import time
23import urllib24import urllib
@@ -604,7 +605,22 @@
604 '{}'.format(sample_type, samples))605 '{}'.format(sample_type, samples))
605 return None606 return None
606607
607# rabbitmq/amqp specific helpers:608 # rabbitmq/amqp specific helpers:
609
610 def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200):
611 """Wait for rmq units extended status to show cluster readiness,
612 after an optional initial sleep period. Initial sleep is likely
613 necessary to be effective following a config change, as status
614 message may not instantly update to non-ready."""
615
616 if init_sleep:
617 time.sleep(init_sleep)
618
619 message = re.compile('^Unit is ready and clustered$')
620 deployment._auto_wait_for_status(message=message,
621 timeout=timeout,
622 include_only=['rabbitmq-server'])
623
608 def add_rmq_test_user(self, sentry_units,624 def add_rmq_test_user(self, sentry_units,
609 username="testuser1", password="changeme"):625 username="testuser1", password="changeme"):
610 """Add a test user via the first rmq juju unit, check connection as626 """Add a test user via the first rmq juju unit, check connection as
@@ -805,7 +821,10 @@
805 if port:821 if port:
806 config['ssl_port'] = port822 config['ssl_port'] = port
807823
808 deployment.configure('rabbitmq-server', config)824 deployment.d.configure('rabbitmq-server', config)
825
826 # Wait for unit status
827 self.rmq_wait_for_cluster(deployment)
809828
810 # Confirm829 # Confirm
811 tries = 0830 tries = 0
@@ -832,7 +851,10 @@
832851
833 # Disable RMQ SSL852 # Disable RMQ SSL
834 config = {'ssl': 'off'}853 config = {'ssl': 'off'}
835 deployment.configure('rabbitmq-server', config)854 deployment.d.configure('rabbitmq-server', config)
855
856 # Wait for unit status
857 self.rmq_wait_for_cluster(deployment)
836858
837 # Confirm859 # Confirm
838 tries = 0860 tries = 0
839861
=== modified file 'charmhelpers/contrib/openstack/utils.py'
--- charmhelpers/contrib/openstack/utils.py 2015-10-22 13:17:02 +0000
+++ charmhelpers/contrib/openstack/utils.py 2016-01-07 14:29:51 +0000
@@ -127,31 +127,31 @@
127# >= Liberty version->codename mapping127# >= Liberty version->codename mapping
128PACKAGE_CODENAMES = {128PACKAGE_CODENAMES = {
129 'nova-common': OrderedDict([129 'nova-common': OrderedDict([
130 ('12.0.0', 'liberty'),130 ('12.0', 'liberty'),
131 ]),131 ]),
132 'neutron-common': OrderedDict([132 'neutron-common': OrderedDict([
133 ('7.0.0', 'liberty'),133 ('7.0', 'liberty'),
134 ]),134 ]),
135 'cinder-common': OrderedDict([135 'cinder-common': OrderedDict([
136 ('7.0.0', 'liberty'),136 ('7.0', 'liberty'),
137 ]),137 ]),
138 'keystone': OrderedDict([138 'keystone': OrderedDict([
139 ('8.0.0', 'liberty'),139 ('8.0', 'liberty'),
140 ]),140 ]),
141 'horizon-common': OrderedDict([141 'horizon-common': OrderedDict([
142 ('8.0.0', 'liberty'),142 ('8.0', 'liberty'),
143 ]),143 ]),
144 'ceilometer-common': OrderedDict([144 'ceilometer-common': OrderedDict([
145 ('5.0.0', 'liberty'),145 ('5.0', 'liberty'),
146 ]),146 ]),
147 'heat-common': OrderedDict([147 'heat-common': OrderedDict([
148 ('5.0.0', 'liberty'),148 ('5.0', 'liberty'),
149 ]),149 ]),
150 'glance-common': OrderedDict([150 'glance-common': OrderedDict([
151 ('11.0.0', 'liberty'),151 ('11.0', 'liberty'),
152 ]),152 ]),
153 'openstack-dashboard': OrderedDict([153 'openstack-dashboard': OrderedDict([
154 ('8.0.0', 'liberty'),154 ('8.0', 'liberty'),
155 ]),155 ]),
156}156}
157157
@@ -238,7 +238,14 @@
238 error_out(e)238 error_out(e)
239239
240 vers = apt.upstream_version(pkg.current_ver.ver_str)240 vers = apt.upstream_version(pkg.current_ver.ver_str)
241 match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)241 if 'swift' in pkg.name:
242 # Fully x.y.z match for swift versions
243 match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)
244 else:
245 # x.y match only for 20XX.X
246 # and ignore patch level for other packages
247 match = re.match('^(\d+)\.(\d+)', vers)
248
242 if match:249 if match:
243 vers = match.group(0)250 vers = match.group(0)
244251
@@ -250,13 +257,8 @@
250 # < Liberty co-ordinated project versions257 # < Liberty co-ordinated project versions
251 try:258 try:
252 if 'swift' in pkg.name:259 if 'swift' in pkg.name:
253 swift_vers = vers[:5]260 return SWIFT_CODENAMES[vers]
254 if swift_vers not in SWIFT_CODENAMES:
255 # Deal with 1.10.0 upward
256 swift_vers = vers[:6]
257 return SWIFT_CODENAMES[swift_vers]
258 else:261 else:
259 vers = vers[:6]
260 return OPENSTACK_CODENAMES[vers]262 return OPENSTACK_CODENAMES[vers]
261 except KeyError:263 except KeyError:
262 if not fatal:264 if not fatal:
@@ -859,7 +861,9 @@
859 if charm_state != 'active' and charm_state != 'unknown':861 if charm_state != 'active' and charm_state != 'unknown':
860 state = workload_state_compare(state, charm_state)862 state = workload_state_compare(state, charm_state)
861 if message:863 if message:
862 message = "{} {}".format(message, charm_message)864 charm_message = charm_message.replace("Incomplete relations: ",
865 "")
866 message = "{}, {}".format(message, charm_message)
863 else:867 else:
864 message = charm_message868 message = charm_message
865869
866870
=== modified file 'charmhelpers/core/hugepage.py'
--- charmhelpers/core/hugepage.py 2015-10-22 13:17:02 +0000
+++ charmhelpers/core/hugepage.py 2016-01-07 14:29:51 +0000
@@ -46,6 +46,8 @@
46 group_info = add_group(group)46 group_info = add_group(group)
47 gid = group_info.gr_gid47 gid = group_info.gr_gid
48 add_user_to_group(user, group)48 add_user_to_group(user, group)
49 if max_map_count < 2 * nr_hugepages:
50 max_map_count = 2 * nr_hugepages
49 sysctl_settings = {51 sysctl_settings = {
50 'vm.nr_hugepages': nr_hugepages,52 'vm.nr_hugepages': nr_hugepages,
51 'vm.max_map_count': max_map_count,53 'vm.max_map_count': max_map_count,
5254
=== modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py'
--- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2015-10-22 13:17:02 +0000
+++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-07 14:29:51 +0000
@@ -14,13 +14,18 @@
14# You should have received a copy of the GNU Lesser General Public License14# You should have received a copy of the GNU Lesser General Public License
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/>.
1616
17import logging
17import re18import re
19import sys
18import six20import six
19from collections import OrderedDict21from collections import OrderedDict
20from charmhelpers.contrib.amulet.deployment import (22from charmhelpers.contrib.amulet.deployment import (
21 AmuletDeployment23 AmuletDeployment
22)24)
2325
26DEBUG = logging.DEBUG
27ERROR = logging.ERROR
28
2429
25class OpenStackAmuletDeployment(AmuletDeployment):30class OpenStackAmuletDeployment(AmuletDeployment):
26 """OpenStack amulet deployment.31 """OpenStack amulet deployment.
@@ -29,9 +34,12 @@
29 that is specifically for use by OpenStack charms.34 that is specifically for use by OpenStack charms.
30 """35 """
3136
32 def __init__(self, series=None, openstack=None, source=None, stable=True):37 def __init__(self, series=None, openstack=None, source=None,
38 stable=True, log_level=DEBUG):
33 """Initialize the deployment environment."""39 """Initialize the deployment environment."""
34 super(OpenStackAmuletDeployment, self).__init__(series)40 super(OpenStackAmuletDeployment, self).__init__(series)
41 self.log = self.get_logger(level=log_level)
42 self.log.info('OpenStackAmuletDeployment: init')
35 self.openstack = openstack43 self.openstack = openstack
36 self.source = source44 self.source = source
37 self.stable = stable45 self.stable = stable
@@ -39,6 +47,22 @@
39 # out.47 # out.
40 self.current_next = "trusty"48 self.current_next = "trusty"
4149
50 def get_logger(self, name="deployment-logger", level=logging.DEBUG):
51 """Get a logger object that will log to stdout."""
52 log = logging
53 logger = log.getLogger(name)
54 fmt = log.Formatter("%(asctime)s %(funcName)s "
55 "%(levelname)s: %(message)s")
56
57 handler = log.StreamHandler(stream=sys.stdout)
58 handler.setLevel(level)
59 handler.setFormatter(fmt)
60
61 logger.addHandler(handler)
62 logger.setLevel(level)
63
64 return logger
65
42 def _determine_branch_locations(self, other_services):66 def _determine_branch_locations(self, other_services):
43 """Determine the branch locations for the other services.67 """Determine the branch locations for the other services.
4468
@@ -46,6 +70,8 @@
46 stable or next (dev) branch, and based on this, use the corresonding70 stable or next (dev) branch, and based on this, use the corresonding
47 stable or next branches for the other_services."""71 stable or next branches for the other_services."""
4872
73 self.log.info('OpenStackAmuletDeployment: determine branch locations')
74
49 # Charms outside the lp:~openstack-charmers namespace75 # Charms outside the lp:~openstack-charmers namespace
50 base_charms = ['mysql', 'mongodb', 'nrpe']76 base_charms = ['mysql', 'mongodb', 'nrpe']
5177
@@ -83,6 +109,8 @@
83109
84 def _add_services(self, this_service, other_services):110 def _add_services(self, this_service, other_services):
85 """Add services to the deployment and set openstack-origin/source."""111 """Add services to the deployment and set openstack-origin/source."""
112 self.log.info('OpenStackAmuletDeployment: adding services')
113
86 other_services = self._determine_branch_locations(other_services)114 other_services = self._determine_branch_locations(other_services)
87115
88 super(OpenStackAmuletDeployment, self)._add_services(this_service,116 super(OpenStackAmuletDeployment, self)._add_services(this_service,
@@ -112,11 +140,12 @@
112140
113 def _configure_services(self, configs):141 def _configure_services(self, configs):
114 """Configure all of the services."""142 """Configure all of the services."""
143 self.log.info('OpenStackAmuletDeployment: configure services')
115 for service, config in six.iteritems(configs):144 for service, config in six.iteritems(configs):
116 self.d.configure(service, config)145 self.d.configure(service, config)
117146
118 def _auto_wait_for_status(self, message=None, exclude_services=None,147 def _auto_wait_for_status(self, message=None, exclude_services=None,
119 timeout=1800):148 include_only=None, timeout=1800):
120 """Wait for all units to have a specific extended status, except149 """Wait for all units to have a specific extended status, except
121 for any defined as excluded. Unless specified via message, any150 for any defined as excluded. Unless specified via message, any
122 status containing any case of 'ready' will be considered a match.151 status containing any case of 'ready' will be considered a match.
@@ -127,7 +156,7 @@
127 message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE)156 message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE)
128157
129 Wait for all units to reach this status (exact match):158 Wait for all units to reach this status (exact match):
130 message = 'Unit is ready'159 message = re.compile('^Unit is ready and clustered$')
131160
132 Wait for all units to reach any one of these (exact match):161 Wait for all units to reach any one of these (exact match):
133 message = re.compile('Unit is ready|OK|Ready')162 message = re.compile('Unit is ready|OK|Ready')
@@ -139,20 +168,50 @@
139 https://github.com/juju/amulet/blob/master/amulet/sentry.py168 https://github.com/juju/amulet/blob/master/amulet/sentry.py
140169
141 :param message: Expected status match170 :param message: Expected status match
142 :param exclude_services: List of juju service names to ignore171 :param exclude_services: List of juju service names to ignore,
172 not to be used in conjuction with include_only.
173 :param include_only: List of juju service names to exclusively check,
174 not to be used in conjuction with exclude_services.
143 :param timeout: Maximum time in seconds to wait for status match175 :param timeout: Maximum time in seconds to wait for status match
144 :returns: None. Raises if timeout is hit.176 :returns: None. Raises if timeout is hit.
145 """177 """
146178 self.log.info('Waiting for extended status on units...')
147 if not message:179
180 all_services = self.d.services.keys()
181
182 if exclude_services and include_only:
183 raise ValueError('exclude_services can not be used '
184 'with include_only')
185
186 if message:
187 if isinstance(message, re._pattern_type):
188 match = message.pattern
189 else:
190 match = message
191
192 self.log.debug('Custom extended status wait match: '
193 '{}'.format(match))
194 else:
195 self.log.debug('Default extended status wait match: contains '
196 'READY (case-insensitive)')
148 message = re.compile('.*ready.*', re.IGNORECASE)197 message = re.compile('.*ready.*', re.IGNORECASE)
149198
150 if not exclude_services:199 if exclude_services:
200 self.log.debug('Excluding services from extended status match: '
201 '{}'.format(exclude_services))
202 else:
151 exclude_services = []203 exclude_services = []
152204
153 services = list(set(self.d.services.keys()) - set(exclude_services))205 if include_only:
206 services = include_only
207 else:
208 services = list(set(all_services) - set(exclude_services))
209
210 self.log.debug('Waiting up to {}s for extended status on services: '
211 '{}'.format(timeout, services))
154 service_messages = {service: message for service in services}212 service_messages = {service: message for service in services}
155 self.d.sentry.wait_for_messages(service_messages, timeout=timeout)213 self.d.sentry.wait_for_messages(service_messages, timeout=timeout)
214 self.log.info('OK')
156215
157 def _get_openstack_release(self):216 def _get_openstack_release(self):
158 """Get openstack release.217 """Get openstack release.
159218
=== modified file 'tests/charmhelpers/contrib/openstack/amulet/utils.py'
--- tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-22 13:17:02 +0000
+++ tests/charmhelpers/contrib/openstack/amulet/utils.py 2016-01-07 14:29:51 +0000
@@ -18,6 +18,7 @@
18import json18import json
19import logging19import logging
20import os20import os
21import re
21import six22import six
22import time23import time
23import urllib24import urllib
@@ -604,7 +605,22 @@
604 '{}'.format(sample_type, samples))605 '{}'.format(sample_type, samples))
605 return None606 return None
606607
607# rabbitmq/amqp specific helpers:608 # rabbitmq/amqp specific helpers:
609
610 def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200):
611 """Wait for rmq units extended status to show cluster readiness,
612 after an optional initial sleep period. Initial sleep is likely
613 necessary to be effective following a config change, as status
614 message may not instantly update to non-ready."""
615
616 if init_sleep:
617 time.sleep(init_sleep)
618
619 message = re.compile('^Unit is ready and clustered$')
620 deployment._auto_wait_for_status(message=message,
621 timeout=timeout,
622 include_only=['rabbitmq-server'])
623
608 def add_rmq_test_user(self, sentry_units,624 def add_rmq_test_user(self, sentry_units,
609 username="testuser1", password="changeme"):625 username="testuser1", password="changeme"):
610 """Add a test user via the first rmq juju unit, check connection as626 """Add a test user via the first rmq juju unit, check connection as
@@ -805,7 +821,10 @@
805 if port:821 if port:
806 config['ssl_port'] = port822 config['ssl_port'] = port
807823
808 deployment.configure('rabbitmq-server', config)824 deployment.d.configure('rabbitmq-server', config)
825
826 # Wait for unit status
827 self.rmq_wait_for_cluster(deployment)
809828
810 # Confirm829 # Confirm
811 tries = 0830 tries = 0
@@ -832,7 +851,10 @@
832851
833 # Disable RMQ SSL852 # Disable RMQ SSL
834 config = {'ssl': 'off'}853 config = {'ssl': 'off'}
835 deployment.configure('rabbitmq-server', config)854 deployment.d.configure('rabbitmq-server', config)
855
856 # Wait for unit status
857 self.rmq_wait_for_cluster(deployment)
836858
837 # Confirm859 # Confirm
838 tries = 0860 tries = 0

Subscribers

People subscribed via source and target branches