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