Skip to content

Commit

Permalink
Check that template format plugins are registered
Browse files Browse the repository at this point in the history
Otherwise log an error and exit

Change-Id: I2beb33371cf5e6701e22dbb41c8f5aa681c379de
Closes-Bug: #1402426
(cherry picked from commit ed76af4)
  • Loading branch information
tlashchova committed Jan 21, 2015
1 parent 4ee5264 commit 65294f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bin/heat-engine
Expand Up @@ -35,7 +35,9 @@ 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.engine import template
from heat.openstack.common import log as logging
from heat.openstack.common import service

Expand All @@ -51,6 +53,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

srv = engine.EngineService(cfg.CONF.host, rpc_api.ENGINE_TOPIC)
Expand Down
11 changes: 10 additions & 1 deletion heat/engine/template.py
Expand Up @@ -52,7 +52,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):
Expand Down

0 comments on commit 65294f4

Please sign in to comment.