package org.zstack.header.volume; import org.zstack.header.query.APIQueryReply; import org.zstack.header.rest.RestResponse; import org.zstack.utils.data.SizeUnit; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; @RestResponse(allTo = "inventories") public class APIQueryVolumeReply extends APIQueryReply { private List<VolumeInventory> inventories; public List<VolumeInventory> getInventories() { return inventories; } public void setInventories(List<VolumeInventory> inventories) { this.inventories = inventories; } public static APIQueryVolumeReply __example__() { APIQueryVolumeReply reply = new APIQueryVolumeReply(); String volumeUuid = uuid(); List<VolumeInventory> inventories = new ArrayList<>(); VolumeInventory vol = new VolumeInventory(); vol.setName("test-volume"); vol.setCreateDate(new Timestamp(System.currentTimeMillis())); vol.setLastOpDate(new Timestamp(System.currentTimeMillis())); vol.setType(VolumeType.Root.toString()); vol.setUuid(volumeUuid); vol.setSize(SizeUnit.GIGABYTE.toByte(100)); vol.setActualSize(SizeUnit.GIGABYTE.toByte(20)); vol.setDeviceId(0); vol.setState(VolumeState.Enabled.toString()); vol.setFormat("qcow2"); vol.setDiskOfferingUuid(uuid()); vol.setInstallPath(String.format("/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-%s/%s.qcow2", volumeUuid, volumeUuid)); vol.setStatus(VolumeStatus.Ready.toString()); vol.setPrimaryStorageUuid(uuid()); vol.setVmInstanceUuid(uuid()); vol.setRootImageUuid(uuid()); inventories.add(vol); reply.setInventories(inventories); return reply; } }