Os-security-groups

Support management of security group in OS API 1.1 or later version same as it is present in the EC2 API.

Create Security Group API
URL : http://10.2.3.150:8774/v1.1/security_groups

Normal Response Code(s): 200

Error Response Code(s): 500, unauthorized(401), badRequest(400)

This operation creates a new security group into your account.

Error Handling

In all of the above error cases, it returns HTTP status code 400.

Request XML
 test 

Response XML
 test 


 * Note: tenant_id will be the project Id.

Request JSON
{ "security_group" : {       "name" : "test12", "description" : "security group description" } }

Response JSON
{  "security_group": {        "rules": [], "tenant_id": "admin", "id": 41, "name": "test12", "description": "security group description" } }

Get Security Group
URL: http://10.2.3.150:8774/v1.1/security_groups/

Normal Response Code(s): 200

Error Response Code(s): unauthorized(401), ItemNotFound(404)

This operation returns the details of a security group

This operation does not require a request body

Response XML
   22             tcp   22             10.2.6.0/24              22           </from_port> <tenant_id> admin </tenant_id> 11111            tcp </ip_protocol>  22           </to_port>  default </security_group>

Response JSON
{   "security_group": {         "rules": [ {               "from_port": 22, "group": {}, "ip_protocol": "tcp", "to_port": 22, "parent_group_id": 28, "ip_range": { "cidr": "10.2.6.0/24" },                "id": 108 },             {                 "from_port": 22, "group": { "tenant_id": "admin", "name": "11111" },                 "ip_protocol": "tcp", "to_port": 22, "parent_group_id": 28, "ip_range": {}, "id": 109 }         ],          "tenant_id": "admin", "id": 28, "name": "default", "description": "default" } }

List Security Groups
URL : http://10.2.3.150:8774/v1.1/security-groups

Normal Response Code(s): 200

Error Response Code(s): unauthorized(401)

This operation provides a list of security groups with your account. Security groups that have been deleted are not included in this list. The list of security groups doesn't support filtering in this version. The list returned is sorted based on the id, if you are a admin user then the list returned is sorted based on the tenant_id (ProjectID) and security group name.

This operation does not require a request body.

Response XML
<security_groups xmlns="http://docs.openstack.org/compute/api/v1.1"> <security_group id="39" name="11111" tenant_id="admin"> test </security_group> <security_group id="28" name="default" tenant_id="admin"> <rule id="108" parent_group_id="28">  22               </from_port>  tcp </ip_protocol>  22               </to_port>  10.2.6.0/24               </ip_range> <rule id="109" parent_group_id="28">  22               </from_port> <tenant_id> admin </tenant_id> 11111                tcp </ip_protocol>  22               </to_port>  default </security_group> </security_groups>

Response JSON
{   "security_groups": [ {          "rules": [], "tenant_id": "admin", "id": 39, "name": "11111", "description": "test" },       {          "rules": [ {               "from_port": 22, "group": {}, "ip_protocol": "tcp", "to_port": 22, "parent_group_id": 28, "ip_range": { "cidr": "10.2.6.0/24" },                "id": 108 },             {                 "from_port": 22, "group": { "tenant_id": "admin", "name": "11111" },                 "ip_protocol": "tcp", "to_port": 22, "parent_group_id": 28, "ip_range": {}, "id": 109 }         ],          "tenant_id": "admin", "id": 28, "name": "default", "description": "default" }     ] }

= Delete Security Group =

Normal Response Code(s): 202

Error Response Code(s): unauthorized (401), itemNotFound (404)

This operation does not require a request or a response body.

= Create Security Group Rule =

Normal Response Code(s): 202

Error Response Code(s): computeFault(500), unauthorized(401), BadRequest(400), UnprocessableEntity(422), itemNotfound(400)

This operation adds one rule to a security group in a single request.

Exmaple 1 Request XML
<security_group_rule> tcp</ip_protocol> 22</from_port> 22</to_port> <parent_group_id>28</parent_group_id> 10.2.6.0/24 </security_group_rule>

Example 1 XML Response
<security_group_rule id="108" parent_group_id="28" xmlns="http://docs.openstack.org/compute/api/v1.1">  22   </from_port> <ip_protocol> tcp </ip_protocol> <to_port> 22   </to_port> <ip_range> 10.2.6.0/24   </ip_range> </security_group_rule>

Example 2 Request XML
<security_group_rule> <ip_protocol>tcp</ip_protocol> <from_port>22</from_port> <to_port>22</to_port> <parent_group_id>28</parent_group_id> <group_id>45</group_id> </security_group_rule>

Example 2 XML Response
<security_group_rule id="108" parent_group_id="28" xmlns="http://docs.openstack.org/compute/api/v1.1"> <from_port> 22   </from_port> <tenant_id>testproject<tenant_id> test <ip_protocol> tcp </ip_protocol> <to_port> 22   </to_port> </ip_range> </security_group_rule>

Example 1 Request JSON
{  "security_group_rule": { "ip_protocol": "tcp", "from_port": "22", "to_port": "22", "parent_group_id": 2, "cidr": "10.2.3.124/24" } }

Example 2 Request JSON
{ "security_group_rule": { "ip_protocol": "tcp", "from_port": "22", "to_port": "22", "group_id": 1, "parent_group_id": 2 } }

= Delete Security Group Rule =

Normal Response Code(s): 202

Error Response Code(s): unauthorized(401), itemNotfound(404)

This operation removes one rule from a security group.

This operation does not require a request or a response body.