122
122
of specifying multiple key value pairs within the same string. For
123
123
example, a string in the format of 'key1=value1, key2=value2' will
124
124
return a dict of:
128
129
2. A string in the above format, but supporting a comma-delimited list
129
130
of values for the same key. For example, a string in the format of
130
131
'key1=value1, key2=value3,value4,value5' will return a dict of:
132
'key2', 'value2,value3,value4'}
134
'key2', 'value2,value3,value4'}
134
136
3. A string containing a colon character (:) prior to an equal
135
137
character (=) will be treated as yaml and parsed as such. This can be
136
138
used to specify more complex key value pairs. For example,
137
139
a string in the format of 'key1: subkey1=value1, subkey2=value2' will
138
140
return a dict of:
139
{'key1', 'subkey1=value1, subkey2=value2'}
142
{'key1', 'subkey1=value1, subkey2=value2'}
141
144
The provided config_flags string may be a list of comma-separated values
142
145
which themselves may be comma-separated list of values.
240
243
if self.relation_prefix:
241
244
password_setting = self.relation_prefix + '_password'
243
for rid in relation_ids('shared-db'):
246
for rid in relation_ids(self.interfaces[0]):
244
247
for unit in related_units(rid):
245
248
rdata = relation_get(rid=rid, unit=unit)
246
249
host = rdata.get('db_host')
1050
1051
:param config_file : Service's config file to query sections
1051
1052
:param interface : Subordinate interface to inspect
1053
self.service = service
1054
1054
self.config_file = config_file
1055
self.interface = interface
1055
if isinstance(service, list):
1056
self.services = service
1058
self.services = [service]
1059
if isinstance(interface, list):
1060
self.interfaces = interface
1062
self.interfaces = [interface]
1057
1064
def __call__(self):
1058
1065
ctxt = {'sections': {}}
1059
for rid in relation_ids(self.interface):
1067
for interface in self.interfaces:
1068
rids.extend(relation_ids(interface))
1060
1070
for unit in related_units(rid):
1061
1071
sub_config = relation_get('subordinate_configuration',
1062
1072
rid=rid, unit=unit)
1068
1078
'setting from %s' % rid, level=ERROR)
1071
if self.service not in sub_config:
1072
log('Found subordinate_config on %s but it contained'
1073
'nothing for %s service' % (rid, self.service),
1077
sub_config = sub_config[self.service]
1078
if self.config_file not in sub_config:
1079
log('Found subordinate_config on %s but it contained'
1080
'nothing for %s' % (rid, self.config_file),
1084
sub_config = sub_config[self.config_file]
1085
for k, v in six.iteritems(sub_config):
1087
for section, config_dict in six.iteritems(v):
1088
log("adding section '%s'" % (section),
1090
ctxt[k][section] = config_dict
1081
for service in self.services:
1082
if service not in sub_config:
1083
log('Found subordinate_config on %s but it contained'
1084
'nothing for %s service' % (rid, service),
1088
sub_config = sub_config[service]
1089
if self.config_file not in sub_config:
1090
log('Found subordinate_config on %s but it contained'
1091
'nothing for %s' % (rid, self.config_file),
1095
sub_config = sub_config[self.config_file]
1096
for k, v in six.iteritems(sub_config):
1098
for section, config_list in six.iteritems(v):
1099
log("adding section '%s'" % (section),
1101
if ctxt[k].get(section):
1102
ctxt[k][section].extend(config_list)
1104
ctxt[k][section] = config_list
1094
1107
log("%d section(s) found" % (len(ctxt['sections'])), level=DEBUG)