Search in sources :

Example 1 with ConvergenceConfig

use of org.ovirt.engine.core.common.migration.ConvergenceConfig 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)

Example 2 with ConvergenceConfig

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

the class ConvergenceConfigProviderTest method jsonProperlyFilled.

@Test
public void jsonProperlyFilled() throws IOException {
    Guid id = Guid.newGuid();
    List<MigrationPolicy> policies = new ArrayList<>();
    ConvergenceConfig config = new ConvergenceConfig();
    config.setInitialItems(Collections.singletonList(new ConvergenceItem("setDowntime2", 1)));
    config.setLastItems(Collections.singletonList(new ConvergenceItem("setDowntime3", 15)));
    config.setConvergenceItems(Collections.singletonList(new ConvergenceItemWithStallingLimit(1, "someAction", 12)));
    MigrationPolicy policy = new MigrationPolicy(id, "some name", "some long description", config);
    policies.add(policy);
    String json = JsonHelper.objectToJson(policies, false);
    provider.initMigrationPolicies(json, VERSION);
    // just basic sanity check
    assertEquals(policy.getName(), provider.getMigrationPolicy(id, VERSION).getName());
    assertEquals(policy.getDescription(), provider.getMigrationPolicy(id, VERSION).getDescription());
    assertTrue(provider.getMigrationPolicy(id, new Version()) instanceof NoMigrationPolicy);
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) ConvergenceConfig(org.ovirt.engine.core.common.migration.ConvergenceConfig) Version(org.ovirt.engine.core.compat.Version) ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) ArrayList(java.util.ArrayList) ConvergenceItemWithStallingLimit(org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit) Guid(org.ovirt.engine.core.compat.Guid) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) Test(org.junit.Test)

Example 3 with ConvergenceConfig

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

the class MigrationPoliciesValueHelper method getExamplePolicy.

String getExamplePolicy() {
    ConvergenceConfig config = new ConvergenceConfig();
    config.setInitialItems(Arrays.asList(new ConvergenceItem("setDowntime", 100)));
    config.setConvergenceItems(Arrays.asList(new ConvergenceItemWithStallingLimit(1, "setDowntime", 200)));
    config.setLastItems(Arrays.asList(new ConvergenceItem("abort")));
    List<MigrationPolicy> policies = Arrays.asList(new MigrationPolicy(Guid.Empty, "name of the policy", "description", config));
    try {
        return JsonHelper.objectToJson(policies, false);
    } catch (IOException e) {
        // if this fails, than we really want to fail it with an exception
        throw new RuntimeException(e);
    }
}
Also used : ConvergenceConfig(org.ovirt.engine.core.common.migration.ConvergenceConfig) ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) ConvergenceItemWithStallingLimit(org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit) IOException(java.io.IOException) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Example 4 with ConvergenceConfig

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

the class MigrateVmCommand method filterOutPostcopy.

private ConvergenceConfig filterOutPostcopy(ConvergenceConfig config) {
    ConvergenceConfig filteredConfig = new ConvergenceConfig();
    filteredConfig.setInitialItems(config.getInitialItems());
    if (config.getConvergenceItems() != null) {
        filteredConfig.setConvergenceItems(config.getConvergenceItems().stream().filter(item -> !item.getConvergenceItem().getAction().equals("postcopy")).collect(Collectors.toList()));
    }
    if (config.getLastItems() != null) {
        filteredConfig.setLastItems(config.getLastItems().stream().filter(item -> !item.getAction().equals("postcopy")).collect(Collectors.toList()));
    }
    return filteredConfig;
}
Also used : ConvergenceConfig(org.ovirt.engine.core.common.migration.ConvergenceConfig)

Aggregations

ConvergenceConfig (org.ovirt.engine.core.common.migration.ConvergenceConfig)4 MigrationPolicy (org.ovirt.engine.core.common.migration.MigrationPolicy)3 ConvergenceItem (org.ovirt.engine.core.common.migration.ConvergenceItem)2 ConvergenceItemWithStallingLimit (org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit)2 NoMigrationPolicy (org.ovirt.engine.core.common.migration.NoMigrationPolicy)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 MigrateVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.MigrateVDSCommandParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1 Version (org.ovirt.engine.core.compat.Version)1