閱讀752 返回首頁    go 阿裏雲


導入鏡像__鏡像相關接口_API 參考_雲服務器 ECS-阿裏雲

導入自定義鏡像

描述

導入鏡像是把客戶線下的一個鏡像文件導入到ECS環境中生成一個自定義鏡像。可以使用這個鏡像來創建ECS實例和更換係統盤。

  • 請先將鏡像文件上傳到OSS。
  • 導入鏡像的地域必須跟鏡像文件存放的OSS的同一個賬號同一個地域。
  • DiskDeviceMapping.N 暫時隻支持1,也就是隻支持係統盤鏡像,暫時不支持數據盤做鏡像。
  • 鏡像沒有導入完成,是不能進行刪除操作,可以進行取消導入鏡像任務操作。
  • 需要通過RAM給阿裏雲ECS官方服務賬號授權讀取OSS的權限。
  1. 1.創建角色:AliyunECSImageImportDefaultRole(必須是這個名稱,否則導入鏡像會失敗),角色的策略:
  2. {
  3. "Statement": [
  4. {
  5. "Action": "sts:AssumeRole",
  6. "Effect": "Allow",
  7. "Principal": {
  8. "Service": [
  9. "ecs.aliyuncs.com"
  10. ]
  11. }
  12. }
  13. ],
  14. "Version": "1"
  15. }
  16. 2.在該角色下直接加入默認的係統權限策略:AliyunECSImageImportRolePolicy,這個策略是ECS提供導入鏡像的默認策略,你也可以創建自定義策略,權限需要包含:
  17. {
  18. "Version": "1",
  19. "Statement": [
  20. {
  21. "Action": [
  22. "oss:GetObject",
  23. "oss:GetBucketLocation"
  24. ],
  25. "Resource": "*",
  26. "Effect": "Allow"
  27. }
  28. ]
  29. }

請求參數

名稱 類型 是否必須 描述
Action String 係統規定參數,取值:ImportImage
RegionId String 源自定義鏡像的regionId
ImageName String 鏡像名稱,[2,128]英文或中文字符,必須以大小字母或中文開頭,可包含數字,”_”或”-”。不能以https://和https://開頭。
Description String 鏡像的描述信息,長度限製在0~256 個字符,不填則為空,默認為空。不能以https://和https://開頭。
Architecture String 係統架構,取值範圍:i386 | x86_64
默認值:x86_64
OSType String 操作係統平台類型,取值範圍:windows | linux
默認值:linux
Platform String 操作係統發行版,
取值:
  • CentOS
  • Ubuntu
  • SUSE
  • OpenSUSE
  • RedHat
  • Debian
  • CoreOS
  • Aliyun Linux
  • Windows Server 2003
  • Windows Server 2008
  • Windows Server 2012
  • Windows 7
  • Others Linux
  • Customized Linux
默認值:Others Linux
DiskDeviceMapping.n.Format String 鏡像格式,暫時隻支持:RAW 和 VHD
默認值:RAW
DiskDeviceMapping.n.OSSBucket String 鏡像文件所在用戶的OSS Bucket
DiskDeviceMapping.n.OSSObject String 鏡像文件所在用戶的OSS Object的key
DiskDeviceMapping.n.DiskImageSize String 鏡像文件創建係統盤的大小,一定要確保係統盤的空間大於或者等於文件係統的空間。
  • linux類型,取值範圍:20GB-1TB 默認:20GB
  • windows類型,取值範圍:40GB-1TB 默認:40GB

返回參數

名稱 類型 描述
RegionId String 地域 Id
ImageId String 鏡像的ID
ImportTaskId String 導入鏡像任務Id

錯誤碼

錯誤代碼 描述 Http 狀態碼 語義
MissingParameter An input parameter ”RegionId” that is mandatory for processing the request is not supplied. 400 缺少RegionId值
MissingParameter An input parameter ”DiskDeviceMapping.n.OSSBucket” that is mandatory for processing the request is not supplied. 400 缺少OSSBucket的值
MissingParameter An input parameter ”DiskDeviceMapping.n.OSSObject” that is mandatory for processing the request is not supplied. 400 缺少OSSObject值
InvalidImageName.Malformed The specified destination Image name is wrongly formed. 400 指定的鏡像名稱不合法
InvalidDescription.Malformed The specified destination image description is wrongly formed. 400 指定的目標鏡像描述不合法
RegionId.NotFound The specified region is not found. 400 指定的鏡像的regionId不存在
IncorrectImageStatus The specified image is not available. 400 指定的鏡像狀態不正確
InvalidImageName.Duplicated The destination image is exist. 400 鏡像名稱已經重複
QuotaExceed.Image The Image Quota exceeds. 403 已經超過自定義鏡像配額限製,不能再進行導入鏡像
QuotaExceed.Snapshot The Snapshot Quota exceeds. 403 已經超過快照的配額限製,不能再進行導入鏡像。
Forbbiden User not authorized to operate on the specified resource 400 沒有權限進行導入鏡像
InvalidArchitecture.Malformed The specified Architecture is wrongly formed. 400 指定的平台架構不合法
InvalidPlatform.Malformed The specified Platform is wrongly formed. 400 指定的操作係統發行版類型不合法
InvalidOSType.Malformed The specified OSType is wrongly formed. 400 指定的操作係統類型不合法
InvalidFormat.Malformed The specified Image format is wrongly formed. 400 指定的鏡像文件格式不合法
InvalidImageSize The specified “DiskDeviceMapping.n.DiskImageSize” should be not less than system device size. 400 指定的鏡像的磁盤大小不合法
ImageIsImporting The specified Image is importing. 403 指定的鏡像正在複製中
InvalidRegion.NotSupport The specified region does not support image import or export. 403 指定的region暫時不支持導入鏡像

示例

請求示例

  1. https://ecs.aliyuncs.com/?Action=ImportImage
  2. &RegionId=cn-hangzhou
  3. &DiskDeviceMapping.1.OSSBucket=ecsimageos
  4. &DiskDeviceMapping.1.OSSObject=CentOS_5.4_32.raw
  5. &<公共請求參數>

返回示例

XML格式

  1. <ImportImageResponse>
  2. <RequestId>C8B26B44-0189-443E-9816-D951F59623A9</RequestId>
  3. <ImageId>Img-231234567</ImageId>
  4. <ImportTaskId>123-345-2332-22323</ImportTaskId>
  5. </ImportImageResponse>

JSON格式

  1. {
  2. "RequestId": "C8B26B44-0189-443E-9816-D951F59623A9",
  3. "ImageId": "Img-231234567",
  4. "ImportTaskId":"123-345-2332-22323"
  5. }

最後更新:2016-12-12 16:41:28

  上一篇:go 查詢鏡像共享__鏡像相關接口_API 參考_雲服務器 ECS-阿裏雲
  下一篇:go 分配公網 IP 地址__網絡相關接口_API 參考_雲服務器 ECS-阿裏雲