0
votes

Seeking help, I am not able to create Alarms using openstack API.

Currently I am doing something like this :

POST request to :

http://controllerIP:8777/v2/alarms

I have also set my headers [X-Auth-Token and Content-Type]

And the Body I am sending :

{
    "alarm_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "insufficient_data_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "ok_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "comparison_operator" : "gt",
    "description" : "An alarm",
    "evaluation_periods" : 5,
    "meter_name" : "cpu_util",
    "name" : "SwiftObjectAlarm",
    "period" : 60,
    "statistic" : "avg",
    "threshold" : 3.0,
        "repeat_actions" : true,
        "resource_id": "ee827e6d-5ca2-475d-af5b-7fd6976e874c"
}

I am geting error code :

<error_message>
<error>
<faultcode>Client</faultcode>
<faultstring>Invalid input for field/attribute type. Value: 'None'. Mandatory field missing.</faultstring>
<debuginfo/>
</error>
</error_message>

Any one have idea what is going wrong here ?? I guess data perhaps, but I dont have any clue to do it right. :(

1

1 Answers

0
votes

The problem is in the data. This should work:

{
    "alarm_actions" : [ 
        "http://webhookIp/os/alarm" 
    ],
    "insufficient_data_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "ok_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "comparison_operator" : "gt",
    "description" : "An alarm",
    "evaluation_periods" : 5,
    "name" : "SwiftObjectAlarm",
    "period" : 60,
    "statistic" : "avg",
    "type" : "threshold",
    "threshold_rule":  {
        "meter_name" : "cpu_util",
        "threshold" : 3.0
    },
    "repeat_actions" : true,
    "resource_id": "ee827e6d-5ca2-475d-af5b-7fd6976e874c"
}