Add nested_depth column to stack table

Adds a new nested_depth column, with a migration which traverses the
tree via owner_id for existing stacks and populates the appropriate depth.

This is a static, create-time depth, which should be sufficient for our
usage since nested stacks can never be moved within the tree.

The reason for this change is to allow depth validation (e.g enforcing
max_nested_stack_depth) when creating nested stacks via RPC calls,
without incurring the cost of loading every parent stack in the tree
to count the depth.  It may also allow some future optimisations of
some of the recently added API calls which do recursive introspection
considering a nested_depth parameter.

This is a step towards decoupling nested stacks from the current
usage of parent_resource and associated runtime introspection of the
parent stack, and as such the current StackResource is modified to
use the new scheme (required so post-migration we don't end up with
invalid nested_depth data in the DB).

Change-Id: I727651ff738ae668a3f21b374fc7a1b48f6e4777
blueprint: decouple-nested
engine service add nested_depth to create_stack

Adds nested_depth as an optional argument to the top-level interface
for handling stack-creates, so it will be possible to specify the
depth when creating a nested stack via an RPC call between engines.

Change-Id: Idc24d1e55810b10615d764b94f7c708673516295
blueprint: decouple-nested
Add nested_depth to internal _create_stack RPC interface

Adds a nested_depth parameter, which can be used to set the correct
nested_depth value when creating nested stack via RPC calls between
engines.

Change-Id: I71538a4297168a08a1aaaf3d23f42f3878f6cf0e
blueprint: decouple-nested
StackResource add force_reload to nested() accessor method

Adds a force_reload switch to override the local Stack object caching
so you can force retrieval of the latest data from the DB, which is
required in scenarios where polling for state which may be changed by
a different engine is required.

Co-Authored-By: Angus Salkeld <asalkeld@mirantis.com>
Change-Id: I9b34fcfdcde8d314add2f53b86ec1f0e4b6075e8
blueprint: decouple-nested
StackResource add show_deleted option to nested() accessor method

Adds the option to return a stack object even if the stack has been
deleted, which is slightly more convenient when polling for DELETE
COMPLETE state, as you no longer have to handle NotFound when the
delete happens.

Change-Id: I9074bfcec84836cc789cf9f5ecd0a904f020ccb9
blueprint: decouple-nested
engine service add user_creds_id to create_stack interface

Adds the option to pass user_creds_id to create_stack in the service.py
so we can pass the parent user_creds reference in to nested stacks when
creating them via RPC, for compatibility with the way nested stacks
are currently created.

Change-Id: I127628d9af4c148ad7eaf6f0fc8cdb754cc9d6fe
blueprint: decouple-nested
Add user_creds_id to _create_stack RPC interface

Adds the ability to pass the parent user_creds_id into nested stacks
when creating them via RPC, so we can maintain the current behavior
in StackResource, where the parent user_creds record is used by all
nested stacks.

Change-Id: Ifed93860db68a7d23b0c05bd9ec83619e109e386
blueprint: decouple-nested
engine service add stack_user_project_id to create_stack interface

Adds the option to pass stack_user_project_id to align with the recent
change which makes nested stacks inherit the stack user project from
their parent ref bug #1343163.  This will enable the same behavior to
be maintained when creating stacks via RPC calls instead of directly.

Change-Id: I2a102722d3e5228ccbb71ca13f4246725626f5a9
blueprint: decouple-nested
Add stack_user_project_id to _create_stack RPC interface

Adds the ability to pass the parent stack_user_project_id into nested stacks
when creating them via RPC, so we can maintain the recently introduced
behavior where the parent stack user project is inherited by nested
stacks.

Change-Id: I425e80cfc8f9c646ade7d47f202744103142ab55
blueprint: decouple-nested
Move TestInstanceGroup to test_instance_group.py

Change-Id: Ib3bbadf3a868c6c82e30c63750a6ec76f873fc63
Unit test autoscaling._calculate_new_capacity

This is so we can reduce the complexity in test_autoscaling.py

Change-Id: I96050295f48109bd370168f0a5c66e93e506da3e
Move some AutoScalingGroup validation tests to a seperate file

Change-Id: I56da94e89d206b4277c8ee03ebb23c3f20c08853
Convert the autoscaling policy tests into unit tests

Change-Id: I97e13307231c61da7147e02f5706c86cda10c0d9
StackResource convert create operations to use RPC

Modifies create_with_template to create the nested stack via an RPC
call, so it can potentially be handled by a different engine in a
scaled-out heat deployment with multiple heat-engine processes or
workers.

The current introspection interface via nested() is maintained, so we
minimise the impact on existing StackResource subclasses.  A future
optimisation would be to remove the DB polling from the
check_create_complete and instead rely on an RPC notification from the
engine handling the create when it's done.

Change-Id: I7b88a329ddb5df4005b0bc10810bc5e3cdd077ab
blueprint: decouple-nested

Conflicts:
	heat/tests/test_instance_group.py