create security group

Asked by Akilesh

I was trying to use the python-neutronclient for creating security groups and it throws the weird ("NeutronClientException: Unable to find 'security_group' in request body" ) exception. Why is it trying to find a security group when I am trying to create a new one.

the list and get method of the python-neutronclient work well though.

I checked the neutron api documentation and see that it has CRUD methods only for network, subnet and ports. (https://wiki.openstack.org/wiki/Neutron/APIv2-specification)

Now I am really confused about the work-flow. Is neutron responsible for creating security groups or is it nova(create works with python-novaclient except that i do not know how to add rules to the sg).

Can any one tell me which process is responsible for this workflow and what the api is and if there is support for it in any python client.

Question information

Language:
English Edit question
Status:
Solved
For:
neutron Edit question
Assignee:
No assignee Edit question
Solved by:
ZhiQiang Fan
Solved:
Last query:
Last reply:
Revision history for this message
Aaron Rosen (arosen) said :
#1

You should be able to use either the nova or quantum commands to do this. Can you show us what you typed in and what error you are getting?

Revision history for this message
Akilesh (akilesh1597) said :
#2

First try: Rest api
url : http://neutron-server:9696/v2.0/security-groups/
method : post
headers: token, accept and content-typ as usual
body:
{
           "tenant_id": "f5213473f7c5476fa3e98da32145a49a",
           "name": "defaulttest",
           "description": "default test method"
}
Response:

    Status Code: 404 Not Found
    Connection: keep-alive
    Content-Length: 52
    Content-Type: text/plain; charset=UTF-8
    Date: Mon, 03 Feb 2014 07:39:12 GMT

If I alter the url and remove the trailing '/' I get

Response:
    Status Code: 400 Bad Request
    Connection: keep-alive
    Content-Length: 67
    Content-Type: application/json; charset=UTF-8
    Date: Mon, 03 Feb 2014 07:40:36 GMT

response body:

    {
       "NeutronError": "Unable to find 'security_group' in request body"
    }

The same error comes from python-neutronclient

Revision history for this message
Akilesh (akilesh1597) said :
#3

information on request is provided above.

Revision history for this message
Aaron Rosen (arosen) said :
#4

Can you show the output of neutron ext-list ; it looks like you might be using a plugin that doesn't have the security_group extension enabled. What plugin are you using.

Revision history for this message
Best ZhiQiang Fan (aji-zqfan) said :
#5

I think the body is wrong, should be:

{
   "security_group":{
      "name":"new-webservers",
      "description":"security group for webservers"
   }
}

see example: http://api.openstack.org/api-ref-networking.html#security_groups

----
ps: you can open the debug option of CLI `neutron --debug security-group-create defaulttest` to see the detail of http interactive

Revision history for this message
Akilesh (akilesh1597) said :
#6

Thanks ZhiQiang Fan, that solved my question.