Comment 1 for bug 1757994

Revision history for this message
Rajat Dhasmana (whoami-rajat) wrote :

In aodh alarm update command, the following cases are missing in aodhclient code :

1) --type parameter is not parsed from CLI
2) no code for updating the type of an alarm

The server API is working fine that is verified using curl

Initially we have an alarm of type event

+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| alarm_actions | [u'http://example.org/notify'] |
| alarm_id | 91a6eba7-e032-4b92-9acc-73a3e6cc842a |
| description | Alarm when * event occurred. |
| enabled | True |
| event_type | * |
| insufficient_data_actions | [] |
| name | new_alarm |
| ok_actions | [] |
| project_id | 185f9d1ec3a34227b3d0eb23a3216cb8 |
| query | |
| repeat_actions | False |
| severity | low |
| state | insufficient data |
| state_reason | Not evaluated yet |
| state_timestamp | 2018-04-24T06:28:43.327075 |
| time_constraints | [] |
| timestamp | 2018-04-24T06:44:01.708380 |
| type | event |
| user_id | 8919e4c798044b4383467d88c5d4733c |
+---------------------------+--------------------------------------+

after executing curl to update type and rule of alarm

stack@ubuntu-xenial:/usr/local/lib/python2.7/dist-packages/aodhclient/v2$ curl -g -i -X PUT http://127.0.0.1:8042/v2/alarms/91a6eba7-e032-4b92-9acc-73a3e6cc842a -H "Accept: application/json, */*" -H "Content-Type: application/json" -H "User-Agent: aodh keystoneauth1/3.5.0 python-requests/2.18.4 CPython/2.7.12" -H "X-Auth-Token: gAAAAABa3tDpsvIn1kr-13sTCuxMooYpOY7NfsXARSo2Udq_CTUkSgBR-1TpVPEuyN4WNfPFvuX-b957pzHRjd1ywKZQWcf2HdiSPwDCchKgXtniyFwTl5WAuGBT5_02cQ0E3hw-Y8eyxUSqdJ4H7oueZlB14XXsNZgm6Z9UiijZwBKGfUkMsbQ" -d '{"alarm_actions": ["http://example.org/notify"], "project_id": "185f9d1ec3a34227b3d0eb23a3216cb8", "ok_actions": [], "name": "new_alarm", "timestamp": "2018-04-24T06:29:29.621336", "description": "Alarm when * event occurred.", "time_constraints": [], "enabled": true, "state_timestamp": "2018-04-24T06:28:43.327075", "state_reason": "Not evaluated yet", "alarm_id": "91a6eba7-e032-4b92-9acc-73a3e6cc842a", "state": "insufficient data", "insufficient_data_actions": [], "repeat_actions": false, "user_id": "8919e4c798044b4383467d88c5d4733c", "composite_rule": {"type":"gnocchi_aggregation_by_metrics_threshold","threshold": 6, "metrics":["80de2719-d9cc-47aa-adf7-601bd4f572a5"], "evaluation_periods": 3, "granularity": 60, "comparison_operator": "ge", "aggregation_method":"mean"}, "type": "composite", "severity": "low"}'
HTTP/1.1 200 OK
Date: Tue, 24 Apr 2018 06:46:12 GMT
Server: Apache/2.4.18 (Ubuntu)
x-openstack-request-id: req-0cb9c093-d1ff-4309-bc05-658527529464
Content-Length: 827
Connection: close
Content-Type: application/json

{"composite_rule": {"evaluation_periods": 3, "metrics": ["80de2719-d9cc-47aa-adf7-601bd4f572a5"], "threshold": 6.0, "granularity": 60, "aggregation_method": "mean", "type": "gnocchi_aggregation_by_metrics_threshold", "comparison_operator": "ge"}, "alarm_actions": ["http://example.org/notify"], "ok_actions": [], "name": "new_alarm", "severity": "low", "timestamp": "2018-04-24T06:46:12.962305", "enabled": true, "state": "insufficient data", "state_timestamp": "2018-04-24T06:28:43.327075", "alarm_id": "91a6eba7-e032-4b92-9acc-73a3e6cc842a", "time_constraints": [], "insufficient_data_actions": [], "repeat_actions": false, "user_id": "8919e4c798044b4383467d88c5d4733c", "project_id": "185f9d1ec3a34227b3d0eb23a3216cb8", "type": "composite", "state_reason": "Not evaluated yet", "description": "Alarm when * event occurred."}stack@ubuntu-xenial:/usr/local/lib/python2.7/dist-packages/aodhclient/v2$ aodh alarm show new_alarm
+---------------------------+--------------------------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------------------------+
| alarm_actions | [u'http://example.org/notify'] |
| alarm_id | 91a6eba7-e032-4b92-9acc-73a3e6cc842a |
| composite_rule | { |
| | "evaluation_periods": 3, |
| | "metrics": [ |
| | "80de2719-d9cc-47aa-adf7-601bd4f572a5" |
| | ], |
| | "threshold": 6.0, |
| | "granularity": 60, |
| | "aggregation_method": "mean", |
| | "type": "gnocchi_aggregation_by_metrics_threshold", |
| | "comparison_operator": "ge" |
| | } |
| description | Alarm when * event occurred. |
| enabled | True |
| insufficient_data_actions | [] |
| name | new_alarm |
| ok_actions | [] |
| project_id | 185f9d1ec3a34227b3d0eb23a3216cb8 |
| repeat_actions | False |
| severity | low |
| state | insufficient data |
| state_reason | Not evaluated yet |
| state_timestamp | 2018-04-24T06:28:43.327075 |
| time_constraints | [] |
| timestamp | 2018-04-24T06:46:12.962305 |
| type | composite |
| user_id | 8919e4c798044b4383467d88c5d4733c |
+---------------------------+--------------------------------------------------------+

The following command updates an event type alarm to a composite alarm successfully hence verifying the correct functioning of server API.