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);
}
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);
}
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);
}
}
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;
}
Aggregations