Network ResourcesDistributed Switch Related Interfaces

CreateL2VirtualSwitch

POST/zstack/v1/l2-networks/virtual-switch

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "isDistributed": true,
    "name": "dvs-1",
    "description": "Test",
    "zoneUuid": "27f8f98f166a3206b020e83996faabc3",
    "physicalInterface": "bond1",
    "vSwitchType": "LinuxBridge"
  },
  "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":{"isDistributed":true,"name":"dvs-1","description":"Test","zoneUuid":"27f8f98f166a3206b020e83996faabc3","physicalInterface":"bond1","vSwitchType":"LinuxBridge"}}' \
http://localhost:8080/zstack/v1/l2-networks/virtual-switch

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

isDistributed (Optional)

Boolean

body (contained in params structure)

Whether it is distributed.

 

4.1.0

name

String

body (contained in params structure)

The resource name.

 

4.1.0

description (Optional)

String

body (contained in params structure)

The detailed description of the resource.

 

4.1.0

zoneUuid

String

body (contained in params structure)

The Data Center UUID.

 

4.1.0

physicalInterface

String

body (contained in params structure)

Physical NIC.

 

4.1.0

type (Optional)

String

body (contained in params structure)

 

 

4.1.0

vSwitchType (Optional)

String

body (contained in params structure)

Virtual Switch type.

  • LinuxBridge
  • OvsDpdk
  • MacVlan

4.1.0

resourceUuid (Optional)

String

body (contained in params structure)

The resource UUID.

 

4.1.0

tagUuids (Optional)

List

body (contained in params structure)

The tag UUID list.

 

4.1.0

systemTags (Optional)

List

body

The system tags.

 

4.1.0

userTags (Optional)

List

body

The user tags.

 

4.1.0

API Response

Sample Response

{
  "inventory": {
    "isDistributed": true,
    "vSwitchIndex": 1,
    "name": "dvs-1",
    "description": "Test dvs",
    "zoneUuid": "4bc93f4e3a1c35b8948583951e56b5eb",
    "physicalInterface": "bond1",
    "type": "virtualSwitch"
  }
}
NameTypeDescriptionStarting Version
successboolean 4.1.0
inventoryL2VirtualSwitchNetworkInventorySee inventory.4.1.0
errorErrorCodeError code. If not null, the operation fails, or vice versa. The value is null on success. See error.4.1.0

inventory

NameTypeDescriptionStarting Version
isDistributedBooleanWhether it is distributed.4.1.0
uuidStringThe resource UUID.4.1.0
nameStringThe resource name.4.1.0
descriptionStringThe detailed description of the resource.4.1.0
zoneUuidStringThe Data Center UUID.4.1.0
physicalInterfaceStringPhysical NIC.4.1.0
typeString 4.1.0
vSwitchTypeStringVirtual Switch type.4.1.0
virtualNetworkIdIntegerVirtual Network ID.4.1.0
createDateTimestampThe creation date.4.1.0
lastOpDateTimestampThe last operation date.4.1.0
attachedClusterUuidsListThe list of attached Cluster UUIDs.4.1.0
portGroupsListSee portGroups.4.1.0

portGroups

NameTypeDescriptionStarting Version
vSwitchUuidStringVirtual Switch UUID.4.1.0
vlanIdIntegerVLAN ID.4.1.0
vlanRangesStringVLAN range.4.1.0
uuidStringThe resource UUID.4.1.0
nameStringThe resource name.4.1.0
descriptionStringThe detailed description of the resource.4.1.0
zoneUuidStringThe Data Center UUID.4.1.0
physicalInterfaceStringPhysical NIC.4.1.0
typeString 4.1.0
vSwitchTypeStringVirtual Switch type.4.1.0
virtualNetworkIdIntegerVirtual Network ID.4.1.0
createDateTimestampThe creation date.4.1.0
lastOpDateTimestampThe last operation date.4.1.0
attachedClusterUuidsListThe list of attached Cluster UUIDs.4.1.0
vlanModePortGroupVlanModeSee vlanMode.4.1.0

vlanMode

NameTypeDescriptionStarting Version
ACCESSPortGroupVlanMode 4.2.0
TRUNKPortGroupVlanMode 4.2.0
PVLANPortGroupVlanMode 4.2.0

error

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

SDK Sample

Java SDK

CreateL2VirtualSwitchAction action = new CreateL2VirtualSwitchAction();
action.isDistributed = true;
action.name = "dvs-1";
action.description = "Test";
action.zoneUuid = "27f8f98f166a3206b020e83996faabc3";
action.physicalInterface = "bond1";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2VirtualSwitchAction.Result res = action.call();

Python SDK

CreateL2VirtualSwitchAction action = CreateL2VirtualSwitchAction()
action.isDistributed = true
action.name = "dvs-1"
action.description = "Test"
action.zoneUuid = "27f8f98f166a3206b020e83996faabc3"
action.physicalInterface = "bond1"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2VirtualSwitchAction.Result res = action.call()