Tạo security group
POST
/v2.0/security-groupsTạo một security group rỗng. Group mới không có rule nào, nên nó chặn toàn bộ ingress và cho phép toàn bộ egress cho đến khi bạn thêm rule.
info
Nguồn: create-security-group
Request
Tham số
security_groupobjectbắt buộcObject bọc security group.
5 trường
namestringbắt buộcbodyTên group. Tên không unique; ID là định danh.
descriptionstringbodyMô tả tự do.
statefulbooleanbodyMặc định true. Stateful nghĩa là lưu lượng phản hồi cho một kết nối được phép tự động được cho phép. Giữ true trừ khi triển khai hỗ trợ group stateless.
tenant_idstringbodyID của project. Chỉ admin mới có thể tạo group trong project khác.
tagsarraybodyCác tag gắn với group.
Request mẫu
curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
-d '{
"security_group": {
"name": "web-sg",
"description": "HTTP and HTTPS from anywhere"
}
}' https://api.vietnix.cloud:9696/v2.0/security-groups
Response
Response mẫu
Response body
{
"security_group": {
"id": "b7e4d2c1-8f3a-4b6d-9c05-1e2f3a4b5c60",
"name": "web-sg",
"description": "HTTP and HTTPS from anywhere",
"stateful": true,
"tenant_id": "f5d834d636c642c7bfe8af86139c6f26",
"project_id": "f5d834d636c642c7bfe8af86139c6f26",
"security_group_rules": [],
"tags": []
}
}
Mã trạng thái
Thành công
| Mã | Mô tả |
|---|---|
| 201 - Created | Security group đã được tạo. |
Lỗi
| Mã | Mô tả |
|---|---|
| 400 - Bad Request | Tên bị thiếu hoặc body không hợp lệ. |
| 401 - Unauthorized | Cần xác thực trước khi gửi request. |
| 403 - Forbidden | Policy không cho phép user hiện tại thực hiện thao tác này. |
| 409 - Conflict | Đã tồn tại group cùng tên trong project. |
note
Để dùng group, hãy thêm rule (xem Quản lý security group rule) rồi gắn group vào port hoặc truyền tên group trong networks.security_groups khi tạo VM (xem Tạo VM). Group không có rule sẽ chặn toàn bộ lưu lượng vào.