Search in sources :

Example 1 with FencingPolicy

use of org.ovirt.engine.core.common.businessentities.FencingPolicy in project ovirt-engine by oVirt.

the class Cloner method cloneCluster.

private static Cluster cloneCluster(Cluster instance) {
    Cluster obj = new Cluster();
    obj.setId(instance.getId());
    obj.setName(instance.getName());
    obj.setDescription(instance.getDescription());
    obj.setComment(instance.getComment());
    obj.setCpuName(instance.getCpuName());
    obj.setClusterCompatibilityLevelUpgradeNeeded(instance.isClusterCompatibilityLevelUpgradeNeeded());
    obj.setCompatibilityVersion(instance.getCompatibilityVersion());
    obj.setMigrateOnError(instance.getMigrateOnError());
    obj.setTransparentHugepages(instance.getTransparentHugepages());
    obj.setStoragePoolId(instance.getStoragePoolId());
    obj.setMaxVdsMemoryOverCommit(instance.getMaxVdsMemoryOverCommit());
    obj.setCountThreadsAsCores(instance.getCountThreadsAsCores());
    obj.setEmulatedMachine(instance.getEmulatedMachine());
    obj.setDetectEmulatedMachine(instance.isDetectEmulatedMachine());
    obj.setArchitecture(instance.getArchitecture());
    obj.setSerialNumberPolicy(instance.getSerialNumberPolicy());
    obj.setCustomSerialNumber(instance.getCustomSerialNumber());
    obj.setFencingPolicy(new FencingPolicy(instance.getFencingPolicy()));
    obj.setAutoConverge(instance.getAutoConverge());
    obj.setMigrateCompressed(instance.getMigrateCompressed());
    return obj;
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) FencingPolicy(org.ovirt.engine.core.common.businessentities.FencingPolicy)

Example 2 with FencingPolicy

use of org.ovirt.engine.core.common.businessentities.FencingPolicy in project ovirt-engine by oVirt.

the class FenceProxyLocatorTest method findProxyHostExcludesHostDueToFencingPolicy.

/**
 * Checks if the locator excludes specified host as a proxy host, because its supported cluster level is lower
 * than minimal supported cluster level required by fencing policy. And because specified host is the only
 * existing host, no proxy is selected
 */
@Test
public void findProxyHostExcludesHostDueToFencingPolicy() {
    mockExistingHosts(createHost());
    FenceProxyLocator locator = setupLocator(new FencingPolicy());
    setMinSupportedVersionForFencingPolicy(locator, Version.v3_6);
    VDS proxyHost = locator.findProxyHost(false);
    assertNull(proxyHost);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) FencingPolicy(org.ovirt.engine.core.common.businessentities.FencingPolicy) Test(org.junit.Test)

Example 3 with FencingPolicy

use of org.ovirt.engine.core.common.businessentities.FencingPolicy in project ovirt-engine by oVirt.

the class VdsNotRespondingTreatmentCommand method executeCommand.

/**
 * Only fence the host if the VDS is down, otherwise it might have gone back up until this command was executed. If
 * the VDS is not fenced then don't send an audit log event.
 */
@Override
protected void executeCommand() {
    VDS host = getVds();
    if (!previousHostedEngineHost.isPreviousHostId(host.getId()) && !fenceValidator.isStartupTimeoutPassed() && !host.isInFenceFlow()) {
        log.error("Failed to run Fence script on vds '{}'.", getVdsName());
        alertIfPowerManagementOperationSkipped();
        // If fencing can't be done and the host is the SPM, set storage-pool to non-operational
        if (host.getSpmStatus() != VdsSpmStatus.None) {
            setStoragePoolNonOperational();
        }
        return;
    }
    setVds(null);
    if (getVds() == null) {
        setCommandShouldBeLogged(false);
        log.info("Host '{}' ({}) not fenced since it doesn't exist anymore.", getVdsName(), getVdsId());
        getReturnValue().setSucceeded(false);
        return;
    }
    if (shouldFencingBeSkipped(getVds())) {
        setSucceeded(false);
        setCommandShouldBeLogged(false);
        return;
    }
    boolean shouldBeFenced = getVds().shouldVdsBeFenced();
    ActionReturnValue restartVdsResult = null;
    if (shouldBeFenced) {
        getParameters().setParentCommand(ActionType.VdsNotRespondingTreatment);
        ActionReturnValue retVal;
        retVal = runInternalAction(ActionType.SshSoftFencing, getParameters(), cloneContext().withoutExecutionContext());
        if (retVal.getSucceeded()) {
            // SSH Soft Fencing was successful and host is Up, stop non responding treatment
            getReturnValue().setSucceeded(true);
            setCommandShouldBeLogged(false);
            return;
        }
        // proceed with non responding treatment only if PM action are allowed and PM enabled for host
        if (!monitoringStrategyFactory.getMonitoringStrategyForVds(getVds()).isPowerManagementSupported() || !getVds().isPmEnabled()) {
            setSucceeded(false);
            setCommandShouldBeLogged(false);
            return;
        }
        retVal = runInternalAction(ActionType.VdsKdumpDetection, getParameters(), cloneContext().withoutExecutionContext());
        if (retVal.getSucceeded()) {
            // kdump on host detected and finished successfully, stop hard fencing execution
            getReturnValue().setSucceeded(true);
            return;
        }
        // load cluster fencing policy
        FencingPolicy fencingPolicy = clusterDao.get(getVds().getClusterId()).getFencingPolicy();
        getParameters().setFencingPolicy(fencingPolicy);
        waitUntilSkipFencingIfSDActiveAllowed(fencingPolicy.isSkipFencingIfSDActive());
        restartVdsResult = runInternalAction(ActionType.RestartVds, getParameters(), cloneContext().withoutExecutionContext());
    } else {
        setCommandShouldBeLogged(false);
        log.info("Host '{}' ({}) not fenced since it's status is ok, or it doesn't exist anymore.", getVdsName(), getVdsId());
    }
    if (restartVdsResult != null && restartVdsResult.<RestartVdsResult>getActionReturnValue() != null && restartVdsResult.<RestartVdsResult>getActionReturnValue().isSkippedDueToFencingPolicy()) {
        // fencing was skipped, fire an alert and suppress standard command logging
        AuditLogable alb = createAuditLogableForHost(getVds());
        auditLogDirector.log(alb, AuditLogType.VDS_ALERT_NOT_RESTARTED_DUE_TO_POLICY);
        setSucceeded(false);
        setCommandShouldBeLogged(false);
    } else {
        getReturnValue().setSucceeded(shouldBeFenced);
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) FencingPolicy(org.ovirt.engine.core.common.businessentities.FencingPolicy)

Example 4 with FencingPolicy

use of org.ovirt.engine.core.common.businessentities.FencingPolicy in project ovirt-engine by oVirt.

the class ConcurrentAgentsFenceActionExecutorTest method setup.

@Before
public void setup() {
    agent1 = new FenceAgent();
    agent1.setId(Guid.newGuid());
    agent2 = new FenceAgent();
    agent2.setId(Guid.newGuid());
    List<FenceAgent> fenceAgents = new ArrayList<>();
    fenceAgents.add(agent1);
    fenceAgents.add(agent2);
    executor = spy(new ConcurrentAgentsFenceActionExecutor(fencedHost, fenceAgents, new FencingPolicy()));
    doReturn(singleExecutor1).when(executor).createFenceActionExecutor(eq(agent1));
    doReturn(singleExecutor2).when(executor).createFenceActionExecutor(eq(agent2));
}
Also used : FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) ArrayList(java.util.ArrayList) FencingPolicy(org.ovirt.engine.core.common.businessentities.FencingPolicy) Before(org.junit.Before)

Example 5 with FencingPolicy

use of org.ovirt.engine.core.common.businessentities.FencingPolicy in project ovirt-engine by oVirt.

the class HostFenceActionExecutorTest method testSingleAgentFenceActionExecutorUsage.

/**
 * Tests {@code SingleAgentFenceActionExecutor} creation for single fence agent
 */
@Test
public void testSingleAgentFenceActionExecutorUsage() {
    HostFenceActionExecutor executor = new HostFenceActionExecutor(fencedHost, new FencingPolicy());
    assertTrue(executor.createFenceActionExecutor(createSingleAgentList(1)) instanceof SingleAgentFenceActionExecutor);
}
Also used : FencingPolicy(org.ovirt.engine.core.common.businessentities.FencingPolicy) Test(org.junit.Test)

Aggregations

FencingPolicy (org.ovirt.engine.core.common.businessentities.FencingPolicy)8 Before (org.junit.Before)3 Test (org.junit.Test)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 ArrayList (java.util.ArrayList)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)1 FenceAgent (org.ovirt.engine.core.common.businessentities.pm.FenceAgent)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1