Merge lp:~hopem/charms/precise/nova-cloud-controller/lp1246796 into lp:~charmers/charms/precise/nova-cloud-controller/trunk

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 62
Proposed branch: lp:~hopem/charms/precise/nova-cloud-controller/lp1246796
Merge into: lp:~charmers/charms/precise/nova-cloud-controller/trunk
Diff against target: 81 lines (+46/-16)
2 files modified
hooks/charmhelpers/contrib/openstack/context.py (+45/-15)
revision (+1/-1)
To merge this branch: bzr merge lp:~hopem/charms/precise/nova-cloud-controller/lp1246796
Reviewer Review Type Date Requested Status
James Page Approve
Marco Ceppi (community) Abstain
OpenStack Charmers Pending
Review via email: mp+199474@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

Deferring to ~openstack-charmers

review: Abstain
Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
--- hooks/charmhelpers/contrib/openstack/context.py 2013-10-28 19:03:14 +0000
+++ hooks/charmhelpers/contrib/openstack/context.py 2013-12-18 14:58:51 +0000
@@ -433,25 +433,55 @@
433433
434434
435class OSConfigFlagContext(OSContextGenerator):435class OSConfigFlagContext(OSContextGenerator):
436 '''436 """
437 Responsible adding user-defined config-flags in charm config to a437 Responsible for adding user-defined config-flags in charm config to a
438 to a template context.438 template context.
439 '''439
440 NOTE: the value of config-flags may be a comma-separated list of
441 key=value pairs and some Openstack config files support
442 comma-separated lists as values.
443 """
440 def __call__(self):444 def __call__(self):
441 config_flags = config('config-flags')445 config_flags = config('config-flags')
442 if not config_flags or config_flags in ['None', '']:446 if not config_flags:
443 return {}447 return {}
444 config_flags = config_flags.split(',')448
449 if config_flags.find('==') >= 0:
450 log("config_flags is not in expected format (key=value)",
451 level=ERROR)
452 raise OSContextError
453
454 # strip the following from each value.
455 post_strippers = ' ,'
456 # we strip any leading/trailing '=' or ' ' from the string then
457 # split on '='.
458 split = config_flags.strip(' =').split('=')
459 limit = len(split)
445 flags = {}460 flags = {}
446 for flag in config_flags:461 for i in xrange(0, limit - 1):
447 if '=' not in flag:462 current = split[i]
448 log('Improperly formatted config-flag, expected k=v '463 next = split[i + 1]
449 'got %s' % flag, level=WARNING)464 vindex = next.rfind(',')
450 continue465 if (i == limit - 2) or (vindex < 0):
451 k, v = flag.split('=')466 value = next
452 flags[k.strip()] = v467 else:
453 ctxt = {'user_config_flags': flags}468 value = next[:vindex]
454 return ctxt469
470 if i == 0:
471 key = current
472 else:
473 # if this not the first entry, expect an embedded key.
474 index = current.rfind(',')
475 if index < 0:
476 log("invalid config value(s) at index %s" % (i),
477 level=ERROR)
478 raise OSContextError
479 key = current[index + 1:]
480
481 # Add to collection.
482 flags[key.strip(post_strippers)] = value.rstrip(post_strippers)
483
484 return {'user_config_flags': flags}
455485
456486
457class SubordinateConfigContext(OSContextGenerator):487class SubordinateConfigContext(OSContextGenerator):
458488
=== modified file 'revision'
--- revision 2013-11-08 05:41:39 +0000
+++ revision 2013-12-18 14:58:51 +0000
@@ -1,1 +1,1 @@
13111312

Subscribers

People subscribed via source and target branches