use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class BackendStorageDomainDisksResourceTest method getEntity.
@Override
protected org.ovirt.engine.core.common.businessentities.storage.Disk getEntity(int index) {
DiskImage entity = new DiskImage();
entity.setId(GUIDS[index]);
entity.setVolumeFormat(VolumeFormat.RAW);
entity.setImageStatus(ImageStatus.OK);
entity.setVolumeType(VolumeType.Sparse);
entity.setShareable(false);
entity.setPropagateErrors(PropagateErrors.On);
return setUpStatisticalEntityExpectations(entity);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class GetImageInfoVDSCommand method executeIrsBrokerCommand.
@Override
protected void executeIrsBrokerCommand() {
GetVolumeInfoVDSCommandParameters p = new GetVolumeInfoVDSCommandParameters(getCurrentIrsProxy().getCurrentVdsId(), getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupId(), getParameters().getImageId());
DiskImage di = (DiskImage) resourceManager.runVdsCommand(VDSCommandType.GetVolumeInfo, p).getReturnValue();
// if couldn't parse image then succeeded should be false
getVDSReturnValue().setSucceeded(di != null);
if (!getVDSReturnValue().getSucceeded()) {
log.error("Failed to get the volume information, marking as FAILED");
}
setReturnValue(di);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildDiskImagesFromDevices.
/**
* Convert the devices map and make a list of {@linkplain DiskImage}
* Mainly used to import the Hosted Engine Vm disks.
*
* @return A List of Disk Images {@linkplain DiskImage}
*/
public static ArrayList<DiskImage> buildDiskImagesFromDevices(Map<String, Object> vmStruct, Guid vmId) {
ArrayList<DiskImage> diskImages = new ArrayList<>();
Object[] devices = (Object[]) vmStruct.get("devices");
if (devices != null) {
for (Object device : devices) {
Map<String, Object> deviceMap = (Map<String, Object>) device;
if (VdsProperties.Disk.equals(deviceMap.get(VdsProperties.Device))) {
DiskImage image = new DiskImage();
image.setDiskAlias((String) deviceMap.get(VdsProperties.Alias));
Long size = assignLongValue(deviceMap, VdsProperties.disk_apparent_size);
image.setSize(size != null ? size : 0);
Double actualSize = assignDoubleValue(deviceMap, VdsProperties.disk_true_size);
image.setActualSize(actualSize != null ? actualSize : 0);
image.setVolumeFormat(VolumeFormat.valueOf(((String) deviceMap.get(VdsProperties.Format)).toUpperCase()));
image.setShareable(false);
String id = assignStringValue(deviceMap, VdsProperties.DeviceId);
if (id == null) {
id = assignStringValue(deviceMap, VdsProperties.ImageId);
}
image.setId(Guid.createGuidFromString(id));
image.setImageId(Guid.createGuidFromString((String) deviceMap.get(VdsProperties.VolumeId)));
Guid domainId = Guid.createGuidFromString((String) deviceMap.get(VdsProperties.DomainId));
List<Guid> domainIds = Collections.singletonList(domainId);
image.setStorageIds(new ArrayList<>(domainIds));
// TODO not sure how to extract that info
image.setVolumeType(VolumeType.Preallocated);
DiskVmElement dve = new DiskVmElement(image.getId(), vmId);
image.setDiskVmElements(Collections.singletonList(dve));
switch((String) deviceMap.get("iface")) {
case "virtio":
dve.setDiskInterface(DiskInterface.VirtIO);
break;
case "iscsi":
case "scsi":
dve.setDiskInterface(DiskInterface.VirtIO_SCSI);
break;
case "ide":
dve.setDiskInterface(DiskInterface.IDE);
break;
}
diskImages.add(image);
}
}
}
return diskImages;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVmStaticDataFromExternalProvider.
private static VmStatic buildVmStaticDataFromExternalProvider(Map<String, Object> struct) {
if (!struct.containsKey(VdsProperties.vm_guid) || !struct.containsKey(VdsProperties.vm_name) || !struct.containsKey(VdsProperties.mem_size_mb) || !struct.containsKey(VdsProperties.num_of_cpus)) {
return null;
}
VmStatic vmStatic = new VmStatic();
vmStatic.setId(Guid.createGuidFromString((String) struct.get(VdsProperties.vm_guid)));
vmStatic.setName((String) struct.get(VdsProperties.vm_name));
vmStatic.setMemSizeMb(parseIntVdsProperty(struct.get(VdsProperties.mem_size_mb)));
vmStatic.setNumOfSockets(parseIntVdsProperty(struct.get(VdsProperties.num_of_cpus)));
vmStatic.setCustomCpuName((String) struct.get(VdsProperties.cpu_model));
vmStatic.setCustomEmulatedMachine((String) struct.get(VdsProperties.emulatedMachine));
addGraphicsDeviceFromExternalProvider(vmStatic, struct);
if (struct.containsKey(VdsProperties.vm_disks)) {
for (Object disk : (Object[]) struct.get(VdsProperties.vm_disks)) {
Map<String, Object> diskMap = (Map<String, Object>) disk;
if (VdsProperties.Disk.equals(diskMap.get(VdsProperties.type))) {
DiskImage image = buildDiskImageFromExternalProvider(diskMap, vmStatic.getId());
vmStatic.getImages().add(image);
}
}
}
if (struct.containsKey(VdsProperties.NETWORKS)) {
int idx = 0;
for (Object networkMap : (Object[]) struct.get(VdsProperties.NETWORKS)) {
VmNetworkInterface nic = buildNetworkInterfaceFromExternalProvider((Map<String, Object>) networkMap);
nic.setName(String.format("nic%d", ++idx));
nic.setVmName(vmStatic.getName());
nic.setVmId(vmStatic.getId());
vmStatic.getInterfaces().add(nic);
}
}
return vmStatic;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildDiskImageFromExternalProvider.
private static DiskImage buildDiskImageFromExternalProvider(Map<String, Object> map, Guid vmId) {
DiskImage image = new DiskImage();
image.setDiskAlias((String) map.get(VdsProperties.Alias));
image.setSize(Long.parseLong((String) map.get(VdsProperties.DISK_VIRTUAL_SIZE)));
image.setActualSizeInBytes(Long.parseLong((String) map.get(VdsProperties.DISK_ALLOCATION)));
image.setId(Guid.newGuid());
if (map.containsKey(VdsProperties.Format)) {
image.setVolumeFormat(VolumeFormat.valueOf(((String) map.get(VdsProperties.Format)).toUpperCase()));
}
DiskVmElement dve = buildDiskVmElementWithDiskInterfaceFromExternalProvider(map, image, vmId);
image.setDiskVmElements(Collections.singletonList(dve));
return image;
}
Aggregations