Search in sources :

Example 71 with Cluster

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

the class ImportVmFromExportDomainModel method doInit.

protected void doInit() {
    StoragePool dataCenter = getStoragePool();
    if (dataCenter == null) {
        return;
    }
    getClusterQuota().setIsAvailable(dataCenter.getQuotaEnforcementType() != QuotaEnforcementTypeEnum.DISABLED);
    getCluster().getSelectedItemChangedEvent().addListener(clusterChangedListener);
    // get cluster
    getCluster().setItems(null);
    AsyncDataProvider.getInstance().getClusterByServiceList(new AsyncQuery<>(clusters -> {
        ArchitectureType targetArch = getTargetArchitecture();
        if (targetArch != null) {
            List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clusters, targetArch);
            getCluster().setItems(filteredClusters);
            getCluster().setSelectedItem(Linq.firstOrNull(filteredClusters));
        } else {
            getCluster().setItems(clusters);
            getCluster().setSelectedItem(Linq.firstOrNull(clusters));
        }
        // get storage domains
        AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(storageDomains -> {
            // filter storage domains
            filteredStorageDomains = new ArrayList<>();
            for (StorageDomain domain : storageDomains) {
                if (Linq.isDataActiveStorageDomain(domain)) {
                    filteredStorageDomains.add(domain);
                }
            }
            if (getClusterQuota().getIsAvailable()) {
                initQuotaForStorageDomains();
            } else {
                initDisksStorageDomainsList();
            }
        }), getStoragePool().getId());
    }), dataCenter.getId(), true, false);
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) Inject(com.google.inject.Inject) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HashMap(java.util.HashMap) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) ActionType(org.ovirt.engine.core.common.action.ActionType) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) Frontend(org.ovirt.engine.ui.frontend.Frontend) QuotaListModel(org.ovirt.engine.ui.uicommonweb.models.quota.QuotaListModel) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) ClusterListModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterListModel) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Quota(org.ovirt.engine.core.common.businessentities.Quota) ImportVmParameters(org.ovirt.engine.core.common.action.ImportVmParameters) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Entry(java.util.Map.Entry) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) List(java.util.List)

Example 72 with Cluster

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

the class ImportVmsModel method initDataCenters.

private void initDataCenters() {
    getDataCenters().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
        clearVms();
        exportDomain.setEntity(null);
        loadProviders();
        StoragePool dataCenter = dataCenters.getSelectedItem();
        Frontend.getInstance().runQuery(QueryType.GetStorageDomainsByStoragePoolId, new IdQueryParameters(dataCenter.getId()), new AsyncQuery<>(createGetStorageDomainsByStoragePoolIdCallback()));
    });
    dataCenters.getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            AsyncDataProvider.getInstance().getHostListByDataCenter(new AsyncQuery<>(hosts -> {
                List<VDS> upHosts = filterUpHosts(hosts);
                proxyHosts.setItems(addAnyHostInCluster(upHosts));
                xenProxyHosts.setItems(addAnyHostInCluster(upHosts));
                kvmProxyHosts.setItems(addAnyHostInCluster(upHosts));
                ImportVmsModel.this.hosts.setItems(upHosts);
                stopProgress();
            }), dataCenters.getSelectedItem().getId());
        }

        private List<VDS> filterUpHosts(List<VDS> hosts) {
            List<VDS> result = new ArrayList<>();
            for (VDS host : hosts) {
                if (host.getStatus() == VDSStatus.Up) {
                    result.add(host);
                }
            }
            return result;
        }

        private List<VDS> addAnyHostInCluster(List<VDS> hosts) {
            List<VDS> result = new ArrayList<>(hosts);
            // Any host in the cluster
            result.add(0, null);
            return result;
        }
    });
    AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(returnValue -> {
        List<StoragePool> dataCenters = new ArrayList<>();
        for (StoragePool a : returnValue) {
            if (a.getStatus() == StoragePoolStatus.Up) {
                dataCenters.add(a);
            }
        }
        if (dataCenters.isEmpty()) {
            getDataCenters().setIsChangeable(false);
            getImportSources().setIsChangeable(false);
            setError(constants.notAvailableWithNoUpDC());
            stopProgress();
            return;
        }
        Collections.sort(dataCenters, new NameableComparator());
        ImportVmsModel.this.dataCenters.setItems(dataCenters);
    }));
}
Also used : Arrays(java.util.Arrays) NameAndOptionalDomainValidation(org.ovirt.engine.ui.uicommonweb.validation.NameAndOptionalDomainValidation) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) Event(org.ovirt.engine.ui.uicompat.Event) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) URL(com.google.gwt.http.client.URL) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SortedListModel(org.ovirt.engine.ui.uicommonweb.models.SortedListModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) StringHelper(org.ovirt.engine.core.compat.StringHelper) Objects(java.util.Objects) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) ProviderType(org.ovirt.engine.core.common.businessentities.ProviderType) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) XENVmProviderProperties(org.ovirt.engine.core.common.businessentities.XENVmProviderProperties) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) KVMVmProviderProperties(org.ovirt.engine.core.common.businessentities.KVMVmProviderProperties) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) HashMap(java.util.HashMap) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Pair(org.ovirt.engine.core.common.utils.Pair) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) VmwareVmProviderProperties(org.ovirt.engine.core.common.businessentities.VmwareVmProviderProperties) VM(org.ovirt.engine.core.common.businessentities.VM) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) List(java.util.List) ArrayList(java.util.ArrayList) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)

Example 73 with Cluster

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

the class UnitVmModel method updateMigrationOptions.

private void updateMigrationOptions() {
    DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem();
    if (dataCenterWithCluster == null) {
        return;
    }
    Cluster cluster = dataCenterWithCluster.getCluster();
    Version version = getCompatibilityVersion();
    // test migration support for VM/cluster level along with the cluster architecture
    Boolean isMigrationSupported = AsyncDataProvider.getInstance().isMigrationSupported(cluster.getArchitecture(), version);
    if (isMigrationSupported && getVmType().getSelectedItem() != VmType.HighPerformance) {
        getMigrationMode().setItems(Arrays.asList(MigrationSupport.values()));
    } else {
        getMigrationMode().setItems(Arrays.asList(MigrationSupport.PINNED_TO_HOST));
    }
    autoConverge.setIsChangeable(true);
    migrateCompressed.setIsChangeable(true);
}
Also used : TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Version(org.ovirt.engine.core.compat.Version) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 74 with Cluster

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

the class UnitVmModel method validateMemoryAlignment.

private void validateMemoryAlignment(EntityModel<Integer> model) {
    if (!model.getIsValid()) {
        return;
    }
    int memSize = model.getEntity();
    DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem();
    if (dataCenterWithCluster == null) {
        return;
    }
    Cluster cluster = dataCenterWithCluster.getCluster();
    ArchitectureType architectureFamily = cluster.getArchitecture().getFamily();
    if (architectureFamily == ArchitectureType.ppc && memSize % 256 != 0) {
        model.getInvalidityReasons().add(ConstantsManager.getInstance().getMessages().memSizeMultipleOf(architectureFamily.toString(), 256));
        model.setIsValid(false);
    }
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 75 with Cluster

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

the class UnitVmModel method getCompatibilityVersion.

public Version getCompatibilityVersion() {
    ListModel<Version> customCompatibilityVersion = getCustomCompatibilityVersion();
    if (customCompatibilityVersion != null && customCompatibilityVersion.getSelectedItem() != null) {
        return customCompatibilityVersion.getSelectedItem();
    }
    Cluster cluster = getSelectedCluster();
    if (cluster != null) {
        return cluster.getCompatibilityVersion();
    }
    return null;
}
Also used : TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Version(org.ovirt.engine.core.compat.Version) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Aggregations

Cluster (org.ovirt.engine.core.common.businessentities.Cluster)346 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)80 Guid (org.ovirt.engine.core.compat.Guid)77 VDS (org.ovirt.engine.core.common.businessentities.VDS)54 List (java.util.List)50 VM (org.ovirt.engine.core.common.businessentities.VM)36 HashMap (java.util.HashMap)35 Map (java.util.Map)33 HashSet (java.util.HashSet)30 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)30 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)28 Version (org.ovirt.engine.core.compat.Version)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)26 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)26 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)25 Set (java.util.Set)24 QueryType (org.ovirt.engine.core.common.queries.QueryType)23 Collections (java.util.Collections)22 Frontend (org.ovirt.engine.ui.frontend.Frontend)22