All Products
Search
Document Center

Virtual Private Cloud:CreateVSwitchCidrReservation

Last Updated:Dec 20, 2024

Creates a reserved CIDR block for a vSwitch.

Operation description

Description

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
vpc:CreateVSwitchCidrReservationcreate
*VSwitchCidrReservation
acs:vpc:{#regionId}:{#accountId}:vswitchcidrreservation/*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
Tagarray<object>No

Resource tags

objectNo
KeystringNo

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 up to 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

FinanceDept
ValuestringNo

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 start with acs: or aliyun. It cannot contain http:// or https://.

FinanceJoshua
VSwitchIdstringYes

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

vsw-25navfgbue4g****
VSwitchCidrReservationNamestringNo

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.

ReservationName
VSwitchCidrReservationDescriptionstringNo

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://.

ReservationDescription
IpVersionstringNo

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

  • IPv4 (default)
  • IPv6
IPv4
VSwitchCidrReservationMaskstringNo

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.
28
VSwitchCidrReservationCidrstringNo

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.
192.168.1.64/28
VSwitchCidrReservationTypestringNo

The type of reserved CIDR block. Set the value to prefix.

Note When a user or a cloud service 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, an error is returned.
prefix
ClientTokenstringNo

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.
123e4567-e89b-12d3-a456-426655440000
DryRunbooleanNo

Specifies whether to perform only a dry run, without performing the actual request. Valid values:

  • true: performs only 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.
false
RegionIdstringYes

The ID of the region where the vSwitch is deployed.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

Response parameters

ParameterTypeDescriptionExample
object

The ID of the reserved CIDR block.

VSwitchCidrReservationIdstring

The ID of the reserved CIDR block.

vcr-bp1m12saqteraw3rp****
RequestIdstring

The request ID.

54B48E3D-DF70-471B-AA93-08E683A1B45

Examples

Sample success responses

JSONformat

{
  "VSwitchCidrReservationId": "vcr-bp1m12saqteraw3rp****",
  "RequestId": "54B48E3D-DF70-471B-AA93-08E683A1B45"
}

Error codes

HTTP status codeError 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 the VSwitchCidrReservationMask and VSwitchCidrReservationCidr parameters empty. Set a value and try again.
400IllegalParam.VSwitchCidrReservationMaskThe specified VSwitchCidrReservationMask must be greater than the VSwitch mask + 2.VSwitchCidrReservationMask must be at least 3 bits greater than the vSwitch mask.
400UnsupportedRegionUnsupportedRegionThe error message returned because the current region does not support this feature.
400UnsupportedFeature.VpcAdvancedFeatureUnsupportedFeature.VpcAdvancedFeatureThe error message returned because the 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 VSwitchCidrReservationMask value conflicts with the VSwitchCidrReservationCidr value. Adjust the values and try again.
400OperationFailed.CidrNotEnoughInVSwitchNo enough cidr to allocate in this vswitch.The specified vSwitch does not have sufficient CIDR blocks.
400OperationFailed.SystemReservedIpContainedThe specified VSwitchCidrReservationCidr cannot contain system reserved IP addresses.VSwitchCidrReservationCidr cannot contain a reserved IP address.
400OperationFailed.AlreadyUsedIpContainedThe specified VSwitchCidrReservationCidr cannot contain already used IP addresses.The reserved CIDR block cannot contain used IP addresses.
400IncorrectStatus.VSWITCHThe status of the specified VSwitch is invalid.The status of the specified VSwitch is invalid.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-11-27The Error code has changedView Change Details