Document navigation

Port Mirroring APIs

CreatePortMirror

API Request

URLs
POST zstack/v1/port-mirrors
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "mirrorNetworkUuid": "7d4ac8aafcd33306b21a0c40a6dec9cb"
  },
  "systemTags": [],
  "userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"mirrorNetworkUuid":"7d4ac8aafcd33306b21a0c40a6dec9cb"}}' http://localhost:8080/zstack/v1/port-mirrors
Request Parameters
Name Type Location Description Optional Value Starting Version
mirrorNetworkUuid String body (contained in the params structure) The UUID of the mirror network resource. 3.7.0
name String body (contained in the params structure) Optional. The resource name. 3.7.0
description String body (contained in the params structure) Optional. The detailed description of the resource. 3.7.0
stateEvent String body (contained in the params structure) Optional. The port mirroring service state.
  • enable
  • disable
3.7.0
resourceUuid String body (contained in the params structure) Optional. The resource UUID. 3.7.0
tagUuids List body (contained in the params structure) Optional. The list of tag UUIDs. 3.7.0
systemTags List body Optional. The system tags. 3.7.0
userTags List body Optional. The user tags. 3.7.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "66818821906036338c8e8f7773b03263",
    "name": "port mirror",
    "state": "Enabled",
    "mirrorNetworkUuid": "c1da6a9a815f3b17be87c19f9a43fe77",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventory PortMirrorInventory See inventory 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
mirrorNetworkUuid String The mirror network UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
state PortMirrorState See state 3.7.0
sessions List See sessions 3.7.0
#state
Name Type Description Starting Version
Enabled PortMirrorState The enabled state. 3.7.0
Disabled PortMirrorState The disabled state. 3.7.0
#sessions
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
internalId Long The internal ID. 3.7.0
srcEndPoint String The source endpoint. 3.7.0
dstEndPoint String The destination endpoint. 3.7.0
portMirrorUuid String The port mirror UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
status SessionStatus See status 3.7.0
type SessionType See type 3.7.0
#status
Name Type Description Starting Version
Created SessionStatus The created status. 3.7.0
Active SessionStatus The active status. 3.7.0
Inactive SessionStatus The inactive status. 3.7.0
#type
Name Type Description Starting Version
Ingress SessionType The ingress traffic direction. 3.7.0
Egress SessionType The egress traffic direction. 3.7.0
Bidirection SessionType The bidirectional traffic direction. 3.7.0

SDK Sample

Java SDK
CreatePortMirrorAction action = new CreatePortMirrorAction();
action.mirrorNetworkUuid = "7d4ac8aafcd33306b21a0c40a6dec9cb";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePortMirrorAction.Result res = action.call();
Python SDK
action = CreatePortMirrorAction()
action.mirrorNetworkUuid = "7d4ac8aafcd33306b21a0c40a6dec9cb"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

QueryPortMirror

API Request

URLs
GET zstack/v1/port-mirrors
GET zstack/v1/portMirrors/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/port-mirrors?q=name=web&q=state=Enabled
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/portMirrors/5aa247a04fbd3b9e9331e78645e81729

Queryable Fields

Run zstack CLI, enter QueryPortMirror, and press Tab to view all queryable fields and resources that support cross-table queries.

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "a1595ae4032236ed8cf8c0d8b4b498e7",
      "name": "port mirror",
      "state": "Enabled",
      "mirrorNetworkUuid": "2616116e22ab3033adc12890947259a6",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventories List See inventories 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
mirrorNetworkUuid String The mirror network UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
state PortMirrorState See state 3.7.0
sessions List See sessions 3.7.0
#state
Name Type Description Starting Version
Enabled PortMirrorState The enabled state. 3.7.0
Disabled PortMirrorState The disabled state. 3.7.0
#sessions
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
internalId Long The internal ID. 3.7.0
srcEndPoint String The source endpoint. 3.7.0
dstEndPoint String The destination endpoint. 3.7.0
portMirrorUuid String The port mirror UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
status SessionStatus See status 3.7.0
type SessionType See type 3.7.0
#status
Name Type Description Starting Version
Created SessionStatus The created status. 3.7.0
Active SessionStatus The active status. 3.7.0
Inactive SessionStatus The inactive status. 3.7.0
#type
Name Type Description Starting Version
Ingress SessionType The ingress traffic direction. 3.7.0
Egress SessionType The egress traffic direction. 3.7.0
Bidirection SessionType The bidirectional traffic direction. 3.7.0

SDK Sample

Java SDK
QueryPortMirrorAction action = new QueryPortMirrorAction();
action.conditions = asList("name=web","state=Enabled");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPortMirrorAction.Result res = action.call();
Python SDK
action = QueryPortMirrorAction()
action.conditions = ["name=web","state=Enabled"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

UpdatePortMirror

API Request

URLs
PUT zstack/v1/port-mirrors/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updatePortMirror": {
    "name": "new pm",
    "description": "for test update"
  },
  "systemTags": [],
  "userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updatePortMirror":{"name":"new pm","description":"for test update"}}' http://localhost:8080/zstack/v1/port-mirrors/8b4a0c82ba273ceda3ef09daf0ecd90d/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.7.0
name String body (contained in the updatePortMirror structure) Optional. The resource name. 3.7.0
description String body (contained in the updatePortMirror structure) Optional. The detailed description of the resource. 3.7.0
systemTags List body Optional. The system tags. 3.7.0
userTags List body Optional. The user tags. 3.7.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "2bafc0057bac3a6294a24a48c079c738",
    "name": "port mirror",
    "state": "Enabled",
    "mirrorNetworkUuid": "aacd59f03a853463846361bb946097c8",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventory PortMirrorInventory See inventory 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
mirrorNetworkUuid String The mirror network UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
state PortMirrorState See state 3.7.0
sessions List See sessions 3.7.0
#state
Name Type Description Starting Version
Enabled PortMirrorState The enabled state. 3.7.0
Disabled PortMirrorState The disabled state. 3.7.0
#sessions
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
internalId Long The internal ID. 3.7.0
srcEndPoint String The source endpoint. 3.7.0
dstEndPoint String The destination endpoint. 3.7.0
portMirrorUuid String The port mirror UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
status SessionStatus See status 3.7.0
type SessionType See type 3.7.0
#status
Name Type Description Starting Version
Created SessionStatus The created status. 3.7.0
Active SessionStatus The active status. 3.7.0
Inactive SessionStatus The inactive status. 3.7.0
#type
Name Type Description Starting Version
Ingress SessionType The ingress traffic direction. 3.7.0
Egress SessionType The egress traffic direction. 3.7.0
Bidirection SessionType The bidirectional traffic direction. 3.7.0

SDK Sample

Java SDK
UpdatePortMirrorAction action = new UpdatePortMirrorAction();
action.uuid = "8b4a0c82ba273ceda3ef09daf0ecd90d";
action.name = "new pm";
action.description = "for test update";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdatePortMirrorAction.Result res = action.call();
Python SDK
action = UpdatePortMirrorAction()
action.uuid = "8b4a0c82ba273ceda3ef09daf0ecd90d"
action.name = "new pm"
action.description = "for test update"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

DeletePortMirror

API Request

URLs
DELETE zstack/v1/port-mirrors/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/port-mirrors/b4959c6b70c836508290dce51e9a1394
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.7.0
deleteMode String body Optional. The deletion mode. 3.7.0
systemTags List body Optional. The system tags. 3.7.0
userTags List body Optional. The user tags. 3.7.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or an operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK Sample

Java SDK
DeletePortMirrorAction action = new DeletePortMirrorAction();
action.uuid = "b4959c6b70c836508290dce51e9a1394";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePortMirrorAction.Result res = action.call();
Python SDK
action = DeletePortMirrorAction()
action.uuid = "b4959c6b70c836508290dce51e9a1394"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

CreatePortMirrorSession

API Request

URLs
POST zstack/v1/port-mirrors/sessions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "portMirrorUuid": "d848a38e94c53c9dafbb422f5e534237",
    "name": "session",
    "type": "Ingress",
    "srcEndPoint": "404d456d595a3fcf8e758dc864a47c2e",
    "dstEndPoint": "5ffb697b680d3d76bf3c50f344d5f742"
  },
  "systemTags": [],
  "userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"portMirrorUuid":"d848a38e94c53c9dafbb422f5e534237","name":"session","type":"Ingress","srcEndPoint":"404d456d595a3fcf8e758dc864a47c2e","dstEndPoint":"5ffb697b680d3d76bf3c50f344d5f742"}}' http://localhost:8080/zstack/v1/port-mirrors/sessions
Request Parameters
Name Type Location Description Optional Value Starting Version
portMirrorUuid String body (contained in the params structure) The port mirror UUID. 3.7.0
name String body (contained in the params structure) The resource name. 3.7.0
description String body (contained in the params structure) Optional. The detailed description of the resource. 3.7.0
type String body (contained in the params structure) The session resource type.
  • Ingress
  • Egress
  • Bidirection
3.7.0
srcEndPoint String body (contained in the params structure) The source endpoint of the mirror session. 3.7.0
dstEndPoint String body (contained in the params structure) The destination endpoint of the mirror session. 3.7.0
resourceUuid String body (contained in the params structure) Optional. The resource UUID. 3.7.0
tagUuids List body (contained in the params structure) Optional. The list of tag UUIDs. 3.7.0
systemTags List body Optional. The system tags. 3.7.0
userTags List body Optional. The user tags. 3.7.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "6f8ad47ea3a336aca4d32e53e3b6d731",
    "name": "port mirror",
    "srcEndPoint": "f9dbfde2c5bd398a8691b9f4be4a6a79",
    "type": "Ingress",
    "dstEndPoint": "76ea062350ac3a2aacf22545954185ed",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventory PortMirrorSessionInventory See inventory 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
internalId Long The internal ID. 3.7.0
srcEndPoint String The source endpoint. 3.7.0
dstEndPoint String The destination endpoint. 3.7.0
portMirrorUuid String The port mirror UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
status SessionStatus See status 3.7.0
type SessionType See type 3.7.0
#status
Name Type Description Starting Version
Created SessionStatus The created status. 3.7.0
Active SessionStatus The active status. 3.7.0
Inactive SessionStatus The inactive status. 3.7.0
#type
Name Type Description Starting Version
Ingress SessionType The ingress traffic direction. 3.7.0
Egress SessionType The egress traffic direction. 3.7.0
Bidirection SessionType The bidirectional traffic direction. 3.7.0

SDK Sample

Java SDK
CreatePortMirrorSessionAction action = new CreatePortMirrorSessionAction();
action.portMirrorUuid = "d848a38e94c53c9dafbb422f5e534237";
action.name = "session";
action.type = "Ingress";
action.srcEndPoint = "404d456d595a3fcf8e758dc864a47c2e";
action.dstEndPoint = "5ffb697b680d3d76bf3c50f344d5f742";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePortMirrorSessionAction.Result res = action.call();
Python SDK
action = CreatePortMirrorSessionAction()
action.portMirrorUuid = "d848a38e94c53c9dafbb422f5e534237"
action.name = "session"
action.type = "Ingress"
action.srcEndPoint = "404d456d595a3fcf8e758dc864a47c2e"
action.dstEndPoint = "5ffb697b680d3d76bf3c50f344d5f742"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

QueryPortMirrorSession

API Request

URLs
GET zstack/v1/port-mirrors/sessions
GET zstack/v1/port-mirrors/sessions/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/port-mirrors/sessions?q=name=session&q=direction=Egress&q=srcEndPoint=123456xxx

Queryable Fields

Run zstack CLI, enter QueryPortMirrorSession, and press Tab to view all queryable fields and resources that support cross-table queries.

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "aab3ce5ac3de3d2b982bb376fe8909af",
      "name": "port mirror session",
      "status": "Active",
      "srcEndPoint": "c568cf147cff3cac83f855f622986db8",
      "type": "Egress",
      "dstEndPoint": "f5b953f2b56d316894daf4eb2d5a9627",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventories List See inventories 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
internalId Long The internal ID. 3.7.0
srcEndPoint String The source endpoint. 3.7.0
dstEndPoint String The destination endpoint. 3.7.0
portMirrorUuid String The port mirror UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
status SessionStatus See status 3.7.0
type SessionType See type 3.7.0
#status
Name Type Description Starting Version
Created SessionStatus The created status. 3.7.0
Active SessionStatus The active status. 3.7.0
Inactive SessionStatus The inactive status. 3.7.0
#type
Name Type Description Starting Version
Ingress SessionType The ingress traffic direction. 3.7.0
Egress SessionType The egress traffic direction. 3.7.0
Bidirection SessionType The bidirectional traffic direction. 3.7.0

SDK Sample

Java SDK
QueryPortMirrorSessionAction action = new QueryPortMirrorSessionAction();
action.conditions = asList("name=session","direction=Egress","srcEndPoint=123456xxx");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPortMirrorSessionAction.Result res = action.call();
Python SDK
action = QueryPortMirrorSessionAction()
action.conditions = ["name=session","direction=Egress","srcEndPoint=123456xxx"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

ChangePortMirrorState

API Request

URLs
PUT zstack/v1/port-mirrors/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "changePortMirrorState": {
    "stateEvent": "enable"
  },
  "systemTags": [],
  "userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changePortMirrorState":{"stateEvent":"enable"}}' http://localhost:8080/zstack/v1/port-mirrors/3b3454b75a593d718ba24cc7d677cacd/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.7.0
stateEvent String body (contained in the changePortMirrorState structure) The state.
  • enable
  • disable
3.7.0
systemTags List body Optional. The system tags. 3.7.0
userTags List body Optional. The user tags. 3.7.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "8752424e2b1e398a9d28fbb076cff81f",
    "name": "port mirror",
    "state": "Enabled",
    "mirrorNetworkUuid": "ad51cb6be5d83cb4bfeb8eb95b2e6437",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventory PortMirrorInventory See inventory 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
mirrorNetworkUuid String The mirror network UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
state PortMirrorState See state 3.7.0
sessions List See sessions 3.7.0
#state
Name Type Description Starting Version
Enabled PortMirrorState The enabled state. 3.7.0
Disabled PortMirrorState The disabled state. 3.7.0
#sessions
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
name String The resource name. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
internalId Long The internal ID. 3.7.0
srcEndPoint String The source endpoint. 3.7.0
dstEndPoint String The destination endpoint. 3.7.0
portMirrorUuid String The port mirror UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
status SessionStatus See status 3.7.0
type SessionType See type 3.7.0
#status
Name Type Description Starting Version
Created SessionStatus The created status. 3.7.0
Active SessionStatus The active status. 3.7.0
Inactive SessionStatus The inactive status. 3.7.0
#type
Name Type Description Starting Version
Ingress SessionType The ingress traffic direction. 3.7.0
Egress SessionType The egress traffic direction. 3.7.0
Bidirection SessionType The bidirectional traffic direction. 3.7.0

SDK Sample

Java SDK
ChangePortMirrorStateAction action = new ChangePortMirrorStateAction();
action.uuid = "3b3454b75a593d718ba24cc7d677cacd";
action.stateEvent = "enable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangePortMirrorStateAction.Result res = action.call();
Python SDK
action = ChangePortMirrorStateAction()
action.uuid = "3b3454b75a593d718ba24cc7d677cacd"
action.stateEvent = "enable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

DeletePortMirrorSession

API Request

URLs
DELETE zstack/v1/port-mirrors/sessons/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/port-mirrors/sessons/3c1f4de89ffd3f83932bbd95321dbf20
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.7.0
deleteMode String body Optional. The deletion mode. 3.7.0
systemTags List body Optional. The system tags. 3.7.0
userTags List body Optional. The user tags. 3.7.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or an operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK Sample

Java SDK
DeletePortMirrorSessionAction action = new DeletePortMirrorSessionAction();
action.uuid = "3c1f4de89ffd3f83932bbd95321dbf20";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePortMirrorSessionAction.Result res = action.call();
Python SDK
action = DeletePortMirrorSessionAction()
action.uuid = "3c1f4de89ffd3f83932bbd95321dbf20"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

GetCandidateVmNicsForPortMirror

API Request

URLs
GET zstack/v1/port-mirrors/{portMirrorUuid}/vm-instances/candidate-nics/{type}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/port-mirrors/35f9487b28bf3ef3995bdaa9b0c7e14c/vm-instances/candidate-nics/source?
Request Parameters
Name Type Location Description Optional Value Starting Version
portMirrorUuid String url The port mirroring service UUID. 3.7.0
type String url The NIC type.
  • source
  • dest
3.7.0
systemTags List query Optional. The system tags. 3.7.0
userTags List query Optional. The user tags. 3.7.0

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "7b606cc2eaf03d59be9ccf7eb8e64146",
      "vmInstanceUuid": "3426dad7e3b63a8db7cf0f2679b25c3d",
      "usedIpUuid": "6e85b642844e3afe9dfca1a159d982f2",
      "l3NetworkUuid": "dc154c4096f73e4f9ebf14bbdd577927",
      "ip": "192.168.1.10",
      "mac": "00:0c:29:bd:99:fc",
      "hypervisorType": "KVM",
      "netmask": "255.255.255.0",
      "gateway": "192.168.1.1",
      "deviceId": 0.0,
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventories List See inventories 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
vmInstanceUuid String The VM instance UUID. 3.7.0
l3NetworkUuid String The L3 network UUID. 3.7.0
ip String The IP address. 3.7.0
mac String The MAC address. 3.7.0
hypervisorType String The hypervisor type. 3.7.0
netmask String The network mask. 3.7.0
gateway String The gateway IP address. 3.7.0
metaData String The metadata. 3.7.0
ipVersion Integer The IP version. 3.7.0
deviceId Integer The device ID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0
usedIps List See usedIps 3.7.0
#usedIps
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
ipRangeUuid String The IP range UUID. 3.7.0
l3NetworkUuid String The L3 network UUID. 3.7.0
ipVersion Integer The IP version. 3.7.0
ip String The IP address. 3.7.0
netmask String The network mask. 3.7.0
gateway String The gateway IP address. 3.7.0
usedFor String The purpose of the IP address. 3.7.0
ipInLong long The IP address represented as a long integer. 3.7.0
vmNicUuid String The VM NIC UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0

SDK Sample

Java SDK
GetCandidateVmNicsForPortMirrorAction action = new GetCandidateVmNicsForPortMirrorAction();
action.portMirrorUuid = "35f9487b28bf3ef3995bdaa9b0c7e14c";
action.type = "source";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetCandidateVmNicsForPortMirrorAction.Result res = action.call();
Python SDK
action = GetCandidateVmNicsForPortMirrorAction()
action.portMirrorUuid = "35f9487b28bf3ef3995bdaa9b0c7e14c"
action.type = "source"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

QueryPortMirrorNetworkUsedIp

API Request

URLs
GET zstack/v1/port-mirrors/networks/usedIps
GET zstack/v1/port-mirrors/networks/usedIps/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/port-mirrors/networks/usedIps?q=
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/port-mirrors/networks/usedIps/bfe3d806d9cc3e649a3d80e548409c89

Queryable Fields

Run zstack CLI, enter QueryPortMirrorNetworkUsedIp, and press Tab to view all queryable fields and resources that support cross-table queries.

API Response

Sample Response
{
  "inventories": [
    {
      "l3NetworkUuid": "207f29af9d033376ba8f7c2a4ae243c4",
      "hostUuid": "c7a6c1c107e2368e8cec88481e29967b",
      "description": "for test",
      "clusterUuid": "1a4911d67929346b949853fd92d5a0bc",
      "uuid": "fe8301ee9bf93c5db2e2240644619c56"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode Error code, null if operation succeeds, non-null if operation fails, see error 3.7.0
inventories List See inventories 3.7.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.7.0
description String The brief description of the error. 3.7.0
details String The details about the error. 3.7.0
elaboration String The reserved field. Default value: null. 3.7.0
opaque LinkedHashMap The reserved field. Default value: null. 3.7.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.7.0
#inventories
Name Type Description Starting Version
l3NetworkUuid String The L3 network UUID. 3.7.0
hostUuid String The host UUID. 3.7.0
description String Optional. The detailed description of the resource. 3.7.0
clusterUuid String The cluster UUID. 3.7.0
uuid String The resource UUID. 3.7.0
usedIpInventory UsedIpInventory See usedIpInventory 3.7.0
#usedIpInventory
Name Type Description Starting Version
uuid String The resource UUID. 3.7.0
ipRangeUuid String The IP range UUID. 3.7.0
l3NetworkUuid String The L3 network UUID. 3.7.0
ipVersion Integer The IP version. 3.7.0
ip String The IP address. 3.7.0
netmask String The network mask. 3.7.0
gateway String The gateway IP address. 3.7.0
usedFor String The purpose of the IP address. 3.7.0
ipInLong long The IP address represented as a long integer. 3.7.0
vmNicUuid String The VM NIC UUID. 3.7.0
createDate Timestamp The creation date. 3.7.0
lastOpDate Timestamp The last operation date. 3.7.0

SDK Sample

Java SDK
QueryPortMirrorNetworkUsedIpAction action = new QueryPortMirrorNetworkUsedIpAction();
action.conditions = asList("");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPortMirrorNetworkUsedIpAction.Result res = action.call();
Python SDK
action = QueryPortMirrorNetworkUsedIpAction()
action.conditions = [""]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
API Reference | 5.5.38 | ZStack Cloud · ZCF | ZStack Resource Center