Check that template format plugins are registered

Otherwise log an error and exit

Change-Id: I2beb33371cf5e6701e22dbb41c8f5aa681c379de
Closes-Bug: #1402426
This commit is contained in:
Tetiana Lashchova 2014-12-15 18:55:39 +02:00
parent d33a5837d1
commit ed76af4269
2 changed files with 20 additions and 1 deletions

View File

@ -35,8 +35,10 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')):
from oslo.config import cfg from oslo.config import cfg
from oslo import i18n from oslo import i18n
from heat.common.i18n import _LC
from heat.common import messaging from heat.common import messaging
from heat.common import profiler from heat.common import profiler
from heat.engine import template
from heat.openstack.common import log as logging from heat.openstack.common import log as logging
from heat.openstack.common import service from heat.openstack.common import service
@ -52,6 +54,14 @@ if __name__ == '__main__':
logging.setup('heat') logging.setup('heat')
messaging.setup() 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 from heat.engine import service as engine
profiler.setup('heat-engine', cfg.CONF.host) profiler.setup('heat-engine', cfg.CONF.host)

View File

@ -53,7 +53,16 @@ def _get_template_extension_manager():
return extension.ExtensionManager( return extension.ExtensionManager(
namespace='heat.templates', namespace='heat.templates',
invoke_on_load=False, 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): def get_template_class(template_data):