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

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

ParameterTypeRequiredExampleDescription
ActionStringYesCreateVSwitchCidrReservation

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

VSwitchIdStringYesvsw-25navfgbue4g****

The ID of the vSwitch to which the reserved CIDR block belongs.

VSwitchCidrReservationNameStringNoReservationName

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.

VSwitchCidrReservationDescriptionStringNoReservationDescription

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 http:// or https://.

IpVersionStringNoIPv4

The IP version of the reserved CIDR block. Valid values:

  • IPv4 (default)
  • IPv6
VSwitchCidrReservationMaskStringNo28

The subnet mask of the reserved CIDR block.

  • When IpVersion is set to IPv4, the subnet mask length of the CIDR block must be greater than the IPv4 subnet mask length of the vSwitch and cannot be greater than 28.
  • When IpVersion is set to IPv6, the subnet mask length of the CIDR block must be greater than the IPv6 subnet mask length of the vSwitch and cannot be greater than 80.
Note You must specify one of VSwitchCidrReservationMask and VSwitchCidrReservationCidr.
VSwitchCidrReservationCidrStringNo192.168.1.64/28

The reserved CIDR block of the vSwitch.

  • When IpVersion is set to IPv4, the reserved CIDR block must be a proper subset of the IPv4 CIDR block of the vSwitch and the subnet mask length of the reserved CIDR block cannot be greater than 28.
  • When IpVersion is set to IPv6, the reserved CIDR block must be a proper subset of the IPv6 CIDR block of the vSwitch and the subnet mask length of the reserved CIDR block cannot be greater than 80.
Note You must specify one of VSwitchCidrReservationMask and VSwitchCidrReservationCidr.
VSwitchCidrReservationTypeStringNoprefix

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.
ClientTokenStringNo123e4567-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.
DryRunBooleanNofalse

Specifies whether to perform a dry run. Valid values:

  • true: performs a dry run, without performing the actual request. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.
  • false (default): performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.
RegionIdStringYescn-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

ParameterTypeExampleDescription
VSwitchCidrReservationIdStringvcr-bp1m12saqteraw3rp****

The ID of the reserved CIDR block.

RequestIdString54B48E3D-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

HttpCodeError codeError messageDescription
400IllegalParamFormatIllegalParamFormatThe parameter format is invalid.
400IllegalParamFormat.VSwitchCidrReservationCidrThe param format of VSwitchCidrReservationCidr is illegal.The VSwitchCidrReservationCidr value is invalid.
400ResourceNotFound.VSwitchThe specified resource of VSwitch is not found.The specified vSwitch does not exist.
400UnsupportedFeature.ReservedTypeThe specified ReservedType is not supported.The ReservedType value is invalid.
400UnsupportedFeature.VSwitchIpv6The ipv6 feature of switch is not supported.IPv6 is not enabled for the specified vSwitch.
400OperationFailed.VSwitchCidrReservationCidrThe specified VSwitchCidrReservationCidr conflicts with existed cidr reservation or vswitch cidr.The VSwitchCidrReservationCidr value conflicts with an existing VSwitchCidrReservation value.
400MissingParam.CidrReservationMaskOrCidrReservationCidrEither VSwitchCidrReservationMask or VSwitchCidrReservationCidr should be specified.You cannot leave both VSwitchCidrReservationMask and VSwitchCidrReservationCidr empty. Specify one of them and try again.
400IllegalParam.VSwitchCidrReservationMaskThe param of VSwitchCidrReservationMask is illegal.The VSwitchCidrReservationMask value is invalid. Adjust the value and try again.
400UnsupportedRegionUnsupportedRegionThe current region does not support this feature.
400UnsupportedFeature.VpcAdvancedFeatureUnsupportedFeature.VpcAdvancedFeatureThe VPC where the specified vSwitch is deployed does not support advanced VPC features. Specify another vSwitch and try again.
400QuotaExceeded.VSwitchCidrReservationMaskThe quota of VSwitchCidrReservationMask is exceeded.The VSwitchCidrReservationMask value exceeds the upper limit. Adjust the value and try again.
400QuotaExceeded.CidrReservationCountThe quota of VSwitchCidrReservation is exceeded.The VSwitchCidrReservation value exceeds the upper limit.
400Conflict.CidrReservationMaskAndCidrReservationCidrThe 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.
400OperationFailed.CidrNotEnoughInVSwitchNo 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.