Fix docker volumes binds issue

Without the fix, the volumes will not be attached after the container
started.

Closes-Bug: #1322205

Change-Id: Ie8eff402e8714f3c5d478dbc9fc02b43a377dccd
Re-organise top-level template guide structure

The current structure must be baffling for new template authors.

First is a section on Environments, which is actually an advanced
topic. Then is a section on cfn compatible functions which users
should be spurning in favour of HOT intrinisic functions.

The actual docs on how to write a HOT template and the HOT spec
is buried at the end.

This change remedies this state of affairs by moving the
Heat Orchestration Template (HOT) Guide to the start, followed by
the HOT spec.

The Environments section is now after the resource types, and the
Functions section has been renamed CloudFormation Compatible
Functions.

How we document CloudFormation coverage probably needs to be
rethought, but that is beyond the scope of this change.

Change-Id: I2ef2568309427b37555bae3d6b24a1464a7379b1
Add a OS::Nova::ServerGroup resource.

Change-Id: Ia6dc596b3ddcfb29dfe8f712794584fb2f6954ca
Implements: blueprint vm-instance-group-support
Guaranteed password complexity using OS::Heat::RandomString

This will allow users to generate passwords for applications that have
specific password strength requirements.

blueprint random-string-complexity

Change-Id: I801b4b46e1b9a872a02695176f6b7ab6b9a5f19d
Pass the context when updating raw_templates

Without a context, the raw_template was being stored using a different DB
session, with the result that changes did not end up in the database.

Also, don't use the same raw_template DB entry for the backup stack, since
that causes competing modifications to the DB that break rollback.

Change-Id: I6c71c19acac0b87943f36c57c2300cf2b0478aa3
Closes-Bug: #1331872
Related-Bug: #1291905
Related-Bug: #1206702
Related-Bug: #1328342
Fix pagination of stack-list

This was broken by the refactor in dde5a81e8060b373982f165856071a80be1d40bb
because the arguments to the DB call are in a different order to the ones
in the API, presumably for historical reasons.

Change-Id: I7503feb62089b252766a510281e0e4513945ad63
Closes-Bug: #1332611
Use auth_token_info to initialize heat_keystoneclient sessions

Now we have the token info available in the request context, we can
avoid always re-requesting another token every time a client is
created.

This should be better for performance as it avoids one extra request to
keystone, and it also enables trust-scoped tokens to be more easily
used, since these cannot be used to request another token, thus
authentication will fail with the current scheme.

Change-Id: Id34a4104cedbd3f1c231bc0b9229a5cac7bb9402
Partial-Bug: #1317293
Deprecate direct access to clients methods

This change deprecates access to methods like clients.nova()
replacing them with calls to clients.client('nova')

This allows the memoization to be done in one place (the client()
method) and also establishes the preferred API for accessing clients
that are contributed by plugins.

All calls should now be going through the new client() method.
Any calls to the old methods will result in a deprecated log
warning.

Change-Id: I3dc45aaed2655536ed1558e03f468b0733527815
Make heat.engine.clients a package

As blueprint client-plugins progresses, the code in __init__.py
will move into plugin modules, until the only package initialising
code remaining will be the following:
- plugin initialise
- Clients class which memoizes client plugins for a given context
- deprecated clients methods (until deleted later)

Partial-Blueprint: client-plugins
Change-Id: Ic8f67e3519b10c0d3d204e15e5ad72376c50a1dd
Support loading constraints as stevedore extensions

This still maintains support for the existing mechanism
but moves the in tree constraints to using stevedore.

part of blueprint stevedore-plugins
Change-Id: I86907e6518281083a508f840269d79dfa3875e9a
Change template loading to use stevedore extensions

part of blueprint stevedore-plugins
Change-Id: I71ebea421e8eb517a00e10a7e10b63ba7667fc4c
Fix pass incorrect volume_size while building bdm

If specify device_name, snapshot_id, delete_on_termination=True
and not specify volume_size for bdm while create a server,
heat will pass the bdm such as {'vdd': '1234:snap:0:True'} to
novaclient, the volume_size is incorrect,
nova won't create a volume from the snapshot because the
volume_size=0. If not specify volume_size, just to pass ''.

Change-Id: Ic1407671cc7bc6695bcf8e0c9f86fbdbaf245658
Closes-Bug: #1335728
use register_cli_opts instead of register_opts

oslo.config provides api register_cli_opts
to register multiple opts at once and same
is used in this patch to replace the
register_opts

Change-Id: I80b9bf37308c9e7085947200bc7c393c15e5e29d
Closes-bug: #1336224
Merge "Fix pagination of stack-list"
Catch NotFound for every stack delete db operation

A stack delete can be interrupted by another delete request
at any stage, so a stack may be in any state of partial deletion.

This change ensures that every db operation in a stack delete
will catch NotFound exceptions so that the delete process can
continue.

Change-Id: I3b665acbc7979147f24793a314da37150d4efeb8
Partial-Bug: 1328983
Sleep before stopping threads for delete

The logged error in bug #1328983 occurs in the following scenario:
* single heat-engine (so no multi-engine locking paths are invoked)
* multiple stack deletes on the same stack
* when the threads are stopped from a previous delete call so
  that the new delete call can acquire the lock and do the delete

This change does an eventlet sleep before forcefully stopping
the thread when taking over a delete from a different
thread. This gives the previous delete thread an opportunity to
finish naturally.

This may not prevent the error in bug #1328983 from ever
being logged in a production environment, but it is an internal error
which does not propagate to the user. This change should however
prevent this error from being logged during a tempest run, and the
original gate failure was due to ERROR log entry detection rather
than actual failing tests.

By experimentation the timeout of 0.2s was chosen. The error in
bug #1328983 started being logged again when the timeout was
reduced to 0.02s

Closes-Bug: #1328983

Change-Id: I8f95f29bd238e097ed9f4b889afe12c88d193240
Merge "Fix pass incorrect volume_size while building bdm"
Avoid truncating API Response

Removes unnecessary escape characters from an exception message so that
it does not get truncated by the fault middleware in the wsgi pipeline.

Closes-Bug: #1335807
Change-Id: I20281042e617199b1f5a0507c56adca6a6dc601f
Implement Flavor Extra-specs Key/Value Pairs

Add flavor set_keys function to nova_flavor resource.

Change-Id: I5d46ace4d729a2c4a1b136265b146417e7ad2812
Use None instead of mutables in method params defaults

Mutables in the method params defaults might cause errors and
that's why it's anti-pattern in most of the cases and should be
removed.

Change-Id: I8bc284f12ce72082a0482410ec2c20c2fc087a4b
Closes-Bug: #1327473