Network ResourcesDistributed Port Group Related Interfaces

CreatePortGroup

POST/zstack/v1/l3-networks/port-group

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "vSwitchUuid": "04d84d13c7e43c53810bd0d470210b4d",
    "vlanMode": "ACCESS",
    "vlan": 100,
    "name": "port-group-1",
    "description": "Test",
    "type": "L3BasicNetwork",
    "category": "Private",
    "ipVersion": 4,
    "system": false,
    "enableIPAM": false
  },
  "systemTags": [],
  "userTags": []
}

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":{"vSwitchUuid":"04d84d13c7e43c53810bd0d470210b4d","vlanMode":"ACCESS","vlan":100,"name":"port-group-1","description":"Test","type":"L3BasicNetwork","category":"Private","ipVersion":4,"system":false,"enableIPAM":false}}' \
http://localhost:8080/zstack/v1/l3-networks/port-group

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

vSwitchUuid

String

body(contained in params structure)

The virtual Switch UUID.

 

4.2.0

vlanMode (Optional)

String

body(contained in params structure)

Optional. The VLAN mode.

  • ACCESS
  • TRUNK
  • PVLAN

4.2.0

vlan

Integer

body(contained in params structure)

The VLAN number.

 

4.2.0

vlanRanges (Optional)

String

body(contained in params structure)

Optional. The VLAN range.

 

4.2.0

name

String

body(contained in params structure)

The resource name.

 

4.2.0

description (Optional)

String

body(contained in params structure)

Optional. The detailed description of the resource.

 

4.2.0

type (Optional)

String

body(contained in params structure)

Optional. The port group type.

 

4.2.0

category (Optional)

String

body(contained in params structure)

Optional. The network type. This parameter must be used with the system tag. When system is true, you can set it to Public, Private, or System.

  • Public
  • Private
  • System

4.2.0

ipVersion (Optional)

Integer

body(contained in params structure)

Optional. The IP version.

  • 4
  • 6

4.2.0

system (Optional)

boolean

body(contained in params structure)

Optional. Whether it is used for system VMs.

 

4.2.0

dnsDomain (Optional)

String

body(contained in params structure)

Optional. The DNS domain.

 

4.2.0

enableIPAM (Optional)

Boolean

body(contained in params structure)

Optional. Whether IP address management is enabled.

 

4.2.0

resourceUuid (Optional)

String

body(contained in params structure)

Optional. The resource UUID.

 

4.2.0

tagUuids (Optional)

List

body(contained in params structure)

Optional. The tag UUID list.

 

4.2.0

systemTags (Optional)

List

body

Optional. The system tags.

 

4.2.0

userTags (Optional)

List

body

Optional. The user tags.

 

4.2.0

API Response

Sample Response

{
  "inventory": {
    "vSwitchUuid": "39217a13614a3435bcc5ed199dc6bc04",
    "vlanMode": "ACCESS",
    "vlanId": 100,
    "uuid": "afc3dd5d3e5e36f7af08797bd6582a7d",
    "name": "port-group-1",
    "description": "Test",
    "type": "portGroup",
    "zoneUuid": "2ee7572e6ce53147866096c79eb4d4f0",
    "l2NetworkUuid": "5f62648626353514892de22f154eeee7",
    "state": "Enabled",
    "system": false,
    "category": "Private",
    "enableIPAM": false
  }
}
NameTypeDescriptionStarting Version
successboolean 4.6.21
errorErrorCodeThe error code. If not null, the operation fails, or vice versa. For more information, see error.0.6
inventoryL3NetworkInventorySee inventory.0.6

error

NameTypeDescriptionStarting Version
codeStringThe error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001.0.6
descriptionStringThe brief description of the error.0.6
detailsStringThe details about the error.0.6
elaborationStringThe reserved field. Default value: null.0.6
opaqueLinkedHashMapThe reserved field. Default value: null.0.6
causeErrorCodeThe root error, which is the associated root cause of the current error. If no root error exists, this parameter is null.0.6

inventory

NameTypeDescriptionStarting Version
uuidStringThe resource UUID.0.6
nameStringThe resource name.0.6
descriptionStringThe detailed description of the resource.0.6
typeStringThe Distributed Port Group type.0.6
zoneUuidStringThe Data Center UUID.0.6
l2NetworkUuidStringThe port group Distributed Switch UUID.0.6
stateStringThe Distributed Port Group availability status.0.6
dnsDomainStringThe DNS domain.0.6
systemBooleanWhether it is used for system VMs.0.6
categoryStringThe network type. This parameter must be used with the system tag. When system is false, you can set it to Public or Private.0.6
ipVersionIntegerThe IP version.3.1.0
enableIPAMBooleanWhether IP address management is enabled.4.10.16
createDateTimestampThe creation date.0.6
lastOpDateTimestampThe last operation date.0.6
dnsListThe DNS server.0.6
ipRangesListSee ipRanges.0.6
networkServicesListSee networkServices.0.6
hostRouteListSee hostRoute.2.3
reservedIpRangesListSee reservedIpRanges.4.10.16

ipRanges

NameTypeDescriptionStarting Version
uuidStringThe resource UUID.0.6
l3NetworkUuidStringThe Distributed Port Group UUID.0.6
nameStringThe resource name.0.6
descriptionStringThe detailed description of the resource.0.6
startIpStringThe start IP address.4.6.21
endIpStringThe end IP address.4.6.21
netmaskStringThe netmask.4.6.21
prefixLenStringThe prefix length.3.1.0
gatewayStringThe gateway.0.6
networkCidrStringThe network CIDR.4.6.21
ipVersionIntegerThe IP version.3.1.0
addressModeStringThe IPv6 address allocation mode.3.1.0
createDateTimestampThe creation date.0.6
lastOpDateTimestampThe last operation date.0.6
ipRangeTypeIpRangeTypeSee ipRangeType.4.6.21

ipRangeType

NameTypeDescriptionStarting Version
NormalIpRangeTypeNormal address range.4.6.21
AddressPoolIpRangeTypeAddress pool range.4.6.21

networkServices

NameTypeDescriptionStarting Version
l3NetworkUuidStringThe Distributed Port Group UUID.0.6
networkServiceProviderUuidStringThe network service provider module UUID.0.6
networkServiceTypeString 0.6

hostRoute

NameTypeDescriptionStarting Version
idLong 2.3
l3NetworkUuidStringThe Distributed Port Group UUID.2.3
prefixString 2.3
nexthopString 2.3
createDateTimestampThe creation date.2.3
lastOpDateTimestampThe last operation date.2.3

reservedIpRanges

NameTypeDescriptionStarting Version
uuidStringThe resource UUID.4.10.16
l3NetworkUuidStringThe Distributed Port Group UUID.4.10.16
nameStringThe resource name.4.10.16
descriptionStringThe detailed description of the resource.4.10.16
startIpStringThe start IP address (included in the reserved IP range).4.10.16
endIpStringThe end IP address (included in the reserved IP range).4.10.16
ipVersionIntegerThe IP version.4.10.16
createDateTimestampThe creation date.4.10.16
lastOpDateTimestampThe last operation date.4.10.16

SDK Sample

Java SDK

CreatePortGroupAction action = new CreatePortGroupAction();
action.vSwitchUuid = "04d84d13c7e43c53810bd0d470210b4d";
action.vlanMode = "ACCESS";
action.vlan = 100;
action.name = "port-group-1";
action.description = "Test";
action.type = "L3BasicNetwork";
action.category = "Private";
action.ipVersion = 4;
action.system = false;
action.enableIPAM = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePortGroupAction.Result res = action.call();

Python SDK

action = CreatePortGroupAction()
action.vSwitchUuid = "04d84d13c7e43c53810bd0d470210b4d"
action.vlanMode = "ACCESS"
action.vlan = 100
action.name = "port-group-1"
action.description = "Test"
action.type = "L3BasicNetwork"
action.category = "Private"
action.ipVersion = 4
action.system = false
action.enableIPAM = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()