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
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
Update template incrementally as resources change

As a stack update progresses, maintain the contents of the template so that
they represent the current running state of the stack, instead of only
switching over wholesale at the end, so that if a failure occurs our state
and the template stored will be consistent.

Change-Id: If79e8b1dc212c548cad92fdbc340d61f5650f9d4
Implements: partial-blueprint update-failure-recovery
Closes-Bug: #1330016
Update: persist current template on change

After each resource is updated, persist the modified template to the
database so that any new resources will be accessible to API calls -
including signals to new WaitConditionHandles. This also ensures that if
the Heat engine dies completely during an update, the template in the
database will still be in a consistent state.

Change-Id: Ie6f234302cf72213d4b0e1f5b963cd8def422498
Closes-Bug: #1291905
Closes-Bug: #1206702
Closes-Bug: #1328342
Implements: partial-blueprint update-failure-recovery
Sync with oslo incubator

Sync with oslo incubator at 45890dae35cd14a25175cdce7c12a5f9acbd712f

Change-Id: I44ecc69f1d952061be7cb2f41678b879ded93eae
Sync oslo-incubator.middleware module

This syncing has contained oslo-incubator.middleware module
to get capability of x-openstack-request-id.

Change-Id: I8e3b7d23bc1def705a0399bbd5015241a0fba8b1
Partial-Bug: #1324065