Search in sources :

Example 1 with DisksAllocationModel

use of org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel in project ovirt-engine by oVirt.

the class ExistingPoolModelBehavior method postInitStorageDomains.

@Override
protected void postInitStorageDomains() {
    ArrayList<DiskModel> disks = (ArrayList<DiskModel>) getModel().getDisks();
    if (disks == null) {
        return;
    }
    ActionGroup actionGroup = getModel().isCreateInstanceOnly() ? ActionGroup.CREATE_INSTANCE : ActionGroup.CREATE_VM;
    StoragePool dataCenter = getModel().getSelectedDataCenter();
    AsyncDataProvider.getInstance().getPermittedStorageDomainsByStoragePoolId(asyncQuery(storageDomains -> {
        ArrayList<DiskModel> disks1 = (ArrayList<DiskModel>) getModel().getDisks();
        ArrayList<StorageDomain> activeStorageDomains = filterStorageDomains(storageDomains);
        DisksAllocationModel disksAllocationModel = getModel().getDisksAllocationModel();
        disksAllocationModel.setActiveStorageDomains(activeStorageDomains);
        getModel().getStorageDomain().setItems(activeStorageDomains);
        for (DiskModel diskModel : disks1) {
            // Setting Quota
            diskModel.getQuota().setItems(getModel().getQuota().getItems());
            diskModel.getQuota().setIsChangeable(false);
            List<Guid> storageIds = ((DiskImage) diskModel.getDisk()).getStorageIds();
            for (DiskImage disk : pool.getDiskList()) {
                if (diskModel.getDisk() instanceof DiskImage && ((DiskImage) diskModel.getDisk()).getImageId().equals(disk.getImageTemplateId())) {
                    storageIds = new ArrayList<>(disk.getStorageIds());
                    break;
                }
            }
            if (storageIds == null || storageIds.size() == 0) {
                continue;
            }
            Guid storageId = storageIds.get(0);
            StorageDomain storageDomain = activeStorageDomains.stream().filter(new Linq.IdPredicate<>(storageId)).findFirst().orElse(null);
            List<StorageDomain> diskStorageDomains = new ArrayList<>();
            diskStorageDomains.add(storageDomain);
            diskModel.getStorageDomain().setItems(diskStorageDomains);
            diskModel.getStorageDomain().setIsChangeable(false);
        }
    }), dataCenter.getId(), actionGroup);
    getModel().getDisksAllocationModel().initializeAutoSelectTarget(false, actualPool.isAutoStorageSelect());
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StringHelper(org.ovirt.engine.core.compat.StringHelper) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) ExistingPoolInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingPoolInstanceTypeManager) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ExistingPoolNameLengthValidation(org.ovirt.engine.ui.uicommonweb.validation.ExistingPoolNameLengthValidation) LatestVmTemplate(org.ovirt.engine.ui.uicommonweb.models.templates.LatestVmTemplate) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ArrayList(java.util.ArrayList) List(java.util.List) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with DisksAllocationModel

use of org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel in project ovirt-engine by oVirt.

the class NewTemplateVmModelBehavior method initialize.

@Override
public void initialize() {
    super.initialize();
    getModel().getVmInitEnabled().setEntity(vm.getVmInit() != null);
    getModel().getVmInitModel().init(vm.getStaticData());
    getModel().getVmType().setIsChangeable(true);
    getModel().getCopyPermissions().setIsAvailable(true);
    DisksAllocationModel disksAllocationModel = getModel().getDisksAllocationModel();
    disksAllocationModel.setIsVolumeFormatAvailable(true);
    disksAllocationModel.setIsVolumeFormatChangeable(true);
    disksAllocationModel.setIsAliasChangable(true);
    disksAllocationModel.setContainer(getModel());
    disksAllocationModel.setIsThinProvisioning(false);
    AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> {
        if (dataCenter == null) {
            disableNewTemplateModel(ConstantsManager.getInstance().getConstants().dataCenterIsNotAccessibleMsg());
        } else {
            AsyncDataProvider.getInstance().getClusterListByService(new AsyncQuery<>(clusters -> {
                List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clusters, vm.getClusterArch());
                getModel().setDataCentersAndClusters(getModel(), Arrays.asList(dataCenter), filteredClusters, vm.getClusterId());
                initTemplate();
            }), true, false);
            AsyncDataProvider.getInstance().isSoundcardEnabled(new AsyncQuery<>(returnValue -> getModel().getIsSoundcardEnabled().setEntity(returnValue)), vm.getId());
        }
    }), vm.getStoragePoolId());
}
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) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel)

Aggregations

ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 Linq (org.ovirt.engine.ui.uicommonweb.Linq)2 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)2 DisksAllocationModel (org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)1 StorageDomainStatus (org.ovirt.engine.core.common.businessentities.StorageDomainStatus)1 VmPool (org.ovirt.engine.core.common.businessentities.VmPool)1 DiskByDiskAliasComparator (org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)1