Merge lp:~hopem/charm-helpers/lp1337266 into lp:charm-helpers

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 178
Proposed branch: lp:~hopem/charm-helpers/lp1337266
Merge into: lp:charm-helpers
Diff against target: 130 lines (+56/-6)
3 files modified
charmhelpers/contrib/openstack/context.py (+9/-4)
tests/contrib/openstack/test_os_contexts.py (+46/-1)
tests/contrib/storage/test_linux_storage_lvm.py (+1/-1)
To merge this branch: bzr merge lp:~hopem/charm-helpers/lp1337266
Reviewer Review Type Date Requested Status
Matt Bruzek Approve
Benjamin Saller (community) Approve
Jorge Niedbalski (community) Approve
Edward Hope-Morley Pending
Review via email: mp+225502@code.launchpad.net

This proposal supersedes a proposal from 2014-07-03.

To post a comment you must log in.
Revision history for this message
Jorge Niedbalski (niedbalski) wrote : Posted in a previous version of this proposal

LGTM, just a quick fix required; charmhelpers/contrib/openstack/context.py:724 is missed from tests coverage, and that line appears to be a relevant condition.

review: Needs Fixing
Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

> LGTM, just a quick fix required; charmhelpers/contrib/openstack/context.py:724
> is missed from tests coverage, and that line appears to be a relevant
> condition.

Fixed.

review: Needs Resubmitting
Revision history for this message
Jorge Niedbalski (niedbalski) wrote : Posted in a previous version of this proposal

LGTM, thanks for the fix.

review: Approve
Revision history for this message
Edward Hope-Morley (hopem) wrote :

Apologies, i messed up the MP so had to resubmit.

Revision history for this message
Jorge Niedbalski (niedbalski) :
review: Approve
Revision history for this message
Benjamin Saller (bcsaller) wrote :

LGTM, Thanks.

As a counterpoint you might be interested in lp:~cf-charmers/charm-helpers/cloud-foundry which moves something like (inspired by) the context framework into charmhelpers.core. I believe the pattern has been made more general in the CF usage and there is an MP for helpers upsteam. Interestingly it doesn't have any special support for subordinates which might be something we didn't capture so I found looking this branch over informative.

review: Approve
Revision history for this message
Matt Bruzek (mbruzek) wrote :

Unit tests pass. Thanks for the other reviews!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2014-06-26 13:42:36 +0000
3+++ charmhelpers/contrib/openstack/context.py 2014-07-03 14:54:27 +0000
4@@ -24,6 +24,7 @@
5 unit_get,
6 unit_private_ip,
7 ERROR,
8+ INFO
9 )
10
11 from charmhelpers.contrib.hahelpers.cluster import (
12@@ -689,7 +690,7 @@
13 self.interface = interface
14
15 def __call__(self):
16- ctxt = {}
17+ ctxt = {'sections': {}}
18 for rid in relation_ids(self.interface):
19 for unit in related_units(rid):
20 sub_config = relation_get('subordinate_configuration',
21@@ -715,10 +716,14 @@
22
23 sub_config = sub_config[self.config_file]
24 for k, v in sub_config.iteritems():
25- ctxt[k] = v
26+ if k == 'sections':
27+ for section, config_dict in v.iteritems():
28+ log("adding section '%s'" % (section))
29+ ctxt[k][section] = config_dict
30+ else:
31+ ctxt[k] = v
32
33- if not ctxt:
34- ctxt['sections'] = {}
35+ log("%d section(s) found" % (len(ctxt['sections'])), level=INFO)
36
37 return ctxt
38
39
40=== modified file 'tests/contrib/openstack/test_os_contexts.py'
41--- tests/contrib/openstack/test_os_contexts.py 2014-06-24 12:16:53 +0000
42+++ tests/contrib/openstack/test_os_contexts.py 2014-07-03 14:54:27 +0000
43@@ -213,6 +213,24 @@
44 - [glance-key2, value2]
45 """
46
47+CINDER_SUB_CONFIG1 = """
48+cinder:
49+ /etc/cinder/cinder.conf:
50+ sections:
51+ cinder-1-section:
52+ - [key1, value1]
53+"""
54+
55+CINDER_SUB_CONFIG2 = """
56+cinder:
57+ /etc/cinder/cinder.conf:
58+ sections:
59+ cinder-2-section:
60+ - [key2, value2]
61+ not-a-section:
62+ 1234
63+"""
64+
65 SUB_CONFIG_RELATION = {
66 'nova-subordinate:0': {
67 'nova-subordinate/0': {
68@@ -231,7 +249,19 @@
69 'private-address': 'foo_node1',
70 'subordinate_configuration': 'ea8e09324jkadsfh',
71 },
72- }
73+ },
74+ 'cinder-subordinate:0': {
75+ 'cinder-subordinate/0': {
76+ 'private-address': 'cinder_node1',
77+ 'subordinate_configuration': json.dumps(yaml.load(CINDER_SUB_CONFIG1)),
78+ },
79+ },
80+ 'cinder-subordinate:1': {
81+ 'cinder-subordinate/1': {
82+ 'private-address': 'cinder_node1',
83+ 'subordinate_configuration': json.dumps(yaml.load(CINDER_SUB_CONFIG2)),
84+ },
85+ },
86 }
87
88 # Imported in contexts.py and needs patching in setUp()
89@@ -1121,6 +1151,11 @@
90 config_file='/etc/glance/glance.conf',
91 interface='glance-subordinate',
92 )
93+ cinder_sub_ctxt = context.SubordinateConfigContext(
94+ service='cinder',
95+ config_file='/etc/cinder/cinder.conf',
96+ interface='cinder-subordinate',
97+ )
98 foo_sub_ctxt = context.SubordinateConfigContext(
99 service='foo',
100 config_file='/etc/foo/foo.conf',
101@@ -1142,6 +1177,16 @@
102 ['glance-key2', 'value2']]
103 }}
104 )
105+ self.assertEquals(
106+ cinder_sub_ctxt(),
107+ {'sections': {
108+ 'cinder-1-section': [
109+ ['key1', 'value1']],
110+ 'cinder-2-section': [
111+ ['key2', 'value2']]
112+
113+ }, 'not-a-section': 1234}
114+ )
115
116 # subrodinate supplies nothing for given config
117 glance_sub_ctxt.config_file = '/etc/glance/glance-api-paste.ini'
118
119=== modified file 'tests/contrib/storage/test_linux_storage_lvm.py'
120--- tests/contrib/storage/test_linux_storage_lvm.py 2014-06-23 10:00:22 +0000
121+++ tests/contrib/storage/test_linux_storage_lvm.py 2014-07-03 14:54:27 +0000
122@@ -22,7 +22,7 @@
123 EMPTY_VG_IN_PVDISPLAY = """
124 --- Physical volume ---
125 PV Name /dev/loop0
126- VG Name
127+ VG Name
128 PV Size 10.00 MiB / not usable 2.00 MiB
129 Allocatable yes
130 PE Size 4.00 MiB

Subscribers

People subscribed via source and target branches