Fix status reason in events for deployment signals

When a signal is received and processed by a Resource, there could be an
event generated automatically. For such an event, Heat is supposed to
provide some useful message (including status_reason).  But currently,
the resource code can only process ceilometer alarms and watch rules,
for signals sent for a SoftwareDeployment resource, the signal is only
providing an string 'Unknown' as the status change reason.  This is
confusing when a user performs 'heat event-list stack'.

This patch adds an additional check (guess) whether the signal comes
from a SoftwareDeployment.  If that is the case, fill in the status
reason as 'deployment succeeded', or 'deployment failed (n)', where n is
the deploy_status_code that comes with the signal.

Closes-Bug: #1300679
Change-Id: Ic970a5dac923fffdcdd365983df58f4d338de849
Refined schema for VPCZoneIdentifier

The schema now says it is a list of strings. Also upgraded the
description.  Also clarified the name of
test_invalid_vpc_zone_identifier.

Change-Id: I4b17dbd146965df3df3f4205dddafc0b65061294
Closes-Bug: #1294717
Validate user_data_format for server with deployment

Validation error will be raised if user_data_format is not set
correctly.

Partial-Bug: #1295536
Change-Id: I0509c9c3a71d09fa8e2113710d561ffd3289d814
Change volume size property type to integer

Before it was possible to provide a rational number for SIZE, but cinder
would silently round it down, which leads to inconsistency between
stored resource state and actual cinder volume.

Closes-Bug: #1311707
Change-Id: I97b110f9797e2046bd5d2ae7da227b8dfc19059a
Fix validate failed with an image_name in uuid format

We should support to get the image_id by an image_name which is in uuid
format.

Change-Id: I471ee57ea55f990f852398a43762899dbc3d8692
Closes-Bug: #1312523
Remove unused logger

There are a lot of files contain import logging which is used for
creating logger object. However in some files we only have definition of
logger without using him. In this patch all unused loggers and imports
are deleted.

Change-Id: Iedba6d40850cb050c5c25d9b8a6a1d7128fd4bee
Update openstack-common in prep for graceful stop

Now at oslo-incubator version 95c7598917c7cd16f68a253a2048c21b3df9dfda

Change-Id: I2655ba2b9a0fb5048576f2b738d2af52c76c1d05
Partial-Bug: #1304244
Make events return by insertion order

We fixed the table by having the ID available, but the query uses an
index, so MySQL will return the rows in index order, which is not
necessarily primary key order. We need to explicitly ask that it be
returned in primary key order. This should be a free operation on MySQL.

Change-Id: I48d6260e01736fc7475c13cf736968dbf8eda206
Order and separate imports properly

Alphabetical and separated into system modules and libs.

Change-Id: I367245b10ca428d68350e3f010c17dea7e38fe67
Fix all flake8 problems.

Change-Id: Ibd36add2530a144122a0c3a88f31b3df1b838d24
Distribute create_heat_domain

Rename it to heat-keystone-setup-domain and ship it in bin with the
other helper scripts. This will make it consumable by automated systems
and packaging.

Change-Id: I7914869377cd08b6201007aa0eb6b8a70d763254
Prefetch data in resource_get_by_name_and_stack

This loads resource and resource data in a single query, which means
one less sql query per stack resource in a call to describe_stack_resource.

Change-Id: Ic2e1ab68cf651f290be75206fd5c0c841de4ef82
Related-Bug: #1306743
Support proxying Heat API by using x-forwarded-for header

Adding 'X-Forwarded-For' header support to enable  Heat API
proxying

Implements: blueprint proxying-heat-api
Change-Id: I36a0d3dd3f672a485c4a9c0cd541b705033e9025
Allow empty sections in the yaml templates

Existing check for absent sections in template is not enough for
handling situation with empty content.
Current patch improves using default value for parameters, resources and
outputs sections in yaml templates.

Change-Id: I94b572bf5f5b1593276616d9d0a84386dd12b8fe
Closes-Bug: #1312114
Fixes stack rollback failure with AWS::EC2::Instance

This patch would fix the stack rollback failure that
happens with an errored instance in a stack.
When the instance creation fails, vm status/sate would
be 'ERROR'. After delete is issued to nova, it would take
little time to change from 'ERROR' to 'DELETED'. By
checking for 'ERROR' status and throwing an exception,
it takes the create 'ERROR' status and fails to rollback
the stack.

Change-Id: Ida81117504398e0406d7b6d1e0f277af2acb0081
Closes-Bug: #1312636
Raise InvalidTemplateReference for missing resources

Previously this code raised InvalidTemplateAttribute when a resource
doesn't exist. But our existing code (in the dependency check, which
executes first) raises InvalidTemplateReference in this case and reserves
InvalidTemplateAttribute for when the resource exists but the attribute is
invalid. This patch makes the functions consistent with that behaviour.

It also raises InvalidTemplateReference, instead of KeyError, in the same
case in get_resource. I assumed that this could never fail, but that is
only true for Ref, not get_resource.

Change-Id: Ib7dcd3333bc2fc7778d3a013abae10c5795086dd
unit tests: Test dependency resolution using validate()

It doesn't really matter what triggers the error, we just want to check
that it happens during validation.

Change-Id: Ibfed738683973d35413b15bc9f173a51558c368c
Don't wrap HeatExceptions during validation

If an error of a known type (i.e. already a HeatException) occurs during
validation, don't wrap it in a StackValidationFailed exception.

Change-Id: I136a0def74c3edd5513f8acf6847428706ea2c06
unit tests: Check validation in VPC test

Checking for errors from creating a stack is not a representative test,
since in practice all stacks are validated before being created.

Change-Id: Ie6ef2c07648e4e9bd0375c56c99c8b03576fe7f8
unit tests: Don't mess with template retrospectively

In a couple of places we were modifying the template after creating the
stack with it, which is obviously not guaranteed to work.

Change-Id: I572cf6d7ac58392a9eb983ba8602481d0123c401