Creates a reserved CIDR block for a vSwitch.
Usage notes
Take note of the following items:
- You can create at most 10 reserved IPv4 CIDR blocks and 10 reserved IPv6 CIDR blocks for each vSwitch in a virtual private cloud (VPC).
- After you create a reserved CIDR block for a vSwitch, the CIDR block cannot contain the IP address of the subnet gateway of the VPC to which the vSwitch belongs.
- CreateVSwitchCidrReservation 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 ListVSwitchCidrReservations operation to query the status of the task.
- If the vSwitch is in the Assigning state, the reserved CIDR block is being created.
- If the vSwitch is in the Assigned state, the reserved CIDR block is created.
- When you create a reserved IPv4 CIDR block for a vSwitch, the first IP address and the last three IP addresses of the vSwitch are reserved by the system. The four IP addresses will not be allocated.
When you create a reserved IPv6 CIDR block for a vSwitch, the first IP address and the last nine IP addresses of the vSwitch are reserved by the system. The 10 IP addresses will not be allocated.
For example, if you create a reserved IPv4 CIDR block for a vSwitch whose CIDR block is 192.168.1.0/24, the reserved CIDR block cannot contain the following IP addresses: 192.168.1.0, 192.168.1.253, 192.168.1.254, and 192.168.1.255.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateVSwitchCidrReservation | The operation that you want to perform. Set the value to CreateVSwitchCidrReservation. |
VSwitchId | String | Yes | vsw-25navfgbue4g**** | The ID of the vSwitch to which the reserved CIDR block belongs. |
VSwitchCidrReservationName | String | No | ReservationName | The name of the reserved CIDR block. The name must be 2 to 128 characters in length and can contain digits, underscores (_), and hyphens (-). It must start with a letter. |
VSwitchCidrReservationDescription | String | No | ReservationDescription | The description of the reserved CIDR block. This parameter is empty by default. The description must be 2 to 256 characters in length. It must start with a letter and cannot start with |
IpVersion | String | No | IPv4 | The IP version of the reserved CIDR block. Valid values:
|
VSwitchCidrReservationMask | String | No | 28 | The subnet mask of the reserved CIDR block.
Note You must specify one of VSwitchCidrReservationMask and VSwitchCidrReservationCidr. |
VSwitchCidrReservationCidr | String | No | 192.168.1.64/28 | The reserved CIDR block of the vSwitch.
Note You must specify one of VSwitchCidrReservationMask and VSwitchCidrReservationCidr. |
VSwitchCidrReservationType | String | No | prefix | The type of the reserved CIDR block. Set the value to prefix, which specifies that IP addresses are allocated based on the CIDR block. Note When you allocate or the system automatically allocates a CIDR block to an elastic network interface (ENI), the CIDR block must be allocated from the reserved CIDR block. If the reserved CIDR block is exhausted, the system returns an error. |
ClientToken | String | No | 123e4567-e89b-12d3-a456-426655440000 | 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. |
DryRun | Boolean | No | false | Specifies whether to perform a dry run. Valid values:
|
RegionId | String | Yes | cn-hangzhou | The ID of the region where the vSwitch is deployed. You can call the DescribeRegions operation to query the most recent region list. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
VSwitchCidrReservationId | String | vcr-bp1m12saqteraw3rp**** | The ID of the reserved CIDR block. |
RequestId | String | 54B48E3D-DF70-471B-AA93-08E683A1B45 | The request ID. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateVSwitchCidrReservation
&VSwitchId=vsw-25navfgbue4g****
&VSwitchCidrReservationName=ReservationName
&VSwitchCidrReservationDescription=ReservationDescription
&IpVersion=IPv4
&VSwitchCidrReservationMask=28
&VSwitchCidrReservationCidr=192.168.1.64/28
&VSwitchCidrReservationType=prefix
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&DryRun=false
&RegionId=cn-hangzhou
&Common request parameters
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateVSwitchCidrReservationResponse>
<VSwitchCidrReservationId>vcr-bp1m12saqteraw3rp****</VSwitchCidrReservationId>
<RequestId>54B48E3D-DF70-471B-AA93-08E683A1B45</RequestId>
</CreateVSwitchCidrReservationResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"VSwitchCidrReservationId" : "vcr-bp1m12saqteraw3rp****",
"RequestId" : "54B48E3D-DF70-471B-AA93-08E683A1B45"
}
Error codes
HttpCode | Error code | Error message | Description |
---|---|---|---|
400 | IllegalParamFormat | IllegalParamFormat | The parameter format is invalid. |
400 | IllegalParamFormat.VSwitchCidrReservationCidr | The param format of VSwitchCidrReservationCidr is illegal. | The VSwitchCidrReservationCidr value is invalid. |
400 | ResourceNotFound.VSwitch | The specified resource of VSwitch is not found. | The specified vSwitch does not exist. |
400 | UnsupportedFeature.ReservedType | The specified ReservedType is not supported. | The ReservedType value is invalid. |
400 | UnsupportedFeature.VSwitchIpv6 | The ipv6 feature of switch is not supported. | IPv6 is not enabled for the specified vSwitch. |
400 | OperationFailed.VSwitchCidrReservationCidr | The specified VSwitchCidrReservationCidr conflicts with existed cidr reservation or vswitch cidr. | The VSwitchCidrReservationCidr value conflicts with an existing VSwitchCidrReservation value. |
400 | MissingParam.CidrReservationMaskOrCidrReservationCidr | Either VSwitchCidrReservationMask or VSwitchCidrReservationCidr should be specified. | You cannot leave both VSwitchCidrReservationMask and VSwitchCidrReservationCidr empty. Specify one of them and try again. |
400 | IllegalParam.VSwitchCidrReservationMask | The param of VSwitchCidrReservationMask is illegal. | The VSwitchCidrReservationMask value is invalid. Adjust the value and try again. |
400 | UnsupportedRegion | UnsupportedRegion | The current region does not support this feature. |
400 | UnsupportedFeature.VpcAdvancedFeature | UnsupportedFeature.VpcAdvancedFeature | The VPC where the specified vSwitch is deployed does not support advanced VPC features. Specify another vSwitch and try again. |
400 | QuotaExceeded.VSwitchCidrReservationMask | The quota of VSwitchCidrReservationMask is exceeded. | The VSwitchCidrReservationMask value exceeds the upper limit. Adjust the value and try again. |
400 | QuotaExceeded.CidrReservationCount | The quota of VSwitchCidrReservation is exceeded. | The VSwitchCidrReservation value exceeds the upper limit. |
400 | Conflict.CidrReservationMaskAndCidrReservationCidr | The specified VSwitchCidrReservationMask and VSwitchCidrReservationCidr is conflict. | The value of VSwitchCidrReservationMask conflicts with the value of VSwitchCidrReservationCidr. Refer to this topic, specify valid values, and then try again. |
400 | OperationFailed.CidrNotEnoughInVSwitch | No enough cidr to allocate in this vswitch. | The specified vSwitch does not have sufficient CIDR blocks. |
For a list of error codes, see Service error codes.