Search in sources :

Example 6 with MigrationPolicy

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

the class ConvergenceConfigProvider method initMigrationPolicies.

void initMigrationPolicies(String policiesStr, Version version) {
    List<MigrationPolicy> policies = Collections.emptyList();
    try {
        policies = parse(policiesStr);
    } catch (IOException e) {
        log.error("The provided migration policies: '{}' are not valid, ignoring", policiesStr);
    }
    // init it to an empty map even the parsing failed
    Map<Guid, MigrationPolicy> migrationPolicies = policies.stream().collect(toMap(MigrationPolicy::getId, identity()));
    // the null object
    migrationPolicies.put(NoMigrationPolicy.ID, new NoMigrationPolicy());
    migrationPoliciesByVersion.put(version, migrationPolicies);
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) IOException(java.io.IOException) Guid(org.ovirt.engine.core.compat.Guid) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Example 7 with MigrationPolicy

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

the class ClusterModel method refreshMigrationPolicies.

public void refreshMigrationPolicies() {
    Version version = getEffectiveVersion();
    Guid selectedPolicyId = null;
    if (getMigrationPolicies() != null && getMigrationPolicies().getSelectedItem() != null) {
        selectedPolicyId = getMigrationPolicies().getSelectedItem().getId();
    }
    List<MigrationPolicy> policies = AsyncDataProvider.getInstance().getMigrationPolicies(version);
    getMigrationPolicies().setItems(policies);
    MigrationPolicy migrationPolicy;
    if (selectedPolicyId == null) {
        migrationPolicy = getIsEdit() ? findMigrationPolicyById(getEntity().getMigrationPolicyId(), policies) : findFirstNonEmptyMigrationPolicy(policies);
    } else {
        migrationPolicy = findMigrationPolicyById(selectedPolicyId, policies);
    }
    getMigrationPolicies().setSelectedItem(migrationPolicy != null ? migrationPolicy : findMigrationPolicyById(NoMigrationPolicy.ID, policies));
    getMigrationPolicies().updateChangeability(ConfigValues.MigrationPoliciesSupported, version);
}
Also used : 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 8 with MigrationPolicy

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

the class ConvergenceConfigProviderTest method jsonInvalidJson.

@Test
public void jsonInvalidJson() throws IOException {
    provider.initMigrationPolicies("this is not a valid json", VERSION);
    MigrationPolicy policy = provider.getMigrationPolicy(Guid.newGuid(), VERSION);
    assertTrue(policy instanceof NoMigrationPolicy);
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) Test(org.junit.Test)

Example 9 with MigrationPolicy

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

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

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