Creates a default vSwitch.

Usage notes

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

  • The first IP address and last three IP addresses of a 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 the default vSwitch cannot exceed the remaining number of instances supported by the VPC (15,000 minus the number of existing instances).
  • Default vSwitches do not support multicasting or broadcasting.
  • After you create a default vSwitch, you cannot modify its CIDR block.
  • CreateDefaultVSwitch is an asynchronous operation. After you send a request, the system returns a request ID and runs the task in the background. You can call the DescribeVSwitchAttributes operation to query the status of a default vSwitch:
    • If a default vSwitch is in the Pending state, it is being configured.
    • If a default vSwitch is in the Available state, it is available.
  • If a default vSwitch already exists in a region, you cannot call this operation to create a default vSwitch in this region.
  • Before you create a default vSwitch, make sure that a default VPC is created. You can call the CreateDefaultVpc operation to create a default VPC.

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
ZoneId String Yes cn-hangzhou-b

The zone ID of the default vSwitch.

You can call the DescribeZones operation to query the most recent zone list.

RegionId String Yes cn-hangzhou

The region ID of the default 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.

Action String Yes CreateDefaultVSwitch

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

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

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters.

Note If you do not set this parameter, ClientToken is set to the value of RequestId. The value of RequestId for each API request may be different.

Response parameters

Parameter Type Example Description
VSwitchId String vsw-bp1a4b5qhmxftjimq****

The ID of the default vSwitch.

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

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?ZoneId=cn-hangzhou-b
&RegionId=cn-hangzhou
&Ipv6CidrBlock=12
&Action=CreateDefaultVSwitch
&ClientToken=0c593ea1-3bea-11e9-b96b-88e9fe63****
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateDefaultVSwitchResponse>
    <VSwitchId>vsw-bp1a4b5qhmxftjimq****</VSwitchId>
    <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</CreateDefaultVSwitchResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

HttpCode Error code Error message Description
400 InvalidVSwitchName.Malformed Specified virtual switch name is not valid. The error message returned because the format of the specified vSwitch name is invalid. Specify the name in the valid format.
400 InvalidVSwitchDiscription.Malformed Specified virtual switch description is not valid. The error message returned because the 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 quota. 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 this operation cannot be performed when the VPC is in the current state.
400 CreateVSwitch.IncorrectStatus.cbnStatus Current CBN status does not support this operation. The error message returned because you cannot create a vSwitch when the Cloud Enterprise Network (CEN) instance is in the current state.
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 some required parameters are not set. Check whether you have set all 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 TaskConflict The operation is too frequent, TaskConflict. The error message returned because the system is busy. Try again later.
400 Forbidden.VpcNotFound Specified VPC can not found. The error message returned because the specified VPC does not exist.
400 RouteConflict.AlreadyExist Route conflict exists in routing table. The error message returned because route conflicts exist in the route table.
400 IncorrectStatus.cbnStatus Current CBN status does not support this operation. The error message returned because the status of the CEN instance is invalid.
400 UnsupportedFeature.CloudBoxIpv6 The IPv6 feature is not supported by cloud box. The error message returned because you cannot create IPv6 addresses for a cloud box.
400 OperationDenied.VpcPeerExist The operation is not allowed because the VPC peer exists. The error message returned because the VPC has a peering connection and the operation failed.
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 CEN instance and the operation failed.
400 OperationDenied.NatgwExist The operation is not allowed because the NAT gateway exists in VPC. The error message returned because NAT gateways exist in the VPC and the operation failed.
400 OperationFailed.DefaultVSwitchExist A default vSwitch already exists in the zone. The error message returned because the default vSwitch already exists in the current zone.
404 InvalidZoneId.NotFound Specified zone does not exist. The error message returned because the zone ID is invalid.
404 InvalidVpcId.NotFound Specified VPC does not exist. The error message returned because the specified VPC does not exist.

For a list of error codes, see Service error codes.