> I know the initial target is for the horizon subordinate plugin charms > to use this, but would you mind giving an example of how horizon would use it?
Sure. The charm would register a pattern config:
> register_config('/path/to/dashboard/enabled/_{}_juju_{}.py')
Then,
> class RouterSettingContext(OSPatternContextGenerator): > def __call__(self): > ctxt = { > (40, 'router'): {'DISABLED': False if config('profile') in ['cisco'] else True} > } > return ctxt
and, for example > class PluginContext(OSPatternContextGenerator): > def __call__(self): > # ... > ctxt = {} > for rid in relation_ids('plugin'): > # ... > rdata = relation_get(rid=rid, unit=unit) > ctxt[(rdata['priority'], unit): {'DASHBOARD': rdata['DASHBOARD'], > 'DISABLED': rdata['DISABLED'], > # ... > return ctxt
This would result in generating files, say:
> /path/to/config/enabled/_40_juju_router.py > /path/to/config/enabled/_99_juju_horizon-contrail.py
In PluginContext I can then warn about conflicts etc. Multiple subordinates could even override one another.
HTH, let me know if I should explain more of this in the docstring.
« Back to merge proposal
> I know the initial target is for the horizon subordinate plugin charms
> to use this, but would you mind giving an example of how horizon would use it?
Sure. The charm would register a pattern config:
> register_ config( '/path/ to/dashboard/ enabled/ _{}_juju_ {}.py')
Then,
> class RouterSettingCo ntext(OSPattern ContextGenerato r):
> def __call__(self):
> ctxt = {
> (40, 'router'): {'DISABLED': False if config('profile') in ['cisco'] else True}
> }
> return ctxt
and, for example OSPatternContex tGenerator) : ids('plugin' ): get(rid= rid, unit=unit) 'priority' ], unit): {'DASHBOARD': rdata['DASHBOARD'],
> class PluginContext(
> def __call__(self):
> # ...
> ctxt = {}
> for rid in relation_
> # ...
> rdata = relation_
> ctxt[(rdata[
> 'DISABLED': rdata['DISABLED'],
> # ...
> return ctxt
This would result in generating files, say:
> /path/to/ config/ enabled/ _40_juju_ router. py config/ enabled/ _99_juju_ horizon- contrail. py
> /path/to/
In PluginContext I can then warn about conflicts etc. Multiple subordinates could even override one another.
HTH, let me know if I should explain more of this in the docstring.