Image Storage Related InterfacesImage Related Interfaces

Add Image

POST/zstack/v1/images

Add an image to the image storage.

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "TinyLinux",
    "url": "http://192.168.1.20/share/images/tinylinux.qcow2",
    "mediaType": "RootVolumeTemplate",
    "architecture": "x86_64",
    "system": false,
    "format": "qcow2",
    "platform": "Linux",
    "backupStorageUuids": [
      "b8fc9c1c027438c28d36af24eca06595"
    ],
    "virtio": false
  },
  "systemTags": [],
  "userTags": []
}

In the example above, userTags field can be omitted. It is listed to indicate that the body can contain this field.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d'{"params":{"name":"TinyLinux","url":"http://192.168.1.20/share/images/tinylinux.qcow2","mediaType":"RootVolumeTemplate","architecture":"x86_64","system":false,"format":"qcow2","platform":"Linux","backupStorageUuids":["b8fc9c1c027438c28d36af24eca06595"],"virtio":false}}' http://localhost:8080/zstack/v1/images

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

name

String

body (contained in params structure)

Image name

 

0.6

description (Optional)

String

body (contained in params structure)

Detailed description of the image

 

0.6

url

String

body (contained in params structure)

URL address of the image to be added

 

0.6

mediaType (Optional)

String

body (contained in params structure)

Type of the image

  • RootVolumeTemplate
  • ISO
  • DataVolumeTemplate

0.6

guestOsType (Optional)

String

body (contained in params structure)

Guest OS type corresponding to the image

 

0.6

system (Optional)

boolean

body (contained in params structure)

Whether it is a system image

 

0.6

format (Optional)

String

body (contained in params structure)

Format of the image, for example: raw

 

4.0.0

platform (Optional)

String

body (contained in params structure)

Platform of the image

  • Linux
  • Windows
  • WindowsVirtio
  • Other
  • Paravirtualization

0.6

backupStorageUuids

List

body (contained in params structure)

List of image storage UUIDs where the image will be added

 

0.6

type (Optional)

String

body (contained in params structure)

Internal use field

 

0.6

resourceUuid (Optional)

String

body (contained in params structure)

Resource UUID. If specified, the image will use this value as its UUID.

 

0.6

architecture (Optional)

String

body (contained in params structure)

 

  • x86_64
  • aarch64
  • mips64el

4.0.0

tagUuids (Optional)

List

body (contained in params structure)

List of tag UUIDs

 

4.0.0

systemTags

List

body

System tags

 

0.6

userTags (Optional)

List

body

User tags

 

0.6

API Response

Response Example

{
  "inventory": {
    "uuid": "1eb26d06364036b7860d2b7dbb462b8c",
    "name": "TinyLinux",
    "url": "http://192.168.1.20/share/images/tinylinux.qcow2",
    "mediaType": "RootVolumeTemplate",
    "platform": "Linux",
    "architecture": "x86_64",
    "format": "qcow2",
    "backupStorageRefs": [
      {
        "id": 0.0,
        "imageUuid": "1eb26d06364036b7860d2b7dbb462b8c",
        "backupStorageUuid": "902dcc8d1015318fb4903df890765c4d",
        "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd",
        "status": "Ready"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. See error0.6
inventoryImageInventorySee inventory0.6

error

NameTypeDescriptionStarting Version
codeStringError code number, globally unique identifier, for example SYS.1000, HOST.10010.6
descriptionStringBrief description of the error0.6
detailsStringDetailed error information0.6
elaborationStringReserved field, defaults to null0.6
opaqueLinkedHashMapReserved field, defaults to null0.6
causeErrorCodeRoot cause. The source error that triggered the current error. This field is null if there is no original error0.6

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
nameStringResource name0.6
descriptionStringDetailed description of the resource0.6
stateStringBoot state of the image4.0.0
statusStringReady state of the image4.0.0
sizeLongImage size4.0.0
actualSizeLongActual image size4.0.0
md5SumStringMD5 value of the image4.0.0
urlStringURL address of the image4.0.0
mediaTypeStringType of the image4.0.0
guestOsTypeStringGuest OS type corresponding to the image4.0.0
typeStringInternal use field4.0.0
platformStringPlatform of the image4.0.0
formatStringFormat of the image, for example: raw4.0.0
systemBooleanIndicates whether it is a system image4.0.0
createDateTimestampCreation time0.6
lastOpDateTimestampLast modification time0.6
backupStorageRefsListSee backupStorageRefs0.6

backupStorageRefs

NameTypeDescriptionStarting Version
imageUuidStringImage UUID0.6
backupStorageUuidStringImage storage UUID0.6
installPathStringInstall path on the image storage4.0.0
exportUrlStringExport URL of the image4.0.0
exportMd5SumStringExport MD5 value of the image4.0.0
statusStringImage ready state4.0.0
createDateTimestampCreation time0.6
lastOpDateTimestampLast modification time0.6

SDK Examples

Java SDK

AddImageAction action = new AddImageAction();
action.name = "TinyLinux";
action.url = "http://192.168.1.20/share/images/tinylinux.qcow2";
action.mediaType = "RootVolumeTemplate";
action.architecture = "x86_64";
action.system = false;
action.format = "qcow2";
action.platform = "Linux";
action.backupStorageUuids = asList("b8fc9c1c027438c28d36af24eca06595");
action.virtio = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddImageAction.Result res = action.call();

Python SDK

AddImageAction action = AddImageAction()
action.name = "TinyLinux"
action.url = "http://192.168.1.20/share/images/tinylinux.qcow2"
action.mediaType = "RootVolumeTemplate"
action.architecture = "x86_64"
action.system = false
action.format = "qcow2"
action.platform = "Linux"
action.backupStorageUuids = [b8fc9c1c027438c28d36af24eca06595]
action.virtio = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddImageAction.Result res = action.call()