Search in sources :

Example 1 with SpmStopOnIrsVDSCommandParameters

use of org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters in project ovirt-engine by oVirt.

the class ForceSelectSPMCommand method executeCommand.

@Override
protected void executeCommand() {
    SpmStopOnIrsVDSCommandParameters params = new SpmStopOnIrsVDSCommandParameters(getStoragePoolForVds().getId(), getParameters().getPreferredSPMId());
    if (runVdsCommand(VDSCommandType.SpmStopOnIrs, params).getSucceeded()) {
        auditLogDirector.log(this, AuditLogType.USER_FORCE_SELECTED_SPM);
    } else {
        auditLogDirector.log(this, AuditLogType.USER_FORCE_SELECTED_SPM_STOP_FAILED);
    }
    setSucceeded(true);
}
Also used : SpmStopOnIrsVDSCommandParameters(org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters)

Example 2 with SpmStopOnIrsVDSCommandParameters

use of org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters in project ovirt-engine by oVirt.

the class DeactivateStorageDomainCommand method executeCommand.

@Override
protected void executeCommand() {
    if (isCinderStorageDomain()) {
        deactivateCinderStorageDomain();
        return;
    }
    final StoragePoolIsoMap map = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(getParameters().getStorageDomainId(), getParameters().getStoragePoolId()));
    map.setStatus(StorageDomainStatus.Unknown);
    changeStorageDomainStatusInTransaction(map, getParameters().isInactive() ? StorageDomainStatus.Locked : StorageDomainStatus.PreparingForMaintenance);
    final StorageDomain newMaster;
    if (getStorageDomain().getStorageDomainType() == StorageDomainType.Master) {
        newMaster = electNewMaster();
        isLastMaster = proceedStorageDomainTreatmentByDomainType(newMaster, true);
    } else {
        newMaster = null;
        isLastMaster = false;
    }
    final Guid newMasterId = newMaster != null ? newMaster.getId() : Guid.Empty;
    if (isLastMaster) {
        executeInNewTransaction(() -> {
            getCompensationContext().snapshotEntityStatus(getStoragePool());
            getStoragePool().setStatus(StoragePoolStatus.Maintenance);
            storagePoolDao.updateStatus(getStoragePool().getId(), getStoragePool().getStatus());
            getCompensationContext().stateChanged();
            return null;
        });
        StoragePoolStatusHandler.poolStatusChanged(getStoragePool().getId(), getStoragePool().getStatus());
        getStorageDomain().getStorageDynamicData().setAvailableDiskSize(null);
        getStorageDomain().getStorageDynamicData().setUsedDiskSize(null);
    }
    if (!getParameters().isInactive()) {
        runVdsCommand(VDSCommandType.DeactivateStorageDomain, new DeactivateStorageDomainVDSCommandParameters(getStoragePool().getId(), getStorageDomain().getId(), newMasterId, getStoragePool().getMasterDomainVersion()));
    }
    freeLock();
    VDS spm = null;
    if (getStoragePool().getSpmVdsId() != null) {
        spm = vdsDao.get(getStoragePool().getSpmVdsId());
    }
    if (isLastMaster) {
        if (spm != null) {
            final VDSReturnValue stopSpmReturnValue = runVdsCommand(VDSCommandType.SpmStopOnIrs, new SpmStopOnIrsVDSCommandParameters(getStoragePool().getId()));
            if (!stopSpmReturnValue.getSucceeded()) {
                // no need to continue because DisconnectStoragePool will
                // fail if host is SPM
                log.error("Aborting execution due to failure to stop SPM");
                setSucceeded(false);
                return;
            }
            runVdsCommand(VDSCommandType.DisconnectStoragePool, new DisconnectStoragePoolVDSCommandParameters(spm.getId(), getStoragePool().getId(), spm.getVdsSpmId()));
        }
        runSynchronizeOperation(new DisconnectStoragePoolAsyncOperationFactory());
    }
    if (!getParameters().isInactive()) {
        getEventQueue().submitEventSync(new Event(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), null, EventType.POOLREFRESH, ""), () -> {
            runSynchronizeOperation(new AfterDeactivateSingleAsyncOperationFactory(), isLastMaster, newMasterId);
            return null;
        });
        if (spm != null) {
            getStorageHelper(getStorageDomain()).disconnectStorageFromDomainByVdsId(getStorageDomain(), spm.getId());
        }
    }
    executeInNewTransaction(() -> {
        if (getParameters().isInactive()) {
            map.setStatus(StorageDomainStatus.Inactive);
        } else if (isLastMaster) {
            map.setStatus(StorageDomainStatus.Maintenance);
        } else {
            log.info("Domain '{}' will remain in '{}' status until deactivated on all hosts", getStorageDomain().getId(), map.getStatus());
        }
        storagePoolIsoMapDao.updateStatus(map.getId(), map.getStatus());
        if (newMaster != null) {
            StoragePoolIsoMap mapOfNewMaster = newMaster.getStoragePoolIsoMapData();
            mapOfNewMaster.setStatus(StorageDomainStatus.Active);
            storagePoolIsoMapDao.updateStatus(mapOfNewMaster.getId(), mapOfNewMaster.getStatus());
        }
        return null;
    });
    if (!getParameters().isSkipChecks()) {
        notifyAsyncTasks();
    }
    setSucceeded(true);
}
Also used : DeactivateStorageDomainVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DeactivateStorageDomainVDSCommandParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) SpmStopOnIrsVDSCommandParameters(org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId) DisconnectStoragePoolAsyncOperationFactory(org.ovirt.engine.core.bll.storage.pool.DisconnectStoragePoolAsyncOperationFactory) Event(org.ovirt.engine.core.common.eventqueue.Event) Guid(org.ovirt.engine.core.compat.Guid) DisconnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters) AfterDeactivateSingleAsyncOperationFactory(org.ovirt.engine.core.bll.storage.pool.AfterDeactivateSingleAsyncOperationFactory) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with SpmStopOnIrsVDSCommandParameters

use of org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters in project ovirt-engine by oVirt.

the class StorageHandlingCommandBase method handleDestroyStoragePoolCommand.

protected void handleDestroyStoragePoolCommand() {
    try {
        runVdsCommand(VDSCommandType.DestroyStoragePool, new IrsBaseVDSCommandParameters(getStoragePool().getId()));
    } catch (EngineException e) {
        try {
            TransactionSupport.executeInNewTransaction(() -> {
                runVdsCommand(VDSCommandType.SpmStopOnIrs, new SpmStopOnIrsVDSCommandParameters(getStoragePool().getId()));
                return null;
            });
        } catch (Exception e1) {
            log.error("Failed destroy storage pool with id '{}' and after that failed to stop spm: {}", getStoragePoolId(), e1.getMessage());
            log.debug("Exception", e1);
        }
        throw e;
    }
}
Also used : IrsBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters) SpmStopOnIrsVDSCommandParameters(org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) EngineException(org.ovirt.engine.core.common.errors.EngineException) IOException(java.io.IOException)

Aggregations

SpmStopOnIrsVDSCommandParameters (org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters)3 IOException (java.io.IOException)1 AfterDeactivateSingleAsyncOperationFactory (org.ovirt.engine.core.bll.storage.pool.AfterDeactivateSingleAsyncOperationFactory)1 DisconnectStoragePoolAsyncOperationFactory (org.ovirt.engine.core.bll.storage.pool.DisconnectStoragePoolAsyncOperationFactory)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)1 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 Event (org.ovirt.engine.core.common.eventqueue.Event)1 DeactivateStorageDomainVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.DeactivateStorageDomainVDSCommandParameters)1 DisconnectStoragePoolVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters)1 IrsBaseVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 Guid (org.ovirt.engine.core.compat.Guid)1