Set rollback status early in update if triggered

Before when rollback was triggered during stack update, the stack continued to
have status UPDATE_IN_PROGRESS, and only at the very end flipped to
ROLLBACK_COMPLETE.
This patch sets the stack state to ROLLBACK as soon as
rollback is started to notify the user properly on the action being
performed.

Change-Id: Idbd78a3a2a8d0c32fb26c7d0c38c87857d1565d8
Closes-Bug: #1316558
ec2token tolerate fully-qualified ec2authtoken auth_uri

If (as is currently done by the puppet-heat manifiests) the ec2authtoken
auth_uri is specified, and it looks like http://127.0.0.1:5000/v2.0/ec2tokens
ec2token authentication will fail, because we always append "ec2tokens" to
the auth_uri.  Instead, only add it when needed.

This probably needs to be combined with a change to the puppet manifiests so
we don't set the ec2authtoken auth_uri, as it's an optional section - we can
derive the correct path with only the auth_uri from the keystone_authtoken
section.

Change-Id: I8c89772b40523b30f1c46b2ca8b68f9e20d5c213
Closes-Bug: #1318599
Fix property-parameter mapping for boolean property

resource-template returns wrong parameter type "string" for
boolean property, which is wrong after boolean-parameter-type
(commit:6984a7793883164af0e28c3e707048e989670e9d) was merged.
boolean property should be mapped to parameters.Schema.BOOLEAN

Change-Id: I9841545a8e740ecf5ba1806e807bbe15feede69f
Closes-Bug: #1328022
Deprecate old schema definition in dbinstance

using new schema definition for dbinstance in test_dbinstance.py,
the old definition is deprecated.

Change-Id: I648074ff9c7d84af5dc5b3765642244fcf7a870f
Respect schema data type in constraint validation

This patch makes Constraint objects aware of the data type of the
owning Schema object so constraint validation can apply potential
type casts based on the data type.
This is especially useful and necessary for an AllowedValues
constraint and numeric values, where items may be defined as
strings or numbers and cause comparison issues with user values
at runtime.

Change-Id: Id1884b4968993fc9356e7ba4ad03dced4cd00d4e
Closes-Bug: #1321540
Add AllowedValues constraint to Rackspace::Cloud::LoadBalancer

The Rackspace Cloud Load Balancer service only allows certain
values for the algorithm property. This patch adds constraints
so that users get validation feedback prior to creating the
resource.

Closes-Bug: #1328654
Change-Id: Id24b426b1d3e49b09b3e468ea9e9675c05eaa160
Fix String Parameter Receive a unicode

Add unicode encode to parameter to make sure unicode will be
accepted correctly.

Change-Id: Idc9afad7971eaf0320d719946a3f09b8e15c1479
Closes-Bug: #1330370
Use ResourceDefinition to generate UpdatePolicy

Change-Id: I08cedd0fb9c7b804a4bf9dd5233f7b9060337a71
Get deletion policy from ResourceDefinition

Change-Id: I5e402e3ed02b9e09d3f78ef3c910c4c3d2f90fc0
Get the resource type from ResourceDefinition

Change-Id: Ie34a39a9d6d11bdbd2601e2c4be01b5411c2ac5a
Get metadata from ResourceDefinition

Change-Id: Ic232030015a95a17f3f8c420adbe6da61393eaab
Get resource description from ResourceDefinition

Change-Id: I3b95f1f048a7190d3b37982257a98f5867eebc0a
RPC API: Really don't include metadata in resource list

I made an attempt in e743158e7a61c00e2a32c340d3f268d0835f4c69 to not
include resource metadata when listing resources in the RPC API. Probably
due to a merge conflict, this was unsuccessful (although it did have the
effect of doubling the number of times we refreshed it from the database).

Neither the cfn API nor the native API passes on the metadata information
from list_stack_resources, so it is safe to remove this from the RPC API
for that call (which is the only one that passes detail=False) without
affecting the user-facing APIs.

Change-Id: Ibaddef9b290e88eb548c0427df5c007e3e14bc59
Update: Make addition/removal of resources more explicit

Use add_resource() and remove_resource() functions instead of indexing to
add and remove resources, to make it less surprising that the resources
themselves are being modified in the process.

Change-Id: I392cca8f68165988842affd1e23bce958645921b
Implement Stack loading from DB as a separate function

Separate out the lookup of a stack in the DB from the actual creation from
an existing DB representation.

Change-Id: I709fb7c4059229371ba85a2cd6e87ec5361a5400
List stacks using Stack.load_all()

Abstract the code to list stacks in the database out of service.py and into
the Stack class itself.

Change-Id: If27a184ffc87067f708868f91aaf380753f2de3b
Refactor resource initialisation from DB

Initialise the resource unconditionally to begin with, and use a separate
method to load data from the DB representation.

Change-Id: Ief7c0fb78944dafb1ff30c82647404178d549981
Load resources using Resource.load_all_from_stack()

Move responsbility for loading resource information back into the Resource
class. To maintain efficiency, load everything from the database at once in
the new load_all_from_stack() method. This allows us to remove the
_db_resources state from the Stack, collects the implementation in one
place and restores responsibility for its own DB state to the Resource
class.

Change-Id: Ia8059af57131e4b0a986c1f566b78aa935741a23
Update: Keep a copy of the old template for rollback

To implement the blueprint update-failure-recovery we will need to modify
the current template as we change the stack. We'll need an unmodified copy
to roll back to in the event of failure, so base the previous stack on a
copy.

Change-Id: Ic06acd3c9a89312d1ad8922e26ab02bee4bafeb0
Allow raw templates to be updated in the DB

Note that although this raw_template_update_template() will get called at
least every time the stack changes state (so twice for each operation), the
performance cost is negligible: we use the context's session, so the get()
will just retrieve the session's cached object, and we don't issue the
write unless the template has actually changed.

Change-Id: I3f231b88d08ab31c275cb9fecbf2600456c793c3