Search in sources :

Example 21 with StorageType

use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.

the class EditDiskModel method validate.

@Override
public boolean validate() {
    StorageType storageType = getStorageDomain().getSelectedItem() == null ? StorageType.UNKNOWN : getStorageDomain().getSelectedItem().getStorageType();
    IntegerValidation sizeValidation = new IntegerValidation();
    if (storageType.isBlockDomain()) {
        Integer maxBlockDiskSize = (Integer) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.MaxBlockDiskSize);
        sizeValidation.setMaximum(maxBlockDiskSize - getSize().getEntity());
    }
    getSizeExtend().validateEntity(new IValidation[] { new NotEmptyValidation(), new NonNegativeLongNumberValidation(), sizeValidation });
    return super.validate() && getSizeExtend().getIsValid();
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) NonNegativeLongNumberValidation(org.ovirt.engine.ui.uicommonweb.validation.NonNegativeLongNumberValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 22 with StorageType

use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.

the class DataCenterStorageListModel method attachInternal.

private void attachInternal(ListModel listModel, StorageDomainType storageType) {
    if (getWindow() != null) {
        return;
    }
    this.setStorageDomainType(storageType);
    setWindow(listModel);
    if (storageType == StorageDomainType.ISO) {
        AsyncDataProvider.getInstance().getISOStorageDomainList(new AsyncQuery<>(list -> {
            Collection<StorageDomain> currItems = getItems() != null ? getItems() : new ArrayList<>();
            List<EntityModel> models = list.stream().filter(a -> currItems.stream().noneMatch(new Linq.IdPredicate<>(a.getId()))).map(EntityModel::new).collect(Collectors.toList());
            postAttachInternal(models);
        }));
    } else {
        AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(list -> {
            List<EntityModel> models = new ArrayList<>();
            boolean addToList;
            Collection<StorageDomain> items1 = getItems() != null ? getItems() : new ArrayList<>();
            for (StorageDomain a : list) {
                addToList = false;
                if (a.getStorageDomainSharedStatus() != StorageDomainSharedStatus.Unattached || items1.stream().anyMatch(new Linq.IdPredicate<>(a.getId()))) {
                    continue;
                }
                if (a.getStorageDomainType() == StorageDomainType.Volume) {
                    addToList = true;
                } else if (a.getStorageDomainType() == getStorageDomainType()) {
                    if (getStorageDomainType() == StorageDomainType.Data) {
                        if (getEntity().getStoragePoolFormatType() == null) {
                            addToList = true;
                        } else if (getEntity().getStoragePoolFormatType().compareTo(a.getStorageStaticData().getStorageFormat()) >= 0) {
                            addToList = true;
                        } else {
                            if (a.getStorageStaticData().getStorageFormat() == StorageFormatType.V1 || a.getStorageStaticData().getStorageFormat() == StorageFormatType.V2) {
                                addToList = true;
                            }
                        }
                    } else if (getStorageDomainType() == StorageDomainType.ImportExport) {
                        addToList = true;
                    }
                }
                if (addToList) {
                    EntityModel tempVar2 = new EntityModel();
                    tempVar2.setEntity(a);
                    models.add(tempVar2);
                }
            }
            postAttachInternal(models);
        }));
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) Collectors(java.util.stream.Collectors) NotifyCollectionChangedEventArgs(org.ovirt.engine.ui.uicompat.NotifyCollectionChangedEventArgs) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) Linq(org.ovirt.engine.ui.uicommonweb.Linq) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List)

Example 23 with StorageType

use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.

the class ImportVmCommand method validateLunDisk.

private List<EngineMessage> validateLunDisk(LunDisk lunDisk) {
    DiskValidator diskValidator = getDiskValidator(lunDisk);
    LUNs lun = lunDisk.getLun();
    StorageType storageType;
    if (lun.getLunConnections() != null && !lun.getLunConnections().isEmpty()) {
        // We set the storage type based on the first connection since connections should be with the same
        // storage type
        storageType = lun.getLunConnections().get(0).getStorageType();
    } else {
        storageType = StorageType.FCP;
    }
    if (storageType == StorageType.ISCSI) {
        ValidationResult connectionsInLunResult = diskValidator.validateConnectionsInLun(storageType);
        if (!connectionsInLunResult.isValid()) {
            return connectionsInLunResult.getMessages();
        }
    }
    ValidationResult lunAlreadyInUseResult = diskValidator.validateLunAlreadyInUse();
    if (!lunAlreadyInUseResult.isValid()) {
        return lunAlreadyInUseResult.getMessages();
    }
    DiskVmElementValidator diskVmElementValidator = new DiskVmElementValidator(lunDisk, lunDisk.getDiskVmElementForVm(getVmId()));
    ValidationResult virtIoScsiResult = isVirtIoScsiValid(getVm(), diskVmElementValidator);
    if (!virtIoScsiResult.isValid()) {
        return virtIoScsiResult.getMessages();
    }
    ValidationResult diskInterfaceResult = diskVmElementValidator.isDiskInterfaceSupported(getVm());
    if (!diskInterfaceResult.isValid()) {
        return diskInterfaceResult.getMessages();
    }
    Guid vdsId = vdsCommandsHelper.getHostForExecution(getStoragePoolId());
    if (vdsId == null || !validateLunExistsAndInitDeviceData(lun, storageType, vdsId)) {
        return Arrays.asList(EngineMessage.ACTION_TYPE_FAILED_DISK_LUN_INVALID);
    }
    ValidationResult usingScsiReservationResult = diskValidator.isUsingScsiReservationValid(getVm(), lunDisk.getDiskVmElementForVm(getVmId()), lunDisk);
    if (!usingScsiReservationResult.isValid()) {
        return usingScsiReservationResult.getMessages();
    }
    return Collections.emptyList();
}
Also used : DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.DiskVmElementValidator) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 24 with StorageType

use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.

the class BackendHostResource method unregisteredStorageDomainsDiscover.

@Override
public Response unregisteredStorageDomainsDiscover(Action action) {
    StorageType storageType = ((action.getIscsi() != null) && (action.getIscsi().getAddress() != null)) ? StorageType.ISCSI : StorageType.FCP;
    // Validate if the Host exists.
    getEntity();
    List<StorageServerConnections> storageServerConnections = new ArrayList<>();
    if (storageType == StorageType.ISCSI) {
        Action.IscsiTargetsList iscsiTargets = action.getIscsiTargets();
        if (iscsiTargets != null) {
            for (String iscsiTarget : iscsiTargets.getIscsiTargets()) {
                StorageServerConnections connectionDetails = getInitializedConnectionIscsiDetails(action);
                connectionDetails.setIqn(iscsiTarget);
                storageServerConnections.add(connectionDetails);
            }
        }
    } else {
    // For FC we don't need to do anything.
    }
    GetUnregisteredBlockStorageDomainsParameters unregisteredBlockStorageDomainsParameters = new GetUnregisteredBlockStorageDomainsParameters(guid, storageType, storageServerConnections);
    try {
        Pair<List<StorageDomain>, List<StorageServerConnections>> pair = getEntity(Pair.class, QueryType.GetUnregisteredBlockStorageDomains, unregisteredBlockStorageDomainsParameters, "GetUnregisteredBlockStorageDomains", true);
        List<StorageDomain> storageDomains = pair.getFirst();
        return actionSuccess(mapToStorageDomains(action, storageDomains));
    } catch (Exception e) {
        return handleError(e, false);
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) GetUnregisteredBlockStorageDomainsParameters(org.ovirt.engine.core.common.queries.GetUnregisteredBlockStorageDomainsParameters) List(java.util.List) ArrayList(java.util.ArrayList)

Example 25 with StorageType

use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.

the class VmDiskPopupWidget method revealStorageView.

private void revealStorageView(final AbstractDiskModel diskModel) {
    if (!diskModel.getIsNew()) {
        return;
    }
    StorageType storageType = diskModel.getStorageType().getSelectedItem();
    // Set view and model by storage type
    if (storageType == StorageType.ISCSI) {
        storageView = iscsiStorageView;
        sanStorageModelBase = iscsiStorageModel;
    } else if (storageType == StorageType.FCP) {
        storageView = fcpStorageView;
        sanStorageModelBase = fcpStorageModel;
    }
    storageModel.setCurrentStorageItem(sanStorageModelBase);
    diskModel.setSanStorageModelBase(sanStorageModelBase);
    // Execute 'UpdateCommand' to call 'GetDeviceList'
    sanStorageModelBase.getUpdateCommand().execute();
    sanStorageModelBase.setWidgetModel(diskModel);
    externalDiskPanel.clear();
    externalDiskPanel.add(storageView);
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)

Aggregations

StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)26 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)8 ArrayList (java.util.ArrayList)7 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)7 List (java.util.List)6 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)6 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)5 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)5 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)5 Guid (org.ovirt.engine.core.compat.Guid)5 ActionType (org.ovirt.engine.core.common.action.ActionType)3 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)2 RemoveStorageDomainParameters (org.ovirt.engine.core.common.action.RemoveStorageDomainParameters)2 StorageDomainSharedStatus (org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StorageDomainStatus (org.ovirt.engine.core.common.businessentities.StorageDomainStatus)2