Network ServicesSecurity Group

SetVmNicSecurityGroup

PUT/zstack/v1/security-groups/nics/{vmNicUuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "setVmNicSecurityGroup": {
    "refs": [
      {
        "securityGroupUuid": "a63c3b35a6553b4a912ee60cd06d5066",
        "priority": 1
      }
    ]
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. They are listed here to indicate that these two fields can be included in the body.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X PUT -d '{"setVmNicSecurityGroup":{"refs":[{"securityGroupUuid":"a63c3b35a6553b4a912ee60cd06d5066","priority":1}]}}'
http://localhost:8080/zstack/v1/security-groups/nics/6b7ad223ebb2328bb646f2e77b34957b/actions

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
vmNicUuidStringurlThe UUID of the NIC, uniquely identifying the resource 4.7.21
refsListbody (included in the setVmNicSecurityGroup structure)The security groups attached to the NIC 4.7.21
systemTags (Optional)ListbodySystem tags 4.7.21
userTags (Optional)ListbodyUser tags 4.7.21

API Response

Response Example

{
  "inventory": [
    {
      "uuid": "33aa195b943c3faa87e2c75a787cb7f5",
      "priority": 1,
      "securityGroupUuid": "63ec5dcb248138968f0153160b5b8b3a"
    }
  ]
}
NameTypeDescriptionStarting Version
successboolean 4.7.21
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. See error4.7.21
inventorySecurityGroupInventorySee inventory4.7.21

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier for the error, for example SYS.1000, HOST.10014.7.21
descriptionStringBrief description of the error4.7.21
detailsStringDetailed error information4.7.21
elaborationStringReserved field, defaults to null4.7.21
opaqueLinkedHashMapReserved field, defaults to null4.7.21
causeErrorCodeRoot error: the source error that caused the current error. If there is no original error, this field is null4.7.21

inventory

NameTypeDescriptionStarting Version
priorityIntegerThe security group priority4.7.21
vmNicUuidStringThe VM NIC UUID4.7.21
securityGroupUuidStringThe security group UUID4.7.21
vmInstanceUuidStringThe VM instance UUID4.7.21
createDateTimestampThe creation time4.7.21
lastOpDateTimestampThe last modification time4.7.21

SDK Examples

Java SDK

SetVmNicSecurityGroupAction action = new SetVmNicSecurityGroupAction();
action.vmNicUuid = "6b7ad223ebb2328bb646f2e77b34957b";
action.refs = asList([securityGroupUuid:a63c3b35a6553b4a912ee60cd06d5066, priority:1]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetVmNicSecurityGroupAction.Result res = action.call();

Python SDK

SetVmNicSecurityGroupAction action = SetVmNicSecurityGroupAction()
action.vmNicUuid = "6b7ad223ebb2328bb646f2e77b34957b"
action.refs = [[securityGroupUuid:a63c3b35a6553b4a912ee60cd06d5066, priority:1]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SetVmNicSecurityGroupAction.Result res = action.call()