From ed76af426934147b895e2b746193491896369f82 Mon Sep 17 00:00:00 2001 From: Tetiana Lashchova Date: Mon, 15 Dec 2014 18:55:39 +0200 Subject: [PATCH] Check that template format plugins are registered Otherwise log an error and exit Change-Id: I2beb33371cf5e6701e22dbb41c8f5aa681c379de Closes-Bug: #1402426 --- bin/heat-engine | 10 ++++++++++ heat/engine/template.py | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bin/heat-engine b/bin/heat-engine index 52f5beabf..a25f11aef 100755 --- a/bin/heat-engine +++ b/bin/heat-engine @@ -35,8 +35,10 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')): from oslo.config import cfg from oslo import i18n +from heat.common.i18n import _LC from heat.common import messaging from heat.common import profiler +from heat.engine import template from heat.openstack.common import log as logging from heat.openstack.common import service @@ -52,6 +54,14 @@ if __name__ == '__main__': logging.setup('heat') messaging.setup() + mgr = None + try: + mgr = template._get_template_extension_manager() + except template.TemplatePluginNotRegistered as ex: + LOG.critical(_LC("%s"), ex) + if not mgr or not mgr.names(): + sys.exit("ERROR: No template format plugins registered") + from heat.engine import service as engine profiler.setup('heat-engine', cfg.CONF.host) diff --git a/heat/engine/template.py b/heat/engine/template.py index 0b62712e1..866e5616e 100644 --- a/heat/engine/template.py +++ b/heat/engine/template.py @@ -53,7 +53,16 @@ def _get_template_extension_manager(): return extension.ExtensionManager( namespace='heat.templates', invoke_on_load=False, - verify_requirements=True) + verify_requirements=True, + on_load_failure_callback=raise_extension_exception) + + +def raise_extension_exception(extmanager, ep, err): + raise TemplatePluginNotRegistered(name=ep.name, error=six.text_type(err)) + + +class TemplatePluginNotRegistered(exception.HeatException): + msg_fmt = _("Could not load %(name)s: %(error)s") def get_template_class(template_data):