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