Merge lp:~gnuoy/charm-helpers/subconfs-multi-sections into lp:charm-helpers

Proposed by Liam Young
Status: Merged
Merged at revision: 415
Proposed branch: lp:~gnuoy/charm-helpers/subconfs-multi-sections
Merge into: lp:charm-helpers
Diff against target: 96 lines (+32/-28)
2 files modified
charmhelpers/contrib/openstack/context.py (+30/-26)
tests/contrib/openstack/test_os_contexts.py (+2/-2)
To merge this branch: bzr merge lp:~gnuoy/charm-helpers/subconfs-multi-sections
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+266237@code.launchpad.net
To post a comment you must log in.
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 'charmhelpers/contrib/openstack/context.py'
--- charmhelpers/contrib/openstack/context.py 2015-07-27 10:15:04 +0000
+++ charmhelpers/contrib/openstack/context.py 2015-07-29 14:22:46 +0000
@@ -1051,8 +1051,11 @@
1051 :param config_file : Service's config file to query sections1051 :param config_file : Service's config file to query sections
1052 :param interface : Subordinate interface to inspect1052 :param interface : Subordinate interface to inspect
1053 """1053 """
1054 self.service = service
1055 self.config_file = config_file1054 self.config_file = config_file
1055 if isinstance(service, list):
1056 self.services = service
1057 else:
1058 self.services = [service]
1056 if isinstance(interface, list):1059 if isinstance(interface, list):
1057 self.interfaces = interface1060 self.interfaces = interface
1058 else:1061 else:
@@ -1075,31 +1078,32 @@
1075 'setting from %s' % rid, level=ERROR)1078 'setting from %s' % rid, level=ERROR)
1076 continue1079 continue
10771080
1078 if self.service not in sub_config:1081 for service in self.services:
1079 log('Found subordinate_config on %s but it contained'1082 if service not in sub_config:
1080 'nothing for %s service' % (rid, self.service),1083 log('Found subordinate_config on %s but it contained'
1081 level=INFO)1084 'nothing for %s service' % (rid, service),
1082 continue1085 level=INFO)
10831086 continue
1084 sub_config = sub_config[self.service]1087
1085 if self.config_file not in sub_config:1088 sub_config = sub_config[service]
1086 log('Found subordinate_config on %s but it contained'1089 if self.config_file not in sub_config:
1087 'nothing for %s' % (rid, self.config_file),1090 log('Found subordinate_config on %s but it contained'
1088 level=INFO)1091 'nothing for %s' % (rid, self.config_file),
1089 continue1092 level=INFO)
10901093 continue
1091 sub_config = sub_config[self.config_file]1094
1092 for k, v in six.iteritems(sub_config):1095 sub_config = sub_config[self.config_file]
1093 if k == 'sections':1096 for k, v in six.iteritems(sub_config):
1094 for section, config_list in six.iteritems(v):1097 if k == 'sections':
1095 log("adding section '%s'" % (section),1098 for section, config_list in six.iteritems(v):
1096 level=DEBUG)1099 log("adding section '%s'" % (section),
1097 if ctxt[k].get(section):1100 level=DEBUG)
1098 ctxt[k][section].extend(config_list)1101 if ctxt[k].get(section):
1099 else:1102 ctxt[k][section].extend(config_list)
1100 ctxt[k][section] = config_list1103 else:
1101 else:1104 ctxt[k][section] = config_list
1102 ctxt[k] = v1105 else:
1106 ctxt[k] = v
1103 log("%d section(s) found" % (len(ctxt['sections'])), level=DEBUG)1107 log("%d section(s) found" % (len(ctxt['sections'])), level=DEBUG)
1104 return ctxt1108 return ctxt
11051109
11061110
=== modified file 'tests/contrib/openstack/test_os_contexts.py'
--- tests/contrib/openstack/test_os_contexts.py 2015-07-27 10:15:04 +0000
+++ tests/contrib/openstack/test_os_contexts.py 2015-07-29 14:22:46 +0000
@@ -340,7 +340,7 @@
340340
341341
342NOVA_SUB_CONFIG2 = """342NOVA_SUB_CONFIG2 = """
343nova:343nova-compute:
344 /etc/nova/nova.conf:344 /etc/nova/nova.conf:
345 sections:345 sections:
346 DEFAULT:346 DEFAULT:
@@ -2097,7 +2097,7 @@
2097 self.relation_ids.side_effect = relation.relation_ids2097 self.relation_ids.side_effect = relation.relation_ids
2098 self.related_units.side_effect = relation.relation_units2098 self.related_units.side_effect = relation.relation_units
2099 nova_sub_ctxt = context.SubordinateConfigContext(2099 nova_sub_ctxt = context.SubordinateConfigContext(
2100 service='nova',2100 service=['nova', 'nova-compute'],
2101 config_file='/etc/nova/nova.conf',2101 config_file='/etc/nova/nova.conf',
2102 interface=['nova-ceilometer', 'neutron-plugin'],2102 interface=['nova-ceilometer', 'neutron-plugin'],
2103 )2103 )

Subscribers

People subscribed via source and target branches