華為云計算 云知識 創(chuàng)建鏡像元數(shù)據(jù)(OpenStack原生)GlanceCreateImageMetadata
創(chuàng)建鏡像元數(shù)據(jù)(OpenStack原生)GlanceCreateImageMetadata

 

功能介紹

創(chuàng)建 鏡像 元數(shù)據(jù)。

調(diào)用創(chuàng)建鏡像元數(shù)據(jù)接口成功后,只是創(chuàng)建了鏡像的元數(shù)據(jù),鏡像對應的實際鏡像文件并不存在。

調(diào)試

您可以在API Explorer中調(diào)試該接口。

URI

POST /v2/images

請求消息

  • 請求參數(shù)

    參數(shù)

    是否必選

    參數(shù)類型

    描述

    __os_version

    String

    鏡像的操作系統(tǒng)具體版本,取值范圍見相關參數(shù)取值列表。

    如果未指定__os_version,則默認設置為Other Linux (64 bit),不保證該鏡像能成功創(chuàng)建虛擬機以及通過該鏡像創(chuàng)建的虛擬機能夠正常使用。

    visibility

    String

    其他租戶是否可見。

    默認取值為private。創(chuàng)建鏡像元數(shù)據(jù)時,visibility取值只能為private。

    name

    String

    鏡像名稱,如果未指定name的取值,則默認為空,但是使用該鏡像創(chuàng)建虛擬機會失敗。名稱的長度為1~255位。name參數(shù)說明請參考鏡像屬性。默認值為空。

    protected

    Boolean

    鏡像是否被保護,保護后的鏡像不可刪除。默認取值為false。

    container_format

    String

    容器格式。

    默認取值為bare。

    disk_format

    String

    鏡像格式,目前支持zvhd2、vhd、raw、qcow2、iso。非iso格式時默認值是zvhd2。

    tags

    Array of strings

    鏡像標簽列表。長度為1~255位。默認為空。

    說明:

    tag中key的賦值方式為 "key=value"。例如:

    "tagkey=tagvalue"

    min_ram

    Integer

    鏡像運行需要的最小內(nèi)存,單位為MB。參數(shù)取值依據(jù) 云服務器 的規(guī)格限制。默認取值為0。

    云服務器的規(guī)格限制,請參見規(guī)格清單。

    min_disk

    Integer

    鏡像運行需要的最小磁盤,單位為GB 。取值為40~1024GB。

    必須大于鏡像系統(tǒng)盤容量,否則創(chuàng)建云服務器可能失敗。

請求示例

創(chuàng)建鏡像元數(shù)據(jù),其中,鏡像操作系統(tǒng)為“Ubuntu 14.04 server 64bit”,容器格式為“bare”、鏡像格式為“vhd”、鏡像運行需要的最小磁盤為100GB、鏡像運行需要的最小內(nèi)存為1024MB。

POST https://{Endpoint}/v2/images

{
    "__os_version": "Ubuntu 14.04 server 64bit",
    "container_format": "bare",
    "disk_format": "vhd",
    "min_disk": 100,
    "min_ram": 1024,
    "name": "test",
    "tags": [
        "test=testvalue",
        "image=imagevalue"
    ],
    "visibility": "private",
    "protected": false
}

響應消息

  • 響應參數(shù)

    參數(shù)

    參數(shù)類型

    描述

    visibility

    String

    其他租戶是否可見。取值為private。

    name

    String

    鏡像名稱,如果未指定name的取值,則默認為空,但是使用該鏡像創(chuàng)建虛擬機會失敗。名稱的長度為1~128位。name參數(shù)說明請參考鏡像屬性。

    protected

    Boolean

    鏡像是否被保護,保護后的鏡像不可刪除。取值為false。

    container_format

    String

    容器格式。

    取值為bare。

    disk_format

    String

    鏡像格式,目前支持zvhd2、vhd、raw、qcow2、iso。非iso格式時默認值是zvhd2。

    tags

    Array of strings

    鏡像標簽列表。長度為1~255位。

    min_ram

    Integer

    鏡像運行最小內(nèi)存,單位為MB。取值參考ECS規(guī)格限制,一般設置為0。

    云服務器的規(guī)格限制,請參見規(guī)格清單。

    min_disk

    Integer

    鏡像運行需要的最小磁盤容量,單位為GB 。取值為40~1024GB。必須大于鏡像系統(tǒng)盤容量,否則創(chuàng)建云服務器可能失敗。

    status

    String

    鏡像狀態(tài)。取值如下:

    • queued:表示鏡像元數(shù)據(jù)已經(jīng)創(chuàng)建成功,等待上傳鏡像文件。
    • saving:表示鏡像正在上傳文件到后端存儲。
    • deleted:表示鏡像已經(jīng)刪除。
    • killed:表示鏡像上傳錯誤。
    • active:表示鏡像可以正常使用。

    created_at

    String

    創(chuàng)建時間。格式為UTC時間。

    updated_at

    String

    更新時間。格式為UTC時間。

    self

    String

    本鏡像鏈接。

    id

    String

    鏡像ID。用戶調(diào)用創(chuàng)建鏡像接口后,需保存該鏡像的ID,用來調(diào)用上傳鏡像接口完成鏡像上傳。

    file

    String

    上傳下載鏡像文件的地址鏈接。

    schema

    String

    視圖鏈接。

    __image_source_type

    String

    鏡像后端存儲類型,目前支持uds。

    __image_size

    String

    鏡像大小。單位為字節(jié)。

    __isregistered

    String

    鏡像是否注冊。只有已注冊的鏡像才能在Portal界面上查詢到。取值為true。

    __os_version

    String

    鏡像的操作系統(tǒng)具體版本,取值范圍見相關參數(shù)取值列表。

    __os_type

    String

    鏡像的操作系統(tǒng)類型,取值由__os_version確定。支持Windows、Linux和other。

    __platform

    String

    表示鏡像支持的操作系統(tǒng)平臺。取值由__os_version確定。

    __os_bit

    String

    表示操作系統(tǒng)位數(shù)。取值由__os_version確定,取值為32或64。

    __imagetype

    String

    鏡像類型。取值為private,表示私有鏡像。

    virtual_env_type

    String

    平臺類型。

    鏡像使用環(huán)境類型:FusionCompute、Ironic、DataImage、IsoImage。

    • 如果是云服務器鏡像,則取值為FusionCompute。
    • 如果是數(shù)據(jù)盤鏡像,則取值為DataImage。
    • 如果是 裸金屬服務器 鏡像,則取值為Ironic。
    • 如果是ISO鏡像,則取值是IsoImage。

    owner

    String

    鏡像所屬項目ID。

    __root_origin

    String

    表示當前鏡像來源是從外部導入。取值:file。

    checksum

    String

    鏡像文件md5值。

    size

    Long

    目前暫時不使用。

    virtual_size

    Integer

    鏡像虛擬大小。單位為字節(jié)。

    properties

    Properties object

    鏡像屬性的集合,不表示具體的鏡像屬性。

  • 響應樣例
    STATUS CODE 201
    {
        "schema": "/v2/schemas/image",
        "min_disk": 100,
        "created_at": "2016-06-02T07:49:48Z",
        "__image_source_type": "uds",
        "container_format": "bare",
        "__image_size": "0",
        "file": "/v2/images/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba86/file",
        "updated_at": "2016-06-02T07:49:49Z",
        "protected": false,
        "id": "4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba86",
        "__isregistered": "true",
        "min_ram": 1024,
        "owner": "b912fb4a4c464b568ecfca1071b21b10",
        "__os_type": "Linux",
        "__imagetype": "private",
        "visibility": "private",
        "virtual_env_type": "FusionCompute",
        "tags": [
            "test=testvalue",
            "image=imagevalue"
    
        ],
        "__platform": "Ubuntu",
        "__os_bit": "64",
        "__os_version": "Ubuntu 14.04 server 64bit",
        "name": "test",
        "self": "/v2/images/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba86",
        "disk_format": "vhd",
        "status": "queued"
    }

返回值

  • 正常

    201

  • 異常

    返回值

    說明

    400 Bad Request

    請求錯誤。

    401 Unauthorized

    鑒權(quán)失敗。

    403 Forbidden

    沒有操作權(quán)限。

    404 Not Found

    找不到資源。

    500 Internal Server Error

    服務內(nèi)部錯誤。

    503 Service Unavailable

    服務不可用。