AddImage

API Request

URLs
POST zstack/v1/images
Headers
Authorization: OAuth the-session-uuid
Body
{   "params": {     "name": "TinyLinux",     "url": "http://192.168.1.20/share/images/tinylinux.qcow2",     "mediaType": "RootVolumeTemplate",     "system": false,     "format": "qcow2",     "platform": "Linux",     "backupStorageUuids": [       "c340364aad7b4130a12e641afe3a968f"     ]   },   "systemTags": [],   "userTags": [] }
Note: In the preceding sample, the userTags field is optional. This field can be included in the body structure.
Curl Sample
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","system":false,"format":"qcow2","platform":"Linux","backupStorageUuids":["b8fc9c1c027438c28d36af24eca06595"]}}' \ http://localhost:8080/zstack/v1/images
Request Parameters
Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The image name. 0.6
description String body (contained in the params structure) Optional. The detailed description of the image. 0.6
url String body (contained in the params structure) The URL of the image to be added. 0.6
mediaType String body (contained in the params structure) Optional. The image type.
  • RootVolumeTemplate
  • ISO
  • DataVolumeTemplate
0.6
guestOsType String body (contained in the params structure) Optional. The operating system type of the guest VM instance that corresponds to the image. 0.6
system boolean body (contained in the params structure) Optional. Whether the image is a system image, for example, vRouter image. 0.6
format String body (contained in the params structure) The image format, for example, raw. 0.6
platform String body (contained in the params structure) Optional. The system platform of the image.
  • Linux
  • Windows
  • WindowsVirtio
  • Other
  • Paravirtualization
0.6
backupStorageUuids List body (contained in the params structure) The UUID list of the backup storages on which the image is to be added. 0.6
type String body (contained in the params structure) Optional. The reserved field for internal use. 0.6
resourceUuid String body (contained in the params structure) Optional. The resource UUID. If specified, the image will use the specified value as UUID. 0.6
systemTags List body The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

Sample Response
{   "inventory": {     "uuid": "8c63603a810a4838a4cd62228e6e13b2",     "name": "TinyLinux",     "url": "http://192.168.1.20/share/images/tinylinux.qcow2",     "mediaType": "RootVolumeTemplate",     "platform": "Linux",     "format": "qcow2",     "backupStorageRefs": [       {         "id": 0.0,         "imageUuid": "8c63603a810a4838a4cd62228e6e13b2",         "backupStorageUuid": "06ccc8e0322a4cd3ae5555d9d88451de",         "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd",         "status": "Ready"       }     ]   } }
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 0.6
inventory ImageInventory See inventory. 0.6
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 0.6
description String The brief description of the error. 0.6
details String The details about the error. 0.6
elaboration String The reserved field. Default value: null. 0.6
opaque LinkedHashMap The reserved field. Default value: null. 0.6
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 0.6
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
state String 0.6
status String 0.6
size Long 0.6
actualSize Long 0.6
md5Sum String 0.6
url String 0.6
mediaType String 0.6
guestOsType String 0.6
type String 0.6
platform String 0.6
format String 0.6
system Boolean 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6
backupStorageRefs List See backupStorageRefs. 0.6
#backupStorageRefs
Name Type Description Starting Version
imageUuid String The image UUID. 0.6
backupStorageUuid String The backup storage UUID. 0.6
installPath String 0.6
exportUrl String 0.6
exportMd5Sum String 0.6
status String 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK
AddImageAction action = new AddImageAction(); action.name = "TinyLinux"; action.url = "http://192.168.1.20/share/images/tinylinux.qcow2"; action.mediaType = "RootVolumeTemplate"; action.system = false; action.format = "qcow2"; action.platform = "Linux"; action.backupStorageUuids = asList("93bb676bfdaf466595da28fa4e4bfadb"); action.sessionId = "363c0781f96944708e5b9d9679299c71"; 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.system = false action.format = "qcow2" action.platform = "Linux" action.backupStorageUuids = [82cf390987674fe09c05c87720815e00] action.sessionId = "180d52fb2f2146c8a522d723b9ae1cf7" AddImageAction.Result res = action.call()

DeleteImage

API Request

URLs
DELETE zstack/v1/images/{uuid}?backupStorageUuids={backupStorageUuids}&deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Body
{   "params": {     "backupStorageUuids": [       "2499cd48fc33450a8737efff67ccb920"     ],     "deleteMode": "Permissive"   },   "systemTags": [],   "userTags": [] }
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth fb8be86094544022ad3e3abd0027b420" \ -X DELETE http://localhost:8080/zstack/v1/images/f92e888c970c4f739d91e59f6dd94b1e?backupStorageUuids=b5a48099da3e3423a8e41bf25b073ce0&deleteMode=Permissive
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The image UUID. 0.6
backupStorageUuids List body Optional. The backup storage UUID list. 0.6
deleteMode String body Optional. The delete mode. Options: Permissive | Enforcing. Default mode: Permissive. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{     "error": {         "code": "SYS.1001",         "description": "A message or a operation timeout",         "details": "Create VM on KVM timeout after 300s"     } }

SDK Sample

Java SDK
DeleteImageAction action = new DeleteImageAction(); action.uuid = "22850dff70934ffdaa839a950cb5a470"; action.backupStorageUuids = asList("32974c8955cd4ed79d13458e41490883"); action.deleteMode = "Permissive"; action.sessionId = "517a458b87ca49cf80bf26e6000bc611"; DeleteImageAction.Result res = action.call();
Python SDK
DeleteImageAction action = DeleteImageAction() action.uuid = "5bbd892e048b48b283e5d2f49a6a4e94" action.backupStorageUuids = [fd127191bf504e3daf5292800c1ea2d8] action.deleteMode = "Permissive" action.sessionId = "cf5cf2689379496aaa4449fd14dc8330" DeleteImageAction.Result res = action.call()

ExpungeImage

API Request

URLs
PUT zstack/v1/images/{imageUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{   "expungeImage": {     "backupStorageUuids": [       "ef3843bdde80427e9c8c0d4f05aa5cde"     ]   },   "systemTags": [],   "userTags": [] }
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"expungeImage":{"backupStorageUuids":["3be136c8d8b8323bb94b8464aae4b0a7"]}}' \ http://localhost:8080/zstack/v1/images/4dcddfadcd113b5f89f181c4f4a080c7/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
Uuid String body (contained in the params structure) The resource UUID. 0.6
imageUuid String url The image UUID. 0.6
backupStorageUuids List body (contained in the params structure) Optional. The backup storage UUID list. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{     "error": {         "code": "SYS.1001",         "description": "A message or a operation timeout",         "details": "Create VM on KVM timeout after 300s"     } }

SDK Sample

Java SDK
ExpungeImageAction action = new ExpungeImageAction(); action.imageUuid = "ddb63556ae714ee78bf468d5067beedd"; action.backupStorageUuids = asList("6f21a1307fb24117a25ed907c00a3e47"); action.sessionId = "b12c879167d3459a844b6ac1f8ff3b74"; ExpungeImageAction.Result res = action.call();
Python SDK
ExpungeImageAction action = ExpungeImageAction() action.imageUuid = "59fcc3775336469facfd93c5c16bdb2d" action.backupStorageUuids = [2dfcf2dfadb14022ac09172a82fb3aac] action.sessionId = "11fe68c420514cb0a8d8e1d1c5755d11" ExpungeImageAction.Result res = action.call()













Back to Top

Download

Already filled the basic info?Click here.

Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

An email with a verification code will be sent to you. Make sure the address you provided is valid and correct.

Download

Not filled the basic info yet? Click here.

Invalid email address or mobile number.

Email Us

contact@zstack.io
ZStack Training and Certification
Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

Email Us

contact@zstack.io
Request Trial
Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

Email Us

contact@zstack.io

The download link is sent to your email address.

If you don't see it, check your spam folder, subscription folder, or AD folder. After receiving the email, click the URL to download the documentation.

The download link is sent to your email address.

If you don't see it, check your spam folder, subscription folder, or AD folder.
Or click on the URL below. (For Internet Explorer, right-click the URL and save it.)

Thank you for using ZStack products and services.

Submit successfully.

We'll connect soon.

Thank you for using ZStack products and services.