use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.
the class AsyncDataProvider method getDiskInterfaceList.
public void getDiskInterfaceList(int osId, Version clusterVersion, AsyncQuery<List<DiskInterface>> asyncQuery) {
asyncQuery.converterCallback = returnValue -> {
ArrayList<String> interfaces = (ArrayList<String>) returnValue;
List<DiskInterface> interfaceTypes = new ArrayList<>();
for (String diskIfs : interfaces) {
try {
interfaceTypes.add(DiskInterface.valueOf(diskIfs));
} catch (IllegalArgumentException e) {
// ignore if we can't find the enum value.
}
}
return interfaceTypes;
};
Frontend.getInstance().runQuery(QueryType.OsRepository, new OsQueryParameters(OsRepositoryVerb.GetDiskInterfaces, osId, clusterVersion), asyncQuery);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.
the class AbstractDiskModel method updatePlugChangeability.
private void updatePlugChangeability() {
if (getVm() == null) {
// No point in updating plug to VM if there's no VM
return;
}
DiskInterface diskInterface = getDiskInterface().getSelectedItem();
boolean isVmRunning = getVm() != null && getVm().getStatus() != VMStatus.Down;
if (DiskInterface.IDE.equals(diskInterface) && isVmRunning) {
getIsPlugged().setChangeProhibitionReason(constants.cannotHotPlugDiskWithIdeInterface());
getIsPlugged().setIsChangeable(false);
getIsPlugged().setEntity(false);
} else {
if (!canDiskBePlugged(getVm())) {
getIsPlugged().setChangeProhibitionReason(constants.cannotPlugDiskIncorrectVmStatus());
getIsPlugged().setIsChangeable(false);
getIsPlugged().setEntity(false);
} else {
getIsPlugged().setIsChangeable(isEditEnabled());
getIsPlugged().setEntity(true);
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.
the class AbstractDiskModel method DiskInterface_SelectedItemChanged.
private void DiskInterface_SelectedItemChanged() {
boolean isLunDisk = getDiskStorageType().getEntity() == DiskStorageType.LUN;
DiskInterface diskInterface = getDiskInterface().getSelectedItem();
getIsSgIoUnfiltered().setIsAvailable(isLunDisk && DiskInterface.VirtIO_SCSI.equals(diskInterface));
getIsScsiPassthrough().setIsAvailable(isLunDisk && DiskInterface.VirtIO_SCSI.equals(diskInterface));
getIsUsingScsiReservation().setIsAvailable(isLunDisk && DiskInterface.VirtIO_SCSI.equals(diskInterface));
getIsReadOnly().setIsAvailable(!DiskInterface.IDE.equals(diskInterface));
updatePassDiscardAvailability();
updateScsiPassthroughChangeability();
updateScsiReservationChangeability();
updateReadOnlyChangeability();
updatePlugChangeability();
updatePassDiscardChangeability();
updateWipeAfterDeleteChangeability();
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmVirtioScsi.
@Override
public void buildVmVirtioScsi() {
List<VmDevice> vmDevices = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI);
Map<DiskInterface, Integer> controllerIndexMap = ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new GetControllerIndices()).returnValue();
int virtioScsiIndex = controllerIndexMap.get(DiskInterface.VirtIO_SCSI);
for (VmDevice vmDevice : vmDevices) {
Map<String, Object> struct = new HashMap<>();
struct.put(VdsProperties.Type, VmDeviceGeneralType.CONTROLLER.getValue());
struct.put(VdsProperties.Device, VdsProperties.Scsi);
struct.put(VdsProperties.Model, VdsProperties.VirtioScsi);
struct.put(VdsProperties.Index, Integer.toString(virtioScsiIndex));
vmInfoBuildUtils.addAddress(vmDevice, struct);
virtioScsiIndex++;
addDevice(struct, vmDevice, null);
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.
the class AbstractDiskVmCommand method getDiskAddressMap.
/**
* Returns disk's address map by specified VmDevice and DiskInterface
* (note: for VirtIO_SCSI/SPAPR_VSCSI interfaces, the method updates the VM device's address accordingly).
* @return disk's address map
*/
public Map<String, String> getDiskAddressMap(VmDevice vmDevice, DiskInterface diskInterface) {
String address = vmDevice.getAddress();
if (diskInterface != DiskInterface.VirtIO_SCSI && diskInterface != DiskInterface.SPAPR_VSCSI) {
if (StringUtils.isNotBlank(address)) {
return StringMapUtils.string2Map(address);
}
} else {
EngineLock vmDiskHotPlugEngineLock = null;
try {
vmDiskHotPlugEngineLock = lockVmDiskHotPlugWithWait();
VM vm = vmDao.get(getParameters().getVmId());
Map<DiskInterface, Integer> controllerIndexMap = ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new GetControllerIndices()).returnValue();
int virtioScsiIndex = controllerIndexMap.get(DiskInterface.VirtIO_SCSI);
int sPaprVscsiIndex = controllerIndexMap.get(DiskInterface.SPAPR_VSCSI);
if (diskInterface == DiskInterface.VirtIO_SCSI) {
Map<Integer, Map<VmDevice, Integer>> vmDeviceUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForVirtioScsiDisks(getVm());
return getAddressMapForScsiDisk(address, vmDeviceUnitMapForController(vmDevice, vmDeviceUnitMap), vmDevice, virtioScsiIndex, false, false);
} else if (diskInterface == DiskInterface.SPAPR_VSCSI) {
Map<Integer, Map<VmDevice, Integer>> vmDeviceUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForSpaprScsiDisks(getVm());
return getAddressMapForScsiDisk(address, vmDeviceUnitMapForController(vmDevice, vmDeviceUnitMap), vmDevice, sPaprVscsiIndex, true, true);
}
} finally {
lockManager.releaseLock(vmDiskHotPlugEngineLock);
}
}
return null;
}
Aggregations