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
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
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 a dict for clients memoization

This is in preperation for the client being contributed by a plugin
rather than inline.

Change-Id: I191f848ccb97e1cc975ea702016b5637eab0c976
parser.Stack add use_stored_context option

Add an option to switch to a context based on the user_creds data
at constructor time, which allows a cleaner interface for selecting
the stored context than creating it before creating the Stack object.

Partial-Bug: #1306294

Change-Id: I44df4e142dfbba1e70199b0d8f14c910f028a0f1
Convert service.py to use_stored_context

Related-Bug: #1306294

Change-Id: Ia75126ad77e6cad187a1953c2fb43eceb50299f2
Remove test_autoscaling _stub_validate

The _stub_validate is stubbing the wrong thing, it stubs the top-level
validate which hides the fact that the image validation fails for all
delete operations, where the validation always fails because the call
to glance is not correctly stubbed.

Partial-Bug: #1306294

Change-Id: Ibe3480f5ff358c00a4ad3c2df9b6cd7d15bda71d
test_autoscaling refactor suspend/resume stubbing

Rework to encapsulate the suspend/resume stubbing in functions and add a
stub of the image validation, which is required because the properties
get revalidated when we create the events associated with the state
transition (ref bug #1324102).

With the current keystoneclient mocking this is not visible in the
tests because the error creating the client to do the validation is
obscured by the fact that the Event constructor tolerates a validation
error and the error creating the client is just treated as an unexpected
validation error by the CustomConstraint code.

Moving to a model where clients.keystone() is consistently mocked
exposes the fact that we will try to connect to glance on suspend when
the event is created if the validation is not correctly stubbed.

Partial-Bug: #1306294

Change-Id: I001d3a432397d4cdfaa62145228aad7eaf051b98
tests add stub_keystoneclient to base test class

Add convenience function to allow easy stubbing of keystoneclient
in all tests where explicit control and verification is not required.
This is a precursor to making all clients use the auth_token property
from keystoneclient (instead of using the context auth_token in
preference) such that trust tokens can be refreshed before expiry.

Partial-Bug: #1306294

Change-Id: I9ba4595b8750ff769e76972cc30b55a68253e76d
engine.clients always use keystoneclient auth_token

Always get the token from keystoneclient, even if there is one in
the request context, as if the context contains a username and
password, there is the possibility the keystoneclient auth_token
may be a reissued token which should be preferred to the one in
the context which may have expired.

Change-Id: Icbce9ae7a8ff7cad5eadec3de4f69b977949c265
Partial-Bug: #1306294
Merge "Respect schema data type in constraint validation"
Merge "Use a dict for clients memoization"
Merge "Fix property-parameter mapping for boolean property"
Merge "Fix String Parameter Receive a unicode"
Merge "ec2token tolerate fully-qualified ec2authtoken auth_uri"
Merge "parser.Stack add use_stored_context option"
Merge "Convert service.py to use_stored_context"
Merge "Remove test_autoscaling _stub_validate"
Merge "test_autoscaling refactor suspend/resume stubbing"