check if templates exist before rendering config file

Change-Id: Idd1b088e8e003b01bb921afc39494e8ca12c015d
This commit is contained in:
grace.yu 2014-09-08 11:31:28 -07:00
parent d6ea19ad98
commit 277185e954
2 changed files with 9 additions and 0 deletions

View File

@ -222,6 +222,11 @@ class CobblerInstaller(OSInstaller):
tmpl_path = os.path.join(
os.path.join(self.tmpl_dir, os_version), self.SYS_TMPL_NAME
)
if not os.path.exists(tmpl_path):
err_msg = "Template '%s' does not exists!" % self.SYS_TMPL_NAME
logging.error(err_msg)
raise Exception(err_msg)
system_config = self.get_config_from_template(tmpl_path,
host_vars_dict)

View File

@ -246,6 +246,10 @@ class ChefInstaller(PKInstaller):
env_tmpl_path = os.path.join(
os.path.join(self.tmpl_dir, self.ENV_TMPL_DIR), tmpl_name
)
if not os.path.exists(env_tmpl_path):
logging.error("Environment template '%s' doesn't exist", tmpl_name)
raise Exception("Template '%s' does not exist!" % tmpl_name)
logging.debug("generating env from template %s", env_tmpl_path)
return self.get_config_from_template(env_tmpl_path, global_vars_dict)