Add template_dir to config

Allow global environment contain global template files.
This can lead to further access to global template files.
For example a template file `my_tmpl.yaml` under global template
directory (`/etc/heat/templates` by default) can be directly accessed in
stack with `get_file`.
Partial-Bug: #1454401

Change-Id: I0a1c9d50441f88144980214fbc8e6757193cfb41
This commit is contained in:
ricolin 2016-04-11 16:14:59 +08:00
parent 5b2bcd8b2e
commit 83966b7bde
4 changed files with 34 additions and 0 deletions

View File

@ -70,6 +70,28 @@ If the :file:`my_env.yaml` file from the example above had been put in the
heat stack-create my_stack -P "some_parm=bla" -f my_tmpl.yaml
Global templates
----------------
A global template directory allows files to be pre-loaded in the global
environment. A global template is determined by your cloud operator.
An entry in the user template takes precedence over the global environment.
OpenStack includes a default global template, but your cloud operator
can add additional template entries.
The cloud operator can add new global templates by putting template
files in a configurable directory wherever the Orchestration engine runs.
The configuration variable is named ``template_dir`` and is found in the
``[DEFAULT]`` section of :file:`/etc/heat/heat.conf`. The default for
that directory is :file:`/etc/heat/templates`. Its contents are
combined in whatever order the shell delivers them when the service
starts up, which is the time when these files are read.
If the :file:`my_tmpl.yaml` file from the example below has been put in the
``template_dir``, other templates which we used to create stacks could
contain following way to include `my_tmpl.yaml` in it::
resourceA:
type: {get_file: "my_tmpl.yaml"}
Usage examples
~~~~~~~~~~~~~~

View File

@ -96,6 +96,9 @@ engine_opts = [
cfg.StrOpt('environment_dir',
default='/etc/heat/environment.d',
help=_('The directory to search for environment files.')),
cfg.StrOpt('template_dir',
default='/etc/heat/templates',
help=_('The directory to search for template files.')),
cfg.StrOpt('deferred_auth_method',
choices=['password', 'trusts'],
default='trusts',

View File

@ -102,9 +102,12 @@ class HeatTestCase(testscenarios.WithScenarios,
project_dir = os.path.abspath(os.path.join(mod_dir, '../../'))
env_dir = os.path.join(project_dir, 'etc', 'heat',
'environment.d')
template_dir = os.path.join(project_dir, 'etc', 'heat',
'templates')
cfg.CONF.set_default('environment_dir', env_dir)
cfg.CONF.set_override('error_wait_time', None, enforce_type=True)
cfg.CONF.set_default('template_dir', template_dir)
self.addCleanup(cfg.CONF.reset)
messaging.setup("fake://", optional=True)

View File

@ -0,0 +1,6 @@
---
features:
- Add `template_dir` to config. Normally heat has template directory
`/etc/heat/templates`. This change makes it more official. In the future,
it is possible to implement features like access templates directly from
global template environment.