Search in sources :

Example 51 with StoragePool

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

the class AbstractDiskModel method validate.

public boolean validate() {
    getDescription().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation(), new LengthValidation(BusinessEntitiesDefinitions.DISK_DESCRIPTION_MAX_SIZE) });
    getAlias().validateEntity(getDiskAliasValidations());
    StoragePool dataCenter = getDataCenter().getSelectedItem();
    if (dataCenter != null && dataCenter.getQuotaEnforcementType() == QuotaEnforcementTypeEnum.HARD_ENFORCEMENT) {
        getQuota().validateSelectedItem(new IValidation[] { new NotEmptyQuotaValidation() });
    }
    if (getCinderVolumeType().getIsAvailable()) {
        getCinderVolumeType().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    }
    return getAlias().getIsValid() && getDescription().getIsValid() && getQuota().getIsValid() && getDiskInterface().getIsValid() && getCinderVolumeType().getIsValid();
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation)

Example 52 with StoragePool

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

the class AbstractDiskModel method updateDiskProfiles.

private void updateDiskProfiles(StoragePool selectedItem) {
    StorageDomain storageDomain = getStorageDomain().getSelectedItem();
    if (storageDomain == null) {
        return;
    }
    Frontend.getInstance().runQuery(QueryType.GetDiskProfilesByStorageDomainId, new IdQueryParameters(storageDomain.getId()), new AsyncQuery<QueryReturnValue>(value -> setDiskProfilesList((List<DiskProfile>) value.getReturnValue())));
}
Also used : Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Event(org.ovirt.engine.ui.uicompat.Event) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Predicate(java.util.function.Predicate) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Collectors(java.util.stream.Collectors) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Quota(org.ovirt.engine.core.common.businessentities.Quota) VM(org.ovirt.engine.core.common.businessentities.VM) ScsiGenericIO(org.ovirt.engine.core.common.businessentities.storage.ScsiGenericIO) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 53 with StoragePool

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

the class AbstractDiskModel method updateQuota.

private void updateQuota(StoragePool datacenter) {
    if (datacenter.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED) || !getDiskStorageType().getEntity().isInternal()) {
        getQuota().setIsAvailable(false);
        return;
    }
    getQuota().setIsAvailable(true);
    StorageDomain storageDomain = getStorageDomain().getSelectedItem();
    if (storageDomain == null) {
        return;
    }
    final Guid diskQuota = getDisk() != null ? ((DiskImage) getDisk()).getQuotaId() : null;
    final Guid vmQuota = getVm() != null ? getVm().getQuotaId() : null;
    final Guid defaultQuota = diskQuota != null ? diskQuota : vmQuota;
    AsyncDataProvider.getInstance().getAllRelevantQuotasForStorageSorted(new AsyncQuery<>(quotaList -> {
        if (quotaList != null && !quotaList.isEmpty()) {
            getQuota().setItems(quotaList);
            // If list contains default quota, return
            if (quotaList.get(0).getId().equals(defaultQuota)) {
                return;
            }
        }
        if (diskQuota != null) {
            Quota quota = new Quota();
            quota.setId(diskQuota);
            quota.setQuotaName(getDiskImage().getQuotaName());
            if (quotaList == null) {
                quotaList = new ArrayList<>();
            }
            quotaList.add(quota);
            getQuota().setItems(quotaList);
            getQuota().setSelectedItem(quota);
        }
    }), storageDomain.getId(), defaultQuota);
}
Also used : Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Event(org.ovirt.engine.ui.uicompat.Event) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Predicate(java.util.function.Predicate) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Collectors(java.util.stream.Collectors) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Quota(org.ovirt.engine.core.common.businessentities.Quota) VM(org.ovirt.engine.core.common.businessentities.VM) ScsiGenericIO(org.ovirt.engine.core.common.businessentities.storage.ScsiGenericIO) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 54 with StoragePool

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

the class StorageModel method updateHost.

void updateHost() {
    if (getDataCenter().getItems() == null) {
        return;
    }
    if (getCurrentStorageItem() == null) {
        return;
    }
    StoragePool dataCenter = getDataCenter().getSelectedItem();
    boolean localFsOnly = getCurrentStorageItem() instanceof LocalStorageModel;
    Guid dataCenterId = dataCenter == null ? null : dataCenter.getId();
    AsyncDataProvider.getInstance().getHostsForStorageOperation(new AsyncQuery<>(this::postUpdateHost), dataCenterId, localFsOnly);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Guid(org.ovirt.engine.core.compat.Guid)

Example 55 with StoragePool

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

the class StoragePopupView method initListBoxEditors.

@SuppressWarnings({ "unchecked", "rawtypes" })
void initListBoxEditors() {
    datacenterListEditor = new ListModelListBoxEditor<>(new AbstractRenderer<StoragePool>() {

        @Override
        public String render(StoragePool storage) {
            // $NON-NLS-1$
            String formattedString = "";
            if (storage != null) {
                // Get formatted storage type and format using Enum renders
                // $NON-NLS-1$
                String storageType = storage.isLocal() ? constants.storageTypeLocal() : "";
                String storageFormatType = // $NON-NLS-1$
                storage.getStoragePoolFormatType() == null ? // $NON-NLS-1$
                "" : new EnumRenderer<StorageFormatType>().render(storage.getStoragePoolFormatType());
                // Add storage type and format if available
                if (!storageType.isEmpty() || !storageFormatType.isEmpty()) {
                    // $NON-NLS-1$
                    formattedString = " (";
                    if (storage.isLocal()) {
                        formattedString += storageType;
                    } else {
                        formattedString += storageFormatType;
                    }
                    // $NON-NLS-1$
                    formattedString += ")";
                }
                formattedString = storage.getName() + formattedString;
            }
            return formattedString;
        }
    });
    formatListEditor = new ListModelListBoxEditor<>(new EnumRenderer());
    hostListEditor = new ListModelListBoxEditor<>(new NameRenderer<VDS>());
    domainFunctionListEditor = new ListModelListBoxEditor<>(new EnumRenderer<StorageDomainType>());
    storageTypeListEditor = new ListModelListBoxEditor<>(new EnumRenderer<StorageType>());
    activateDomainEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    wipeAfterDeleteEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    backup = new EntityModelCheckBoxEditor(Align.RIGHT);
    discardAfterDeleteEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
}
Also used : EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)

Aggregations

StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)239 Guid (org.ovirt.engine.core.compat.Guid)83 ArrayList (java.util.ArrayList)78 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)60 Test (org.junit.Test)59 List (java.util.List)46 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)35 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)34 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)31 QueryType (org.ovirt.engine.core.common.queries.QueryType)31 Frontend (org.ovirt.engine.ui.frontend.Frontend)31 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)28 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)28 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)27 Linq (org.ovirt.engine.ui.uicommonweb.Linq)26 Arrays (java.util.Arrays)25 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)25