Search in sources :

Example 1 with HostStoragePoolParametersBase

use of org.ovirt.engine.core.common.action.HostStoragePoolParametersBase in project ovirt-engine by oVirt.

the class VdsEventListener method processStorageOnVdsInactive.

private void processStorageOnVdsInactive(final VDS vds) {
    // anymore.
    if (!Guid.Empty.equals(vds.getStoragePoolId())) {
        // when vds is being moved to maintenance, this is the part in which we disconnect it from the pool
        // and the storage server. it should be synced with the host autorecovery mechanism to try to avoid
        // leaving the host with storage/pool connection when it's on maintenance.
        EngineLock lock = new EngineLock(Collections.singletonMap(vds.getId().toString(), new Pair<>(LockingGroup.VDS_POOL_AND_STORAGE_CONNECTIONS.toString(), EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED.toString())), null);
        try {
            lockManager.acquireLockWait(lock);
            clearDomainCache(vds);
            StoragePool storage_pool = storagePoolDao.get(vds.getStoragePoolId());
            if (StoragePoolStatus.Uninitialized != storage_pool.getStatus()) {
                vdsBroker.runVdsCommand(VDSCommandType.DisconnectStoragePool, new DisconnectStoragePoolVDSCommandParameters(vds.getId(), vds.getStoragePoolId(), vds.getVdsSpmId()));
                HostStoragePoolParametersBase params = new HostStoragePoolParametersBase(storage_pool, vds);
                backend.runInternalAction(ActionType.DisconnectHostFromStoragePoolServers, params);
            }
        } finally {
            lockManager.releaseLock(lock);
        }
    }
}
Also used : HostStoragePoolParametersBase(org.ovirt.engine.core.common.action.HostStoragePoolParametersBase) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) DisconnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 2 with HostStoragePoolParametersBase

use of org.ovirt.engine.core.common.action.HostStoragePoolParametersBase in project ovirt-engine by oVirt.

the class VdsEventListener method vdsUpEvent.

@Override
public boolean vdsUpEvent(final VDS vds) {
    HostStoragePoolParametersBase params = new HostStoragePoolParametersBase(vds);
    CommandContext commandContext = new CommandContext(new EngineContext()).withoutExecutionContext();
    commandContext.getExecutionContext().setJobRequired(true);
    boolean isSucceeded = backend.runInternalAction(ActionType.InitVdsOnUp, params, commandContext).getSucceeded();
    if (isSucceeded) {
        ThreadPoolUtil.execute(() -> {
            try {
                // migrate vms that its their default vds and failback
                // is on
                List<VmStatic> vmsToMigrate = vmStaticDao.getAllWithFailbackByVds(vds.getId());
                if (!vmsToMigrate.isEmpty()) {
                    CommandContext ctx = new CommandContext(new EngineContext());
                    ctx.getExecutionContext().setMonitored(true);
                    backend.runInternalMultipleActions(ActionType.MigrateVmToServer, new ArrayList<>(createMigrateVmToServerParametersList(vmsToMigrate, vds, null)), ctx);
                }
            } catch (RuntimeException e) {
                log.error("Failed to initialize Vds on up: {}", e.getMessage());
                log.error("Exception", e);
            }
        });
    }
    return isSucceeded;
}
Also used : HostStoragePoolParametersBase(org.ovirt.engine.core.common.action.HostStoragePoolParametersBase) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) EngineContext(org.ovirt.engine.core.bll.context.EngineContext) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Aggregations

HostStoragePoolParametersBase (org.ovirt.engine.core.common.action.HostStoragePoolParametersBase)2 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 EngineContext (org.ovirt.engine.core.bll.context.EngineContext)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 Pair (org.ovirt.engine.core.common.utils.Pair)1 DisconnectStoragePoolVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters)1 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)1