Search in sources :

Example 1 with MigrationPolicy

use of org.ovirt.engine.core.common.migration.MigrationPolicy in project ovirt-engine by oVirt.

the class AsyncDataProvider method initMigrationPolicies.

private void initMigrationPolicies() {
    AsyncQuery<Map<Version, List<MigrationPolicy>>> aQuery = new AsyncQuery<>(returnValue -> migrationPoliciesByVersion = returnValue);
    aQuery.converterCallback = returnValue -> {
        if (returnValue == null) {
            return new HashMap<>();
        }
        Map<Version, List<MigrationPolicy>> policiesByVersion = (Map<Version, List<MigrationPolicy>>) returnValue;
        for (List<MigrationPolicy> policies : policiesByVersion.values()) {
            Collections.sort(policies, Comparator.comparing((MigrationPolicy m) -> !NoMigrationPolicy.ID.equals(m.getId())).thenComparing(MigrationPolicy::getName));
        }
        return policiesByVersion;
    };
    Frontend.getInstance().runQuery(QueryType.GetAllMigrationPolicies, new QueryParametersBase(), aQuery);
}
Also used : HashMap(java.util.HashMap) Version(org.ovirt.engine.core.compat.Version) RpmVersion(org.ovirt.engine.core.compat.RpmVersion) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StorageServerConnectionQueryParametersBase(org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with MigrationPolicy

use of org.ovirt.engine.core.common.migration.MigrationPolicy in project ovirt-engine by oVirt.

the class UnitVmModel method selectMigrationPolicy.

public void selectMigrationPolicy(Guid id) {
    if (getMigrationPolicies().getItems() == null) {
        return;
    }
    boolean migrationPolicyOverridden = id != null;
    getOverrideMigrationPolicy().setEntity(migrationPolicyOverridden);
    if (migrationPolicyOverridden) {
        for (MigrationPolicy policy : getMigrationPolicies().getItems()) {
            if (Objects.equals(policy.getId(), id)) {
                getMigrationPolicies().setSelectedItem(policy);
                break;
            }
        }
    }
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Example 3 with MigrationPolicy

use of org.ovirt.engine.core.common.migration.MigrationPolicy in project ovirt-engine by oVirt.

the class UnitVmModel method refreshMigrationPolicies.

private void refreshMigrationPolicies() {
    Version version = getCompatibilityVersion();
    Guid selectedPolicyId = null;
    if (getMigrationPolicies() != null && getMigrationPolicies().getSelectedItem() != null) {
        selectedPolicyId = getMigrationPolicies().getSelectedItem().getId();
    }
    List<MigrationPolicy> policies = AsyncDataProvider.getInstance().getMigrationPolicies(version);
    getMigrationPolicies().setItems(policies);
    if (selectedPolicyId != null) {
        for (MigrationPolicy policy : policies) {
            if (Objects.equals(policy.getId(), selectedPolicyId)) {
                getMigrationPolicies().setSelectedItem(policy);
                break;
            }
        }
    }
}
Also used : TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Version(org.ovirt.engine.core.compat.Version) Guid(org.ovirt.engine.core.compat.Guid) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Example 4 with MigrationPolicy

use of org.ovirt.engine.core.common.migration.MigrationPolicy 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 5 with MigrationPolicy

use of org.ovirt.engine.core.common.migration.MigrationPolicy in project ovirt-engine by oVirt.

the class MigrateVmCommand method createMigrateVDSCommandParameters.

private MigrateVDSCommandParameters createMigrateVDSCommandParameters() {
    String srcVdsHost = getVds().getHostName();
    String dstVdsHost = String.format("%1$s:%2$s", getDestinationVds().getHostName(), getDestinationVds().getPort());
    Map<String, Object> convergenceSchedule = null;
    Integer maxBandwidth = null;
    Boolean autoConverge = getAutoConverge();
    Boolean migrateCompressed = getMigrateCompressed();
    Boolean enableGuestEvents = null;
    Integer maxIncomingMigrations = null;
    Integer maxOutgoingMigrations = null;
    if (FeatureSupported.migrationPoliciesSupported(getVm().getCompatibilityVersion())) {
        MigrationPolicy clusterMigrationPolicy = convergenceConfigProvider.getMigrationPolicy(getCluster().getMigrationPolicyId(), getCluster().getCompatibilityVersion());
        MigrationPolicy effectiveMigrationPolicy = findEffectiveConvergenceConfig(clusterMigrationPolicy);
        ConvergenceConfig convergenceConfig = getVm().getStatus() == VMStatus.Paused ? filterOutPostcopy(effectiveMigrationPolicy.getConfig()) : effectiveMigrationPolicy.getConfig();
        convergenceSchedule = ConvergenceSchedule.from(convergenceConfig).asMap();
        maxBandwidth = getMaxBandwidth(clusterMigrationPolicy);
        if (!NoMigrationPolicy.ID.equals(effectiveMigrationPolicy.getId())) {
            autoConverge = effectiveMigrationPolicy.isAutoConvergence();
            migrateCompressed = effectiveMigrationPolicy.isMigrationCompression();
        }
        enableGuestEvents = effectiveMigrationPolicy.isEnableGuestEvents();
        maxIncomingMigrations = maxOutgoingMigrations = effectiveMigrationPolicy.getMaxMigrations();
    }
    return new MigrateVDSCommandParameters(getVdsId(), getVmId(), srcVdsHost, getDestinationVdsId(), dstVdsHost, MigrationMethod.ONLINE, isTunnelMigrationUsed(), getLiteralMigrationNetworkIp(), getVds().getClusterCompatibilityVersion(), getMaximumMigrationDowntime(), autoConverge, migrateCompressed, getDestinationVds().getConsoleAddress(), maxBandwidth, convergenceSchedule, enableGuestEvents, maxIncomingMigrations, maxOutgoingMigrations);
}
Also used : ConvergenceConfig(org.ovirt.engine.core.common.migration.ConvergenceConfig) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) MigrateVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.MigrateVDSCommandParameters)

Aggregations

MigrationPolicy (org.ovirt.engine.core.common.migration.MigrationPolicy)11 NoMigrationPolicy (org.ovirt.engine.core.common.migration.NoMigrationPolicy)9 Version (org.ovirt.engine.core.compat.Version)5 Guid (org.ovirt.engine.core.compat.Guid)4 ConvergenceConfig (org.ovirt.engine.core.common.migration.ConvergenceConfig)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 ConvergenceItem (org.ovirt.engine.core.common.migration.ConvergenceItem)2 ConvergenceItemWithStallingLimit (org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AdditionalFeature (org.ovirt.engine.core.common.businessentities.AdditionalFeature)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)1 StorageServerConnectionQueryParametersBase (org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)1 MigrateVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.MigrateVDSCommandParameters)1 RpmVersion (org.ovirt.engine.core.compat.RpmVersion)1 AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)1