Merge lp:~hopem/charms/trusty/cinder/lp1499643 into lp:~openstack-charmers-archive/charms/trusty/cinder/next
- Trusty Tahr (14.04)
- lp1499643
- Merge into next
Proposed by
Edward Hope-Morley
Status: | Merged |
---|---|
Merged at revision: | 128 |
Proposed branch: | lp:~hopem/charms/trusty/cinder/lp1499643 |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/cinder/next |
Diff against target: |
810 lines (+407/-53) 11 files modified
hooks/charmhelpers/contrib/network/ip.py (+5/-3) hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+9/-10) hooks/charmhelpers/contrib/openstack/context.py (+52/-7) hooks/charmhelpers/contrib/openstack/templating.py (+30/-2) hooks/charmhelpers/contrib/openstack/utils.py (+181/-2) hooks/charmhelpers/core/hookenv.py (+32/-0) hooks/charmhelpers/core/hugepage.py (+8/-1) hooks/charmhelpers/core/strutils.py (+30/-0) tests/charmhelpers/contrib/amulet/deployment.py (+4/-2) tests/charmhelpers/contrib/amulet/utils.py (+47/-16) tests/charmhelpers/contrib/openstack/amulet/deployment.py (+9/-10) |
To merge this branch: | bzr merge lp:~hopem/charms/trusty/cinder/lp1499643 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Liam Young (community) | Approve | ||
Review via email: mp+272532@code.launchpad.net |
Commit message
Description of the change
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 #10058 cinder-next for hopem mp272532
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6841 cinder-next for hopem mp272532
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/network/ip.py' | |||
2 | --- hooks/charmhelpers/contrib/network/ip.py 2015-09-03 09:43:34 +0000 | |||
3 | +++ hooks/charmhelpers/contrib/network/ip.py 2015-09-27 18:46:57 +0000 | |||
4 | @@ -23,7 +23,7 @@ | |||
5 | 23 | from functools import partial | 23 | from functools import partial |
6 | 24 | 24 | ||
7 | 25 | from charmhelpers.core.hookenv import unit_get | 25 | from charmhelpers.core.hookenv import unit_get |
9 | 26 | from charmhelpers.fetch import apt_install | 26 | from charmhelpers.fetch import apt_install, apt_update |
10 | 27 | from charmhelpers.core.hookenv import ( | 27 | from charmhelpers.core.hookenv import ( |
11 | 28 | log, | 28 | log, |
12 | 29 | WARNING, | 29 | WARNING, |
13 | @@ -32,13 +32,15 @@ | |||
14 | 32 | try: | 32 | try: |
15 | 33 | import netifaces | 33 | import netifaces |
16 | 34 | except ImportError: | 34 | except ImportError: |
18 | 35 | apt_install('python-netifaces') | 35 | apt_update(fatal=True) |
19 | 36 | apt_install('python-netifaces', fatal=True) | ||
20 | 36 | import netifaces | 37 | import netifaces |
21 | 37 | 38 | ||
22 | 38 | try: | 39 | try: |
23 | 39 | import netaddr | 40 | import netaddr |
24 | 40 | except ImportError: | 41 | except ImportError: |
26 | 41 | apt_install('python-netaddr') | 42 | apt_update(fatal=True) |
27 | 43 | apt_install('python-netaddr', fatal=True) | ||
28 | 42 | import netaddr | 44 | import netaddr |
29 | 43 | 45 | ||
30 | 44 | 46 | ||
31 | 45 | 47 | ||
32 | === modified file 'hooks/charmhelpers/contrib/openstack/amulet/deployment.py' | |||
33 | --- hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2015-09-14 20:19:57 +0000 | |||
34 | +++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2015-09-27 18:46:57 +0000 | |||
35 | @@ -58,19 +58,17 @@ | |||
36 | 58 | else: | 58 | else: |
37 | 59 | base_series = self.current_next | 59 | base_series = self.current_next |
38 | 60 | 60 | ||
44 | 61 | if self.stable: | 61 | for svc in other_services: |
45 | 62 | for svc in other_services: | 62 | if svc['name'] in force_series_current: |
46 | 63 | if svc['name'] in force_series_current: | 63 | base_series = self.current_next |
47 | 64 | base_series = self.current_next | 64 | # If a location has been explicitly set, use it |
48 | 65 | 65 | if svc.get('location'): | |
49 | 66 | continue | ||
50 | 67 | if self.stable: | ||
51 | 66 | temp = 'lp:charms/{}/{}' | 68 | temp = 'lp:charms/{}/{}' |
52 | 67 | svc['location'] = temp.format(base_series, | 69 | svc['location'] = temp.format(base_series, |
53 | 68 | svc['name']) | 70 | svc['name']) |
59 | 69 | else: | 71 | else: |
55 | 70 | for svc in other_services: | ||
56 | 71 | if svc['name'] in force_series_current: | ||
57 | 72 | base_series = self.current_next | ||
58 | 73 | |||
60 | 74 | if svc['name'] in base_charms: | 72 | if svc['name'] in base_charms: |
61 | 75 | temp = 'lp:charms/{}/{}' | 73 | temp = 'lp:charms/{}/{}' |
62 | 76 | svc['location'] = temp.format(base_series, | 74 | svc['location'] = temp.format(base_series, |
63 | @@ -79,6 +77,7 @@ | |||
64 | 79 | temp = 'lp:~openstack-charmers/charms/{}/{}/next' | 77 | temp = 'lp:~openstack-charmers/charms/{}/{}/next' |
65 | 80 | svc['location'] = temp.format(self.current_next, | 78 | svc['location'] = temp.format(self.current_next, |
66 | 81 | svc['name']) | 79 | svc['name']) |
67 | 80 | |||
68 | 82 | return other_services | 81 | return other_services |
69 | 83 | 82 | ||
70 | 84 | def _add_services(self, this_service, other_services): | 83 | def _add_services(self, this_service, other_services): |
71 | 85 | 84 | ||
72 | === modified file 'hooks/charmhelpers/contrib/openstack/context.py' | |||
73 | --- hooks/charmhelpers/contrib/openstack/context.py 2015-09-12 06:32:34 +0000 | |||
74 | +++ hooks/charmhelpers/contrib/openstack/context.py 2015-09-27 18:46:57 +0000 | |||
75 | @@ -194,10 +194,50 @@ | |||
76 | 194 | class OSContextGenerator(object): | 194 | class OSContextGenerator(object): |
77 | 195 | """Base class for all context generators.""" | 195 | """Base class for all context generators.""" |
78 | 196 | interfaces = [] | 196 | interfaces = [] |
79 | 197 | related = False | ||
80 | 198 | complete = False | ||
81 | 199 | missing_data = [] | ||
82 | 197 | 200 | ||
83 | 198 | def __call__(self): | 201 | def __call__(self): |
84 | 199 | raise NotImplementedError | 202 | raise NotImplementedError |
85 | 200 | 203 | ||
86 | 204 | def context_complete(self, ctxt): | ||
87 | 205 | """Check for missing data for the required context data. | ||
88 | 206 | Set self.missing_data if it exists and return False. | ||
89 | 207 | Set self.complete if no missing data and return True. | ||
90 | 208 | """ | ||
91 | 209 | # Fresh start | ||
92 | 210 | self.complete = False | ||
93 | 211 | self.missing_data = [] | ||
94 | 212 | for k, v in six.iteritems(ctxt): | ||
95 | 213 | if v is None or v == '': | ||
96 | 214 | if k not in self.missing_data: | ||
97 | 215 | self.missing_data.append(k) | ||
98 | 216 | |||
99 | 217 | if self.missing_data: | ||
100 | 218 | self.complete = False | ||
101 | 219 | log('Missing required data: %s' % ' '.join(self.missing_data), level=INFO) | ||
102 | 220 | else: | ||
103 | 221 | self.complete = True | ||
104 | 222 | return self.complete | ||
105 | 223 | |||
106 | 224 | def get_related(self): | ||
107 | 225 | """Check if any of the context interfaces have relation ids. | ||
108 | 226 | Set self.related and return True if one of the interfaces | ||
109 | 227 | has relation ids. | ||
110 | 228 | """ | ||
111 | 229 | # Fresh start | ||
112 | 230 | self.related = False | ||
113 | 231 | try: | ||
114 | 232 | for interface in self.interfaces: | ||
115 | 233 | if relation_ids(interface): | ||
116 | 234 | self.related = True | ||
117 | 235 | return self.related | ||
118 | 236 | except AttributeError as e: | ||
119 | 237 | log("{} {}" | ||
120 | 238 | "".format(self, e), 'INFO') | ||
121 | 239 | return self.related | ||
122 | 240 | |||
123 | 201 | 241 | ||
124 | 202 | class SharedDBContext(OSContextGenerator): | 242 | class SharedDBContext(OSContextGenerator): |
125 | 203 | interfaces = ['shared-db'] | 243 | interfaces = ['shared-db'] |
126 | @@ -213,6 +253,7 @@ | |||
127 | 213 | self.database = database | 253 | self.database = database |
128 | 214 | self.user = user | 254 | self.user = user |
129 | 215 | self.ssl_dir = ssl_dir | 255 | self.ssl_dir = ssl_dir |
130 | 256 | self.rel_name = self.interfaces[0] | ||
131 | 216 | 257 | ||
132 | 217 | def __call__(self): | 258 | def __call__(self): |
133 | 218 | self.database = self.database or config('database') | 259 | self.database = self.database or config('database') |
134 | @@ -246,6 +287,7 @@ | |||
135 | 246 | password_setting = self.relation_prefix + '_password' | 287 | password_setting = self.relation_prefix + '_password' |
136 | 247 | 288 | ||
137 | 248 | for rid in relation_ids(self.interfaces[0]): | 289 | for rid in relation_ids(self.interfaces[0]): |
138 | 290 | self.related = True | ||
139 | 249 | for unit in related_units(rid): | 291 | for unit in related_units(rid): |
140 | 250 | rdata = relation_get(rid=rid, unit=unit) | 292 | rdata = relation_get(rid=rid, unit=unit) |
141 | 251 | host = rdata.get('db_host') | 293 | host = rdata.get('db_host') |
142 | @@ -257,7 +299,7 @@ | |||
143 | 257 | 'database_password': rdata.get(password_setting), | 299 | 'database_password': rdata.get(password_setting), |
144 | 258 | 'database_type': 'mysql' | 300 | 'database_type': 'mysql' |
145 | 259 | } | 301 | } |
147 | 260 | if context_complete(ctxt): | 302 | if self.context_complete(ctxt): |
148 | 261 | db_ssl(rdata, ctxt, self.ssl_dir) | 303 | db_ssl(rdata, ctxt, self.ssl_dir) |
149 | 262 | return ctxt | 304 | return ctxt |
150 | 263 | return {} | 305 | return {} |
151 | @@ -278,6 +320,7 @@ | |||
152 | 278 | 320 | ||
153 | 279 | ctxt = {} | 321 | ctxt = {} |
154 | 280 | for rid in relation_ids(self.interfaces[0]): | 322 | for rid in relation_ids(self.interfaces[0]): |
155 | 323 | self.related = True | ||
156 | 281 | for unit in related_units(rid): | 324 | for unit in related_units(rid): |
157 | 282 | rel_host = relation_get('host', rid=rid, unit=unit) | 325 | rel_host = relation_get('host', rid=rid, unit=unit) |
158 | 283 | rel_user = relation_get('user', rid=rid, unit=unit) | 326 | rel_user = relation_get('user', rid=rid, unit=unit) |
159 | @@ -287,7 +330,7 @@ | |||
160 | 287 | 'database_user': rel_user, | 330 | 'database_user': rel_user, |
161 | 288 | 'database_password': rel_passwd, | 331 | 'database_password': rel_passwd, |
162 | 289 | 'database_type': 'postgresql'} | 332 | 'database_type': 'postgresql'} |
164 | 290 | if context_complete(ctxt): | 333 | if self.context_complete(ctxt): |
165 | 291 | return ctxt | 334 | return ctxt |
166 | 292 | 335 | ||
167 | 293 | return {} | 336 | return {} |
168 | @@ -348,6 +391,7 @@ | |||
169 | 348 | ctxt['signing_dir'] = cachedir | 391 | ctxt['signing_dir'] = cachedir |
170 | 349 | 392 | ||
171 | 350 | for rid in relation_ids(self.rel_name): | 393 | for rid in relation_ids(self.rel_name): |
172 | 394 | self.related = True | ||
173 | 351 | for unit in related_units(rid): | 395 | for unit in related_units(rid): |
174 | 352 | rdata = relation_get(rid=rid, unit=unit) | 396 | rdata = relation_get(rid=rid, unit=unit) |
175 | 353 | serv_host = rdata.get('service_host') | 397 | serv_host = rdata.get('service_host') |
176 | @@ -366,7 +410,7 @@ | |||
177 | 366 | 'service_protocol': svc_protocol, | 410 | 'service_protocol': svc_protocol, |
178 | 367 | 'auth_protocol': auth_protocol}) | 411 | 'auth_protocol': auth_protocol}) |
179 | 368 | 412 | ||
181 | 369 | if context_complete(ctxt): | 413 | if self.context_complete(ctxt): |
182 | 370 | # NOTE(jamespage) this is required for >= icehouse | 414 | # NOTE(jamespage) this is required for >= icehouse |
183 | 371 | # so a missing value just indicates keystone needs | 415 | # so a missing value just indicates keystone needs |
184 | 372 | # upgrading | 416 | # upgrading |
185 | @@ -405,6 +449,7 @@ | |||
186 | 405 | ctxt = {} | 449 | ctxt = {} |
187 | 406 | for rid in relation_ids(self.rel_name): | 450 | for rid in relation_ids(self.rel_name): |
188 | 407 | ha_vip_only = False | 451 | ha_vip_only = False |
189 | 452 | self.related = True | ||
190 | 408 | for unit in related_units(rid): | 453 | for unit in related_units(rid): |
191 | 409 | if relation_get('clustered', rid=rid, unit=unit): | 454 | if relation_get('clustered', rid=rid, unit=unit): |
192 | 410 | ctxt['clustered'] = True | 455 | ctxt['clustered'] = True |
193 | @@ -437,7 +482,7 @@ | |||
194 | 437 | ha_vip_only = relation_get('ha-vip-only', | 482 | ha_vip_only = relation_get('ha-vip-only', |
195 | 438 | rid=rid, unit=unit) is not None | 483 | rid=rid, unit=unit) is not None |
196 | 439 | 484 | ||
198 | 440 | if context_complete(ctxt): | 485 | if self.context_complete(ctxt): |
199 | 441 | if 'rabbit_ssl_ca' in ctxt: | 486 | if 'rabbit_ssl_ca' in ctxt: |
200 | 442 | if not self.ssl_dir: | 487 | if not self.ssl_dir: |
201 | 443 | log("Charm not setup for ssl support but ssl ca " | 488 | log("Charm not setup for ssl support but ssl ca " |
202 | @@ -469,7 +514,7 @@ | |||
203 | 469 | ctxt['oslo_messaging_flags'] = config_flags_parser( | 514 | ctxt['oslo_messaging_flags'] = config_flags_parser( |
204 | 470 | oslo_messaging_flags) | 515 | oslo_messaging_flags) |
205 | 471 | 516 | ||
207 | 472 | if not context_complete(ctxt): | 517 | if not self.complete: |
208 | 473 | return {} | 518 | return {} |
209 | 474 | 519 | ||
210 | 475 | return ctxt | 520 | return ctxt |
211 | @@ -507,7 +552,7 @@ | |||
212 | 507 | if not os.path.isdir('/etc/ceph'): | 552 | if not os.path.isdir('/etc/ceph'): |
213 | 508 | os.mkdir('/etc/ceph') | 553 | os.mkdir('/etc/ceph') |
214 | 509 | 554 | ||
216 | 510 | if not context_complete(ctxt): | 555 | if not self.context_complete(ctxt): |
217 | 511 | return {} | 556 | return {} |
218 | 512 | 557 | ||
219 | 513 | ensure_packages(['ceph-common']) | 558 | ensure_packages(['ceph-common']) |
220 | @@ -1366,6 +1411,6 @@ | |||
221 | 1366 | 'auth_protocol': | 1411 | 'auth_protocol': |
222 | 1367 | rdata.get('auth_protocol') or 'http', | 1412 | rdata.get('auth_protocol') or 'http', |
223 | 1368 | } | 1413 | } |
225 | 1369 | if context_complete(ctxt): | 1414 | if self.context_complete(ctxt): |
226 | 1370 | return ctxt | 1415 | return ctxt |
227 | 1371 | return {} | 1416 | return {} |
228 | 1372 | 1417 | ||
229 | === modified file 'hooks/charmhelpers/contrib/openstack/templating.py' | |||
230 | --- hooks/charmhelpers/contrib/openstack/templating.py 2015-07-29 10:49:28 +0000 | |||
231 | +++ hooks/charmhelpers/contrib/openstack/templating.py 2015-09-27 18:46:57 +0000 | |||
232 | @@ -18,7 +18,7 @@ | |||
233 | 18 | 18 | ||
234 | 19 | import six | 19 | import six |
235 | 20 | 20 | ||
237 | 21 | from charmhelpers.fetch import apt_install | 21 | from charmhelpers.fetch import apt_install, apt_update |
238 | 22 | from charmhelpers.core.hookenv import ( | 22 | from charmhelpers.core.hookenv import ( |
239 | 23 | log, | 23 | log, |
240 | 24 | ERROR, | 24 | ERROR, |
241 | @@ -29,6 +29,7 @@ | |||
242 | 29 | try: | 29 | try: |
243 | 30 | from jinja2 import FileSystemLoader, ChoiceLoader, Environment, exceptions | 30 | from jinja2 import FileSystemLoader, ChoiceLoader, Environment, exceptions |
244 | 31 | except ImportError: | 31 | except ImportError: |
245 | 32 | apt_update(fatal=True) | ||
246 | 32 | apt_install('python-jinja2', fatal=True) | 33 | apt_install('python-jinja2', fatal=True) |
247 | 33 | from jinja2 import FileSystemLoader, ChoiceLoader, Environment, exceptions | 34 | from jinja2 import FileSystemLoader, ChoiceLoader, Environment, exceptions |
248 | 34 | 35 | ||
249 | @@ -112,7 +113,7 @@ | |||
250 | 112 | 113 | ||
251 | 113 | def complete_contexts(self): | 114 | def complete_contexts(self): |
252 | 114 | ''' | 115 | ''' |
254 | 115 | Return a list of interfaces that have atisfied contexts. | 116 | Return a list of interfaces that have satisfied contexts. |
255 | 116 | ''' | 117 | ''' |
256 | 117 | if self._complete_contexts: | 118 | if self._complete_contexts: |
257 | 118 | return self._complete_contexts | 119 | return self._complete_contexts |
258 | @@ -293,3 +294,30 @@ | |||
259 | 293 | [interfaces.extend(i.complete_contexts()) | 294 | [interfaces.extend(i.complete_contexts()) |
260 | 294 | for i in six.itervalues(self.templates)] | 295 | for i in six.itervalues(self.templates)] |
261 | 295 | return interfaces | 296 | return interfaces |
262 | 297 | |||
263 | 298 | def get_incomplete_context_data(self, interfaces): | ||
264 | 299 | ''' | ||
265 | 300 | Return dictionary of relation status of interfaces and any missing | ||
266 | 301 | required context data. Example: | ||
267 | 302 | {'amqp': {'missing_data': ['rabbitmq_password'], 'related': True}, | ||
268 | 303 | 'zeromq-configuration': {'related': False}} | ||
269 | 304 | ''' | ||
270 | 305 | incomplete_context_data = {} | ||
271 | 306 | |||
272 | 307 | for i in six.itervalues(self.templates): | ||
273 | 308 | for context in i.contexts: | ||
274 | 309 | for interface in interfaces: | ||
275 | 310 | related = False | ||
276 | 311 | if interface in context.interfaces: | ||
277 | 312 | related = context.get_related() | ||
278 | 313 | missing_data = context.missing_data | ||
279 | 314 | if missing_data: | ||
280 | 315 | incomplete_context_data[interface] = {'missing_data': missing_data} | ||
281 | 316 | if related: | ||
282 | 317 | if incomplete_context_data.get(interface): | ||
283 | 318 | incomplete_context_data[interface].update({'related': True}) | ||
284 | 319 | else: | ||
285 | 320 | incomplete_context_data[interface] = {'related': True} | ||
286 | 321 | else: | ||
287 | 322 | incomplete_context_data[interface] = {'related': False} | ||
288 | 323 | return incomplete_context_data | ||
289 | 296 | 324 | ||
290 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
291 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-14 20:19:57 +0000 | |||
292 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-09-27 18:46:57 +0000 | |||
293 | @@ -42,7 +42,9 @@ | |||
294 | 42 | charm_dir, | 42 | charm_dir, |
295 | 43 | INFO, | 43 | INFO, |
296 | 44 | relation_ids, | 44 | relation_ids, |
298 | 45 | relation_set | 45 | relation_set, |
299 | 46 | status_set, | ||
300 | 47 | hook_name | ||
301 | 46 | ) | 48 | ) |
302 | 47 | 49 | ||
303 | 48 | from charmhelpers.contrib.storage.linux.lvm import ( | 50 | from charmhelpers.contrib.storage.linux.lvm import ( |
304 | @@ -52,7 +54,8 @@ | |||
305 | 52 | ) | 54 | ) |
306 | 53 | 55 | ||
307 | 54 | from charmhelpers.contrib.network.ip import ( | 56 | from charmhelpers.contrib.network.ip import ( |
309 | 55 | get_ipv6_addr | 57 | get_ipv6_addr, |
310 | 58 | is_ipv6, | ||
311 | 56 | ) | 59 | ) |
312 | 57 | 60 | ||
313 | 58 | from charmhelpers.contrib.python.packages import ( | 61 | from charmhelpers.contrib.python.packages import ( |
314 | @@ -517,6 +520,12 @@ | |||
315 | 517 | relation_prefix=None): | 520 | relation_prefix=None): |
316 | 518 | hosts = get_ipv6_addr(dynamic_only=False) | 521 | hosts = get_ipv6_addr(dynamic_only=False) |
317 | 519 | 522 | ||
318 | 523 | if config('vip'): | ||
319 | 524 | vips = config('vip').split() | ||
320 | 525 | for vip in vips: | ||
321 | 526 | if vip and is_ipv6(vip): | ||
322 | 527 | hosts.append(vip) | ||
323 | 528 | |||
324 | 520 | kwargs = {'database': database, | 529 | kwargs = {'database': database, |
325 | 521 | 'username': database_user, | 530 | 'username': database_user, |
326 | 522 | 'hostname': json.dumps(hosts)} | 531 | 'hostname': json.dumps(hosts)} |
327 | @@ -754,6 +763,176 @@ | |||
328 | 754 | return None | 763 | return None |
329 | 755 | 764 | ||
330 | 756 | 765 | ||
331 | 766 | def os_workload_status(configs, required_interfaces, charm_func=None): | ||
332 | 767 | """ | ||
333 | 768 | Decorator to set workload status based on complete contexts | ||
334 | 769 | """ | ||
335 | 770 | def wrap(f): | ||
336 | 771 | @wraps(f) | ||
337 | 772 | def wrapped_f(*args, **kwargs): | ||
338 | 773 | # Run the original function first | ||
339 | 774 | f(*args, **kwargs) | ||
340 | 775 | # Set workload status now that contexts have been | ||
341 | 776 | # acted on | ||
342 | 777 | set_os_workload_status(configs, required_interfaces, charm_func) | ||
343 | 778 | return wrapped_f | ||
344 | 779 | return wrap | ||
345 | 780 | |||
346 | 781 | |||
347 | 782 | def set_os_workload_status(configs, required_interfaces, charm_func=None): | ||
348 | 783 | """ | ||
349 | 784 | Set workload status based on complete contexts. | ||
350 | 785 | status-set missing or incomplete contexts | ||
351 | 786 | and juju-log details of missing required data. | ||
352 | 787 | charm_func is a charm specific function to run checking | ||
353 | 788 | for charm specific requirements such as a VIP setting. | ||
354 | 789 | """ | ||
355 | 790 | incomplete_rel_data = incomplete_relation_data(configs, required_interfaces) | ||
356 | 791 | state = 'active' | ||
357 | 792 | missing_relations = [] | ||
358 | 793 | incomplete_relations = [] | ||
359 | 794 | message = None | ||
360 | 795 | charm_state = None | ||
361 | 796 | charm_message = None | ||
362 | 797 | |||
363 | 798 | for generic_interface in incomplete_rel_data.keys(): | ||
364 | 799 | related_interface = None | ||
365 | 800 | missing_data = {} | ||
366 | 801 | # Related or not? | ||
367 | 802 | for interface in incomplete_rel_data[generic_interface]: | ||
368 | 803 | if incomplete_rel_data[generic_interface][interface].get('related'): | ||
369 | 804 | related_interface = interface | ||
370 | 805 | missing_data = incomplete_rel_data[generic_interface][interface].get('missing_data') | ||
371 | 806 | # No relation ID for the generic_interface | ||
372 | 807 | if not related_interface: | ||
373 | 808 | juju_log("{} relation is missing and must be related for " | ||
374 | 809 | "functionality. ".format(generic_interface), 'WARN') | ||
375 | 810 | state = 'blocked' | ||
376 | 811 | if generic_interface not in missing_relations: | ||
377 | 812 | missing_relations.append(generic_interface) | ||
378 | 813 | else: | ||
379 | 814 | # Relation ID exists but no related unit | ||
380 | 815 | if not missing_data: | ||
381 | 816 | # Edge case relation ID exists but departing | ||
382 | 817 | if ('departed' in hook_name() or 'broken' in hook_name()) \ | ||
383 | 818 | and related_interface in hook_name(): | ||
384 | 819 | state = 'blocked' | ||
385 | 820 | if generic_interface not in missing_relations: | ||
386 | 821 | missing_relations.append(generic_interface) | ||
387 | 822 | juju_log("{} relation's interface, {}, " | ||
388 | 823 | "relationship is departed or broken " | ||
389 | 824 | "and is required for functionality." | ||
390 | 825 | "".format(generic_interface, related_interface), "WARN") | ||
391 | 826 | # Normal case relation ID exists but no related unit | ||
392 | 827 | # (joining) | ||
393 | 828 | else: | ||
394 | 829 | juju_log("{} relations's interface, {}, is related but has " | ||
395 | 830 | "no units in the relation." | ||
396 | 831 | "".format(generic_interface, related_interface), "INFO") | ||
397 | 832 | # Related unit exists and data missing on the relation | ||
398 | 833 | else: | ||
399 | 834 | juju_log("{} relation's interface, {}, is related awaiting " | ||
400 | 835 | "the following data from the relationship: {}. " | ||
401 | 836 | "".format(generic_interface, related_interface, | ||
402 | 837 | ", ".join(missing_data)), "INFO") | ||
403 | 838 | if state != 'blocked': | ||
404 | 839 | state = 'waiting' | ||
405 | 840 | if generic_interface not in incomplete_relations \ | ||
406 | 841 | and generic_interface not in missing_relations: | ||
407 | 842 | incomplete_relations.append(generic_interface) | ||
408 | 843 | |||
409 | 844 | if missing_relations: | ||
410 | 845 | message = "Missing relations: {}".format(", ".join(missing_relations)) | ||
411 | 846 | if incomplete_relations: | ||
412 | 847 | message += "; incomplete relations: {}" \ | ||
413 | 848 | "".format(", ".join(incomplete_relations)) | ||
414 | 849 | state = 'blocked' | ||
415 | 850 | elif incomplete_relations: | ||
416 | 851 | message = "Incomplete relations: {}" \ | ||
417 | 852 | "".format(", ".join(incomplete_relations)) | ||
418 | 853 | state = 'waiting' | ||
419 | 854 | |||
420 | 855 | # Run charm specific checks | ||
421 | 856 | if charm_func: | ||
422 | 857 | charm_state, charm_message = charm_func(configs) | ||
423 | 858 | if charm_state != 'active' and charm_state != 'unknown': | ||
424 | 859 | state = workload_state_compare(state, charm_state) | ||
425 | 860 | if message: | ||
426 | 861 | message = "{} {}".format(message, charm_message) | ||
427 | 862 | else: | ||
428 | 863 | message = charm_message | ||
429 | 864 | |||
430 | 865 | # Set to active if all requirements have been met | ||
431 | 866 | if state == 'active': | ||
432 | 867 | message = "Unit is ready" | ||
433 | 868 | juju_log(message, "INFO") | ||
434 | 869 | |||
435 | 870 | status_set(state, message) | ||
436 | 871 | |||
437 | 872 | |||
438 | 873 | def workload_state_compare(current_workload_state, workload_state): | ||
439 | 874 | """ Return highest priority of two states""" | ||
440 | 875 | hierarchy = {'unknown': -1, | ||
441 | 876 | 'active': 0, | ||
442 | 877 | 'maintenance': 1, | ||
443 | 878 | 'waiting': 2, | ||
444 | 879 | 'blocked': 3, | ||
445 | 880 | } | ||
446 | 881 | |||
447 | 882 | if hierarchy.get(workload_state) is None: | ||
448 | 883 | workload_state = 'unknown' | ||
449 | 884 | if hierarchy.get(current_workload_state) is None: | ||
450 | 885 | current_workload_state = 'unknown' | ||
451 | 886 | |||
452 | 887 | # Set workload_state based on hierarchy of statuses | ||
453 | 888 | if hierarchy.get(current_workload_state) > hierarchy.get(workload_state): | ||
454 | 889 | return current_workload_state | ||
455 | 890 | else: | ||
456 | 891 | return workload_state | ||
457 | 892 | |||
458 | 893 | |||
459 | 894 | def incomplete_relation_data(configs, required_interfaces): | ||
460 | 895 | """ | ||
461 | 896 | Check complete contexts against required_interfaces | ||
462 | 897 | Return dictionary of incomplete relation data. | ||
463 | 898 | |||
464 | 899 | configs is an OSConfigRenderer object with configs registered | ||
465 | 900 | |||
466 | 901 | required_interfaces is a dictionary of required general interfaces | ||
467 | 902 | with dictionary values of possible specific interfaces. | ||
468 | 903 | Example: | ||
469 | 904 | required_interfaces = {'database': ['shared-db', 'pgsql-db']} | ||
470 | 905 | |||
471 | 906 | The interface is said to be satisfied if anyone of the interfaces in the | ||
472 | 907 | list has a complete context. | ||
473 | 908 | |||
474 | 909 | Return dictionary of incomplete or missing required contexts with relation | ||
475 | 910 | status of interfaces and any missing data points. Example: | ||
476 | 911 | {'message': | ||
477 | 912 | {'amqp': {'missing_data': ['rabbitmq_password'], 'related': True}, | ||
478 | 913 | 'zeromq-configuration': {'related': False}}, | ||
479 | 914 | 'identity': | ||
480 | 915 | {'identity-service': {'related': False}}, | ||
481 | 916 | 'database': | ||
482 | 917 | {'pgsql-db': {'related': False}, | ||
483 | 918 | 'shared-db': {'related': True}}} | ||
484 | 919 | """ | ||
485 | 920 | complete_ctxts = configs.complete_contexts() | ||
486 | 921 | incomplete_relations = [] | ||
487 | 922 | for svc_type in required_interfaces.keys(): | ||
488 | 923 | # Avoid duplicates | ||
489 | 924 | found_ctxt = False | ||
490 | 925 | for interface in required_interfaces[svc_type]: | ||
491 | 926 | if interface in complete_ctxts: | ||
492 | 927 | found_ctxt = True | ||
493 | 928 | if not found_ctxt: | ||
494 | 929 | incomplete_relations.append(svc_type) | ||
495 | 930 | incomplete_context_data = {} | ||
496 | 931 | for i in incomplete_relations: | ||
497 | 932 | incomplete_context_data[i] = configs.get_incomplete_context_data(required_interfaces[i]) | ||
498 | 933 | return incomplete_context_data | ||
499 | 934 | |||
500 | 935 | |||
501 | 757 | def do_action_openstack_upgrade(package, upgrade_callback, configs): | 936 | def do_action_openstack_upgrade(package, upgrade_callback, configs): |
502 | 758 | """Perform action-managed OpenStack upgrade. | 937 | """Perform action-managed OpenStack upgrade. |
503 | 759 | 938 | ||
504 | 760 | 939 | ||
505 | === modified file 'hooks/charmhelpers/core/hookenv.py' | |||
506 | --- hooks/charmhelpers/core/hookenv.py 2015-09-03 09:43:34 +0000 | |||
507 | +++ hooks/charmhelpers/core/hookenv.py 2015-09-27 18:46:57 +0000 | |||
508 | @@ -623,6 +623,38 @@ | |||
509 | 623 | return unit_get('private-address') | 623 | return unit_get('private-address') |
510 | 624 | 624 | ||
511 | 625 | 625 | ||
512 | 626 | @cached | ||
513 | 627 | def storage_get(attribute="", storage_id=""): | ||
514 | 628 | """Get storage attributes""" | ||
515 | 629 | _args = ['storage-get', '--format=json'] | ||
516 | 630 | if storage_id: | ||
517 | 631 | _args.extend(('-s', storage_id)) | ||
518 | 632 | if attribute: | ||
519 | 633 | _args.append(attribute) | ||
520 | 634 | try: | ||
521 | 635 | return json.loads(subprocess.check_output(_args).decode('UTF-8')) | ||
522 | 636 | except ValueError: | ||
523 | 637 | return None | ||
524 | 638 | |||
525 | 639 | |||
526 | 640 | @cached | ||
527 | 641 | def storage_list(storage_name=""): | ||
528 | 642 | """List the storage IDs for the unit""" | ||
529 | 643 | _args = ['storage-list', '--format=json'] | ||
530 | 644 | if storage_name: | ||
531 | 645 | _args.append(storage_name) | ||
532 | 646 | try: | ||
533 | 647 | return json.loads(subprocess.check_output(_args).decode('UTF-8')) | ||
534 | 648 | except ValueError: | ||
535 | 649 | return None | ||
536 | 650 | except OSError as e: | ||
537 | 651 | import errno | ||
538 | 652 | if e.errno == errno.ENOENT: | ||
539 | 653 | # storage-list does not exist | ||
540 | 654 | return [] | ||
541 | 655 | raise | ||
542 | 656 | |||
543 | 657 | |||
544 | 626 | class UnregisteredHookError(Exception): | 658 | class UnregisteredHookError(Exception): |
545 | 627 | """Raised when an undefined hook is called""" | 659 | """Raised when an undefined hook is called""" |
546 | 628 | pass | 660 | pass |
547 | 629 | 661 | ||
548 | === modified file 'hooks/charmhelpers/core/hugepage.py' | |||
549 | --- hooks/charmhelpers/core/hugepage.py 2015-08-19 13:51:56 +0000 | |||
550 | +++ hooks/charmhelpers/core/hugepage.py 2015-09-27 18:46:57 +0000 | |||
551 | @@ -25,11 +25,13 @@ | |||
552 | 25 | fstab_mount, | 25 | fstab_mount, |
553 | 26 | mkdir, | 26 | mkdir, |
554 | 27 | ) | 27 | ) |
555 | 28 | from charmhelpers.core.strutils import bytes_from_string | ||
556 | 29 | from subprocess import check_output | ||
557 | 28 | 30 | ||
558 | 29 | 31 | ||
559 | 30 | def hugepage_support(user, group='hugetlb', nr_hugepages=256, | 32 | def hugepage_support(user, group='hugetlb', nr_hugepages=256, |
560 | 31 | max_map_count=65536, mnt_point='/run/hugepages/kvm', | 33 | max_map_count=65536, mnt_point='/run/hugepages/kvm', |
562 | 32 | pagesize='2MB', mount=True): | 34 | pagesize='2MB', mount=True, set_shmmax=False): |
563 | 33 | """Enable hugepages on system. | 35 | """Enable hugepages on system. |
564 | 34 | 36 | ||
565 | 35 | Args: | 37 | Args: |
566 | @@ -49,6 +51,11 @@ | |||
567 | 49 | 'vm.max_map_count': max_map_count, | 51 | 'vm.max_map_count': max_map_count, |
568 | 50 | 'vm.hugetlb_shm_group': gid, | 52 | 'vm.hugetlb_shm_group': gid, |
569 | 51 | } | 53 | } |
570 | 54 | if set_shmmax: | ||
571 | 55 | shmmax_current = int(check_output(['sysctl', '-n', 'kernel.shmmax'])) | ||
572 | 56 | shmmax_minsize = bytes_from_string(pagesize) * nr_hugepages | ||
573 | 57 | if shmmax_minsize > shmmax_current: | ||
574 | 58 | sysctl_settings['kernel.shmmax'] = shmmax_minsize | ||
575 | 52 | sysctl.create(yaml.dump(sysctl_settings), '/etc/sysctl.d/10-hugepage.conf') | 59 | sysctl.create(yaml.dump(sysctl_settings), '/etc/sysctl.d/10-hugepage.conf') |
576 | 53 | mkdir(mnt_point, owner='root', group='root', perms=0o755, force=False) | 60 | mkdir(mnt_point, owner='root', group='root', perms=0o755, force=False) |
577 | 54 | lfstab = fstab.Fstab() | 61 | lfstab = fstab.Fstab() |
578 | 55 | 62 | ||
579 | === modified file 'hooks/charmhelpers/core/strutils.py' | |||
580 | --- hooks/charmhelpers/core/strutils.py 2015-04-13 19:41:31 +0000 | |||
581 | +++ hooks/charmhelpers/core/strutils.py 2015-09-27 18:46:57 +0000 | |||
582 | @@ -18,6 +18,7 @@ | |||
583 | 18 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. | 18 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
584 | 19 | 19 | ||
585 | 20 | import six | 20 | import six |
586 | 21 | import re | ||
587 | 21 | 22 | ||
588 | 22 | 23 | ||
589 | 23 | def bool_from_string(value): | 24 | def bool_from_string(value): |
590 | @@ -40,3 +41,32 @@ | |||
591 | 40 | 41 | ||
592 | 41 | msg = "Unable to interpret string value '%s' as boolean" % (value) | 42 | msg = "Unable to interpret string value '%s' as boolean" % (value) |
593 | 42 | raise ValueError(msg) | 43 | raise ValueError(msg) |
594 | 44 | |||
595 | 45 | |||
596 | 46 | def bytes_from_string(value): | ||
597 | 47 | """Interpret human readable string value as bytes. | ||
598 | 48 | |||
599 | 49 | Returns int | ||
600 | 50 | """ | ||
601 | 51 | BYTE_POWER = { | ||
602 | 52 | 'K': 1, | ||
603 | 53 | 'KB': 1, | ||
604 | 54 | 'M': 2, | ||
605 | 55 | 'MB': 2, | ||
606 | 56 | 'G': 3, | ||
607 | 57 | 'GB': 3, | ||
608 | 58 | 'T': 4, | ||
609 | 59 | 'TB': 4, | ||
610 | 60 | 'P': 5, | ||
611 | 61 | 'PB': 5, | ||
612 | 62 | } | ||
613 | 63 | if isinstance(value, six.string_types): | ||
614 | 64 | value = six.text_type(value) | ||
615 | 65 | else: | ||
616 | 66 | msg = "Unable to interpret non-string value '%s' as boolean" % (value) | ||
617 | 67 | raise ValueError(msg) | ||
618 | 68 | matches = re.match("([0-9]+)([a-zA-Z]+)", value) | ||
619 | 69 | if not matches: | ||
620 | 70 | msg = "Unable to interpret string value '%s' as bytes" % (value) | ||
621 | 71 | raise ValueError(msg) | ||
622 | 72 | return int(matches.group(1)) * (1024 ** BYTE_POWER[matches.group(2)]) | ||
623 | 43 | 73 | ||
624 | === modified file 'tests/charmhelpers/contrib/amulet/deployment.py' | |||
625 | --- tests/charmhelpers/contrib/amulet/deployment.py 2015-01-26 09:47:37 +0000 | |||
626 | +++ tests/charmhelpers/contrib/amulet/deployment.py 2015-09-27 18:46:57 +0000 | |||
627 | @@ -51,7 +51,8 @@ | |||
628 | 51 | if 'units' not in this_service: | 51 | if 'units' not in this_service: |
629 | 52 | this_service['units'] = 1 | 52 | this_service['units'] = 1 |
630 | 53 | 53 | ||
632 | 54 | self.d.add(this_service['name'], units=this_service['units']) | 54 | self.d.add(this_service['name'], units=this_service['units'], |
633 | 55 | constraints=this_service.get('constraints')) | ||
634 | 55 | 56 | ||
635 | 56 | for svc in other_services: | 57 | for svc in other_services: |
636 | 57 | if 'location' in svc: | 58 | if 'location' in svc: |
637 | @@ -64,7 +65,8 @@ | |||
638 | 64 | if 'units' not in svc: | 65 | if 'units' not in svc: |
639 | 65 | svc['units'] = 1 | 66 | svc['units'] = 1 |
640 | 66 | 67 | ||
642 | 67 | self.d.add(svc['name'], charm=branch_location, units=svc['units']) | 68 | self.d.add(svc['name'], charm=branch_location, units=svc['units'], |
643 | 69 | constraints=svc.get('constraints')) | ||
644 | 68 | 70 | ||
645 | 69 | def _add_relations(self, relations): | 71 | def _add_relations(self, relations): |
646 | 70 | """Add all of the relations for the services.""" | 72 | """Add all of the relations for the services.""" |
647 | 71 | 73 | ||
648 | === modified file 'tests/charmhelpers/contrib/amulet/utils.py' | |||
649 | --- tests/charmhelpers/contrib/amulet/utils.py 2015-09-14 20:19:57 +0000 | |||
650 | +++ tests/charmhelpers/contrib/amulet/utils.py 2015-09-27 18:46:57 +0000 | |||
651 | @@ -326,7 +326,7 @@ | |||
652 | 326 | 326 | ||
653 | 327 | def service_restarted_since(self, sentry_unit, mtime, service, | 327 | def service_restarted_since(self, sentry_unit, mtime, service, |
654 | 328 | pgrep_full=None, sleep_time=20, | 328 | pgrep_full=None, sleep_time=20, |
656 | 329 | retry_count=2, retry_sleep_time=30): | 329 | retry_count=30, retry_sleep_time=10): |
657 | 330 | """Check if service was been started after a given time. | 330 | """Check if service was been started after a given time. |
658 | 331 | 331 | ||
659 | 332 | Args: | 332 | Args: |
660 | @@ -334,8 +334,9 @@ | |||
661 | 334 | mtime (float): The epoch time to check against | 334 | mtime (float): The epoch time to check against |
662 | 335 | service (string): service name to look for in process table | 335 | service (string): service name to look for in process table |
663 | 336 | pgrep_full: [Deprecated] Use full command line search mode with pgrep | 336 | pgrep_full: [Deprecated] Use full command line search mode with pgrep |
666 | 337 | sleep_time (int): Seconds to sleep before looking for process | 337 | sleep_time (int): Initial sleep time (s) before looking for file |
667 | 338 | retry_count (int): If service is not found, how many times to retry | 338 | retry_sleep_time (int): Time (s) to sleep between retries |
668 | 339 | retry_count (int): If file is not found, how many times to retry | ||
669 | 339 | 340 | ||
670 | 340 | Returns: | 341 | Returns: |
671 | 341 | bool: True if service found and its start time it newer than mtime, | 342 | bool: True if service found and its start time it newer than mtime, |
672 | @@ -359,11 +360,12 @@ | |||
673 | 359 | pgrep_full) | 360 | pgrep_full) |
674 | 360 | self.log.debug('Attempt {} to get {} proc start time on {} ' | 361 | self.log.debug('Attempt {} to get {} proc start time on {} ' |
675 | 361 | 'OK'.format(tries, service, unit_name)) | 362 | 'OK'.format(tries, service, unit_name)) |
677 | 362 | except IOError: | 363 | except IOError as e: |
678 | 363 | # NOTE(beisner) - race avoidance, proc may not exist yet. | 364 | # NOTE(beisner) - race avoidance, proc may not exist yet. |
679 | 364 | # https://bugs.launchpad.net/charm-helpers/+bug/1474030 | 365 | # https://bugs.launchpad.net/charm-helpers/+bug/1474030 |
680 | 365 | self.log.debug('Attempt {} to get {} proc start time on {} ' | 366 | self.log.debug('Attempt {} to get {} proc start time on {} ' |
682 | 366 | 'failed'.format(tries, service, unit_name)) | 367 | 'failed\n{}'.format(tries, service, |
683 | 368 | unit_name, e)) | ||
684 | 367 | time.sleep(retry_sleep_time) | 369 | time.sleep(retry_sleep_time) |
685 | 368 | tries += 1 | 370 | tries += 1 |
686 | 369 | 371 | ||
687 | @@ -383,35 +385,62 @@ | |||
688 | 383 | return False | 385 | return False |
689 | 384 | 386 | ||
690 | 385 | def config_updated_since(self, sentry_unit, filename, mtime, | 387 | def config_updated_since(self, sentry_unit, filename, mtime, |
692 | 386 | sleep_time=20): | 388 | sleep_time=20, retry_count=30, |
693 | 389 | retry_sleep_time=10): | ||
694 | 387 | """Check if file was modified after a given time. | 390 | """Check if file was modified after a given time. |
695 | 388 | 391 | ||
696 | 389 | Args: | 392 | Args: |
697 | 390 | sentry_unit (sentry): The sentry unit to check the file mtime on | 393 | sentry_unit (sentry): The sentry unit to check the file mtime on |
698 | 391 | filename (string): The file to check mtime of | 394 | filename (string): The file to check mtime of |
699 | 392 | mtime (float): The epoch time to check against | 395 | mtime (float): The epoch time to check against |
701 | 393 | sleep_time (int): Seconds to sleep before looking for process | 396 | sleep_time (int): Initial sleep time (s) before looking for file |
702 | 397 | retry_sleep_time (int): Time (s) to sleep between retries | ||
703 | 398 | retry_count (int): If file is not found, how many times to retry | ||
704 | 394 | 399 | ||
705 | 395 | Returns: | 400 | Returns: |
706 | 396 | bool: True if file was modified more recently than mtime, False if | 401 | bool: True if file was modified more recently than mtime, False if |
708 | 397 | file was modified before mtime, | 402 | file was modified before mtime, or if file not found. |
709 | 398 | """ | 403 | """ |
711 | 399 | self.log.debug('Checking %s updated since %s' % (filename, mtime)) | 404 | unit_name = sentry_unit.info['unit_name'] |
712 | 405 | self.log.debug('Checking that %s updated since %s on ' | ||
713 | 406 | '%s' % (filename, mtime, unit_name)) | ||
714 | 400 | time.sleep(sleep_time) | 407 | time.sleep(sleep_time) |
716 | 401 | file_mtime = self._get_file_mtime(sentry_unit, filename) | 408 | file_mtime = None |
717 | 409 | tries = 0 | ||
718 | 410 | while tries <= retry_count and not file_mtime: | ||
719 | 411 | try: | ||
720 | 412 | file_mtime = self._get_file_mtime(sentry_unit, filename) | ||
721 | 413 | self.log.debug('Attempt {} to get {} file mtime on {} ' | ||
722 | 414 | 'OK'.format(tries, filename, unit_name)) | ||
723 | 415 | except IOError as e: | ||
724 | 416 | # NOTE(beisner) - race avoidance, file may not exist yet. | ||
725 | 417 | # https://bugs.launchpad.net/charm-helpers/+bug/1474030 | ||
726 | 418 | self.log.debug('Attempt {} to get {} file mtime on {} ' | ||
727 | 419 | 'failed\n{}'.format(tries, filename, | ||
728 | 420 | unit_name, e)) | ||
729 | 421 | time.sleep(retry_sleep_time) | ||
730 | 422 | tries += 1 | ||
731 | 423 | |||
732 | 424 | if not file_mtime: | ||
733 | 425 | self.log.warn('Could not determine file mtime, assuming ' | ||
734 | 426 | 'file does not exist') | ||
735 | 427 | return False | ||
736 | 428 | |||
737 | 402 | if file_mtime >= mtime: | 429 | if file_mtime >= mtime: |
738 | 403 | self.log.debug('File mtime is newer than provided mtime ' | 430 | self.log.debug('File mtime is newer than provided mtime ' |
740 | 404 | '(%s >= %s)' % (file_mtime, mtime)) | 431 | '(%s >= %s) on %s (OK)' % (file_mtime, |
741 | 432 | mtime, unit_name)) | ||
742 | 405 | return True | 433 | return True |
743 | 406 | else: | 434 | else: |
746 | 407 | self.log.warn('File mtime %s is older than provided mtime %s' | 435 | self.log.warn('File mtime is older than provided mtime' |
747 | 408 | % (file_mtime, mtime)) | 436 | '(%s < on %s) on %s' % (file_mtime, |
748 | 437 | mtime, unit_name)) | ||
749 | 409 | return False | 438 | return False |
750 | 410 | 439 | ||
751 | 411 | def validate_service_config_changed(self, sentry_unit, mtime, service, | 440 | def validate_service_config_changed(self, sentry_unit, mtime, service, |
752 | 412 | filename, pgrep_full=None, | 441 | filename, pgrep_full=None, |
755 | 413 | sleep_time=20, retry_count=2, | 442 | sleep_time=20, retry_count=30, |
756 | 414 | retry_sleep_time=30): | 443 | retry_sleep_time=10): |
757 | 415 | """Check service and file were updated after mtime | 444 | """Check service and file were updated after mtime |
758 | 416 | 445 | ||
759 | 417 | Args: | 446 | Args: |
760 | @@ -456,7 +485,9 @@ | |||
761 | 456 | sentry_unit, | 485 | sentry_unit, |
762 | 457 | filename, | 486 | filename, |
763 | 458 | mtime, | 487 | mtime, |
765 | 459 | sleep_time=0) | 488 | sleep_time=sleep_time, |
766 | 489 | retry_count=retry_count, | ||
767 | 490 | retry_sleep_time=retry_sleep_time) | ||
768 | 460 | 491 | ||
769 | 461 | return service_restart and config_update | 492 | return service_restart and config_update |
770 | 462 | 493 | ||
771 | 463 | 494 | ||
772 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py' | |||
773 | --- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2015-09-10 09:30:00 +0000 | |||
774 | +++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2015-09-27 18:46:57 +0000 | |||
775 | @@ -58,19 +58,17 @@ | |||
776 | 58 | else: | 58 | else: |
777 | 59 | base_series = self.current_next | 59 | base_series = self.current_next |
778 | 60 | 60 | ||
784 | 61 | if self.stable: | 61 | for svc in other_services: |
785 | 62 | for svc in other_services: | 62 | if svc['name'] in force_series_current: |
786 | 63 | if svc['name'] in force_series_current: | 63 | base_series = self.current_next |
787 | 64 | base_series = self.current_next | 64 | # If a location has been explicitly set, use it |
788 | 65 | 65 | if svc.get('location'): | |
789 | 66 | continue | ||
790 | 67 | if self.stable: | ||
791 | 66 | temp = 'lp:charms/{}/{}' | 68 | temp = 'lp:charms/{}/{}' |
792 | 67 | svc['location'] = temp.format(base_series, | 69 | svc['location'] = temp.format(base_series, |
793 | 68 | svc['name']) | 70 | svc['name']) |
799 | 69 | else: | 71 | else: |
795 | 70 | for svc in other_services: | ||
796 | 71 | if svc['name'] in force_series_current: | ||
797 | 72 | base_series = self.current_next | ||
798 | 73 | |||
800 | 74 | if svc['name'] in base_charms: | 72 | if svc['name'] in base_charms: |
801 | 75 | temp = 'lp:charms/{}/{}' | 73 | temp = 'lp:charms/{}/{}' |
802 | 76 | svc['location'] = temp.format(base_series, | 74 | svc['location'] = temp.format(base_series, |
803 | @@ -79,6 +77,7 @@ | |||
804 | 79 | temp = 'lp:~openstack-charmers/charms/{}/{}/next' | 77 | temp = 'lp:~openstack-charmers/charms/{}/{}/next' |
805 | 80 | svc['location'] = temp.format(self.current_next, | 78 | svc['location'] = temp.format(self.current_next, |
806 | 81 | svc['name']) | 79 | svc['name']) |
807 | 80 | |||
808 | 82 | return other_services | 81 | return other_services |
809 | 83 | 82 | ||
810 | 84 | def _add_services(self, this_service, other_services): | 83 | def _add_services(self, this_service, other_services): |
charm_lint_check #10886 cinder-next for hopem mp272532
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/10886/