Creates a vSwitch.
Usage notes
When you call this operation, take note of the following limits:
- You can create at most 150 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.
- vSwitches do not support multicast or broadcast.
- After you create a vSwitch, you cannot modify its CIDR block.
- CreateVSwitch is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the DescribeVSwitchAttributes operation to query the status of the task.
- If the vSwitch is in the Pending state, the vSwitch is being configured.
- If the vSwitch is in the Available state, the vSwitch is available.
- You cannot repeatedly call the CreateVSwitch operation to create a vSwitch in a VPC within the specified period of time.
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
| Action | String | Yes | CreateVSwitch | The operation that you want to perform. Set the value to CreateVSwitch. |
| Tag.N.Key | String | No | FinanceJoshua | The key of tag N to add to the resource. You can specify at most 20 tag keys. The tag key cannot be an empty string. The tag key can be at most 128 characters in length. It cannot start with |
| Tag.N.Value | String | No | FinanceDept | The value of tag N to add to the resource. You can specify at most 20 tag values. The tag value can be an empty string. The tag value can be up to 128 characters in length, and cannot contain |
| ZoneId | String | Yes | cn-hangzhou-b | The zone ID of the vSwitch. You can call the DescribeZones operation to query the most recent zone list. |
| RegionId | String | No | cn-hangzhou | The region ID of the vSwitch. You can call the DescribeRegions operation to query the most recent region list. |
| CidrBlock | String | Yes | 172.16.0.0/24 | The CIDR block of the vSwitch. Take note of the following limits:
|
| Ipv6CidrBlock | Integer | No | 12 | The last eight bits of the IPv6 CIDR block of the vSwitch. Valid values: 0 to 255. |
| VpcId | String | Yes | vpc-257gqcdfvx6n**** | The ID of the VPC where you want to create the vSwitch. |
| VSwitchName | String | No | vSwitch-1 | The name of the vSwitch. The name must be 1 to 128 characters in length and cannot start with |
| Description | String | No | vSwitch | The description of the vSwitch. The description must be 1 to 256 characters in length, and cannot start with |
| 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 specify this parameter, the system automatically uses the request ID as the client token. The request ID may be different for each request. |
| 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 request ID. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateVSwitch
&Tag=[{"Key":"FinanceJoshua","Value":"FinanceDept"}]
&ZoneId=cn-hangzhou-b
&RegionId=cn-hangzhou
&CidrBlock=172.16.0.0/24
&Ipv6CidrBlock=12
&VpcId=vpc-257gqcdfvx6n****
&VSwitchName=vSwitch-1
&Description=vSwitch
&ClientToken=0c593ea1-3bea-11e9-b96b-88e9fe63****
&VpcIpv6CidrBlock=2408:XXXX:0:6a::/56
&Common request parameters
Sample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateVSwitchResponse>
<VSwitchId>vsw-25navfgbue4g****</VSwitchId>
<RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</CreateVSwitchResponse>
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"VSwitchId" : "vsw-25navfgbue4g****",
"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 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 vSwitch description is invalid. |
| 400 | MissingParam.vpcId | The parameter vpcId is mandatory. | vpcId is required. |
| 400 | ResourceNotAvailable | Resource you requested is not available in this region or zone. | You cannot create a vSwitch in the current region or zone. |
| 400 | InvalidParameter | Specified CIDR block is not valid in VPC. | The CIDR block does not fall within the VPC CIDR block. |
| 400 | InvalidCidrBlock.Overlapped | Specified CIDR block overlapped with other subnets. | The vSwitch CIDR block overlaps with another vSwitch CIDR block or with the destination CIDR block of a custom route entry. Try a different CIDR block that is not in use. |
| 400 | InvalidCidrBlock.Overlapped | Specified CIDR block overlapped with other entry. | The vSwitch CIDR block overlaps with another vSwitch CIDR block or with the destination CIDR block of a custom route entry. Try a different CIDR block that is not in use. |
| 400 | QuotaExceeded.VSwitch | Virtual switch quota exceeded. | 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. | 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. | Multiple vSwitches are in the Modifying state in the same VPC. Try again later. |
| 400 | InvalidCirdrBlock.MaskLength | Specified CIDR block is not valid . | The format of the CIDR block is invalid. |
| 400 | IncorrectVpcStatus | Current VPC status does not support this operation. | 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. | You cannot create a vSwitch when the CEN instance is in the current state. |
| 400 | InvalidCidrBlock.Malformed | Specified CIDR block is not valid. | The format of the specified CIDR block is invalid. |
| 400 | MissingParameter | Miss mandatory parameter. | One or more 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 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 system is busy. Try again later. |
| 400 | Forbidden.VpcNotFound | Specified VPC can not found. | The specified VPC does not exist. |
| 400 | RouteConflict.AlreadyExist | Route conflict exists in routing table. | Route conflicts exist in the route table. |
| 400 | IncorrectStatus.cbnStatus | Current CBN status does not support this operation. | The status of the CEN instance is invalid. |
| 400 | UnsupportedFeature.CloudBoxIpv6 | The IPv6 feature is not supported by cloud box. | You cannot create an IPv6 address for a cloud box. |
| 400 | OperationDenied.VpcPeerExist | The operation is not allowed because the VPC peer exists. | The VPC has a VPC peering connection. |
| 400 | OperationDenied.CenAttached | The operation is not allowed because the VPC is attached to CEN. | The operation is not allowed because the VPC is attached to a CEN instance. |
| 400 | OperationDenied.NatgwExist | The operation is not allowed because the NAT gateway exists in VPC. | The operation is not allowed because NAT gateways exist in the VPC. |
| 400 | MissingParam.Ipv6CidrBlock | The parameter Ipv6CidrBlock is mandatory. | Ipv6CidrBlock is required. |
| 400 | OperationDenied.VpcPeerExists | The operation is not allowed because the VpcPeer exists. | The VPC has a VPC peering connection. |
| 404 | InvalidZoneId.NotFound | Specified zone does not exist. | The zone ID is invalid. |
| 404 | InvalidVpcId.NotFound | Specified VPC does not exist. | The VPC is not found. |
For a list of error codes, see Service error codes.