CreatePortForwardingRule

API Request

URLs
POST zstack/v1/port-forwarding
Headers
Authorization: OAuth the-session-uuid
Body
{
"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-forwarding
Request 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.
  • TCP
  • UDP
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"
  }
}
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
inventory PortForwardingRuleInventory See inventory. 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
#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()