• CLI

sdk
  1. Help Center
  2. CLI
  3. Developer Guide
  4. SDK
  5. JAVA
  6. IMS Java SDK Demo

IMS Java SDK Demo

Public Images

A public image is a widely used and standard image. Each public image contains an OS and multiple pre-installed public applications and is visible to all users. You can configure the OS and software in the public image as needed.

Obtain the image ID from the console as follows:

Optionally, you can use the following code to list all the images:

os.imagesV2().list()

Using OpenStack4j to Create a Private Image

IMS supports the native OpenStack Glance v2 image API, with which you can create a private image with your image file. The supported image types are VHD, ZVHD, QCOW2, and VMDK.

The following uses the image in the QCOW2 format as an example. Image uploading takes a long time, which depends on the image size and network quality.

//Create an Image. 
Image createdImage = os.imagesV2().create(Builders.imageV2() 
.osDistro("ubuntu") 
.name("image-name") 
.containerFormat(ContainerFormat.BARE) 
.visibility(ImageVisibility.PRIVATE) 
.diskFormat(DiskFormat.QCOW2) 
.architecture("x86_64") 
.build()); 
//Upload the image's image file. 
Payload<File> payload = Payloads.create(new File("root.img")); 
ActionResponse uploadResult = os.imagesV2().upload(createdImage.getId(), payload, os.imagesV2().get(createdImage.getId())); 
System.out.println("Uploaded done");
Table 1 Parameter description

Parameter

Description

Example Value

diskFormat

Specifies the format of the disk.

QCOW2

IMS supports VHD, ZVHD, QCOW2, and VMDK images.