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