Search in sources :

Example 76 with Cluster

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

the class UnitVmModel method updateMigrationRelatedFields.

private void updateMigrationRelatedFields() {
    Cluster cluster = getSelectedCluster();
    boolean override = Boolean.TRUE.equals(getOverrideMigrationPolicy().getEntity());
    boolean hasMigrationPolicy = true;
    if (override) {
        MigrationPolicy selectedPolicy = getMigrationPolicies().getSelectedItem();
        if (selectedPolicy == null) {
            // if had selected something which does not exist anymore
            hasMigrationPolicy = false;
        } else if (selectedPolicy.getId().equals(NoMigrationPolicy.ID)) {
            // explicitly selected the empty
            hasMigrationPolicy = false;
        }
    } else {
        if (cluster == null) {
            // for non-cluster entities (e.g. blank template, instance types)
            hasMigrationPolicy = false;
        } else if (cluster.getMigrationPolicyId() == null || cluster.getMigrationPolicyId().equals(NoMigrationPolicy.ID)) {
            // explicitly selected the empty
            hasMigrationPolicy = false;
        }
    }
    getOverrideMigrationDowntime().setIsChangeable(!hasMigrationPolicy, constants.availableOnlyWithLegacyPolicy());
    boolean overrideDowntime = Boolean.TRUE.equals(getOverrideMigrationDowntime().getEntity());
    getMigrationDowntime().setIsChangeable(!hasMigrationPolicy && overrideDowntime, constants.availableOnlyWithLegacyPolicy());
    getAutoConverge().setIsChangeable(!hasMigrationPolicy, constants.availableOnlyWithLegacyPolicy());
    getMigrateCompressed().setIsChangeable(!hasMigrationPolicy, constants.availableOnlyWithLegacyPolicy());
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Example 77 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster 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 78 with Cluster

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

the class VirtioScsiUtil method updateVirtioScsiEnabled.

public void updateVirtioScsiEnabled(final Guid vmId, int osId, VirtioScasiEnablingFinished finishedCallback) {
    this.finishedCallback = finishedCallback;
    final Cluster cluster = model.getSelectedCluster();
    if (cluster == null) {
        return;
    }
    AsyncDataProvider.getInstance().getDiskInterfaceList(osId, cluster.getCompatibilityVersion(), model.asyncQuery(diskInterfaces -> {
        boolean isOsSupportVirtioScsi = diskInterfaces.contains(DiskInterface.VirtIO_SCSI);
        callBeforeUpdates();
        model.getIsVirtioScsiEnabled().setIsChangeable(isOsSupportVirtioScsi);
        if (!isOsSupportVirtioScsi) {
            model.getIsVirtioScsiEnabled().setEntity(false);
            model.getIsVirtioScsiEnabled().setChangeProhibitionReason(constants.cannotEnableVirtioScsiForOs());
            callAfterUpdates();
        } else {
            AsyncDataProvider.getInstance().isVirtioScsiEnabledForVm(model.asyncQuery(returnValue -> {
                model.getIsVirtioScsiEnabled().setEntity(returnValue);
                callAfterUpdates();
            }), vmId);
        }
    }));
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) Guid(org.ovirt.engine.core.compat.Guid) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 79 with Cluster

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

the class ExistingVmModelBehavior method loadDataCenter.

private void loadDataCenter() {
    // Preinitialize the VM compatibility version because it's needed during init
    Version newCustomCompatibilityVersion = ((ExistingVmModelBehavior) getModel().getBehavior()).getVm().getStaticData().getCustomCompatibilityVersion();
    if (newCustomCompatibilityVersion != null) {
        getModel().getCustomCompatibilityVersion().setItems(Collections.singletonList(newCustomCompatibilityVersion), newCustomCompatibilityVersion);
    }
    AsyncDataProvider.getInstance().getDataCenterById(asyncQuery(dataCenter -> {
        if (dataCenter != null) {
            final List<StoragePool> dataCenters = new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter }));
            initClusters(dataCenters);
        } else {
            ExistingVmModelBehavior behavior = (ExistingVmModelBehavior) getModel().getBehavior();
            VM currentVm = behavior.vm;
            Cluster cluster = new Cluster();
            cluster.setId(currentVm.getClusterId());
            cluster.setName(currentVm.getClusterName());
            cluster.setCompatibilityVersion(currentVm.getClusterCompatibilityVersion());
            cluster.setStoragePoolId(currentVm.getStoragePoolId());
            DataCenterWithCluster dataCenterWithCluster = new DataCenterWithCluster(null, cluster);
            getModel().getDataCenterWithClustersList().setItems(Arrays.asList(dataCenterWithCluster));
            getModel().getDataCenterWithClustersList().setSelectedItem(dataCenterWithCluster);
            behavior.initTemplate();
            behavior.updateCdImage();
        }
    }), vm.getStoragePoolId());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) Map(java.util.Map) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Version(org.ovirt.engine.core.compat.Version) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) EnumSet(java.util.EnumSet) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmActionByVmOriginTypeValidator(org.ovirt.engine.core.common.validation.VmActionByVmOriginTypeValidator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) CommonCompatibilityVersionUtils(org.ovirt.engine.core.common.utils.CommonCompatibilityVersionUtils) ExistingVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingVmInstanceTypeManager) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ArrayList(java.util.ArrayList) List(java.util.List)

Example 80 with Cluster

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

the class ExistingVmModelBehavior method isHotSetCpuSupported.

public boolean isHotSetCpuSupported() {
    Cluster selectedCluster = getModel().getSelectedCluster();
    Version compatibilityVersion = getModel().getCompatibilityVersion();
    boolean hotplugCpuSupported = Boolean.parseBoolean(((Map<String, String>) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.HotPlugCpuSupported, compatibilityVersion.getValue())).get(selectedCluster.getArchitecture().name()));
    return getVm().getStatus() == VMStatus.Up && hotplugCpuSupported;
}
Also used : 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