Make sure we have tripleo-heat-templates at tuskar startup

If we don't then tuskar startup cannot proceed, with an appropriate
error message. A conf var is added: CONF.tht_local_dir that points
to the local path in which the templates exist. A relevant note
was added to INSTALL.rst

Implements: blueprint retrieve-ooo-templates
Change-Id: I7cb1151f35aef00f416a7d06be6229553fbe9d22
This commit is contained in:
marios 2013-10-04 15:46:10 +03:00
parent 1639baab1e
commit b74fc0738e
5 changed files with 29 additions and 0 deletions

1
.gitignore vendored
View File

@ -31,3 +31,4 @@ AUTHORS
ChangeLog ChangeLog
etc/tuskar/tuskar.conf etc/tuskar/tuskar.conf
*.sqlite *.sqlite
tuskar/api/templates/tripleo-heat-templates/

View File

@ -56,6 +56,17 @@ Note: replace these values with credentials for our undercloud OpenStack. If
you're using `Devstack <http://devstack.org/>`_, the username and password are you're using `Devstack <http://devstack.org/>`_, the username and password are
printed out when `stack.sh` finishes its job. printed out when `stack.sh` finishes its job.
You will need a local checkout of the tripleo-heat-templates. A
configuration entry is defined for this purpose: tht_local_dir should point
to your local copy of the tripleo-heat-templates.
tht_local_dir = "/etc/tuskar/tripleo-heat-templates/"
At tuskar startup, if the directory specified by tht_local_dir in your
tuskar.conf doesn't exist startup will fail. You can clone the templates:
(sudo) git clone https://github.com/openstack/tripleo-heat-templates.git /etc/tuskar/tripleo-heat-templates/
We need to initialise the database schema:: We need to initialise the database schema::
# activate the virtualenv # activate the virtualenv

View File

@ -27,6 +27,7 @@
# The port for the Tuskar API server (integer value) # The port for the Tuskar API server (integer value)
#tuskar_api_port=8585 #tuskar_api_port=8585
#tht_local_dir="/etc/tuskar/tripleo-heat-templates/"
# #
# Options defined in tuskar.api.app # Options defined in tuskar.api.app

View File

@ -31,6 +31,10 @@ API_SERVICE_OPTS = [
default=8585, default=8585,
help='The port for the Tuskar API server', help='The port for the Tuskar API server',
), ),
cfg.StrOpt('tht_local_dir',
default='/etc/tuskar/tripleo-heat-templates/',
help='Local path holding tripleo-heat-templates',
)
] ]
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -21,6 +21,7 @@
"""The Tuskar Service API.""" """The Tuskar Service API."""
import logging import logging
import os
import sys import sys
from oslo.config import cfg from oslo.config import cfg
@ -48,6 +49,17 @@ def main():
LOG.info("Serving on http://%s:%s" % (host, port)) LOG.info("Serving on http://%s:%s" % (host, port))
LOG.info("Configuration:") LOG.info("Configuration:")
CONF.log_opt_values(LOG, logging.INFO) CONF.log_opt_values(LOG, logging.INFO)
# make sure we have tripleo-heat-templates:
heat_template_path = CONF.tht_local_dir
try:
templates = os.listdir(heat_template_path)
except OSError:
LOG.info("Can't find local tripleo-heat-template files at %s"
% (heat_template_path))
LOG.info("Cannot proceed - missing tripleo heat templates " +
"See INSTALL documentation for more info")
raise
LOG.info("Using tripleo-heat-templates at %s" % (heat_template_path))
try: try:
wsgi.serve_forever() wsgi.serve_forever()