Creates a vSwitch.

Descriptions

When you call this operation, take note of the following limits:

  • You can create at most 24 vSwitches in a virtual private cloud (VPC).
  • The first IP address and last three IP addresses of each vSwitch CIDR block are reserved. For example, if the CIDR block of a vSwitch is 192.168.1.0/24, the IP addresses 192.168.1.0, 192.168.1.253, 192.168.1.254, and 192.168.1.255 are reserved.
  • The number of instances in a vSwitch cannot exceed the remaining capacity of the VPC. The remaining capacity is the difference between 15,000 and the current number of instances.
  • Each instance can belong to only one vSwitch.
  • Broadcasting or multicasting are not supported by vSwitches.
  • After you create a vSwitch, you cannot modify its CIDR block.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateVSwitch

The operation that you want to perform. Set the value to CreateVSwitch.

CidrBlock String Yes 172.16.0.0/24

The CIDR block of the vSwitch. The vSwitch CIDR block must meet the following requirements:

  • The subnet mask of the CIDR block must be 16 to 29 bits in length.
  • The CIDR block of the vSwitch must fall within the range of the CIDR block of the VPC to which the vSwitch belongs.
  • The CIDR block of a vSwitch cannot be the same as the destination CIDR block in a route entry of the VPC. However, it can be a subset of the destination CIDR block.
VpcId String Yes vpc-257gqcdfvx6n****

The ID of the VPC where you want to create the vSwitch.

ZoneId String Yes cn-hangzhou-b

The ID of the zone where you want to create the vSwitch. You can call the DescribeZones operation to query the most zone list.

RegionId String Yes cn-hangzhou

The ID of the region where you want to create the vSwitch. You can call the DescribeRegions operation to query the most recent region list.

Ipv6CidrBlock Integer No 12

The last eight bits of the IPv6 CIDR block of the vSwitch. Valid values: 0 to 255.

Description String No This is my vswitch.

The description of the vSwitch.

The description must be 2 to 256 characters in length. It must start with a letter but cannot start with http:// or https://.

VSwitchName String No VSwitch-1

Enter a name for the vSwitch.

The name must be 2 to 128 characters in length and must start with a letter. The description cannot start with http:// or https://.

ClientToken String No 0c593ea1-3bea-11e9-b96b-88e9fe637760

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that it is unique among different requests. The ClientToken value can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How can I ensure idempotence?

VpcIpv6CidrBlock String No 2408:XXXX:0:6a::/56

The IPv6 CIDR block of the VPC.

Response parameters

Parameter Type Example Description
VSwitchId String vsw-25navfgbue4g****

The ID of the vSwitch.

RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

Examples

Sample requests

http(s)://vpc.aliyuncs.com/?Action=CreateVSwitch
&CidrBlock=172.16.0.0/24
&VpcId=vpc-257gqcdfvx6n****
&ZoneId=cn-hangzhou-b
&<Common request parameters>

Sample success responses

XML format

<CreateVSwitchResponse>
      <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
      <VSwitchId>vsw-25naue4cdvf****</VSwitchId>
</CreateVSwitchResponse>

JSON format

{
    "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
    "VSwitchId": "vsw-25naue4cdvf****"
}

Error codes

HttpCode Error code Error message Description
404 InvalidZoneId.NotFound Specified zone does not exist. The error message returned because the ID of the zone is invalid.
404 InvalidVpcId.NotFound Specified VPC does not exist. The error message returned because the specified VPC does not exist.
400 InvalidVSwitchName.Malformed Specified virtual switch name is not valid. The error message returned because the format of the specified vSwitch name is invalid. Check whether the specified name is valid.
400 InvalidVSwitchDiscription.Malformed Specified virtual switch description is not valid. The error message returned because the specified description of the vSwitch is invalid.
400 ResourceNotAvailable Resource you requested is not available in this region or zone. The error message returned because you cannot create a vSwitch in the current region or zone.
400 InvalidParameter Specified CIDR block is not valid in VPC. The error message returned because the vSwitch CIDR block does not fall within the VPC CIDR block.
400 InvalidCidrBlock.Overlapped Specified CIDR block overlapped with other subnets. The error message returned because the vSwitch CIDR block overlaps with another vSwitch CIDR block or the destination CIDR block of a custom route entry. Make sure that the vSwitch CIDR block does not overlap with another vSwitch CIDR block or the destination CIDR block of a route entry.
400 InvalidCidrBlock.Overlapped Specified CIDR block overlapped with other entry. The error message returned because the vSwitch CIDR block overlaps with another vSwitch CIDR block or the destination CIDR block of a custom route entry. Make sure that the vSwitch CIDR block does not overlap with another vSwitch CIDR block or the destination CIDR block of a route entry.
400 QuotaExceeded.VSwitch Virtual switch quota exceeded. The error message returned because the number of vSwitches has reached the upper limit. Reduce the number of vSwitches and try again later.
400 IncorrectRouteEntryStatus Some route entry status blocked this operation. The error message returned because one or more route entries in the current route table are in the Pending or Modifying state.
400 IncorrectVSwitchStatus Some virtual switch is modifying within the same VPC. The error message returned because multiple vSwitches are in the Modifying state in the same VPC. Try again later.
400 InvalidCirdrBlock.MaskLength Specified CIDR block is not valid . The error message returned because the format of the CIDR block is invalid.
400 IncorrectVpcStatus Current VPC status does not support this operation. The error message returned because the state of the VPC does not support this operation.
400 InvalidCidrBlock.Malformed Specified CIDR block is not valid. The error message returned because the format of the specified CIDR block is invalid.
400 MissingParameter Miss mandatory parameter. The error message returned because required parameters are not set. Check whether you have set all the required parameters before you call this operation.
400 IncorrectVSwitchStatus VSwitch Creation simultaneously is not supported. The error message returned because the system failed to create the vSwitch and one or more vSwitches that belong to the VPC are in the Creating state.
400 Forbidden.VpcNotFound Specified VPC can not found. The error message returned because the specified VPC does not exist. Check whether the specified VPC ID is valid.
400 UnsupportedFeature.CloudBoxIpv6 The IPv6 feature is not supported by cloud box. The error message returned because cloud boxes do not support creating IPv6 addresses.
400 OperationDenied.VpcPeerExist The operation is not allowed because the VPC peer exists. The error message returned because the VPC has a peering connection.
400 OperationDenied.CenAttached The operation is not allowed because the VPC is attached to CEN. The error message returned because the VPC is attached to a Cloud Enterprise Network (CEN) instance.
400 OperationDenied.NatgwExist The operation is not allowed because the NAT gateway exists in VPC. The error message returned because the VPC has a NAT gateway.

For a list of error codes, visit the API Error Center.