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.
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
+------ ------- ------- ------- +------ ------- ------- ------- ------- ----+ ------- ------- ------- +------ ------- ------- ------- ------- ----+ example. org/notify'] | e032-4b92- 9acc-73a3e6cc84 2a | data_actions | [] | 7b3d0eb23a3216c b8 | 24T06:28: 43.327075 | 24T06:44: 01.708380 | 383467d88c5d473 3c | ------- ------- ------- +------ ------- ------- ------- ------- ----+
| Field | Value |
+------
| alarm_actions | [u'http://
| alarm_id | 91a6eba7-
| description | Alarm when * event occurred. |
| enabled | True |
| event_type | * |
| insufficient_
| name | new_alarm |
| ok_actions | [] |
| project_id | 185f9d1ec3a3422
| query | |
| repeat_actions | False |
| severity | low |
| state | insufficient data |
| state_reason | Not evaluated yet |
| state_timestamp | 2018-04-
| time_constraints | [] |
| timestamp | 2018-04-
| type | event |
| user_id | 8919e4c798044b4
+------
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-73a3e6cc84 2a -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: gAAAAABa3tDpsvI n1kr-13sTCuxMoo YpOY7NfsXARSo2U dq_CTUkSgBR- 1TpVPEuyN4WNfPF vuX-b957pzHRjd1 ywKZQWcf2HdiSPw DCchKgXtniyFwTl 5WAuGBT5_ 02cQ0E3hw- Y8eyxUSqdJ4H7ou eZlB14XXsNZgm6Z 9UiijZwBKGfUkMs bQ" -d '{"alarm_actions": ["http:// example. org/notify"], "project_id": "185f9d1ec3a342 27b3d0eb23a3216 cb8", "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-73a3e6cc84 2a", "state": "insufficient data", "insufficient_ data_actions" : [], "repeat_actions": false, "user_id": "8919e4c798044b 4383467d88c5d47 33c", "composite_rule": {"type" :"gnocchi_ aggregation_ by_metrics_ threshold" ,"threshold" : 6, "metrics" :["80de2719- d9cc-47aa- adf7-601bd4f572 a5"], "evaluation_ periods" : 3, "granularity": 60, "comparison_ operator" : "ge", "aggregation_ method" :"mean" }, "type": "composite", "severity": "low"}' request- id: req-0cb9c093- d1ff-4309- bc05-6585275294 64
HTTP/1.1 200 OK
Date: Tue, 24 Apr 2018 06:46:12 GMT
Server: Apache/2.4.18 (Ubuntu)
x-openstack-
Content-Length: 827
Connection: close
Content-Type: application/json
{"composite_rule": {"evaluation_ periods" : 3, "metrics": ["80de2719- d9cc-47aa- adf7-601bd4f572 a5"], "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-73a3e6cc84 2a", "time_constraints": [], "insufficient_ data_actions" : [], "repeat_actions": false, "user_id": "8919e4c798044b 4383467d88c5d47 33c", "project_id": "185f9d1ec3a342 27b3d0eb23a3216 cb8", "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 ------- ------- ------- +------ ------- ------- ------- ------- ------- ------- ------- -+ ------- ------- ------- +------ ------- ------- ------- ------- ------- ------- ------- -+ example. org/notify'] | e032-4b92- 9acc-73a3e6cc84 2a | periods" : 3, | d9cc-47aa- adf7-601bd4f572 a5" | method" : "mean", | aggregation_ by_metrics_ threshold" , | operator" : "ge" | data_actions | [] | 7b3d0eb23a3216c b8 | 24T06:28: 43.327075 | 24T06:46: 12.962305 | 383467d88c5d473 3c | ------- ------- ------- +------ ------- ------- ------- ------- ------- ------- ------- -+
+------
| Field | Value |
+------
| alarm_actions | [u'http://
| alarm_id | 91a6eba7-
| composite_rule | { |
| | "evaluation_
| | "metrics": [ |
| | "80de2719-
| | ], |
| | "threshold": 6.0, |
| | "granularity": 60, |
| | "aggregation_
| | "type": "gnocchi_
| | "comparison_
| | } |
| description | Alarm when * event occurred. |
| enabled | True |
| insufficient_
| name | new_alarm |
| ok_actions | [] |
| project_id | 185f9d1ec3a3422
| repeat_actions | False |
| severity | low |
| state | insufficient data |
| state_reason | Not evaluated yet |
| state_timestamp | 2018-04-
| time_constraints | [] |
| timestamp | 2018-04-
| type | composite |
| user_id | 8919e4c798044b4
+------
The following command updates an event type alarm to a composite alarm successfully hence verifying the correct functioning of server API.