Search in sources :

Example 1 with DiskInterface

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);
}
Also used : OsQueryParameters(org.ovirt.engine.core.common.queries.OsQueryParameters) ArrayList(java.util.ArrayList) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface)

Example 2 with DiskInterface

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);
        }
    }
}
Also used : DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface)

Example 3 with DiskInterface

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();
}
Also used : DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface)

Example 4 with DiskInterface

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);
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HashMap(java.util.HashMap) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices)

Example 5 with DiskInterface

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;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VM(org.ovirt.engine.core.common.businessentities.VM) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) Map(java.util.Map) HashMap(java.util.HashMap) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices)

Aggregations

DiskInterface (org.ovirt.engine.core.common.businessentities.storage.DiskInterface)13 HashMap (java.util.HashMap)5 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)5 GetControllerIndices (org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 VM (org.ovirt.engine.core.common.businessentities.VM)4 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)4 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 Collections (java.util.Collections)3 Comparator (java.util.Comparator)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Entry (java.util.Map.Entry)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang.StringUtils)3