235
235
sources_var='install_sources',
236
236
keys_var='install_keys'):
238
Configure multiple sources from charm configuration
238
Configure multiple sources from charm configuration.
240
The lists are encoded as yaml fragments in the configuration.
241
The frament needs to be included as a string.
243
246
- "http://example.com/repo precise main"
248
251
Note that 'null' (a.k.a. None) should not be quoted.
250
sources = safe_load(config(sources_var))
251
keys = config(keys_var)
253
keys = safe_load(keys)
254
if isinstance(sources, basestring) and (
255
keys is None or isinstance(keys, basestring)):
256
add_source(sources, keys)
253
sources = safe_load((config(sources_var) or '').strip()) or []
254
keys = safe_load((config(keys_var) or '').strip()) or None
256
if isinstance(sources, basestring):
260
for source in sources:
261
add_source(source, None)
258
if not len(sources) == len(keys):
259
msg = 'Install sources and keys lists are different lengths'
260
raise SourceConfigError(msg)
261
for src_num in range(len(sources)):
262
add_source(sources[src_num], keys[src_num])
263
if isinstance(keys, basestring):
266
if len(sources) != len(keys):
267
raise SourceConfigError(
268
'Install sources and keys lists are different lengths')
269
for source, key in zip(sources, keys):
270
add_source(source, key)
264
272
apt_update(fatal=True)