VM Related Interfaces

Change NIC Default Traffic Policy

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

Headers

Authorization: OAuth the-session-uuid

Body

{
  "changeVmNicSecurityPolicy": {
    "ingressPolicy": "ALLOW",
    "egressPolicy": "DENY"
  },
  "systemTags": [],
  "userTags": []
}

In the example above, systemTags and userTags fields can be omitted. They are listed to indicate that the body can contain these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"changeVmNicSecurityPolicy":{"ingressPolicy":"ALLOW","egressPolicy":"DENY"}}' http://localhost:8080/zstack/v1/security-groups/nics/5551303bee7037c8848cdb5741be7ff7/security-policy/actions

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

vmNicUuid

String

url

UUID of the NIC, uniquely identifies the resource

 

4.7.21

ingressPolicy (Optional)

String

body (contained in the changeVmNicSecurityPolicy structure)

NIC ingress security policy

  • DENY
  • ALLOW

4.7.21

egressPolicy (Optional)

String

body (contained in the changeVmNicSecurityPolicy structure)

NIC egress security policy

  • DENY
  • ALLOW

4.7.21

systemTags (Optional)

List

body

System Tag

 

4.0.0

userTags (Optional)

List

body

User Tag

 

4.0.0

API Response

Response Example

{
  "inventory": {
    "uuid": "2c8164f7e3213f1491640a2f98d0a979",
    "vmNicUuid": "c731cb960eb635a997e58d154d3c4252",
    "ingressPolicy": "DENY",
    "egressPolicy": "ALLOW",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
NameTypeDescriptionStarting Version
successboolean 4.7.21
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation is successful. For details, see error4.7.21
inventorySecurityGroupInventoryFor details, see inventory4.7.21

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier for the error, for example SYS.1000, HOST.10010.6
descriptionStringBrief description of the error0.6
detailsStringDetailed error information0.6
elaborationStringReserved field, defaults to null0.6
opaqueLinkedHashMapReserved field, defaults to null0.6
causeErrorCodeRoot cause. The source error that caused the current error. If there is no original error, this field is null0.6

inventory

NameTypeDescriptionStarting Version
vmNicUuidStringVirtual Machine NIC UUID4.7.21
ingressPolicyStringNIC ingress security policy4.7.21
egressPolicyStringNIC egress security policy4.7.21
createDateTimestampCreate time4.7.21
lastOpDateTimestampLast modification time4.7.21

SDK Examples

Java SDK

ChangeVmNicSecurityPolicyAction action = new ChangeVmNicSecurityPolicyAction();
action.vmNicUuid = "5551303bee7037c8848cdb5741be7ff7";
action.ingressPolicy = "ALLOW";
action.egressPolicy = "DENY";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmNicSecurityPolicyAction.Result res = action.call();

Python SDK

ChangeVmNicSecurityPolicyAction action = ChangeVmNicSecurityPolicyAction()
action.vmNicUuid = "5551303bee7037c8848cdb5741be7ff7"
action.ingressPolicy = "ALLOW"
action.egressPolicy = "DENY"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeVmNicSecurityPolicyAction.Result res = action.call()