use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmDrives.
@Override
public void buildVmDrives() {
boolean bootDiskFound = false;
List<Disk> disks = vmInfoBuildUtils.getSortedDisks(vm);
Map<Integer, Map<VmDevice, Integer>> vmDeviceVirtioScsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForVirtioScsiDisks(vm);
Map<Integer, Map<VmDevice, Integer>> vmDeviceSpaprVscsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForSpaprScsiDisks(vm);
Map<Guid, StorageQos> qosCache = new HashMap<>();
int pinnedDriveIndex = 0;
for (Disk disk : disks) {
Map<String, Object> struct = new HashMap<>();
// get vm device for this disk from DB
VmDevice vmDevice = vmInfoBuildUtils.getVmDeviceByDiskId(disk.getId(), vm.getId());
DiskVmElement dve = disk.getDiskVmElementForVm(vm.getId());
// skip unmanaged devices (handled separately)
if (!vmDevice.isManaged()) {
continue;
}
if (vmDevice.isPlugged()) {
struct.put(VdsProperties.Type, vmDevice.getType().getValue());
struct.put(VdsProperties.Device, vmDevice.getDevice());
switch(dve.getDiskInterface()) {
case IDE:
struct.put(VdsProperties.INTERFACE, VdsProperties.Ide);
break;
case VirtIO:
struct.put(VdsProperties.INTERFACE, VdsProperties.Virtio);
int pinTo = vmInfoBuildUtils.pinToIoThreads(vm, pinnedDriveIndex++);
if (pinTo > 0) {
vmDevice.getSpecParams().put(VdsProperties.pinToIoThread, pinTo);
}
break;
case VirtIO_SCSI:
// set device type as 'lun' (instead of 'disk') and set the specified SGIO.
if (disk.getDiskStorageType() == DiskStorageType.LUN && disk.isScsiPassthrough()) {
struct.put(VdsProperties.Device, VmDeviceType.LUN.getName());
struct.put(VdsProperties.Sgio, disk.getSgio().toString().toLowerCase());
}
case SPAPR_VSCSI:
struct.put(VdsProperties.INTERFACE, VdsProperties.Scsi);
vmInfoBuildUtils.calculateAddressForScsiDisk(vm, disk, vmDevice, vmDeviceSpaprVscsiUnitMap, vmDeviceVirtioScsiUnitMap);
break;
default:
logUnsupportedInterfaceType();
break;
}
// Insure that boot disk is created first
if (!bootDiskFound && dve.isBoot()) {
bootDiskFound = true;
struct.put(VdsProperties.Index, getBootableDiskIndex(disk));
}
if (FeatureSupported.passDiscardSupported(vm.getCompatibilityVersion())) {
struct.put(VdsProperties.DISCARD, dve.isPassDiscard());
}
vmInfoBuildUtils.addAddress(vmDevice, struct);
switch(disk.getDiskStorageType()) {
case IMAGE:
DiskImage diskImage = (DiskImage) disk;
struct.put(VdsProperties.DiskType, vmInfoBuildUtils.getDiskType(vm, diskImage));
struct.put(VdsProperties.PoolId, diskImage.getStoragePoolId().toString());
struct.put(VdsProperties.DomainId, diskImage.getStorageIds().get(0).toString());
struct.put(VdsProperties.ImageId, diskImage.getId().toString());
struct.put(VdsProperties.VolumeId, diskImage.getImageId().toString());
struct.put(VdsProperties.Format, diskImage.getVolumeFormat().toString().toLowerCase());
struct.put(VdsProperties.PropagateErrors, disk.getPropagateErrors().toString().toLowerCase());
if (!qosCache.containsKey(diskImage.getDiskProfileId())) {
qosCache.put(diskImage.getDiskProfileId(), vmInfoBuildUtils.loadStorageQos(diskImage));
}
vmInfoBuildUtils.handleIoTune(vmDevice, qosCache.get(diskImage.getDiskProfileId()));
break;
case LUN:
LunDisk lunDisk = (LunDisk) disk;
struct.put(VdsProperties.Guid, lunDisk.getLun().getLUNId());
struct.put(VdsProperties.Format, VolumeFormat.RAW.toString().toLowerCase());
struct.put(VdsProperties.PropagateErrors, PropagateErrors.Off.toString().toLowerCase());
break;
case CINDER:
vmInfoBuildUtils.buildCinderDisk((CinderDisk) disk, struct);
break;
}
struct.put(VdsProperties.Shareable, (vmDevice.getSnapshotId() != null) ? VdsProperties.Transient : String.valueOf(disk.isShareable()));
struct.put(VdsProperties.Optional, Boolean.FALSE.toString());
struct.put(VdsProperties.ReadOnly, String.valueOf(vmDevice.getReadOnly()));
struct.put(VdsProperties.SpecParams, vmDevice.getSpecParams());
struct.put(VdsProperties.DeviceId, String.valueOf(vmDevice.getId().getDeviceId()));
devices.add(struct);
bootableDevices.add(vmDevice);
}
}
ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new CreateAdditionalControllers(devices));
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class CinderDisksValidator method validateCinderVolumeTypesExist.
/**
* Validates that the disk's volume type exists in Cinder
* (note that this method validates only against a single disk).
*/
public ValidationResult validateCinderVolumeTypesExist() {
return validate(() -> {
final CinderDisk disk = cinderDisks.iterator().next();
OpenStackVolumeProviderProxy proxy = diskProxyMap.get(disk.getId());
List<CinderVolumeType> volumeTypes = proxy.getVolumeTypes();
boolean volumeTypeExists = volumeTypes.stream().anyMatch(v -> v.getName().equals(disk.getCinderVolumeType()));
if (!volumeTypeExists) {
return new ValidationResult(EngineMessage.CINDER_VOLUME_TYPE_NOT_EXISTS, String.format("$cinderVolumeType %s", disk.getCinderVolumeType()));
}
return ValidationResult.VALID;
});
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class CinderDisksValidator method getRelatedCinderDisksToStorageDomainMap.
private Map<Guid, CinderStorageRelatedDisksAndProxy> getRelatedCinderDisksToStorageDomainMap() {
if (cinderStorageToRelatedDisks == null) {
cinderStorageToRelatedDisks = new HashMap<>();
for (CinderDisk cinderDisk : cinderDisks) {
Guid storageDomainId = cinderDisk.getStorageIds().get(0);
CinderStorageRelatedDisksAndProxy cinderRelatedDisksAndProxy = cinderStorageToRelatedDisks.get(storageDomainId);
if (cinderRelatedDisksAndProxy == null) {
List<CinderDisk> cinderDisks = new ArrayList<>();
cinderDisks.add(cinderDisk);
OpenStackVolumeProviderProxy proxy = diskProxyMap.get(cinderDisk.getId());
CinderStorageRelatedDisksAndProxy newCinderRelatedDisksAndProxy = new CinderStorageRelatedDisksAndProxy(storageDomainId, cinderDisks, proxy);
cinderStorageToRelatedDisks.put(storageDomainId, newCinderRelatedDisksAndProxy);
} else {
cinderRelatedDisksAndProxy.getCinderDisks().add(cinderDisk);
}
}
}
return cinderStorageToRelatedDisks;
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class OvfOvirtReader method buildFileReference.
@Override
protected void buildFileReference() {
XmlNodeList list = selectNodes(_document, "//*/File", _xmlNS);
for (XmlNode node : list) {
// If the disk storage type is Cinder then override the disk image with Cinder object, otherwise use the
// disk image.
DiskImage disk = new DiskImage();
// image.
if (node.attributes.get("ovf:disk_storage_type") != null) {
String diskStorageType = node.attributes.get("ovf:disk_storage_type").getValue();
if (diskStorageType != null) {
if (diskStorageType.equals(DiskStorageType.LUN.name())) {
LunDisk lun = new LunDisk();
lun.setId(OvfParser.getImageGroupIdFromImageFile(node.attributes.get("ovf:href").getValue()));
luns.add(lun);
continue;
} else if (diskStorageType.equals(DiskStorageType.CINDER.name())) {
disk = new CinderDisk();
if (node.attributes.get("ovf:cinder_volume_type") != null) {
String cinderVolumeType = node.attributes.get("ovf:cinder_volume_type").getValue();
disk.setCinderVolumeType(cinderVolumeType);
}
}
}
}
disk.setImageId(new Guid(node.attributes.get("ovf:id").getValue()));
disk.setId(OvfParser.getImageGroupIdFromImageFile(node.attributes.get("ovf:href").getValue()));
disk.setDescription(node.attributes.get("ovf:description").getValue());
_images.add(disk);
}
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class HotPlugDiskVDSCommand method initDriveData.
private Map<String, Object> initDriveData() {
Map<String, Object> drive = new HashMap<>();
Disk disk = getParameters().getDisk();
VmDevice vmDevice = getParameters().getVmDevice();
drive.put(VdsProperties.Type, VmDeviceType.DISK.getName());
drive.put(VdsProperties.Address, getParameters().getAddressMap() != null ? getParameters().getAddressMap() : StringUtils.EMPTY);
drive.put(VdsProperties.INTERFACE, getParameters().getDiskInterface().getName());
if (FeatureSupported.passDiscardSupported(getParameters().getVm().getCompatibilityVersion())) {
drive.put(VdsProperties.DISCARD, getParameters().isPassDiscard());
}
int numOfIoThreads = getParameters().getVm().getNumOfIoThreads();
if (numOfIoThreads != 0 && getParameters().getDiskInterface() == DiskInterface.VirtIO) {
if (vmDevice.getSpecParams() == null) {
vmDevice.setSpecParams(new HashMap<>());
}
List<DiskVmElement> diskVmElements = diskVmElementDao.getAllPluggedToVm(getParameters().getVmId());
int numOfAttachedVirtioInterfaces = 0;
for (DiskVmElement dve : diskVmElements) {
if (dve.getDiskInterface() == DiskInterface.VirtIO) {
numOfAttachedVirtioInterfaces++;
}
}
int pinToIoThread = numOfAttachedVirtioInterfaces % numOfIoThreads + 1;
vmDevice.getSpecParams().put(VdsProperties.pinToIoThread, pinToIoThread);
}
drive.put(VdsProperties.Shareable, (vmDevice.getSnapshotId() != null) ? VdsProperties.Transient : String.valueOf(disk.isShareable()));
drive.put(VdsProperties.Optional, Boolean.FALSE.toString());
drive.put(VdsProperties.ReadOnly, String.valueOf(vmDevice.getReadOnly()));
drive.put(VdsProperties.DeviceId, vmDevice.getId().getDeviceId().toString());
switch(disk.getDiskStorageType()) {
case IMAGE:
DiskImage diskImage = (DiskImage) disk;
drive.put(VdsProperties.DiskType, vmInfoBuildUtils.getDiskType(getParameters().getVm(), diskImage));
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
drive.put(VdsProperties.Format, diskImage.getVolumeFormat().toString().toLowerCase());
drive.put(VdsProperties.DomainId, diskImage.getStorageIds().get(0).toString());
drive.put(VdsProperties.PoolId, diskImage.getStoragePoolId().toString());
drive.put(VdsProperties.VolumeId, diskImage.getImageId().toString());
drive.put(VdsProperties.ImageId, diskImage.getId().toString());
drive.put(VdsProperties.PropagateErrors, disk.getPropagateErrors().toString().toLowerCase());
vmInfoBuildUtils.handleIoTune(vmDevice, vmInfoBuildUtils.loadStorageQos(diskImage));
if (vmDevice.getSpecParams() != null) {
drive.put(VdsProperties.SpecParams, vmDevice.getSpecParams());
}
break;
case LUN:
LunDisk lunDisk = (LunDisk) disk;
// If SCSI pass-through is enabled (VirtIO-SCSI/DirectLUN disk and SGIO is defined),
// set device type as 'lun' (instead of 'disk') and set the specified SGIO
boolean isVirtioScsi = getParameters().getDiskInterface() == DiskInterface.VirtIO_SCSI;
boolean isScsiPassthrough = getParameters().getDisk().isScsiPassthrough();
if (isVirtioScsi) {
if (isScsiPassthrough) {
drive.put(VdsProperties.Device, VmDeviceType.LUN.getName());
drive.put(VdsProperties.Sgio, getParameters().getDisk().getSgio().toString().toLowerCase());
} else {
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
}
} else {
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
}
drive.put(VdsProperties.Guid, lunDisk.getLun().getLUNId());
drive.put(VdsProperties.Format, VolumeFormat.RAW.toString().toLowerCase());
drive.put(VdsProperties.PropagateErrors, PropagateErrors.Off.toString().toLowerCase());
break;
case CINDER:
CinderDisk cinderDisk = (CinderDisk) disk;
vmInfoBuildUtils.buildCinderDisk(cinderDisk, drive);
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
break;
}
return drive;
}
Aggregations