Merge lp:~james-page/charms/trusty/cinder/lp1531102-trunk into lp:~openstack-charmers-archive/charms/trusty/cinder/trunk
- Trusty Tahr (14.04)
- lp1531102-trunk
- Merge into trunk
Proposed by
James Page
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 105 | ||||
Proposed branch: | lp:~james-page/charms/trusty/cinder/lp1531102-trunk | ||||
Merge into: | lp:~openstack-charmers-archive/charms/trusty/cinder/trunk | ||||
Diff against target: |
761 lines (+351/-44) 10 files modified
hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+100/-1) hooks/charmhelpers/contrib/openstack/amulet/utils.py (+26/-4) hooks/charmhelpers/contrib/openstack/context.py (+40/-13) hooks/charmhelpers/contrib/openstack/neutron.py (+17/-3) hooks/charmhelpers/contrib/openstack/templates/ceph.conf (+6/-0) 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 (+26/-4) |
||||
To merge this branch: | bzr merge lp:~james-page/charms/trusty/cinder/lp1531102-trunk | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Liam Young (community) | Approve | ||
Review via email: mp+281861@code.launchpad.net |
Commit message
Resync helpers
Description of the change
Resync helpers to fixup issues with liberty point releases.
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 #15635 cinder for james-page mp281861
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #8572 cinder for james-page mp281861
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:13 +0000 | |||
3 | +++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-07 14:14:00 +0000 | |||
4 | @@ -14,12 +14,18 @@ | |||
5 | 14 | # You should have received a copy of the GNU Lesser General Public License | 14 | # You should have received a copy of the GNU Lesser General Public License |
6 | 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/>. |
7 | 16 | 16 | ||
8 | 17 | import logging | ||
9 | 18 | import re | ||
10 | 19 | import sys | ||
11 | 17 | import six | 20 | import six |
12 | 18 | from collections import OrderedDict | 21 | from collections import OrderedDict |
13 | 19 | from charmhelpers.contrib.amulet.deployment import ( | 22 | from charmhelpers.contrib.amulet.deployment import ( |
14 | 20 | AmuletDeployment | 23 | AmuletDeployment |
15 | 21 | ) | 24 | ) |
16 | 22 | 25 | ||
17 | 26 | DEBUG = logging.DEBUG | ||
18 | 27 | ERROR = logging.ERROR | ||
19 | 28 | |||
20 | 23 | 29 | ||
21 | 24 | class OpenStackAmuletDeployment(AmuletDeployment): | 30 | class OpenStackAmuletDeployment(AmuletDeployment): |
22 | 25 | """OpenStack amulet deployment. | 31 | """OpenStack amulet deployment. |
23 | @@ -28,9 +34,12 @@ | |||
24 | 28 | that is specifically for use by OpenStack charms. | 34 | that is specifically for use by OpenStack charms. |
25 | 29 | """ | 35 | """ |
26 | 30 | 36 | ||
28 | 31 | def __init__(self, series=None, openstack=None, source=None, stable=True): | 37 | def __init__(self, series=None, openstack=None, source=None, |
29 | 38 | stable=True, log_level=DEBUG): | ||
30 | 32 | """Initialize the deployment environment.""" | 39 | """Initialize the deployment environment.""" |
31 | 33 | super(OpenStackAmuletDeployment, self).__init__(series) | 40 | super(OpenStackAmuletDeployment, self).__init__(series) |
32 | 41 | self.log = self.get_logger(level=log_level) | ||
33 | 42 | self.log.info('OpenStackAmuletDeployment: init') | ||
34 | 34 | self.openstack = openstack | 43 | self.openstack = openstack |
35 | 35 | self.source = source | 44 | self.source = source |
36 | 36 | self.stable = stable | 45 | self.stable = stable |
37 | @@ -38,6 +47,22 @@ | |||
38 | 38 | # out. | 47 | # out. |
39 | 39 | self.current_next = "trusty" | 48 | self.current_next = "trusty" |
40 | 40 | 49 | ||
41 | 50 | def get_logger(self, name="deployment-logger", level=logging.DEBUG): | ||
42 | 51 | """Get a logger object that will log to stdout.""" | ||
43 | 52 | log = logging | ||
44 | 53 | logger = log.getLogger(name) | ||
45 | 54 | fmt = log.Formatter("%(asctime)s %(funcName)s " | ||
46 | 55 | "%(levelname)s: %(message)s") | ||
47 | 56 | |||
48 | 57 | handler = log.StreamHandler(stream=sys.stdout) | ||
49 | 58 | handler.setLevel(level) | ||
50 | 59 | handler.setFormatter(fmt) | ||
51 | 60 | |||
52 | 61 | logger.addHandler(handler) | ||
53 | 62 | logger.setLevel(level) | ||
54 | 63 | |||
55 | 64 | return logger | ||
56 | 65 | |||
57 | 41 | def _determine_branch_locations(self, other_services): | 66 | def _determine_branch_locations(self, other_services): |
58 | 42 | """Determine the branch locations for the other services. | 67 | """Determine the branch locations for the other services. |
59 | 43 | 68 | ||
60 | @@ -45,6 +70,8 @@ | |||
61 | 45 | stable or next (dev) branch, and based on this, use the corresonding | 70 | stable or next (dev) branch, and based on this, use the corresonding |
62 | 46 | stable or next branches for the other_services.""" | 71 | stable or next branches for the other_services.""" |
63 | 47 | 72 | ||
64 | 73 | self.log.info('OpenStackAmuletDeployment: determine branch locations') | ||
65 | 74 | |||
66 | 48 | # Charms outside the lp:~openstack-charmers namespace | 75 | # Charms outside the lp:~openstack-charmers namespace |
67 | 49 | base_charms = ['mysql', 'mongodb', 'nrpe'] | 76 | base_charms = ['mysql', 'mongodb', 'nrpe'] |
68 | 50 | 77 | ||
69 | @@ -82,6 +109,8 @@ | |||
70 | 82 | 109 | ||
71 | 83 | def _add_services(self, this_service, other_services): | 110 | def _add_services(self, this_service, other_services): |
72 | 84 | """Add services to the deployment and set openstack-origin/source.""" | 111 | """Add services to the deployment and set openstack-origin/source.""" |
73 | 112 | self.log.info('OpenStackAmuletDeployment: adding services') | ||
74 | 113 | |||
75 | 85 | other_services = self._determine_branch_locations(other_services) | 114 | other_services = self._determine_branch_locations(other_services) |
76 | 86 | 115 | ||
77 | 87 | super(OpenStackAmuletDeployment, self)._add_services(this_service, | 116 | super(OpenStackAmuletDeployment, self)._add_services(this_service, |
78 | @@ -111,9 +140,79 @@ | |||
79 | 111 | 140 | ||
80 | 112 | def _configure_services(self, configs): | 141 | def _configure_services(self, configs): |
81 | 113 | """Configure all of the services.""" | 142 | """Configure all of the services.""" |
82 | 143 | self.log.info('OpenStackAmuletDeployment: configure services') | ||
83 | 114 | for service, config in six.iteritems(configs): | 144 | for service, config in six.iteritems(configs): |
84 | 115 | self.d.configure(service, config) | 145 | self.d.configure(service, config) |
85 | 116 | 146 | ||
86 | 147 | def _auto_wait_for_status(self, message=None, exclude_services=None, | ||
87 | 148 | include_only=None, timeout=1800): | ||
88 | 149 | """Wait for all units to have a specific extended status, except | ||
89 | 150 | for any defined as excluded. Unless specified via message, any | ||
90 | 151 | status containing any case of 'ready' will be considered a match. | ||
91 | 152 | |||
92 | 153 | Examples of message usage: | ||
93 | 154 | |||
94 | 155 | Wait for all unit status to CONTAIN any case of 'ready' or 'ok': | ||
95 | 156 | message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE) | ||
96 | 157 | |||
97 | 158 | Wait for all units to reach this status (exact match): | ||
98 | 159 | message = re.compile('^Unit is ready and clustered$') | ||
99 | 160 | |||
100 | 161 | Wait for all units to reach any one of these (exact match): | ||
101 | 162 | message = re.compile('Unit is ready|OK|Ready') | ||
102 | 163 | |||
103 | 164 | Wait for at least one unit to reach this status (exact match): | ||
104 | 165 | message = {'ready'} | ||
105 | 166 | |||
106 | 167 | See Amulet's sentry.wait_for_messages() for message usage detail. | ||
107 | 168 | https://github.com/juju/amulet/blob/master/amulet/sentry.py | ||
108 | 169 | |||
109 | 170 | :param message: Expected status match | ||
110 | 171 | :param exclude_services: List of juju service names to ignore, | ||
111 | 172 | not to be used in conjuction with include_only. | ||
112 | 173 | :param include_only: List of juju service names to exclusively check, | ||
113 | 174 | not to be used in conjuction with exclude_services. | ||
114 | 175 | :param timeout: Maximum time in seconds to wait for status match | ||
115 | 176 | :returns: None. Raises if timeout is hit. | ||
116 | 177 | """ | ||
117 | 178 | self.log.info('Waiting for extended status on units...') | ||
118 | 179 | |||
119 | 180 | all_services = self.d.services.keys() | ||
120 | 181 | |||
121 | 182 | if exclude_services and include_only: | ||
122 | 183 | raise ValueError('exclude_services can not be used ' | ||
123 | 184 | 'with include_only') | ||
124 | 185 | |||
125 | 186 | if message: | ||
126 | 187 | if isinstance(message, re._pattern_type): | ||
127 | 188 | match = message.pattern | ||
128 | 189 | else: | ||
129 | 190 | match = message | ||
130 | 191 | |||
131 | 192 | self.log.debug('Custom extended status wait match: ' | ||
132 | 193 | '{}'.format(match)) | ||
133 | 194 | else: | ||
134 | 195 | self.log.debug('Default extended status wait match: contains ' | ||
135 | 196 | 'READY (case-insensitive)') | ||
136 | 197 | message = re.compile('.*ready.*', re.IGNORECASE) | ||
137 | 198 | |||
138 | 199 | if exclude_services: | ||
139 | 200 | self.log.debug('Excluding services from extended status match: ' | ||
140 | 201 | '{}'.format(exclude_services)) | ||
141 | 202 | else: | ||
142 | 203 | exclude_services = [] | ||
143 | 204 | |||
144 | 205 | if include_only: | ||
145 | 206 | services = include_only | ||
146 | 207 | else: | ||
147 | 208 | services = list(set(all_services) - set(exclude_services)) | ||
148 | 209 | |||
149 | 210 | self.log.debug('Waiting up to {}s for extended status on services: ' | ||
150 | 211 | '{}'.format(timeout, services)) | ||
151 | 212 | service_messages = {service: message for service in services} | ||
152 | 213 | self.d.sentry.wait_for_messages(service_messages, timeout=timeout) | ||
153 | 214 | self.log.info('OK') | ||
154 | 215 | |||
155 | 117 | def _get_openstack_release(self): | 216 | def _get_openstack_release(self): |
156 | 118 | """Get openstack release. | 217 | """Get openstack release. |
157 | 119 | 218 | ||
158 | 120 | 219 | ||
159 | === modified file 'hooks/charmhelpers/contrib/openstack/amulet/utils.py' | |||
160 | --- hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-22 13:19:13 +0000 | |||
161 | +++ hooks/charmhelpers/contrib/openstack/amulet/utils.py 2016-01-07 14:14:00 +0000 | |||
162 | @@ -18,6 +18,7 @@ | |||
163 | 18 | import json | 18 | import json |
164 | 19 | import logging | 19 | import logging |
165 | 20 | import os | 20 | import os |
166 | 21 | import re | ||
167 | 21 | import six | 22 | import six |
168 | 22 | import time | 23 | import time |
169 | 23 | import urllib | 24 | import urllib |
170 | @@ -604,7 +605,22 @@ | |||
171 | 604 | '{}'.format(sample_type, samples)) | 605 | '{}'.format(sample_type, samples)) |
172 | 605 | return None | 606 | return None |
173 | 606 | 607 | ||
175 | 607 | # rabbitmq/amqp specific helpers: | 608 | # rabbitmq/amqp specific helpers: |
176 | 609 | |||
177 | 610 | def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200): | ||
178 | 611 | """Wait for rmq units extended status to show cluster readiness, | ||
179 | 612 | after an optional initial sleep period. Initial sleep is likely | ||
180 | 613 | necessary to be effective following a config change, as status | ||
181 | 614 | message may not instantly update to non-ready.""" | ||
182 | 615 | |||
183 | 616 | if init_sleep: | ||
184 | 617 | time.sleep(init_sleep) | ||
185 | 618 | |||
186 | 619 | message = re.compile('^Unit is ready and clustered$') | ||
187 | 620 | deployment._auto_wait_for_status(message=message, | ||
188 | 621 | timeout=timeout, | ||
189 | 622 | include_only=['rabbitmq-server']) | ||
190 | 623 | |||
191 | 608 | def add_rmq_test_user(self, sentry_units, | 624 | def add_rmq_test_user(self, sentry_units, |
192 | 609 | username="testuser1", password="changeme"): | 625 | username="testuser1", password="changeme"): |
193 | 610 | """Add a test user via the first rmq juju unit, check connection as | 626 | """Add a test user via the first rmq juju unit, check connection as |
194 | @@ -752,7 +768,7 @@ | |||
195 | 752 | self.log.debug('SSL is enabled @{}:{} ' | 768 | self.log.debug('SSL is enabled @{}:{} ' |
196 | 753 | '({})'.format(host, port, unit_name)) | 769 | '({})'.format(host, port, unit_name)) |
197 | 754 | return True | 770 | return True |
199 | 755 | elif not port and not conf_ssl: | 771 | elif not conf_ssl: |
200 | 756 | self.log.debug('SSL not enabled @{}:{} ' | 772 | self.log.debug('SSL not enabled @{}:{} ' |
201 | 757 | '({})'.format(host, port, unit_name)) | 773 | '({})'.format(host, port, unit_name)) |
202 | 758 | return False | 774 | return False |
203 | @@ -805,7 +821,10 @@ | |||
204 | 805 | if port: | 821 | if port: |
205 | 806 | config['ssl_port'] = port | 822 | config['ssl_port'] = port |
206 | 807 | 823 | ||
208 | 808 | deployment.configure('rabbitmq-server', config) | 824 | deployment.d.configure('rabbitmq-server', config) |
209 | 825 | |||
210 | 826 | # Wait for unit status | ||
211 | 827 | self.rmq_wait_for_cluster(deployment) | ||
212 | 809 | 828 | ||
213 | 810 | # Confirm | 829 | # Confirm |
214 | 811 | tries = 0 | 830 | tries = 0 |
215 | @@ -832,7 +851,10 @@ | |||
216 | 832 | 851 | ||
217 | 833 | # Disable RMQ SSL | 852 | # Disable RMQ SSL |
218 | 834 | config = {'ssl': 'off'} | 853 | config = {'ssl': 'off'} |
220 | 835 | deployment.configure('rabbitmq-server', config) | 854 | deployment.d.configure('rabbitmq-server', config) |
221 | 855 | |||
222 | 856 | # Wait for unit status | ||
223 | 857 | self.rmq_wait_for_cluster(deployment) | ||
224 | 836 | 858 | ||
225 | 837 | # Confirm | 859 | # Confirm |
226 | 838 | tries = 0 | 860 | tries = 0 |
227 | 839 | 861 | ||
228 | === modified file 'hooks/charmhelpers/contrib/openstack/context.py' | |||
229 | --- hooks/charmhelpers/contrib/openstack/context.py 2015-10-22 13:19:13 +0000 | |||
230 | +++ hooks/charmhelpers/contrib/openstack/context.py 2016-01-07 14:14:00 +0000 | |||
231 | @@ -14,6 +14,7 @@ | |||
232 | 14 | # You should have received a copy of the GNU Lesser General Public License | 14 | # You should have received a copy of the GNU Lesser General Public License |
233 | 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/>. |
234 | 16 | 16 | ||
235 | 17 | import glob | ||
236 | 17 | import json | 18 | import json |
237 | 18 | import os | 19 | import os |
238 | 19 | import re | 20 | import re |
239 | @@ -951,6 +952,19 @@ | |||
240 | 951 | 'config': config} | 952 | 'config': config} |
241 | 952 | return ovs_ctxt | 953 | return ovs_ctxt |
242 | 953 | 954 | ||
243 | 955 | def midonet_ctxt(self): | ||
244 | 956 | driver = neutron_plugin_attribute(self.plugin, 'driver', | ||
245 | 957 | self.network_manager) | ||
246 | 958 | midonet_config = neutron_plugin_attribute(self.plugin, 'config', | ||
247 | 959 | self.network_manager) | ||
248 | 960 | mido_ctxt = {'core_plugin': driver, | ||
249 | 961 | 'neutron_plugin': 'midonet', | ||
250 | 962 | 'neutron_security_groups': self.neutron_security_groups, | ||
251 | 963 | 'local_ip': unit_private_ip(), | ||
252 | 964 | 'config': midonet_config} | ||
253 | 965 | |||
254 | 966 | return mido_ctxt | ||
255 | 967 | |||
256 | 954 | def __call__(self): | 968 | def __call__(self): |
257 | 955 | if self.network_manager not in ['quantum', 'neutron']: | 969 | if self.network_manager not in ['quantum', 'neutron']: |
258 | 956 | return {} | 970 | return {} |
259 | @@ -972,6 +986,8 @@ | |||
260 | 972 | ctxt.update(self.nuage_ctxt()) | 986 | ctxt.update(self.nuage_ctxt()) |
261 | 973 | elif self.plugin == 'plumgrid': | 987 | elif self.plugin == 'plumgrid': |
262 | 974 | ctxt.update(self.pg_ctxt()) | 988 | ctxt.update(self.pg_ctxt()) |
263 | 989 | elif self.plugin == 'midonet': | ||
264 | 990 | ctxt.update(self.midonet_ctxt()) | ||
265 | 975 | 991 | ||
266 | 976 | alchemy_flags = config('neutron-alchemy-flags') | 992 | alchemy_flags = config('neutron-alchemy-flags') |
267 | 977 | if alchemy_flags: | 993 | if alchemy_flags: |
268 | @@ -1104,7 +1120,7 @@ | |||
269 | 1104 | 1120 | ||
270 | 1105 | ctxt = { | 1121 | ctxt = { |
271 | 1106 | ... other context ... | 1122 | ... other context ... |
273 | 1107 | 'subordinate_config': { | 1123 | 'subordinate_configuration': { |
274 | 1108 | 'DEFAULT': { | 1124 | 'DEFAULT': { |
275 | 1109 | 'key1': 'value1', | 1125 | 'key1': 'value1', |
276 | 1110 | }, | 1126 | }, |
277 | @@ -1145,22 +1161,23 @@ | |||
278 | 1145 | try: | 1161 | try: |
279 | 1146 | sub_config = json.loads(sub_config) | 1162 | sub_config = json.loads(sub_config) |
280 | 1147 | except: | 1163 | except: |
283 | 1148 | log('Could not parse JSON from subordinate_config ' | 1164 | log('Could not parse JSON from ' |
284 | 1149 | 'setting from %s' % rid, level=ERROR) | 1165 | 'subordinate_configuration setting from %s' |
285 | 1166 | % rid, level=ERROR) | ||
286 | 1150 | continue | 1167 | continue |
287 | 1151 | 1168 | ||
288 | 1152 | for service in self.services: | 1169 | for service in self.services: |
289 | 1153 | if service not in sub_config: | 1170 | if service not in sub_config: |
293 | 1154 | log('Found subordinate_config on %s but it contained' | 1171 | log('Found subordinate_configuration on %s but it ' |
294 | 1155 | 'nothing for %s service' % (rid, service), | 1172 | 'contained nothing for %s service' |
295 | 1156 | level=INFO) | 1173 | % (rid, service), level=INFO) |
296 | 1157 | continue | 1174 | continue |
297 | 1158 | 1175 | ||
298 | 1159 | sub_config = sub_config[service] | 1176 | sub_config = sub_config[service] |
299 | 1160 | if self.config_file not in sub_config: | 1177 | if self.config_file not in sub_config: |
303 | 1161 | log('Found subordinate_config on %s but it contained' | 1178 | log('Found subordinate_configuration on %s but it ' |
304 | 1162 | 'nothing for %s' % (rid, self.config_file), | 1179 | 'contained nothing for %s' |
305 | 1163 | level=INFO) | 1180 | % (rid, self.config_file), level=INFO) |
306 | 1164 | continue | 1181 | continue |
307 | 1165 | 1182 | ||
308 | 1166 | sub_config = sub_config[self.config_file] | 1183 | sub_config = sub_config[self.config_file] |
309 | @@ -1363,7 +1380,7 @@ | |||
310 | 1363 | normalized.update({port: port for port in resolved | 1380 | normalized.update({port: port for port in resolved |
311 | 1364 | if port in ports}) | 1381 | if port in ports}) |
312 | 1365 | if resolved: | 1382 | if resolved: |
314 | 1366 | return {bridge: normalized[port] for port, bridge in | 1383 | return {normalized[port]: bridge for port, bridge in |
315 | 1367 | six.iteritems(portmap) if port in normalized.keys()} | 1384 | six.iteritems(portmap) if port in normalized.keys()} |
316 | 1368 | 1385 | ||
317 | 1369 | return None | 1386 | return None |
318 | @@ -1374,12 +1391,22 @@ | |||
319 | 1374 | def __call__(self): | 1391 | def __call__(self): |
320 | 1375 | ctxt = {} | 1392 | ctxt = {} |
321 | 1376 | mappings = super(PhyNICMTUContext, self).__call__() | 1393 | mappings = super(PhyNICMTUContext, self).__call__() |
324 | 1377 | if mappings and mappings.values(): | 1394 | if mappings and mappings.keys(): |
325 | 1378 | ports = mappings.values() | 1395 | ports = sorted(mappings.keys()) |
326 | 1379 | napi_settings = NeutronAPIContext()() | 1396 | napi_settings = NeutronAPIContext()() |
327 | 1380 | mtu = napi_settings.get('network_device_mtu') | 1397 | mtu = napi_settings.get('network_device_mtu') |
328 | 1398 | all_ports = set() | ||
329 | 1399 | # If any of ports is a vlan device, its underlying device must have | ||
330 | 1400 | # mtu applied first. | ||
331 | 1401 | for port in ports: | ||
332 | 1402 | for lport in glob.glob("/sys/class/net/%s/lower_*" % port): | ||
333 | 1403 | lport = os.path.basename(lport) | ||
334 | 1404 | all_ports.add(lport.split('_')[1]) | ||
335 | 1405 | |||
336 | 1406 | all_ports = list(all_ports) | ||
337 | 1407 | all_ports.extend(ports) | ||
338 | 1381 | if mtu: | 1408 | if mtu: |
340 | 1382 | ctxt["devs"] = '\\n'.join(ports) | 1409 | ctxt["devs"] = '\\n'.join(all_ports) |
341 | 1383 | ctxt['mtu'] = mtu | 1410 | ctxt['mtu'] = mtu |
342 | 1384 | 1411 | ||
343 | 1385 | return ctxt | 1412 | return ctxt |
344 | 1386 | 1413 | ||
345 | === modified file 'hooks/charmhelpers/contrib/openstack/neutron.py' | |||
346 | --- hooks/charmhelpers/contrib/openstack/neutron.py 2015-10-22 13:19:13 +0000 | |||
347 | +++ hooks/charmhelpers/contrib/openstack/neutron.py 2016-01-07 14:14:00 +0000 | |||
348 | @@ -209,6 +209,20 @@ | |||
349 | 209 | 'server_packages': ['neutron-server', | 209 | 'server_packages': ['neutron-server', |
350 | 210 | 'neutron-plugin-plumgrid'], | 210 | 'neutron-plugin-plumgrid'], |
351 | 211 | 'server_services': ['neutron-server'] | 211 | 'server_services': ['neutron-server'] |
352 | 212 | }, | ||
353 | 213 | 'midonet': { | ||
354 | 214 | 'config': '/etc/neutron/plugins/midonet/midonet.ini', | ||
355 | 215 | 'driver': 'midonet.neutron.plugin.MidonetPluginV2', | ||
356 | 216 | 'contexts': [ | ||
357 | 217 | context.SharedDBContext(user=config('neutron-database-user'), | ||
358 | 218 | database=config('neutron-database'), | ||
359 | 219 | relation_prefix='neutron', | ||
360 | 220 | ssl_dir=NEUTRON_CONF_DIR)], | ||
361 | 221 | 'services': [], | ||
362 | 222 | 'packages': [[headers_package()] + determine_dkms_package()], | ||
363 | 223 | 'server_packages': ['neutron-server', | ||
364 | 224 | 'python-neutron-plugin-midonet'], | ||
365 | 225 | 'server_services': ['neutron-server'] | ||
366 | 212 | } | 226 | } |
367 | 213 | } | 227 | } |
368 | 214 | if release >= 'icehouse': | 228 | if release >= 'icehouse': |
369 | @@ -310,10 +324,10 @@ | |||
370 | 310 | def parse_data_port_mappings(mappings, default_bridge='br-data'): | 324 | def parse_data_port_mappings(mappings, default_bridge='br-data'): |
371 | 311 | """Parse data port mappings. | 325 | """Parse data port mappings. |
372 | 312 | 326 | ||
374 | 313 | Mappings must be a space-delimited list of port:bridge mappings. | 327 | Mappings must be a space-delimited list of bridge:port. |
375 | 314 | 328 | ||
378 | 315 | Returns dict of the form {port:bridge} where port may be an mac address or | 329 | Returns dict of the form {port:bridge} where ports may be mac addresses or |
379 | 316 | interface name. | 330 | interface names. |
380 | 317 | """ | 331 | """ |
381 | 318 | 332 | ||
382 | 319 | # NOTE(dosaboy): we use rvalue for key to allow multiple values to be | 333 | # NOTE(dosaboy): we use rvalue for key to allow multiple values to be |
383 | 320 | 334 | ||
384 | === modified file 'hooks/charmhelpers/contrib/openstack/templates/ceph.conf' | |||
385 | --- hooks/charmhelpers/contrib/openstack/templates/ceph.conf 2015-08-10 16:34:04 +0000 | |||
386 | +++ hooks/charmhelpers/contrib/openstack/templates/ceph.conf 2016-01-07 14:14:00 +0000 | |||
387 | @@ -13,3 +13,9 @@ | |||
388 | 13 | err to syslog = {{ use_syslog }} | 13 | err to syslog = {{ use_syslog }} |
389 | 14 | clog to syslog = {{ use_syslog }} | 14 | clog to syslog = {{ use_syslog }} |
390 | 15 | 15 | ||
391 | 16 | [client] | ||
392 | 17 | {% if rbd_client_cache_settings -%} | ||
393 | 18 | {% for key, value in rbd_client_cache_settings.iteritems() -%} | ||
394 | 19 | {{ key }} = {{ value }} | ||
395 | 20 | {% endfor -%} | ||
396 | 21 | {%- endif %} | ||
397 | 16 | \ No newline at end of file | 22 | \ No newline at end of file |
398 | 17 | 23 | ||
399 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
400 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-10-22 13:19:13 +0000 | |||
401 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-07 14:14:00 +0000 | |||
402 | @@ -121,36 +121,37 @@ | |||
403 | 121 | ('2.2.2', 'kilo'), | 121 | ('2.2.2', 'kilo'), |
404 | 122 | ('2.3.0', 'liberty'), | 122 | ('2.3.0', 'liberty'), |
405 | 123 | ('2.4.0', 'liberty'), | 123 | ('2.4.0', 'liberty'), |
406 | 124 | ('2.5.0', 'liberty'), | ||
407 | 124 | ]) | 125 | ]) |
408 | 125 | 126 | ||
409 | 126 | # >= Liberty version->codename mapping | 127 | # >= Liberty version->codename mapping |
410 | 127 | PACKAGE_CODENAMES = { | 128 | PACKAGE_CODENAMES = { |
411 | 128 | 'nova-common': OrderedDict([ | 129 | 'nova-common': OrderedDict([ |
413 | 129 | ('12.0.0', 'liberty'), | 130 | ('12.0', 'liberty'), |
414 | 130 | ]), | 131 | ]), |
415 | 131 | 'neutron-common': OrderedDict([ | 132 | 'neutron-common': OrderedDict([ |
417 | 132 | ('7.0.0', 'liberty'), | 133 | ('7.0', 'liberty'), |
418 | 133 | ]), | 134 | ]), |
419 | 134 | 'cinder-common': OrderedDict([ | 135 | 'cinder-common': OrderedDict([ |
421 | 135 | ('7.0.0', 'liberty'), | 136 | ('7.0', 'liberty'), |
422 | 136 | ]), | 137 | ]), |
423 | 137 | 'keystone': OrderedDict([ | 138 | 'keystone': OrderedDict([ |
425 | 138 | ('8.0.0', 'liberty'), | 139 | ('8.0', 'liberty'), |
426 | 139 | ]), | 140 | ]), |
427 | 140 | 'horizon-common': OrderedDict([ | 141 | 'horizon-common': OrderedDict([ |
429 | 141 | ('8.0.0', 'liberty'), | 142 | ('8.0', 'liberty'), |
430 | 142 | ]), | 143 | ]), |
431 | 143 | 'ceilometer-common': OrderedDict([ | 144 | 'ceilometer-common': OrderedDict([ |
433 | 144 | ('5.0.0', 'liberty'), | 145 | ('5.0', 'liberty'), |
434 | 145 | ]), | 146 | ]), |
435 | 146 | 'heat-common': OrderedDict([ | 147 | 'heat-common': OrderedDict([ |
437 | 147 | ('5.0.0', 'liberty'), | 148 | ('5.0', 'liberty'), |
438 | 148 | ]), | 149 | ]), |
439 | 149 | 'glance-common': OrderedDict([ | 150 | 'glance-common': OrderedDict([ |
441 | 150 | ('11.0.0', 'liberty'), | 151 | ('11.0', 'liberty'), |
442 | 151 | ]), | 152 | ]), |
443 | 152 | 'openstack-dashboard': OrderedDict([ | 153 | 'openstack-dashboard': OrderedDict([ |
445 | 153 | ('8.0.0', 'liberty'), | 154 | ('8.0', 'liberty'), |
446 | 154 | ]), | 155 | ]), |
447 | 155 | } | 156 | } |
448 | 156 | 157 | ||
449 | @@ -237,7 +238,14 @@ | |||
450 | 237 | error_out(e) | 238 | error_out(e) |
451 | 238 | 239 | ||
452 | 239 | vers = apt.upstream_version(pkg.current_ver.ver_str) | 240 | vers = apt.upstream_version(pkg.current_ver.ver_str) |
454 | 240 | match = re.match('^(\d+)\.(\d+)\.(\d+)', vers) | 241 | if 'swift' in pkg.name: |
455 | 242 | # Fully x.y.z match for swift versions | ||
456 | 243 | match = re.match('^(\d+)\.(\d+)\.(\d+)', vers) | ||
457 | 244 | else: | ||
458 | 245 | # x.y match only for 20XX.X | ||
459 | 246 | # and ignore patch level for other packages | ||
460 | 247 | match = re.match('^(\d+)\.(\d+)', vers) | ||
461 | 248 | |||
462 | 241 | if match: | 249 | if match: |
463 | 242 | vers = match.group(0) | 250 | vers = match.group(0) |
464 | 243 | 251 | ||
465 | @@ -249,13 +257,8 @@ | |||
466 | 249 | # < Liberty co-ordinated project versions | 257 | # < Liberty co-ordinated project versions |
467 | 250 | try: | 258 | try: |
468 | 251 | if 'swift' in pkg.name: | 259 | if 'swift' in pkg.name: |
474 | 252 | swift_vers = vers[:5] | 260 | return SWIFT_CODENAMES[vers] |
470 | 253 | if swift_vers not in SWIFT_CODENAMES: | ||
471 | 254 | # Deal with 1.10.0 upward | ||
472 | 255 | swift_vers = vers[:6] | ||
473 | 256 | return SWIFT_CODENAMES[swift_vers] | ||
475 | 257 | else: | 261 | else: |
476 | 258 | vers = vers[:6] | ||
477 | 259 | return OPENSTACK_CODENAMES[vers] | 262 | return OPENSTACK_CODENAMES[vers] |
478 | 260 | except KeyError: | 263 | except KeyError: |
479 | 261 | if not fatal: | 264 | if not fatal: |
480 | @@ -858,7 +861,9 @@ | |||
481 | 858 | if charm_state != 'active' and charm_state != 'unknown': | 861 | if charm_state != 'active' and charm_state != 'unknown': |
482 | 859 | state = workload_state_compare(state, charm_state) | 862 | state = workload_state_compare(state, charm_state) |
483 | 860 | if message: | 863 | if message: |
485 | 861 | message = "{} {}".format(message, charm_message) | 864 | charm_message = charm_message.replace("Incomplete relations: ", |
486 | 865 | "") | ||
487 | 866 | message = "{}, {}".format(message, charm_message) | ||
488 | 862 | else: | 867 | else: |
489 | 863 | message = charm_message | 868 | message = charm_message |
490 | 864 | 869 | ||
491 | 865 | 870 | ||
492 | === modified file 'hooks/charmhelpers/core/host.py' | |||
493 | --- hooks/charmhelpers/core/host.py 2015-10-22 13:19:13 +0000 | |||
494 | +++ hooks/charmhelpers/core/host.py 2016-01-07 14:14:00 +0000 | |||
495 | @@ -566,7 +566,14 @@ | |||
496 | 566 | os.chdir(cur) | 566 | os.chdir(cur) |
497 | 567 | 567 | ||
498 | 568 | 568 | ||
500 | 569 | def chownr(path, owner, group, follow_links=True): | 569 | def chownr(path, owner, group, follow_links=True, chowntopdir=False): |
501 | 570 | """ | ||
502 | 571 | Recursively change user and group ownership of files and directories | ||
503 | 572 | in given path. Doesn't chown path itself by default, only its children. | ||
504 | 573 | |||
505 | 574 | :param bool follow_links: Also Chown links if True | ||
506 | 575 | :param bool chowntopdir: Also chown path itself if True | ||
507 | 576 | """ | ||
508 | 570 | uid = pwd.getpwnam(owner).pw_uid | 577 | uid = pwd.getpwnam(owner).pw_uid |
509 | 571 | gid = grp.getgrnam(group).gr_gid | 578 | gid = grp.getgrnam(group).gr_gid |
510 | 572 | if follow_links: | 579 | if follow_links: |
511 | @@ -574,6 +581,10 @@ | |||
512 | 574 | else: | 581 | else: |
513 | 575 | chown = os.lchown | 582 | chown = os.lchown |
514 | 576 | 583 | ||
515 | 584 | if chowntopdir: | ||
516 | 585 | broken_symlink = os.path.lexists(path) and not os.path.exists(path) | ||
517 | 586 | if not broken_symlink: | ||
518 | 587 | chown(path, uid, gid) | ||
519 | 577 | for root, dirs, files in os.walk(path): | 588 | for root, dirs, files in os.walk(path): |
520 | 578 | for name in dirs + files: | 589 | for name in dirs + files: |
521 | 579 | full = os.path.join(root, name) | 590 | full = os.path.join(root, name) |
522 | 580 | 591 | ||
523 | === modified file 'hooks/charmhelpers/core/hugepage.py' | |||
524 | --- hooks/charmhelpers/core/hugepage.py 2015-10-22 13:19:13 +0000 | |||
525 | +++ hooks/charmhelpers/core/hugepage.py 2016-01-07 14:14:00 +0000 | |||
526 | @@ -46,6 +46,8 @@ | |||
527 | 46 | group_info = add_group(group) | 46 | group_info = add_group(group) |
528 | 47 | gid = group_info.gr_gid | 47 | gid = group_info.gr_gid |
529 | 48 | add_user_to_group(user, group) | 48 | add_user_to_group(user, group) |
530 | 49 | if max_map_count < 2 * nr_hugepages: | ||
531 | 50 | max_map_count = 2 * nr_hugepages | ||
532 | 49 | sysctl_settings = { | 51 | sysctl_settings = { |
533 | 50 | 'vm.nr_hugepages': nr_hugepages, | 52 | 'vm.nr_hugepages': nr_hugepages, |
534 | 51 | 'vm.max_map_count': max_map_count, | 53 | 'vm.max_map_count': max_map_count, |
535 | 52 | 54 | ||
536 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py' | |||
537 | --- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2015-10-22 13:19:13 +0000 | |||
538 | +++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-07 14:14:00 +0000 | |||
539 | @@ -14,12 +14,18 @@ | |||
540 | 14 | # You should have received a copy of the GNU Lesser General Public License | 14 | # You should have received a copy of the GNU Lesser General Public License |
541 | 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/>. |
542 | 16 | 16 | ||
543 | 17 | import logging | ||
544 | 18 | import re | ||
545 | 19 | import sys | ||
546 | 17 | import six | 20 | import six |
547 | 18 | from collections import OrderedDict | 21 | from collections import OrderedDict |
548 | 19 | from charmhelpers.contrib.amulet.deployment import ( | 22 | from charmhelpers.contrib.amulet.deployment import ( |
549 | 20 | AmuletDeployment | 23 | AmuletDeployment |
550 | 21 | ) | 24 | ) |
551 | 22 | 25 | ||
552 | 26 | DEBUG = logging.DEBUG | ||
553 | 27 | ERROR = logging.ERROR | ||
554 | 28 | |||
555 | 23 | 29 | ||
556 | 24 | class OpenStackAmuletDeployment(AmuletDeployment): | 30 | class OpenStackAmuletDeployment(AmuletDeployment): |
557 | 25 | """OpenStack amulet deployment. | 31 | """OpenStack amulet deployment. |
558 | @@ -28,9 +34,12 @@ | |||
559 | 28 | that is specifically for use by OpenStack charms. | 34 | that is specifically for use by OpenStack charms. |
560 | 29 | """ | 35 | """ |
561 | 30 | 36 | ||
563 | 31 | def __init__(self, series=None, openstack=None, source=None, stable=True): | 37 | def __init__(self, series=None, openstack=None, source=None, |
564 | 38 | stable=True, log_level=DEBUG): | ||
565 | 32 | """Initialize the deployment environment.""" | 39 | """Initialize the deployment environment.""" |
566 | 33 | super(OpenStackAmuletDeployment, self).__init__(series) | 40 | super(OpenStackAmuletDeployment, self).__init__(series) |
567 | 41 | self.log = self.get_logger(level=log_level) | ||
568 | 42 | self.log.info('OpenStackAmuletDeployment: init') | ||
569 | 34 | self.openstack = openstack | 43 | self.openstack = openstack |
570 | 35 | self.source = source | 44 | self.source = source |
571 | 36 | self.stable = stable | 45 | self.stable = stable |
572 | @@ -38,6 +47,22 @@ | |||
573 | 38 | # out. | 47 | # out. |
574 | 39 | self.current_next = "trusty" | 48 | self.current_next = "trusty" |
575 | 40 | 49 | ||
576 | 50 | def get_logger(self, name="deployment-logger", level=logging.DEBUG): | ||
577 | 51 | """Get a logger object that will log to stdout.""" | ||
578 | 52 | log = logging | ||
579 | 53 | logger = log.getLogger(name) | ||
580 | 54 | fmt = log.Formatter("%(asctime)s %(funcName)s " | ||
581 | 55 | "%(levelname)s: %(message)s") | ||
582 | 56 | |||
583 | 57 | handler = log.StreamHandler(stream=sys.stdout) | ||
584 | 58 | handler.setLevel(level) | ||
585 | 59 | handler.setFormatter(fmt) | ||
586 | 60 | |||
587 | 61 | logger.addHandler(handler) | ||
588 | 62 | logger.setLevel(level) | ||
589 | 63 | |||
590 | 64 | return logger | ||
591 | 65 | |||
592 | 41 | def _determine_branch_locations(self, other_services): | 66 | def _determine_branch_locations(self, other_services): |
593 | 42 | """Determine the branch locations for the other services. | 67 | """Determine the branch locations for the other services. |
594 | 43 | 68 | ||
595 | @@ -45,6 +70,8 @@ | |||
596 | 45 | stable or next (dev) branch, and based on this, use the corresonding | 70 | stable or next (dev) branch, and based on this, use the corresonding |
597 | 46 | stable or next branches for the other_services.""" | 71 | stable or next branches for the other_services.""" |
598 | 47 | 72 | ||
599 | 73 | self.log.info('OpenStackAmuletDeployment: determine branch locations') | ||
600 | 74 | |||
601 | 48 | # Charms outside the lp:~openstack-charmers namespace | 75 | # Charms outside the lp:~openstack-charmers namespace |
602 | 49 | base_charms = ['mysql', 'mongodb', 'nrpe'] | 76 | base_charms = ['mysql', 'mongodb', 'nrpe'] |
603 | 50 | 77 | ||
604 | @@ -82,6 +109,8 @@ | |||
605 | 82 | 109 | ||
606 | 83 | def _add_services(self, this_service, other_services): | 110 | def _add_services(self, this_service, other_services): |
607 | 84 | """Add services to the deployment and set openstack-origin/source.""" | 111 | """Add services to the deployment and set openstack-origin/source.""" |
608 | 112 | self.log.info('OpenStackAmuletDeployment: adding services') | ||
609 | 113 | |||
610 | 85 | other_services = self._determine_branch_locations(other_services) | 114 | other_services = self._determine_branch_locations(other_services) |
611 | 86 | 115 | ||
612 | 87 | super(OpenStackAmuletDeployment, self)._add_services(this_service, | 116 | super(OpenStackAmuletDeployment, self)._add_services(this_service, |
613 | @@ -111,9 +140,79 @@ | |||
614 | 111 | 140 | ||
615 | 112 | def _configure_services(self, configs): | 141 | def _configure_services(self, configs): |
616 | 113 | """Configure all of the services.""" | 142 | """Configure all of the services.""" |
617 | 143 | self.log.info('OpenStackAmuletDeployment: configure services') | ||
618 | 114 | for service, config in six.iteritems(configs): | 144 | for service, config in six.iteritems(configs): |
619 | 115 | self.d.configure(service, config) | 145 | self.d.configure(service, config) |
620 | 116 | 146 | ||
621 | 147 | def _auto_wait_for_status(self, message=None, exclude_services=None, | ||
622 | 148 | include_only=None, timeout=1800): | ||
623 | 149 | """Wait for all units to have a specific extended status, except | ||
624 | 150 | for any defined as excluded. Unless specified via message, any | ||
625 | 151 | status containing any case of 'ready' will be considered a match. | ||
626 | 152 | |||
627 | 153 | Examples of message usage: | ||
628 | 154 | |||
629 | 155 | Wait for all unit status to CONTAIN any case of 'ready' or 'ok': | ||
630 | 156 | message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE) | ||
631 | 157 | |||
632 | 158 | Wait for all units to reach this status (exact match): | ||
633 | 159 | message = re.compile('^Unit is ready and clustered$') | ||
634 | 160 | |||
635 | 161 | Wait for all units to reach any one of these (exact match): | ||
636 | 162 | message = re.compile('Unit is ready|OK|Ready') | ||
637 | 163 | |||
638 | 164 | Wait for at least one unit to reach this status (exact match): | ||
639 | 165 | message = {'ready'} | ||
640 | 166 | |||
641 | 167 | See Amulet's sentry.wait_for_messages() for message usage detail. | ||
642 | 168 | https://github.com/juju/amulet/blob/master/amulet/sentry.py | ||
643 | 169 | |||
644 | 170 | :param message: Expected status match | ||
645 | 171 | :param exclude_services: List of juju service names to ignore, | ||
646 | 172 | not to be used in conjuction with include_only. | ||
647 | 173 | :param include_only: List of juju service names to exclusively check, | ||
648 | 174 | not to be used in conjuction with exclude_services. | ||
649 | 175 | :param timeout: Maximum time in seconds to wait for status match | ||
650 | 176 | :returns: None. Raises if timeout is hit. | ||
651 | 177 | """ | ||
652 | 178 | self.log.info('Waiting for extended status on units...') | ||
653 | 179 | |||
654 | 180 | all_services = self.d.services.keys() | ||
655 | 181 | |||
656 | 182 | if exclude_services and include_only: | ||
657 | 183 | raise ValueError('exclude_services can not be used ' | ||
658 | 184 | 'with include_only') | ||
659 | 185 | |||
660 | 186 | if message: | ||
661 | 187 | if isinstance(message, re._pattern_type): | ||
662 | 188 | match = message.pattern | ||
663 | 189 | else: | ||
664 | 190 | match = message | ||
665 | 191 | |||
666 | 192 | self.log.debug('Custom extended status wait match: ' | ||
667 | 193 | '{}'.format(match)) | ||
668 | 194 | else: | ||
669 | 195 | self.log.debug('Default extended status wait match: contains ' | ||
670 | 196 | 'READY (case-insensitive)') | ||
671 | 197 | message = re.compile('.*ready.*', re.IGNORECASE) | ||
672 | 198 | |||
673 | 199 | if exclude_services: | ||
674 | 200 | self.log.debug('Excluding services from extended status match: ' | ||
675 | 201 | '{}'.format(exclude_services)) | ||
676 | 202 | else: | ||
677 | 203 | exclude_services = [] | ||
678 | 204 | |||
679 | 205 | if include_only: | ||
680 | 206 | services = include_only | ||
681 | 207 | else: | ||
682 | 208 | services = list(set(all_services) - set(exclude_services)) | ||
683 | 209 | |||
684 | 210 | self.log.debug('Waiting up to {}s for extended status on services: ' | ||
685 | 211 | '{}'.format(timeout, services)) | ||
686 | 212 | service_messages = {service: message for service in services} | ||
687 | 213 | self.d.sentry.wait_for_messages(service_messages, timeout=timeout) | ||
688 | 214 | self.log.info('OK') | ||
689 | 215 | |||
690 | 117 | def _get_openstack_release(self): | 216 | def _get_openstack_release(self): |
691 | 118 | """Get openstack release. | 217 | """Get openstack release. |
692 | 119 | 218 | ||
693 | 120 | 219 | ||
694 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/utils.py' | |||
695 | --- tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-22 13:19:13 +0000 | |||
696 | +++ tests/charmhelpers/contrib/openstack/amulet/utils.py 2016-01-07 14:14:00 +0000 | |||
697 | @@ -18,6 +18,7 @@ | |||
698 | 18 | import json | 18 | import json |
699 | 19 | import logging | 19 | import logging |
700 | 20 | import os | 20 | import os |
701 | 21 | import re | ||
702 | 21 | import six | 22 | import six |
703 | 22 | import time | 23 | import time |
704 | 23 | import urllib | 24 | import urllib |
705 | @@ -604,7 +605,22 @@ | |||
706 | 604 | '{}'.format(sample_type, samples)) | 605 | '{}'.format(sample_type, samples)) |
707 | 605 | return None | 606 | return None |
708 | 606 | 607 | ||
710 | 607 | # rabbitmq/amqp specific helpers: | 608 | # rabbitmq/amqp specific helpers: |
711 | 609 | |||
712 | 610 | def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200): | ||
713 | 611 | """Wait for rmq units extended status to show cluster readiness, | ||
714 | 612 | after an optional initial sleep period. Initial sleep is likely | ||
715 | 613 | necessary to be effective following a config change, as status | ||
716 | 614 | message may not instantly update to non-ready.""" | ||
717 | 615 | |||
718 | 616 | if init_sleep: | ||
719 | 617 | time.sleep(init_sleep) | ||
720 | 618 | |||
721 | 619 | message = re.compile('^Unit is ready and clustered$') | ||
722 | 620 | deployment._auto_wait_for_status(message=message, | ||
723 | 621 | timeout=timeout, | ||
724 | 622 | include_only=['rabbitmq-server']) | ||
725 | 623 | |||
726 | 608 | def add_rmq_test_user(self, sentry_units, | 624 | def add_rmq_test_user(self, sentry_units, |
727 | 609 | username="testuser1", password="changeme"): | 625 | username="testuser1", password="changeme"): |
728 | 610 | """Add a test user via the first rmq juju unit, check connection as | 626 | """Add a test user via the first rmq juju unit, check connection as |
729 | @@ -752,7 +768,7 @@ | |||
730 | 752 | self.log.debug('SSL is enabled @{}:{} ' | 768 | self.log.debug('SSL is enabled @{}:{} ' |
731 | 753 | '({})'.format(host, port, unit_name)) | 769 | '({})'.format(host, port, unit_name)) |
732 | 754 | return True | 770 | return True |
734 | 755 | elif not port and not conf_ssl: | 771 | elif not conf_ssl: |
735 | 756 | self.log.debug('SSL not enabled @{}:{} ' | 772 | self.log.debug('SSL not enabled @{}:{} ' |
736 | 757 | '({})'.format(host, port, unit_name)) | 773 | '({})'.format(host, port, unit_name)) |
737 | 758 | return False | 774 | return False |
738 | @@ -805,7 +821,10 @@ | |||
739 | 805 | if port: | 821 | if port: |
740 | 806 | config['ssl_port'] = port | 822 | config['ssl_port'] = port |
741 | 807 | 823 | ||
743 | 808 | deployment.configure('rabbitmq-server', config) | 824 | deployment.d.configure('rabbitmq-server', config) |
744 | 825 | |||
745 | 826 | # Wait for unit status | ||
746 | 827 | self.rmq_wait_for_cluster(deployment) | ||
747 | 809 | 828 | ||
748 | 810 | # Confirm | 829 | # Confirm |
749 | 811 | tries = 0 | 830 | tries = 0 |
750 | @@ -832,7 +851,10 @@ | |||
751 | 832 | 851 | ||
752 | 833 | # Disable RMQ SSL | 852 | # Disable RMQ SSL |
753 | 834 | config = {'ssl': 'off'} | 853 | config = {'ssl': 'off'} |
755 | 835 | deployment.configure('rabbitmq-server', config) | 854 | deployment.d.configure('rabbitmq-server', config) |
756 | 855 | |||
757 | 856 | # Wait for unit status | ||
758 | 857 | self.rmq_wait_for_cluster(deployment) | ||
759 | 836 | 858 | ||
760 | 837 | # Confirm | 859 | # Confirm |
761 | 838 | tries = 0 | 860 | tries = 0 |
charm_lint_check #16742 cinder for james-page mp281861
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/16742/