Port Forwarding Operations
CreatePortForwardingRule
API Request
URLs
POST zstack/v1/port-forwardingHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"vipUuid": "214cf4f562bf40b98a7c954081f94f03",
"vipPortStart": 22.0,
"protocolType": "TCP",
"vmNicUuid": "84590db8896d4e498bf69d35239a31cc",
"name": "pf1"
},
"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":{"vipUuid":"1c4824bb6043388cac7499dd481ecaa4","vipPortStart":22.0,"protocolType":"TCP","vmNicUuid":"0611006103d335dfbfc0f9bb2a46d541","name":"pf1"}}' \
http://localhost:8080/zstack/v1/port-forwardingRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| vipUuid | String | body (contained in the params structure) | The VIP UUID. | 0.6 | |
| vipPortStart | Integer | body (contained in the params structure) | The VIP start port. | 0.6 | |
| vipPortEnd | Integer | body (contained in the params structure) | Optional. The VIP end port. If not specified, the value of vipPortStart will be used by default. | 0.6 | |
| privatePortStart | Integer | body (contained in the params structure) | Optional. The start port of the guest IP address (the IP address of the VM NIC). If not specified, the value of vipPortStart will be used by default. | 0.6 | |
| privatePortEnd | Integer | body (contained in the params structure) | Optional. The end port of the guest IP address (the IP address of the VM NIC). If not specified, the value of vipPortEnd will be used by default. | 0.6 | |
| protocolType | String | body (contained in the params structure) | The protocol type of the network traffic. |
|
0.6 |
| vmNicUuid | String | body (contained in the params structure) | Optional. The VM NIC UUID. | 0.6 | |
| allowedCidr | String | body (contained in the params structure) | Optional. The source CIDR. The port forwarding rule is only applied to the traffics of the source CIDR. If not specified, 0.0.0.0/0 will be used by default. | 0.6 | |
| name | String | body (contained in the params structure) | The resource name. | 0.6 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 0.6 | |
| resourceUuid | String | body (contained in the params structure) | Optional. The resource UUID. If specified, the system will not allocate randomly a UUID to the resource. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"uuid": "895a8ce93d274db78e2ef1462f8b8a29",
"name": "TestAttachRule",
"description": "test atatch rule",
"vipIp": "192.168.0.187",
"guestIp": "10.0.0.244",
"vipUuid": "6151c96fd2ac4d6cbd8f8eedffc06de5",
"vipPortStart": 33.0,
"vipPortEnd": 33.0,
"privatePortStart": 33.0,
"privatePortEnd": 33.0,
"vmNicUuid": "581ea3b08aef4096ac24e160f1ab0f8e",
"protocolType": "TCP",
"state": "Enabled",
"allowedCidr": "0.0.0.0/0",
"createDate": "Jun 7, 2017 9:20:10 PM",
"lastOpDate": "Jun 7, 2017 9:20:10 PM"
}
}#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| vipIp | String | The IP address of the VIP. | 0.6 |
| guestIp | String | The IP address of the VM NIC. | 0.6 |
| vipUuid | String | The VIP UUID. | 0.6 |
| vipPortStart | Integer | The start port of the VIP. | 0.6 |
| vipPortEnd | Integer | The end port of the VIP. | 0.6 |
| privatePortStart | Integer | The start port of guest IP address. | 0.6 |
| privatePortEnd | Integer | The end port of guest IP address. | 0.6 |
| vmNicUuid | String | The VM NIC UUID. | 0.6 |
| protocolType | String | The protocol type of the network traffic. | 0.6 |
| state | String | The state of the rule. | 0.6 |
| allowedCidr | String | The source CIDR. The port forwarding rule is only applied to the traffics of the source CIDR. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
CreatePortForwardingRuleAction action = new CreatePortForwardingRuleAction();
action.vipUuid = "966f9f294e094243bcfaf7eeee70aeae";
action.vipPortStart = 22.0;
action.protocolType = "TCP";
action.vmNicUuid = "ace8c962d59248e38fadac5df9a108a7";
action.name = "pf1";
action.sessionId = "5f4df8c7fae44602b5f7e5d376904d6b";
CreatePortForwardingRuleAction.Result res = action.call();
Python
SDK
CreatePortForwardingRuleAction action = CreatePortForwardingRuleAction()
action.vipUuid = "1d130b0bb1e44aafa76d6280479f5399"
action.vipPortStart = 22.0
action.protocolType = "TCP"
action.vmNicUuid = "78c6172984874e5e9cdd3bf0248080ca"
action.name = "pf1"
action.sessionId = "4a3371ccd0cc4cdfa75ae46aeec14f41"
CreatePortForwardingRuleAction.Result res = action.call()DeletePortForwardingRule
API Request
URLs
DELETE zstack/v1/port-forwarding/{uuid}?deleteMode={deleteMode}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 064a2c25381042d6b623c12e26418e78" \
-X DELETE http://localhost:8080/zstack/v1/port-forwarding/495b48a2bcf745e1ac584be6e366f0ab?deleteMode=PermissiveRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| deleteMode | String | body | Optional. The delete mode. Options:
Permissive | Enforcing. Default mode: Permissive.
|
0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
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 a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
DeletePortForwardingRuleAction action = new DeletePortForwardingRuleAction();
action.uuid = "42154ff320ea407dbc8b48088e541dcb";
action.deleteMode = "Permissive";
action.sessionId = "2b5cb5c82fb846669cd2c5e557bb140e";
DeletePortForwardingRuleAction.Result res = action.call();Python
SDK
DeletePortForwardingRuleAction action = DeletePortForwardingRuleAction()
action.uuid = "a8ac2d430d71487ea47419950e39ee4a"
action.deleteMode = "Permissive"
action.sessionId = "156eb3cd301546828a925386f331eb34"
DeletePortForwardingRuleAction.Result res = action.call()QueryPortForwardingRule
API Request
URLs
GET zstack/v1/port-forwarding
GET zstack/v1/port-forwarding/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 959a6d98336c4575a31212834d8ccc4d" \
-X GET http://localhost:8080/zstack/v1/port-forwarding?q=name=pf1&q=state=Enabledcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 0389ba8bf3c44bf8a9c5ee89d066fbdc" \
-X GET http://localhost:8080/zstack/v1/port-forwarding/3d9c9dbbea944e039d55e706aacb6899Queryable Fields
You can check all queryable fields and resource names that can be queried across
tables by using zstack-cli, entering
QueryPortForwardingRule, and pressing the Tab key.
API Response
Sample
Response
{
"inventories": [
{
"uuid": "c5cf6d7df3164418b3fe5c7569eb1dea",
"name": "TestAttachRule",
"description": "test atatch rule",
"vipIp": "192.168.0.187",
"guestIp": "10.0.0.244",
"vipUuid": "b5166a0c9adb4aaf8088022b5336209a",
"vipPortStart": 33.0,
"vipPortEnd": 33.0,
"privatePortStart": 33.0,
"privatePortEnd": 33.0,
"vmNicUuid": "8aa417eb4537475b815b289240e0c0c2",
"protocolType": "TCP",
"state": "Enabled",
"allowedCidr": "0.0.0.0/0",
"createDate": "Jun 7, 2017 9:21:17 PM",
"lastOpDate": "Jun 7, 2017 9:21:17 PM"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventories | List | See inventories. | 0.6 |
#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| vipIp | String | The IP address of the VIP. | 0.6 |
| guestIp | String | The IP address of the VM NIC. | 0.6 |
| vipUuid | String | The VIP UUID. | 0.6 |
| vipPortStart | Integer | The start port of the VIP. | 0.6 |
| vipPortEnd | Integer | The end port of the VIP. | 0.6 |
| privatePortStart | Integer | The start port of the guest IP address. | 0.6 |
| privatePortEnd | Integer | The end port of the guest IP address. | 0.6 |
| vmNicUuid | String | The VM NIC UUID. | 0.6 |
| protocolType | String | The protocol type of the network traffic. | 0.6 |
| state | String | The state of the rule. | 0.6 |
| allowedCidr | String | The source CIDR. The port forwarding rule is only applied to the traffics of the source CIDR. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
QueryPortForwardingRuleAction action = new QueryPortForwardingRuleAction();
action.conditions = asList("name=pf1","state=Enabled");
action.sessionId = "4311e616ca8b4bb19d0792be1e08f3b8";
QueryPortForwardingRuleAction.Result res = action.call();Python
SDK
QueryPortForwardingRuleAction action = QueryPortForwardingRuleAction()
action.conditions = ["name=pf1","state=Enabled"]
action.sessionId = "b9745425f62d43289db77d9bfd117b35"
QueryPortForwardingRuleAction.Result res = action.call()UpdatePortForwardingRule
API Request
URLs
PUT zstack/v1/port-forwarding/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"updatePortForwardingRule": {
"name": "pf2",
"description": "new rule"
},
"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 '{"updatePortForwardingRule":{"name":"pf2","description":"new rule"}}' \
http://localhost:8080/zstack/v1/port-forwarding/07eb042c2f5837a99f4018c3ee7e4137/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| name | String | body (contained in the updatePortForwardingRule structure) | Optional. The resource name. | 0.6 | |
| description | String | body (contained in the updatePortForwardingRule structure) | Optional. The detailed description of the resource. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"uuid": "420edb331ec34871a416e570fa4faf8b",
"name": "TestAttachRule",
"description": "test atatch rule",
"vipIp": "192.168.0.187",
"guestIp": "10.0.0.244",
"vipUuid": "8282dbb28b70416790bd83d08d3718ba",
"vipPortStart": 33.0,
"vipPortEnd": 33.0,
"privatePortStart": 33.0,
"privatePortEnd": 33.0,
"vmNicUuid": "2e63ec7524074e9dad1255d5e02f0697",
"protocolType": "TCP",
"state": "Enabled",
"allowedCidr": "0.0.0.0/0",
"createDate": "Jun 7, 2017 9:20:38 PM",
"lastOpDate": "Jun 7, 2017 9:20:38 PM"
}
}#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| vipIp | String | The IP address of the VIP. | 0.6 |
| guestIp | String | The IP address of the VM NIC. | 0.6 |
| vipUuid | String | The VIP UUID. | 0.6 |
| vipPortStart | Integer | The start port of the VIP. | 0.6 |
| vipPortEnd | Integer | The end port of the VIP. | 0.6 |
| privatePortStart | Integer | The start port of the guest IP address. | 0.6 |
| privatePortEnd | Integer | The end port of the guest IP address. | 0.6 |
| vmNicUuid | String | The VM NIC UUID. | 0.6 |
| protocolType | String | The protocol type of the network traffic. | 0.6 |
| state | String | The state of the rule. | 0.6 |
| allowedCidr | String | The source CIDR. The port forwarding rule is only applied to the traffics of the source CIDR. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
UpdatePortForwardingRuleAction action = new UpdatePortForwardingRuleAction();
action.uuid = "b180491f86cd4de4befd11df26ebc4b1";
action.name = "pf2";
action.description = "new rule";
action.sessionId = "1130b06d95ed438386c8199cfae9e55b";
UpdatePortForwardingRuleAction.Result res = action.call();Python
SDK
UpdatePortForwardingRuleAction action = UpdatePortForwardingRuleAction()
action.uuid = "fe896714482549eaac0cd07a6661664a"
action.name = "pf2"
action.description = "new rule"
action.sessionId = "0992d35c275a4def8bcbb013653b65f9"
UpdatePortForwardingRuleAction.Result res = action.call()ChangePortForwardingRuleState
API Request
URLs
PUT zstack/v1/port-forwarding/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"changePortForwardingRuleState": {
"stateEvent": "disable"
},
"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 '{"changePortForwardingRuleState":{"stateEvent":"disable"}}' \
http://localhost:8080/zstack/v1/port-forwarding/d391cd5c4b57369daa48190ec0e193f6/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| stateEvent | String | body (contained in the changePortForwardingRuleState structure) | The state of the port forwarding rule. |
|
0.6 |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"uuid": "59d724e1f8e8417693fbc14d124ce801",
"name": "TestAttachRule",
"description": "test atatch rule",
"vipIp": "192.168.0.187",
"guestIp": "10.0.0.244",
"vipUuid": "f9c5cbc8662d43408dc704003d4f70ad",
"vipPortStart": 33.0,
"vipPortEnd": 33.0,
"privatePortStart": 33.0,
"privatePortEnd": 33.0,
"vmNicUuid": "1b41288698ac45149f352ab6c8de2531",
"protocolType": "TCP",
"state": "Enabled",
"allowedCidr": "0.0.0.0/0",
"createDate": "Jun 7, 2017 9:20:26 PM",
"lastOpDate": "Jun 7, 2017 9:20:26 PM"
}
}#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| vipIp | String | The IP address of the VIP. | 0.6 |
| guestIp | String | The IP address of the VM NIC. | 0.6 |
| vipUuid | String | The VIP UUID. | 0.6 |
| vipPortStart | Integer | The start port of the VIP. | 0.6 |
| vipPortEnd | Integer | The end port of the VIP. | 0.6 |
| privatePortStart | Integer | The start port of the guest IP address. | 0.6 |
| privatePortEnd | Integer | The end port of the guest IP address. | 0.6 |
| vmNicUuid | String | The VM NIC UUID. | 0.6 |
| protocolType | String | The protocol type of the network traffic. | 0.6 |
| state | String | The state of the rule. | 0.6 |
| allowedCidr | String | The source CIDR. The port forwarding rule is only applied to the traffics of the source CIDR. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
ChangePortForwardingRuleStateAction action = new ChangePortForwardingRuleStateAction();
action.uuid = "4a721a0136d94428951072e3314b5187";
action.stateEvent = "disable";
action.sessionId = "ce7e78520ff34fbd8dcc181fba226ee0";
ChangePortForwardingRuleStateAction.Result res = action.call();Python
SDK
ChangePortForwardingRuleStateAction action = ChangePortForwardingRuleStateAction()
action.uuid = "a694cfa2057e4bd087a076e6f970f8cf"
action.stateEvent = "disable"
action.sessionId = "abbfa65e2f3040038dc85a68ffa37c8b"
ChangePortForwardingRuleStateAction.Result res = action.call()GetPortForwardingAttachableVmNics
API Request
URLs
GET zstack/v1/port-forwarding/{ruleUuid}/vm-instances/candidate-nicsHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b6d8f8edb4aa48f388591c2dc83fabe9" \
-X GET http://localhost:8080/zstack/v1/port-forwarding/039e99f4cf9741adabaf972914fa9a30/vm-instances/candidate-nicsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| ruleUuid | String | url | The UUID of the port forwarding rule. | 0.6 | |
| systemTags | List | query | Optional. The system tags. | 0.6 | |
| userTags | List | query | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventories": [
{
"uuid": "2eb90e57e12f400ba8349742840eb9f9",
"vmInstanceUuid": "efa24e175ba34c1196f9818ea6f56e5f",
"l3NetworkUuid": "39e4eeeb2b1e4bb885922cb5c6585277",
"ip": "192.168.0.123",
"mac": "fa:ef:34:5c:6c:00",
"netmask": "255.255.255.0",
"gateway": "192.168.0.1",
"internalName": "eth0",
"deviceId": 0.0
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventories | List | See inventories. | 0.6 |
#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| vmInstanceUuid | String | The VM instance UUID. | 0.6 |
| l3NetworkUuid | String | The L3 network UUID. | 0.6 |
| ip | String | 0.6 | |
| mac | String | 0.6 | |
| netmask | String | 0.6 | |
| gateway | String | 0.6 | |
| metaData | String | 0.6 | |
| deviceId | Integer | 0.6 | |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
GetPortForwardingAttachableVmNicsAction action = new GetPortForwardingAttachableVmNicsAction();
action.ruleUuid = "5980282a68024f039ddfe379b43e49b1";
action.sessionId = "e309fcb7cb0545a3b802a21acfa4b397";
GetPortForwardingAttachableVmNicsAction.Result res = action.call();Python
SDK
GetPortForwardingAttachableVmNicsAction action = GetPortForwardingAttachableVmNicsAction()
action.ruleUuid = "530c24831aaf4ff6bda365c774952576"
action.sessionId = "595b1267d25d4c709c081ecb3ea2f00e"
GetPortForwardingAttachableVmNicsAction.Result res = action.call()AttachPortForwardingRule
API Request
URLs
POST zstack/v1/port-forwarding/{ruleUuid}/vm-instances/nics/{vmNicUuid}Headers
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {},
"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":{}}' http://localhost:8080/zstack/v1/port-forwarding/4c74c079f5b836e1912d20914953d722/vm-instances/nics/05c384cc720e32e4b57e93daea1c5b91Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| ruleUuid | String | url | The UUID of the port forwarding rule. | 0.6 | |
| vmNicUuid | String | url | The VM NIC UUID. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"uuid": "8727976deceb42e898d9efc50863564a",
"name": "TestAttachRule",
"description": "test atatch rule",
"vipIp": "192.168.0.187",
"guestIp": "10.0.0.244",
"vipUuid": "2aa6a4055ce94c319894dfddc330376f",
"vipPortStart": 33,
"vipPortEnd": 33,
"privatePortStart": 33,
"privatePortEnd": 33,
"vmNicUuid": "39f90e4259784eee880e1cbef31c88da",
"protocolType": "TCP",
"state": "Enabled",
"allowedCidr": "0.0.0.0/0",
"createDate": "Jun 7, 2017 9:20:32 PM",
"lastOpDate": "Jun 7, 2017 9:20:32 PM"
}
}#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| vipIp | String | The IP address of the VIP. | 0.6 |
| guestIp | String | The IP address of the VM NIC. | 0.6 |
| vipUuid | String | The VIP UUID. | 0.6 |
| vipPortStart | Integer | The start port of the VIP. | 0.6 |
| vipPortEnd | Integer | The end port of the VIP. | 0.6 |
| privatePortStart | Integer | The start port of the guest IP address. | 0.6 |
| privatePortEnd | Integer | The end port of the guest IP address. | 0.6 |
| vmNicUuid | String | The VM NIC UUID. | 0.6 |
| protocolType | String | The protocol type of the network traffic. | 0.6 |
| state | String | The state of the rule. | 0.6 |
| allowedCidr | String | The source CIDR. The port forwarding rule is only applied to the traffics of the source CIDR. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
AttachPortForwardingRuleAction action = new AttachPortForwardingRuleAction();
action.ruleUuid = "b34b406cf94f432eb0755a9201798d1f";
action.vmNicUuid = "be5e6e16b1f0428a833d3152699766ea";
action.sessionId = "14dc12a577f14f1b9622850e00f06884";
AttachPortForwardingRuleAction.Result res = action.call();Python
SDK
AttachPortForwardingRuleAction action = AttachPortForwardingRuleAction()
action.ruleUuid = "3b83c27e561643778396b003a6294cea"
action.vmNicUuid = "4892663d34c642f8854306188276e890"
action.sessionId = "e1b52fc03d0f479c8da456abd4fd6e6b"
AttachPortForwardingRuleAction.Result res = action.call()DetachPortForwardingRule
API Request
URLs
DELETE/v1/port-forwarding/{uuid}/vm-instances/nicsHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth a6a2c933ccf449c99bd49481e9636751" \
-X DELETE http://localhost:8080/zstack/v1/port-forwarding/484d4bed50ab4c18a670982952ccfe61/vm-instances/nics?Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Value |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"uuid": "dc6ec21666fb42e6be62455f8e5a7307",
"name": "TestAttachRule",
"description": "test atatch rule",
"vipIp": "192.168.0.187",
"guestIp": "10.0.0.244",
"vipUuid": "72dfbe63f95147048a98e514ecbd3ee8",
"vipPortStart": 33.0,
"vipPortEnd": 33.0,
"privatePortStart": 33.0,
"privatePortEnd": 33.0,
"vmNicUuid": "f06654fb4bd6485ebfba84398c98966f",
"protocolType": "TCP",
"state": "Enabled",
"allowedCidr": "0.0.0.0/0",
"createDate": "Jun 7, 2017 9:20:02 PM",
"lastOpDate": "Jun 7, 2017 9:20:02 PM"
}
}#error
| Name | Type | Description | Starting Value |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Value |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| vipIp | String | The IP address of the VIP. | 0.6 |
| guestIp | String | The IP address of the VM NIC. | 0.6 |
| vipUuid | String | The VIP UUID. | 0.6 |
| vipPortStart | Integer | The start port of the VIP. | 0.6 |
| vipPortEnd | Integer | The end port of the VIP. | 0.6 |
| privatePortStart | Integer | The start port of the guest IP address. | 0.6 |
| privatePortEnd | Integer | The end port of the guest IP address. | 0.6 |
| vmNicUuid | String | The VM NIC UUID. | 0.6 |
| protocolType | String | The protocol type of the network traffic. | 0.6 |
| state | String | The state of the rule. | 0.6 |
| allowedCidr | String | The source CIDR. The port forwarding rule is only applied to the traffics of the source CIDR. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
DetachPortForwardingRuleAction action = new DetachPortForwardingRuleAction();
action.uuid = "307d4bf5fed34a859ade0af30c6720f9";
action.sessionId = "8c78997bf11344d79b49a2254ab88bb8";
DetachPortForwardingRuleAction.Result res = action.call();Python
SDK
DetachPortForwardingRuleAction action = DetachPortForwardingRuleAction()
action.uuid = "c284fc4425ea4467b81dad21df147a8e"
action.sessionId = "545a07392cb2409e9888f8737da4ddfc"
DetachPortForwardingRuleAction.Result res = action.call()