調用AttachDisk為一臺ECS實例掛載一塊按量付費數據盤,或者掛載一塊系統盤。實例和磁盤必須在同一個可用區。
接口說明
調用該接口時,您需要注意:
-
磁盤的狀態必須為待掛載(
Available
)。 -
掛載數據盤時:
- 目標 ECS 實例必須處于運行中(
Running
)或者已停止(Stopped
)狀態。 - 如果是您單獨購買的磁盤,計費方式必須是按量付費。
- 從 ECS 實例上卸載的系統盤作為數據盤掛載時,不限制計費方式。
- 彈性臨時盤一旦卸載,只能重新掛載至其原始實例。
- 目標 ECS 實例必須處于運行中(
-
掛載系統盤時:
- 目標 ECS 實例必須是卸載系統盤時的源實例。
- 目標 ECS 實例必須處于已停止(
Stopped
)狀態。 - 您必須設置實例登錄憑證。
- 彈性臨時盤不支持掛載為系統盤。
-
查詢 ECS 實例信息時,如果返回數據中包含
{"OperationLocks": {"LockReason" : "security"}}
,則禁止一切操作。 -
開啟多重掛載特性的云盤,只能掛載到支持 NVMe 協議的實例上。更多信息,請參見ESSD 云盤支持 NVMe以及使用多重掛載功能。
調試
您可以在OpenAPI Explorer中直接運行該接口,免去您計算簽名的困擾。運行成功后,OpenAPI Explorer可以自動生成SDK代碼示例。
授權信息
請求參數
名稱 | 類型 | 必填 | 描述 | 示例值 |
---|---|---|---|---|
InstanceId | string | 是 | 目標 ECS 實例的 ID。 | i-bp1dq5lozx5f4pmd**** |
DiskId | string | 是 | 待掛載的磁盤 ID。磁盤( 說明
支持掛載數據盤和系統盤,相關約束條件請參見上文接口說明章節。
| d-bp1j4l5axzdy6ftk**** |
Device | string | 否 | 磁盤設備名稱。 說明
該參數即將被棄用,為提高兼容性,建議您盡量使用其他參數。
| testDeviceName |
DeleteWithInstance | boolean | 否 | 釋放實例時,該磁盤是否隨實例一起釋放。
默認值:false。 設置該參數時,您需要注意:
| false |
Bootable | boolean | 否 | 是否作為系統盤掛載。 默認值:false。 說明
設置為 Bootable=true 時,目標 ECS 實例必須處于無系統盤狀態。
| false |
Password | string | 否 | 掛載系統盤時,設置實例的用戶名密碼,僅對 administrator 和 root 用戶名生效,其他用戶名不生效。長度為 8 至 30 個字符,必須同時包含大小寫英文字母、數字和特殊符號中的三類字符。特殊符號可以是:
其中,Windows 實例不能以斜線號(/)為密碼首字符。 說明
如果傳入 Password 參數,建議您使用 HTTPS 協議發送請求,避免密碼泄露。
| EcsV587! |
KeyPairName | string | 否 | 掛載系統盤時,為 Linux 系統 ECS 實例綁定的 SSH 密鑰對的名稱。
| KeyPairTestName |
Force | boolean | 否 | 是否強制執行磁盤掛載操作。
默認值為 false。 | false |
返回參數
示例
正常返回示例
JSON
格式
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
錯誤碼
HTTP status code | 錯誤碼 | 錯誤信息 | 描述 |
---|---|---|---|
400 | InvalidDevice.Malformed | The specified device is not valid. | 指定的磁盤設備名不存在。 |
400 | IncorrectInstanceStatus | The current status of the resource does not support this operation. | 該資源目前的狀態不支持此操作。 |
400 | InvalidParameter | The input parameter is mandatory for processing this request is empty. | 參數不能為空。 |
400 | InvalidRegionId.MalFormed | The specified RegionId is not valid. | 指定的地域不存在,請檢查該參數是否正確。 |
400 | InvalidOperation.InstanceTypeNotSupport | The instance type of the specified instance does not support hot attach disk. | 磁盤掛載的實例不支持磁盤熱插拔操作。 |
400 | DiskCategory.OperationNotSupported | The operation is not supported to the specified disk due to its disk category. | 由于磁盤種類限制,指定的磁盤不支持該操作。 |
400 | InvalidOperation.InstanceTypeNotSupport | The specified disk which has kms key should only attach to ioOptimized instance. | 指定的實例無效,只有I/O優化類型的實例支持設置KMS Key。 |
400 | InvalidDisk.DiskNotBootable | The specified disk is not a bootable disk, can not be attached as system disk. | - |
400 | InvalidInstance.NotOriginInstance | The specified disk can not attached to other instance as system disk. | - |
400 | InvalidParameter.AllEmpty | %s | 您沒有輸入任何參數,請輸入必要的參數。 |
400 | InvalidParameterForce.DiskCategoryNotSupported | The specified disk category does not support force attach operation. | 指定的磁盤類型不支持強制掛載操作 |
400 | InvalidParameterForce.PrepaidDiskNotSupported | The prepaid disk does not support force attach operation. | 預付費磁盤不支持強制掛載操作 |
400 | InvalidParameterForce.MultiAttachDiskNotSupported | The multi attach disk does not support force attach operation. | 多重掛載磁盤不支持強制掛載操作 |
400 | InvalidParameterForce.RegionNotSupported | The specified region does not support force attach operation. | 該地域不支持強制掛載操作 |
403 | InstanceDiskLimitExceeded | The amount of the disk on instance in question reach its limits. | 指定實例已經達到可掛載磁盤的最大值。 |
403 | InvalidDevice.InUse | The specified device has been occupied. | 指定的設備已經掛載了磁盤。 |
403 | IncorrectDiskStatus | %s | - |
403 | DiskNotPortable | The specified disk is not a portable disk. | 指定的磁盤不是可卸載的磁盤,Portable 為 false 的磁盤無法卸載。 |
403 | InstanceLockedForSecurity | The instance is locked due to security. | 您的資源被安全鎖定,拒絕操作。 |
403 | ResourcesNotInSameZone | The specified instance and disk are not in the same zone. | 指定的實例和磁盤不在同一可用區。 |
403 | InstanceExpiredOrInArrears | The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode). | 實例已過期或者欠費,請您續費或者結清后再進行操作。 |
403 | DiskInArrears | The specified operation is denied as your disk owing fee. | 指定的磁盤已欠費。 |
403 | DiskError | IncorrectDiskStatus. | 指定的磁盤狀態不合法。 |
403 | DiskId.ValueNotSupported | The specified parameter diskid is not supported. | 指定的塊存儲類型不支持此操作。 |
403 | DiskId.StatusNotSupported | The specified disk status is not supported. | 當前磁盤的狀態不支持此操作。 |
403 | IncorrectInstanceStatus.NotSupportESSD | The operation is not supported in this status, please reboot the instance. | - |
403 | IncorrectDiskStatus | The operation is not supported in this status. | 當前的磁盤不支持此操作,請您確認磁盤處于正常使用狀態,是否欠費。 |
403 | UserNotInTheWhiteList | The user is not in disk white list. | 您不在磁盤白名單中,請加入白名單后重試。 |
403 | InvalidParameter.KMSKeyId.CMKNotEnabled | The CMK needs to be enabled. | 加密云盤設置了 KMSKeyId 后,CMK必須處于啟用狀態。您可以調用密鑰管理服務的 DescribeKey 接口查詢指定CMK的相關信息。 |
403 | InvalidParameter.KMSKeyId.CMKUnauthorized | The CMK needs to be added ECS tag. | CMK 未授權 |
403 | InvalidParameter.KMSKeyId.KMSUnauthorized | ECS service have no right to access your KMS. | ECS 服務無權訪問您的 KMS。 |
403 | DependencyViolation.WindowsInstance | The instance image is windows, cannot use ssh key pair to login. | - |
403 | InvalidInstanceType.NotSupportDiskCategory | The instanceType of the specified instance does not support this disk category. | 指定的實例規格(InstanceType)不支持當前實例的云盤類別。請嘗試更換其它實例規格。關于實例規格支持的云盤類型,請參見實例規格族文檔。 |
403 | InvalidInstanceType.NotSupportPL0 | The instanceType of the specified instance does not support PL0 of cloud_essd. | - |
403 | InvalidInstanceType.NvmeRequired | The instanceType of the specified instance requires nvme protocol. | 指定實例的規格要求使用 NVMe 協議。 |
403 | InvalidInstanceType.NvmeUnsupported | The instanceType of the specified instance does not support nvme protocol. | 指定實例的規格不支持 NVMe 協議。 |
403 | InvalidInstanceType.NotSupportMultiAttachDisk | The instanceType of the specified instance does not support multi attach disk. | 指定的實例規格不支持掛載開啟多重掛載特性的云盤。 |
403 | DiskAttachedNumberExceeded | The attaching times of the specified disk exceeded. | 指定的云盤所掛載的實例數量已達上限。 |
403 | InvalidOperation.CanNotAttachMultiAttachDiskAsSystemDisk | Multi attach disk can not be attached as system disk. | 開啟多重掛載特性的云盤不支持作為系統盤使用。 |
403 | DeleteWithInstance.Conflict | Multi attach disk cannot be set to DeleteWithInstance attribute. | 開啟多重掛載特性的云盤不支持設置 DeleteWithInstance。 |
403 | InvalidParameter.DeleteWithInstance | The DeleteWithInstance for the elastic ephemeral disk must be set to true. | 彈性臨時盤的 DeleteWithInstance 屬性必須設置為 true。 |
403 | InvalidOperation.OtherInstanceUnsupported | The elastic ephemeral disk can only be attached to the instance it was last mounted on, please check the disk's system tag to get the last associated instance. | 彈性臨時盤僅能被掛載到上一次掛載的實例,請檢查磁盤的系統 Tag 來獲取上一次的實例。 |
403 | InvalidInstance.ZoneConflict | The force attach operation is not supported when both the current and target instances are in the same zone. | 強制掛載要求當前實例與目標實例處于不同可用區 |
404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | 指定的實例ID未找到。 |
404 | InvalidDiskId.NotFound | The specified disk does not exist. | 指定的磁盤不存在。請您檢查磁盤 ID 是否正確。 |
404 | InvalidDisk.InUse | The specified disk has been occupied. | 指定的磁盤已占用。 |
404 | InvalidKMSKeyId.NotFound | The KMS key used by the disk does not exist. | 磁盤使用的 KMS 密鑰不存在. |
500 | InternalError | The request processing has failed due to some unknown error. | 內部錯誤,請重試。 |
500 | InternalError | The request processing has failed due to some unknown error, exception or failure. | 內部錯誤,請重試。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
變更時間 | 變更內容概要 | 操作 |
---|---|---|
2024-07-08 | OpenAPI 錯誤碼發生變更 | 查看變更詳情 |
2024-05-08 | OpenAPI 錯誤碼發生變更、OpenAPI 入參發生變更 | 查看變更詳情 |
2023-11-24 | OpenAPI 錯誤碼發生變更 | 查看變更詳情 |