def test_register_templates_multi_modules(self): reg = hct.TemplateRegistry() cfg = Mock(workdir='workdir', modules=['MyModule', 'MyOtherModule']) hct.register_templates(reg, cfg) self.assertEqual(reg.fields['masterhostname'].name, 'masterhostname') self.assertTrue(len(reg.fields['masterhostname'].doc) != 0) self.assertEqual(reg.fields['modules'].fn(), 'MyModule MyOtherModule')
def _mkconfigopts(cfg_opts): reg = TemplateRegistry() register_templates(reg, cfg_opts) for ct in cfg_opts.master_template_kwargs: reg.register(ct) resolver = TemplateResolver(**reg.to_kwargs()) return ConfigOpts.from_params(cfg_opts, resolver)
def _setup_template_resolver(m_config, master_template_args): ''' Build a template resovler using the template args from the master node. ''' reg = TemplateRegistry() register_templates(reg, m_config) for ct in master_template_args: reg.register(ct) return TemplateResolver(**reg.to_kwargs())
def mk_registry(): """Make a TemplateRegistry and register basic items""" config_opts = ConfigOptsParams('svc-name', 'MASTER', 'ExecPreStart', 'ExecStart', 'ExecStop', dict(), workdir='WORKDIR', modulepaths=['MODULEPATHS'], modules=['MODULES'], master_template_kwargs=[], timeout=COMMAND_TIMEOUT) reg = hct.TemplateRegistry() hct.register_templates(reg, config_opts) master_template_kwargs = master_template_opts(reg.fields.values()) for ct in master_template_kwargs: reg.register(ct) return reg