db2 does not allow None as a key for user_id in user collection

mongodb allows None value as a key for _id field, but db2 does not.
this patch will fix the problem when meters coming with user_id
being set to None.

fixes: bug #1234165
(cherry picked from commit 77a0603bebcb25fba94ddfb40e50baed46eb9384)

Change-Id: Icdb53e0835faf7d469a8af882a3dcd7e161a1d1d
Return 401 when action is not authorized

When a user is not authorized to access to something is the API,
this one return 401 instead of 400 now.

Fixes bug #1232045

(cherry picked from commit b2df5f9013f6d30097d5841027a759af0e9c8002)

Change-Id: I37ef87f79cd55e095132e0865cbaa324cd76323c
Ensure combination alarm evaluator can be loaded

Fixes bug 1237578

Previously combination alarms were always skipped as the evaluator
was missing from the loadable stevedore extensions.

Change-Id: I9d164fb2a89ee9931fc032d93ad4a26ba6887f0b
(cherry picked from commit 61af83ddd832e63deb4b72fa11c7b18df7ae4702)
Ensure combination alarms can be evaluated

Fixes bug 1237589

Previously the retrieval of state for the constituent alarms always
failed for combination alarms, due to an incorrect attribute of
ceilometerclient being used. As a result combination alarms could
never be successfully evaluated.

Now the correct pluralized attribute is used.

Change-Id: Id58a5d185854367e5a08011048774ab5aed93d4e
(cherry picked from commit f44e292e7a16d09db36d8b2f9223e3d54202f8d2)
Merge "Return 401 when action is not authorized" into milestone-proposed
Merge "Ensure combination alarm evaluator can be loaded" into milestone-proposed
Merge "Ensure combination alarms can be evaluated" into milestone-proposed
Change resource.resource_metadata to text type

The existing resource.resource_metadata column size is 5k chars,
which is not enough for some large JSON metadata payload,
so change to as Text column to make sure store all JSON string
without truncating.

Fixes bug #1220683

(cherry picked from commit 7f3e7cea0ec9d8eb7095c2790fe0ba327c2df242)

Change-Id: I898ff2706cbaccafec6060bbdb0bbf68a4209edd
Add support for keystoneclient 0.4.0

Keystoneclient auth_middleware changed the way it parses the datetime
returned from the cache, breaking the Ceilometer unit tests. This patch
fixes the fake cache system that's used in unit test, so it works with
all keystoneclient versions.

This also update the sample configuration files to include the new
options provided by keystoneclient 0.4.0.

Fixes-Bug: #1238529

Change-Id: Iecfd50d9e9801aeb919f2c09a728e4ea15245a5e
(cherry picked from commit e3cef871ac5a92d38d42fe09d9ac2dbe4404f679)
Avoid leaking admin-ness into threshold-oriented alarms

Fixes bug 1237567

Previously when an admin created a threshold-oriented alarm on
behalf of an non-admin identity, this had the effect of leaking
visibility onto statistics for resources that would not normally
be visible to the non-admin tenant.

Now we ensure that an additional implicit threshold rule query
constraint is added on the project ID of the non-admin indentity
that will ultimately own the alarm.

This is acheived by splitting the query validation from the
construction of the kwargs from the query. The addition of the
implicit query constraint to the threshold rule can then be
delayed to a later point in the dispatch path where the full
context of the alarm is known (so that we can check for the case
where the alarm is created by an admin on behalf of another tenant).

Change-Id: I1adae8c899112e7c3eb4e94f3f68262c84a98574
(cherry picked from commit 7ee6f6d29451be4f2c9d5146e4cfbc147f33ee04)
Merge "Avoid leaking admin-ness into threshold-oriented alarms" into milestone-proposed
Merge "Change resource.resource_metadata to text type" into milestone-proposed
Avoid leaking admin-ness into combination alarms

Previously when an admin created a combination alarm on
behalf of an non-admin identity, this had the effect of leaking
visibility onto alarms that would not normally
be visible to the non-admin tenant.

Now we validate all alarm ids with the project ID of the non-admin
identity that will ultimately own the alarm instead of the project ID
of the API caller.

Fixes bug #1237632

Change-Id: I5d1cf41c9182f09bc37b93deb14dda58f1d6dcd6
(cherry picked from commit a8e93ddc9e0d79c603573a2e0f26cef115579534)
Change alarm_history.detail to text type

The existing alarm_history.detail column size is 255 chars,
which is not enough for some large JSON payloads.

Change to Text column to make sure we store all detail.

Closes-Bug: #1236861
Signed-off-by: Stephen Gran <stephen.gran@guardian.co.uk>
(cherry picked from commit 57eb9e904aacae166d7265a914960415c57cd133)

Change-Id: I1460c2a5bbd5cb465a605bb80775853468148026
Merge "Change alarm_history.detail to text type" into milestone-proposed
Open stable/havana

Change-Id: I209252af91b42691ac301f606dbf6d6a957928b8
Limit WSME to working version

WSME >= 0.5b6 breaks Ceilometer as it has been released in Havana. So
let's keep WSME with a correct version range.

Fixes-Bug: #1240741

Change-Id: Iac8dfa6a7f5506423f467a96ed9ad0c70cbb35c5
Merge "Open stable/havana" into stable/havana
Changes FakeMemcache to set token to expire on utcnow + 5 mins

fixes bug 1240994

keystoneclient 0.4 will use utcnow to compare expiration date.
The FakMemcache class sets expiration to datetime.now which sets
date for local timezone. If this timezone happens to be behind
utc the test will fail with expiration error because we are
comparing utc + 5 mins with utc - 1 or more hours.

Change-Id: I551506a5aaf0aef77476b11786399a66225603bf
(cherry picked from commit ac2a503d4d9ada69b5d5c1fbd2acf7397d8b4ac9)
Pin test-requirement for Nova to Havana

Change-Id: If5f28cf19211a69b4d2b6094ff05b6e82129d873