Commit Graph

199 Commits

Author SHA1 Message Date
Mehdi Abaakouk
02d017022b Ensure the correct error message is displayed
When a untranslated error message pass through the translation pecan
hook, the previous translated error is send to the client.

This patch fix that by reseting the "translatable_error" of the
translation pecan hook before each request.

Change-Id: Icee79cf09fd696655048c7c0cf8a3d6706e31701
Fixes: bug #1260398
2013-12-17 09:48:11 +01:00
Julien Danjou
80eb536d9b api: raise ClientSideError rather than ValueError
This also enables the error message to be translatable.

Change-Id: If63ba0f7bc04eb490578c7598875407e796700aa
2013-12-13 12:04:54 +01:00
Julien Danjou
06a7b498b5 Implement the /v2/sample API
This is a simple implementation of the new sample endpoint in the API.
It provides raw accesses to the samples collected by Ceilometer, without
imposing any kind of filtering on the meter name.

The fields are also correctly named this time.

Change-Id: I9e01a082c04e0462811befd98899e2f2d4a4dc82
Blueprint: sample-api
2013-12-13 12:04:11 +01:00
ChenZheng
7f542e3ac8 Add i18n warpping for all LOG messages
Add i18n wrapping for all LOG messages

Change-Id: I7f9c71a3aa76364b291f7e21a1737b927cbdc300
Fixes: bug #1199678
2013-11-29 21:09:53 +08:00
Gordon Chung
b5dfb0d97e full pep8 compliance (part 2)
final step to pep8 compliance

Change-Id: Ibe44f55f9415dc8cc380521debee609a20a67416
2013-11-21 12:35:01 -05:00
Mehdi Abaakouk
4a638fab63 Refactor API error handling
Refactor the API error handling to ensure error messages are translated.
Since wsme 0.5b6, the error message doesn't need to be converted to
unicode, wsme handles it for us.

Related bug #1200518

Change-Id: Iec396f045cd3afe817301f0d00917c42c7587b55
2013-11-14 17:17:34 +01:00
Lianhao Lu
0e26faeb69 Corrected import order
Enabled H306 in tox.ini and corrected the import order.

Change-Id: If77984e8c62b0ec0cfb3d068e9c1b0d4d7c3583d
2013-11-13 14:41:33 +08:00
Jenkins
190a02a5fd Merge "Use wsme ClientSideError to handle unicode string" 2013-10-31 05:48:01 +00:00
Mehdi Abaakouk
4b693d2703 Use wsme ClientSideError to handle unicode string
We inherit from wsme.esc.ClientSideError to handle unicode string in
error message.

Fixes bug #1200518

Change-Id: I54a185a436b0a65bef13f303d7e31911cada76d8
2013-10-30 09:31:54 +01:00
Mehdi Abaakouk
93630c3337 Fix the developer documentation of the alarm API
Add body parameter in PUT/POST alarm method.
Add boundary to the BoundedInt doc name.
Remove no more existing alarm_id in put/get_one wsexpose method.
Use state wsme enum instead of unicode string for alarm state get/put
even wsme validation won't work to have the documentation generated
correctly.

Update sphinxcontrib-pecanwsme to generate the documentation of get, put
and custom pecan method.

Change-Id: I9587f3d640cc768a3d788542d2af138411dcee60
2013-10-30 08:11:34 +01:00
Mehdi Abaakouk
2b550c096e Add source to Resource API object
This change add the source the resource API object

Fixes bug #1243651

Change-Id: I4489d34c83d3af7818d3f94afaa31b493df7549d
2013-10-23 12:42:47 +02:00
Julien Danjou
e4a1a4fcef api: update for WSME 0.5b6 compliance
This makes use of the mandatory option of WSME, that now works, to
remove some of our custom validation code. This is needed for new
versions of WSME that do more validation on their own.

Fixes-Bug: #1240741

Change-Id: Icb66d17066b515bebf3f3a326d84e18cbfce01ef
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-10-18 10:53:10 +02:00
Mehdi Abaakouk
a8e93ddc9e 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
2013-10-11 09:08:30 +02:00
Eoghan Glynn
7ee6f6d294 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
2013-10-10 16:28:54 +01:00
Jenkins
a7ae16365f Merge "Add notifications for alarm changes" 2013-10-07 08:29:17 +00:00
Jenkins
772e1a7ed5 Merge "Return 401 when action is not authorized" 2013-10-02 21:47:20 +00:00
Jenkins
0186c0e54b Merge "api: remove useless comments" 2013-10-01 23:40:13 +00:00
Jenkins
924263e93a Merge "api: allow alarm creation for others project by admins" 2013-10-01 22:55:24 +00:00
Sandy Walsh
4ce9177f84 Add notifications for alarm changes
Changes in alarm state (including definition and deletion) now
emit notifications.

Change-Id: I55799d6f00e6832c1d7ffb736f97d3dfcbe801aa
2013-10-01 16:34:27 -03:00
Jenkins
542942ca1a Merge "Add bug number of some wsme issue" 2013-10-01 16:59:48 +00:00
Julien Danjou
f7cb4943c7 api: allow alarm creation for others project by admins
Change-Id: I8da7e81da799b5cbd6b1ce158ac10e12567aa3d7
Fixes-Bug: #1226470
2013-10-01 15:51:50 +02:00
Jenkins
70c4256856 Merge "api: return 404 if a alarm is not found" 2013-10-01 03:12:11 +00:00
Jenkins
d57ab63f23 Merge "api: return 404 if a resource is not found" 2013-09-30 19:18:02 +00:00
Mehdi Abaakouk
d3637c4b52 Add bug number of some wsme issue
This patch add bug number of some wsme issue to keep a trace of the
reason of some workaround

Change-Id: I270b498fae3e17c3043396b4d0c08d74554a4f27
2013-09-30 17:23:08 +02:00
Julien Danjou
450c8c562e api: remove useless comments
- We do return samples with their id.
- This header is not complete nor true, and does not serve anything
  nowadays.

Change-Id: I4b797887fb9ae63b10d67e9b22a5b4d30d7bd829
2013-09-30 16:23:17 +02:00
Mehdi Abaakouk
259350ba7e api: return 404 if a alarm is not found
The patch return 404 instead of 400 if a alarm is not found

Fixes bug #1232041

Change-Id: I797546cf650f6d78a3103867bcb3ac7c024ac08f
2013-09-30 09:42:35 +02:00
Mehdi Abaakouk
b2df5f9013 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

Change-Id: I7ef8ed1f7cd40a845bcf860561c2cb7da52fb9e9
2013-09-27 16:43:34 +02:00
Julien Danjou
acb89bd2c2 api: return 404 if a resource is not found
This also checks for the error message that is returned, and fixes a
problem with the error encoding middleware that was doing double JSON
encoding.

Change-Id: Ieb39a991ddc9ecba0a7e71450a1e57ede18ccbe6
Fixes-Bug: #1218760
Fixes-Bug: #1208552
2013-09-27 16:13:26 +02:00
Mehdi Abaakouk
3cfac4c51a Allow to get a disabled alarm
This change allow to get a disabled alarm.

To do this, it:
* add the ability to query the alarm-list API with the 'enabled' fields.
* change the default visibility of alarm-list API from enabled only to all.

Fixes bug #1231328

Change-Id: I80cd691696f7630d2ac9e9b2a69b5b0ae5ee7968
2013-09-26 11:53:01 +02:00
Jenkins
cff60fbb5a Merge "Add source field to Meter model" 2013-09-25 10:11:51 +00:00
Mehdi Abaakouk
d1cb53db89 Handle manually mandatory field
wsme have a couple of bugs:
 https://bugs.launchpad.net/wsme/+bug/1227004
 https://bugs.launchpad.net/wsme/+bug/1227039

This patch workaround these bugs by doing input validation manually

Change-Id: Id16655ce4c5546b1caededad70a6b9a238e4be20
2013-09-20 16:11:41 +02:00
Mehdi Abaakouk
cd96b61099 Provide new API endpoint for alarm state
This patch add a new endpoint to the alarm API to change only the state
of an alarm. And modifies the evaluator base to use this new endpoint.

Implements blueprint alarming-logical-combination

Change-Id: I8bff74f0686ba17103ee63bcbdb0830c8273596f
2013-09-20 15:10:16 +02:00
Mehdi Abaakouk
d30bf2fa2e Add alarm combination API
This change add a new type of alarm in the API for creating
alarm that combine the state of other alarms.

Implements blueprint alarming-logical-combination

Change-Id: I3203ae6143f5e21b5160a9a04692e7a4c8e550b8
2013-09-20 15:10:16 +02:00
Mehdi Abaakouk
4a05b599b3 Convert BoundedInt value from json into int
Wsme doesn't convert automaticaly the value of a UserType into
its basetype. This changeset do it

Change-Id: I7402e144e6a337bbed13789c1611a163bbf9ba61
2013-09-20 10:47:01 +02:00
Guangyu Suo
c913814445 Add source field to Meter model
Just like Sample model, we should also add source field to
Meter model to identify where the meter comes from.

Change-Id: I2381d67f84692bfc7d167c2b0d90bfa32b845f00
Fixes: Bug #1225583
2013-09-20 10:30:40 +08:00
Mehdi Abaakouk
48c85f740a Alarm API update
This updates the alarm API to match the latest discussion:

https://wiki.openstack.org/wiki/Ceilometer/blueprints/alarm-api

It allows creation of different kinds of alarm.
The current kind of alarm has been named 'threshold'.

It move the defaults values from the storage models to the API
with all tools provided by wsme to ensure mandatory field and default.

A behavior change, it is now mandatory to PUT a full alarm description
in a PUT call.
In the future a new endpoint can be added to allow to modify only one
field (example for state: /v2/alarms/<id>/state)

Implements blueprint alarming-logical-combination

Change-Id: Ib85636728d427cdb70ef530ff9ff20d2b75c5ed1
2013-09-19 16:11:38 +02:00
Gordon Chung
3a480cb424 WSME 0.5b5 breaking unit tests
- fix tests to accept new (accurate) response codes
- wsme doesn't like us sending gettextutils.Message values. pass in
a regular string

Change-Id: Ie9e05edfd542ba1fe8c6fdbeed2daab12cf30caf
Fixes:Bug #1227264
2013-09-19 10:50:00 +02:00
Gordon Chung
f9fbaf2fdd Pecan assuming meter names are extensions
disable Pecan guessing content_type based on url path

Change-Id: I23862af3a9ae41980a8c3f33bf569acf9ff77a08
Fixes: Bug #1224132
2013-09-12 10:03:38 -04:00
Jenkins
d58a133597 Merge "add tests for _query_to_kwargs func" 2013-09-12 10:21:00 +00:00
Gordon Chung
05db82ac1b add tests for _query_to_kwargs func
add test case for _query_to_kwargs function in v2 api.
raise InvalidInput on invalid operator

Change-Id: Ia9e9b3905327d21e3c6f91aa0acd36f19f4f59b0
Partial-Bug: #1217129
2013-09-11 11:09:32 -04:00
Gordon Chung
42d910d820 validate counter_type when posting samples
check to ensure counter_type is valid when posting samples via API

Change-Id: I097c54f6b410c67b117b07eaf146828766f4852a
Fixes: bug #1221007
2013-09-11 15:03:09 +00:00
Doug Hellmann
37a779065f Make type guessing for query args more robust
Improve the error handling of the type-guesser for queries
against metadata fields, and add some test coverage for
specific cases that came out of the discussion of the
source of the bug.

Fixes bug #1221736

Change-Id: I27f84aa2538d2a69a3d7b7e93c36813df8d35204
2013-09-06 10:52:29 -04:00
Eoghan Glynn
a09ef3261c Clean-ups related to alarm history patches
Some non-blocking clean-ups requested in reviews of the alarm
history patches.

Change-Id: If009166be450f2e1bba0e68ce74699b5a032543e
2013-09-05 10:59:27 +01:00
Jenkins
3cd78fdec4 Merge "Add group by statistics in API v2" 2013-09-04 22:25:17 +00:00
Terri Yu
2ca3edcdc6 Add group by statistics in API v2
Implements blueprint api-group-by

Add group by statistics in API v2 and group by statistics tests in
API v2 tests as a new class TestGroupByInstance

The tests use the same data and test cases as the groupby storage
tests in class StatisticsGroupByTest

The tests implemented are group by

 1) single field, "user-id"
 2) single field, "resource-id"
 3) single field, "project-id"
 4) single field, "source" (*)
 5) single field with invalid/unknown field value
 6) multiple fields
 7) single field groupby with query filter
 8) multiple field group by with multiple query filters
 9) single field with start timestamp after all samples
10) single field with end timestamp before all samples
11) single field with start timestamp
12) single field with end timestamp
13) single field with start and end timestamps
14) single field with start and end timestamps and query filter
15) single field with start and end timestamps and period
16) single field with start and end timestamps, query filter, and period

(*) Group by source isn't supported in SQLAlchemy at this time, so
    we have to put this test in its own class TestGroupBySource

Group by metadata fields is not implemented at this time.

Also adds a method _validate_groupby_fields() to process the groupby
part of the request, and tests for _validate_groupby_fields().

Change-Id: Ibce1978cfdf70ab068af43a548241546a85bd464
2013-09-04 21:04:24 +00:00
Jenkins
291686e322 Merge "Add query support to alarm history API" 2013-09-04 20:18:59 +00:00
Eoghan Glynn
c0c2b844a7 Add query support to alarm history API
Allow alarm history retrieval to be constrained by
user, project, change type or timestamp.

Partially implements bp alarm-audit-api

Change-Id: Iba303b422a2893ed63375c79d9dc4b93711cf215
2013-09-04 18:42:40 +01:00
Julien Danjou
7851969319 alarm api: rename counter_name to meter_name
We already have a really poor naming convention the metering API, and we
decided to remove the counter term from everywhere. We can't fix the
metering API since we relesed it, so let's fix the alarming one before
it gets released and we have to handle a lot of complicated
compatibility. :-(

Change-Id: I3e3219d2eae0b72ad4a898630cacfd334e9390cc
2013-09-04 14:06:40 +02:00
Fengqian Gao
e2ccb45931 Add a fake UUID to Meter on API level
The database model of Meter does not have a unique key while
Resource has resource_id and Alarm has alarm_id. This key
can be used to identify a meter object by one single value.
The value of meter_id is the combination of resource_id and
couneter_name with base64 encoding. The mainly useage of this
key is pagination query.
It is part of bp/paginate-db-search.

Implements blueprint paginate-db-search

Change-Id: I602d0a370921dcfb02b5bc17c909937c35874e23
2013-09-03 17:53:46 +08:00
Eoghan Glynn
928fbe82c8 Plug alarm history logic into the API
The alarm scenario tests provide forward-looking coverage
which will be run as the storage backends' support for alarm
history lands.

A new config option alarm.record_history (defaulting to True)
guards the recording of alarm history.

Partially implements bp alarm-audit-api

Change-Id: I0c3bc348c86c7dc645cde3029a6fa76f9f767c37
2013-09-02 12:06:00 +01:00