Creates a VSwitch.
Before you begin
Note the following before you call this action:
- You can create a maximum of 24 VSwitches in a VPC.
- The first and the last three IP addresses of the VSwitch are reserved by the system. For example, if the CIDR block of a VSwitch is 192.168.1.0/24, IP addresses 192.168.1.0, 192.168.1.253, 192.168.1.254, and 192.168.1.255 are reserved.
- The number of cloud product instances under the VSwitch cannot exceed the remaining capacity of the VPC (subtract the current number of cloud product instances from 15,000).
- A cloud product instance can only belong to one VSwitch.
- VSwitches do not support broadcasting or multicasting.
- After a VSwitch is created, you cannot modify its CIDR block.
Make the API call
Request parameters
Parameter | Type | Required? | Example value | Description |
---|---|---|---|---|
Action | String | Yes | CreateVSwitch |
The name of this action. Value: CreateVSwitch. |
CidrBlock | String | Yes | 172.16.0.0/24 |
The CIDR block of the VSwitch. The IP address range must meet the following requirements:
|
VpcId | String | Yes | vpc-257gqcdfvx6n**** |
The ID of the VPC to which the VSwitch belongs. |
ZoneId | String | Yes | cn-hangzhou-b |
The ID of the zone to which the target VSwitch belongs. To query the zone ID, call DescribeZones. |
RegionId | String | Yes | cn-hangzhou |
The ID of the region to which the target VSwitch belongs. To query the region ID, call DescribeRegions. |
Ipv6CidrBlock | Integer | No | 12 |
The last 8 bits of the IPv6 CIDR block of the VSwitch. Value range: 0~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
and cannot start with |
VSwitchName | String | No | VSwitch-1 |
The name of the VSwitch. The name must be 2 to 256 characters in length. It must start with a letter and cannot
start with |
ClientToken | String | No | 0c593ea1-3bea-11e9-b96b-88e9fe637760 |
The client token that guarantees the idempotence of the request. The value of this parameter is generated by the client and is unique among different requests. The ClientToken can contain only ASCII characters, and cannot exceed 64 characters in length. For more information, see How to ensure idempotence. |
OwnerAccount | String | No | ****abc@Alibaba.com |
The logon account of the RAM user. |
Response parameters
Parameter | Type | Example value | Description |
---|---|---|---|
VSwitchId | String | vsw-25navfgbue4g**** |
The ID of the created VSwitch. |
RequestId | String | 861E6630-AEC0-4B2D-B214-6CB5E44B7F04 |
The ID of the request. |
Examples
Request example
http(s)://vpc.aliyuncs.com/? Action=CreateVSwitch
&CidrBlock=172.16.0.0/24
&VpcId=vpc-257gqcdfvx6n****
&ZoneId=cn-hangzhou-b
&<CommonParameters>
Response example
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****"
}
Errors
HTTP status code | Error code | Error message | Description |
---|---|---|---|
404 | InvalidZoneId.NotFound | Specified zone does not exist. | The zone ID is invalid. |
404 | InvalidVpcId.NotFound | Specified VPC does not exist. | The specified VPC does not exist. |
400 | InvalidVSwitchName.Malformed | Specified virtual router name is not valid. | The format of the VSwitch name is invalid. |
400 | InvalidVSwitchDiscription.Malformed | Specified virtual switch description is not valid. | The VSwitch description is invalid. |
400 | ResourceNotAvailable | Resource you requested is not available in this region or zone. | VSwitches are not supported in the specified region or zone. |
400 | InvalidParameter | Specified CIDR block is not valid in VPC. | The specified CIDR block does not belong to the CIDR block of the VPC. |
400 | InvalidCidrBlock.Overlapped | Specified CIDR block overlapped with other subnets. | The specified CIDR block overlaps the CIDR block of another VSwitch or the destination CIDR block of an existing custom route entry. Select a CIDR block that is not used. |
400 | InvalidCidrBlock.Overlapped | Specified CIDR block overlapped with other entry. | The specified CIDR block overlaps the CIDR block of another VSwitch or the destination CIDR block of an existing custom route entry. Select a CIDR block that is not used. |
400 | QuotaExceeded.VSwitch | Virtual switch quota exceeded. | The number of VSwitches has reached the quota. |
400 | IncorrectRouteEntryStatus | Some route entry status blocked this operation. | This operation cannot be processed 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. | Multiple VSwitches in the modifying state exist in the same VPC. |
400 | InvalidCirdrBlock.MaskLength | Specified CIDR block is not valid . | The format of the specified CIDR block is invalid. |
400 | IncorrectVpcStatus | Current VPC status does not support this operation. | The current status of the VPC does not support the action. |
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 missing. |
400 | IncorrectVSwitchStatus | VSwitch Creation simultaneously is not supported. | One VSwitch in the Creating state exists in the VPC. VSwitch creation failed. |
400 | Forbidden.VpcNotFound | Specified VPC can not found. | The specified VPC does not exist. |
For a list of error codes, visit the API Error Center.