Add a new db api stack_get_all_by_owner_id

This is to get the next level of child stacks.

Partial-Bug: #1234010
Change-Id: I64b30b4040bc443b64d23d85a054010da4dd1130
Start the watcher task if a nested stack has watches

Even if the parent stack has no watches.

Change-Id: I06322f908fdbd474778776749cb3e1634183ed23
Partial-Bug: #1234010
Make sure that nested stacks have their watch rules checked

Change-Id: Iee9629739e9549e33f8ed8c4ca08098a7e4d0acf
Closes-Bug: #1234010
Change pyrax identity_type of Rackspace resources

The Rackspace resources utilize the pyrax library. As of v1.4.11 of
pyrax, the manner in which default region is determined changed, such
that the keystone identity_type returned 'RegionOne' as the default
region rather than one of the Rackspace regions. Changing the
identity_type to rackspace fixes this.

Change-Id: I36cd61393a76fbb9b0bb1fd4b31f26f6a95df3a3
Closes-Bug: 1227387
Refactor total_resources

Make the implementation slightly faster and more robust:

- Check that res.nested is callable
- Don't call res.nested() more than once
- Check for None explicitly
- Calculate totals directly, rather than with a for loop

Change-Id: Ib43cf5555620e54b9d4634e40cf46f75b50782ac
Get InstanceGroup InstanceList from get_instances()

Change-Id: I477aeede396e247134c838663fe7d54941758cd0
Don't iterate over Stack.resources dictionary

Now that parser.Stack is a proper Mapping, we can iterate over its
keys/values/items directly instead of accessing the resources attribute.

Change-Id: I6bd9f357c21a0e75623a71543e981d3f4f87fcbe
Implement parser.Stack.__delitem__()

Allow the update code to delete old resources from the stack without
accessing the stack's resource attribute.

Change-Id: I9dbc623d7396dd84cdbee992fa91d88b6c01a0e5
Update resource stacks automatically

When moving resources between stacks during an update, update the
resource's stack pointer automatically when adding it to its new stack.

Change-Id: I92666589fe417f5d905104d5a0890650da70e825
Make the testing of resource loading easier

Pass an environment object around so tests don't have
to use the global object and then conflict with other tests.

Change-Id: I0d9a0d3bd825ac415847213ee4a5d7473f80dbd6
Partial-bug: #1236107
Move the registration of the global env to after plugin resources

This prevents a user's template resources from getting overridden
by a resource plugin.

Change-Id: Idd1a5155dd28d662df8cdc44d190e24c84fd7a81
Closes-bug: #1236107
Fix clashing loop variables in TemplateResource

There were two loops using "v" as a variable name.

Closes-bug: #1235077
Change-Id: I5198621ce724abe9638da4a7482ae6817bbd86e7
Cleanup nested loop variables in TemplateResource

This patch makes these variables more verbose.

Change-Id: I40d6d3d2b0ffc9d792c75de51b5107e5fa73bd91
Partial-bug: #1235077
Don't try validate TemplateResource properties in template_validate

If the user runs "heat template-validate ..." and one of the resources
is a TemplateResource we won't be able to validate the properties
of that resource as we have to instantiate the TemplateResource
to kick off downloading the template and conversion of parameters to
properties.
Note: validation will happen properly when the user creates the stack
      so this just delays the validation of one resource type by one step.

Change-Id: I6ce53a9e78ae470b54320862fe910eef9f603941
Closes-bug: #1236327
Merge "Refactor total_resources"
Merge "Get InstanceGroup InstanceList from get_instances()"
Merge "Don't iterate over Stack.resources dictionary"
Merge "Implement parser.Stack.__delitem__()"
Update some cases of iterating stack resources

Since https://review.openstack.org/#/c/49879 iterating over a
stack will return resource names instead of resources.

This change updates some cases of iterating on a stack, there
are likely others which remaint to be updated.

Change-Id: I3fff5d7d7fd0016d741151010d0e1ce969da01b3
Partial-Bug: #1236678
Merge "Update resource stacks automatically"