Search in sources :

Example 71 with StoragePool

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

the class UnitVmModel method setupDataCenterWithClusters.

protected void setupDataCenterWithClusters(UnitVmModel model, List<StoragePool> dataCenters, List<Cluster> clusters, Guid selectedCluster) {
    Map<Guid, List<Cluster>> dataCenterToCluster = new HashMap<>();
    for (Cluster cluster : clusters) {
        if (cluster.getStoragePoolId() == null) {
            continue;
        }
        if (!dataCenterToCluster.containsKey(cluster.getStoragePoolId())) {
            dataCenterToCluster.put(cluster.getStoragePoolId(), new ArrayList<Cluster>());
        }
        dataCenterToCluster.get(cluster.getStoragePoolId()).add(cluster);
    }
    List<DataCenterWithCluster> dataCentersWithClusters = new ArrayList<>();
    for (StoragePool dataCenter : dataCenters) {
        if (dataCenterToCluster.containsKey(dataCenter.getId())) {
            for (Cluster cluster : dataCenterToCluster.get(dataCenter.getId())) {
                dataCentersWithClusters.add(new DataCenterWithCluster(dataCenter, cluster));
            }
        }
    }
    selectDataCenterWithCluster(selectedCluster, dataCentersWithClusters);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) List(java.util.List) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 72 with StoragePool

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

the class UnitVmModel method validate.

public boolean validate(boolean templateWithVersionRequired) {
    resetTabsValidity();
    getInstanceTypes().setIsValid(true);
    getInstanceTypes().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getDataCenterWithClustersList().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getOSType().validateSelectedItem(new NotEmptyValidation[] { new NotEmptyValidation() });
    DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem();
    StoragePool dataCenter = dataCenterWithCluster == null ? null : dataCenterWithCluster.getDataCenter();
    if (dataCenter != null && dataCenter.getQuotaEnforcementType() == QuotaEnforcementTypeEnum.HARD_ENFORCEMENT) {
        getQuota().validateSelectedItem(new IValidation[] { new NotEmptyQuotaValidation() });
    }
    if (getOSType().getIsValid()) {
        validateNaming();
        getVmId().setIsValid(true);
        if (getVmId().getIsAvailable() && !StringHelper.isNullOrEmpty(getVmId().getEntity())) {
            getVmId().validateEntity(new IValidation[] { new GuidValidation() });
        }
        getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
        setValidTab(TabName.GENERAL_TAB, isValidTab(TabName.GENERAL_TAB) && getVmId().getIsValid() && getComment().getIsValid());
    }
    if (templateWithVersionRequired) {
        getTemplateWithVersion().validateSelectedItem(new IValidation[] { new NotEmptyValidation(), createEachDiskAHasStorageDomainValidation() });
    }
    getDisksAllocationModel().validateEntity(new IValidation[] {});
    getCdImage().setIsValid(true);
    if (getCdImage().getIsChangable()) {
        getCdImage().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    }
    if (getIsLinuxOS()) {
        getKernel_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getInitrd_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getKernel_parameters().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        // initrd path and kernel params require kernel path to be filled
        if (StringHelper.isNullOrEmpty(getKernel_path().getEntity())) {
            if (!StringHelper.isNullOrEmpty(getInitrd_path().getEntity())) {
                getInitrd_path().getInvalidityReasons().add(constants.initrdPathInvalid());
                getInitrd_path().setIsValid(false);
                getKernel_path().getInvalidityReasons().add(constants.initrdPathInvalid());
                getKernel_path().setIsValid(false);
            }
            if (!StringHelper.isNullOrEmpty(getKernel_parameters().getEntity())) {
                getKernel_parameters().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernel_parameters().setIsValid(false);
                getKernel_path().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernel_path().setIsValid(false);
            }
        }
    }
    if (!getBehavior().isBlankTemplateBehavior()) {
        setValidTab(TabName.GENERAL_TAB, isValidTab(TabName.GENERAL_TAB) && getDataCenterWithClustersList().getIsValid() && getTemplateWithVersion().getIsValid());
    }
    setValidTab(TabName.HOST_TAB, isValidTab(TabName.HOST_TAB) && getMigrationDowntime().getIsValid());
    boolean diskAliasesValid = getDisksAllocationModel().getIsValid();
    setValidTab(TabName.RESOURCE_ALLOCATION_TAB, isValidTab(TabName.RESOURCE_ALLOCATION_TAB) && getCpuSharesAmount().getIsValid() && diskAliasesValid);
    setValidTab(TabName.BOOT_OPTIONS_TAB, getCdImage().getIsValid() && getKernel_path().getIsValid());
    boolean vmInitIsValid = getVmInitModel().validate();
    setValidTab(TabName.INITIAL_RUN_TAB, vmInitIsValid);
    getIcon().validateEntity(new IValidation[] { new IconWithOsDefaultValidation() });
    setValidTab(TabName.ICON_TAB, getIcon().getIsValid());
    boolean hwPartValid = validateHwPart();
    boolean isValid = hwPartValid && vmInitIsValid && allTabsValid();
    getValid().setEntity(isValid);
    fireValidationCompleteEvent();
    return isValid;
}
Also used : GuidValidation(org.ovirt.engine.ui.uicommonweb.validation.GuidValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IconWithOsDefaultValidation(org.ovirt.engine.ui.uicommonweb.validation.IconWithOsDefaultValidation) NoTrimmingWhitespacesValidation(org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation)

Example 73 with StoragePool

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

the class NewPoolModelBehavior method postDataCenterWithClusterSelectedItemChanged.

@Override
public void postDataCenterWithClusterSelectedItemChanged() {
    super.postDataCenterWithClusterSelectedItemChanged();
    final DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
    StoragePool dataCenter = getModel().getSelectedDataCenter();
    if (dataCenter == null) {
        return;
    }
    AsyncDataProvider.getInstance().getTemplateListByDataCenter(asyncQuery(templatesByDataCenter -> {
        List<VmTemplate> properArchitectureTemplates = AsyncDataProvider.getInstance().filterTemplatesByArchitecture(templatesByDataCenter, dataCenterWithCluster.getCluster().getArchitecture());
        List<VmTemplate> templatesWithoutBlank = new ArrayList<>();
        for (VmTemplate template : properArchitectureTemplates) {
            final boolean isBlankOrVersionOfBlank = template.getId().equals(Guid.Empty) || template.getBaseTemplateId().equals(Guid.Empty);
            if (!isBlankOrVersionOfBlank) {
                templatesWithoutBlank.add(template);
            }
        }
        // CustomCompatibilityVersion won't be reset by a selected template.
        if (templatesWithoutBlank.isEmpty()) {
            setCustomCompatibilityVersionChangeInProgress(false);
        }
        initTemplateWithVersion(templatesWithoutBlank, null, false);
    }), dataCenter.getId());
    instanceTypeManager.updateAll();
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmType(org.ovirt.engine.core.common.businessentities.VmType) Guid(org.ovirt.engine.core.compat.Guid) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) NewPoolInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.NewPoolInstanceTypeManager) NewPoolNameLengthValidation(org.ovirt.engine.ui.uicommonweb.validation.NewPoolNameLengthValidation) List(java.util.List) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) List(java.util.List)

Example 74 with StoragePool

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

the class NewTemplateVmModelBehavior method updateTemplate.

protected void updateTemplate() {
    final DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
    StoragePool dataCenter = dataCenterWithCluster == null ? null : dataCenterWithCluster.getDataCenter();
    if (dataCenter == null) {
        return;
    }
    AsyncDataProvider.getInstance().getTemplateListByDataCenter(new AsyncQuery<>(templates -> postInitTemplate(AsyncDataProvider.getInstance().filterTemplatesByArchitecture(templates, dataCenterWithCluster.getCluster().getArchitecture()))), dataCenter.getId());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool)

Example 75 with StoragePool

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

the class NewVmModelBehavior method updateTemplate.

private void updateTemplate() {
    final DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
    StoragePool dataCenter = dataCenterWithCluster == null ? null : dataCenterWithCluster.getDataCenter();
    if (dataCenter == null) {
        return;
    }
    AsyncDataProvider.getInstance().getTemplateListByDataCenter(asyncQuery(templates -> postInitTemplate(AsyncDataProvider.getInstance().filterTemplatesByArchitecture(templates, dataCenterWithCluster.getCluster().getArchitecture()))), dataCenter.getId());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) VmType(org.ovirt.engine.core.common.businessentities.VmType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Guid(org.ovirt.engine.core.compat.Guid) CoreVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CoreVmBaseToUnitBuilder) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) NewVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.NewVmInstanceTypeManager) StringHelper(org.ovirt.engine.core.compat.StringHelper) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool)

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