372
374
def _ensure_packages(self):
373
ensure_packages(self.packages)
375
[ensure_packages(pkgs) for pkgs in self.packages]
375
377
def _save_flag_file(self):
376
378
if self.network_manager == 'quantum':
431
433
flags[k.strip()] = v
432
434
ctxt = {'user_config_flags': flags}
438
class SubordinateConfigContext(OSContextGenerator):
440
Responsible for inspecting relations to subordinates that
441
may be exporting required config via a json blob.
443
The subordinate interface allows subordinates to export their
444
configuration requirements to the principle for multiple config
445
files and multiple serivces. Ie, a subordinate that has interfaces
446
to both glance and nova may export to following yaml blob as json:
449
/etc/glance/glance-api.conf:
453
/etc/glance/glance-registry.conf:
463
It is then up to the principle charms to subscribe this context to
464
the service+config file it is interestd in. Configuration data will
465
be available in the template context, in glance's case, as:
467
... other context ...
468
'subordinate_config': {
479
def __init__(self, service, config_file, interface):
481
:param service : Service name key to query in any subordinate
483
:param config_file : Service's config file to query sections
484
:param interface : Subordinate interface to inspect
486
self.service = service
487
self.config_file = config_file
488
self.interface = interface
492
for rid in relation_ids(self.interface):
493
for unit in related_units(rid):
494
sub_config = relation_get('subordinate_configuration',
496
if sub_config and sub_config != '':
498
sub_config = json.loads(sub_config)
500
log('Could not parse JSON from subordinate_config '
501
'setting from %s' % rid, level=ERROR)
504
if self.service not in sub_config:
505
log('Found subordinate_config on %s but it contained'
506
'nothing for %s service' % (rid, self.service))
509
sub_config = sub_config[self.service]
510
if self.config_file not in sub_config:
511
log('Found subordinate_config on %s but it contained'
512
'nothing for %s' % (rid, self.config_file))
515
sub_config = sub_config[self.config_file]
516
for k, v in sub_config.iteritems():
520
ctxt['sections'] = {}