ResetInstance

1. API Description

This API is used to reinstall the operating system on an elastic compute instance.

Prerequisites

Note

  • If the imageId parameter is specified, the instance will be reinstalled using the specified image; otherwise, it will be reinstalled with its current image.

  • The boot disk size of the instance must be greater than or equal to the size of the reinstalled image. Otherwise, the operation will fail.

  • The boot disk will be formatted and reset. Make sure there are no important files in the boot disk.

  • Specify either a password or a key pair, not both.

  • Only operations on instances that are in powered-off state are supported.

  • After reinstallation, the instance enters the DEPLOYING state. If the latest status of the instance changes to RUNNING, it means that the operation is successful. If it changes to REINSTALL_FAILED, it means that the operation has failed. Please contact the administrator. You can call DescribeInstancesStatus to query the instance status.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

instanceId

Yes

String

Instance ID(s).

To obtain the instance ID, you can call DescribeInstances and look for instanceId in the response.

imageId

No

String

Specify a valid image ID. To obtain valid image ID, you can call DescribeImages and look for imageId in the response. You can also reinstall it according to the original image.

password

No

String

Instance password.

The parameter must be 8-16 characters, including:

  • lowercase letters: [a-z]

  • uppercase letters: [A-Z]

  • digits: 0-9

  • special characters: ~!@$^*-_=+

keyId

No

String

Key pair ID. Specify either a password or a key pair, not both.

timezone

No

String

If not specified, the instance will be reinstalled using its original time zone.

enableAgent

No

String

Whether QGA is enabled or not.

3. Output Parameters

Parameter Name
Type
Description

requestId

String

The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Code Example

Reinstall the specified instance by providing an image and password.

POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: ResetInstance
<Common Request Params>

Request:
{
    "instanceId": "instanceId",
    "imageId": "image-xxxxxxxxx",
    "password": "Example+123"
}

Response:
{
  "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453",
  "response": {
    "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453"
  }
}

5. Developer Resources

Zenlayer Cloud API 2.0 integrates SDKs to make it easier for you to call APIs. More programming languages will be supported.

6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

HTTP Status Code
Error Code
Description

404

INVALID_INSTANCE_NOT_FOUND

Instance does not exist.

404

INVALID_IMAGE_NOT_FOUND

The specified image does not exist.

400

INVALID_PASSWORD_MALFORMED

Invalid password. The specified password does not meet the password complexity limit. For example, the password length does not meet the limit.

400

UNSUPPORTED_OPERATION_INSTANCE_STATUS

Operations on the instances in the current state are not supported.

400

INVALID_IMAGE_SIZE_EXCEED

The selected boot disk size is less than the size required for the image.

400

INVALID_IMAGE_TYPE_NOT_SAME

The selected image type is different from the original image.

400

INVALID_IMAGE_AGENT_NOT_SUPPORT

QGA is not supported on the selected image.

404

INVALID_PASSWORD_KEY_PAIR_NOT_FOUND

No password or keyId specified.

403

INVALID_REGION_KEY_PAIR_NOT_SUPPORT

keyPair is not supported in the selected region.

Last updated