Search in sources :

Example 1 with ReconstructMasterParameters

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

the class ForceRemoveStorageDomainCommand method executeCommand.

@Override
protected void executeCommand() {
    if (isAttachedStorageDomain() && hasRunningHostsInPool() && !isLastStorageInPool()) {
        try {
            // If master and there are more storage domains in the DC try to reconstruct.
            if (getStorageDomain().getStorageDomainType() == StorageDomainType.Master) {
                ReconstructMasterParameters reconstructMasterParameters = new ReconstructMasterParameters(getStoragePool().getId(), getStorageDomain().getId(), false);
                reconstructMasterParameters.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
                runInternalAction(ActionType.ReconstructMasterDomain, reconstructMasterParameters);
            }
            // try to force detach first
            DetachStorageDomainVDSCommandParameters detachParameters = new DetachStorageDomainVDSCommandParameters(getStoragePool().getId(), getStorageDomain().getId(), Guid.Empty, -1);
            detachParameters.setForce(true);
            runVdsCommand(VDSCommandType.DetachStorageDomain, detachParameters);
        } catch (RuntimeException ex) {
            log.error("Could not force detach storage domain '{}': {}", getStorageDomain().getStorageName(), ex.getMessage());
            log.debug("Exception", ex);
        }
    } else {
        log.info("Avoid running host operations like reconstruct/detach on force remove for storage domain '{}'." + "Storage domain attached to pool: '{}'" + "Active Hosts exists in DC: '{}'", getStorageDomain().getStorageName(), isAttachedStorageDomain(), hasRunningHostsInPool());
    }
    releaseStorageDomainMacPool(getVmsOnlyOnStorageDomain());
    storageHelperDirector.getItem(getStorageDomain().getStorageType()).storageDomainRemoved(getStorageDomain().getStorageStaticData());
    storageDomainDao.remove(getStorageDomain().getId());
    if (isAttachedStorageDomain()) {
        // if iso reset path for pool
        if (getStorageDomain().getStorageDomainType() == StorageDomainType.ISO) {
            // todo: when iso in multiple pools will be implemented, we
            // should reset iso path for all related pools
            runVdsCommand(VDSCommandType.ResetISOPath, new IrsBaseVDSCommandParameters(getStoragePool().getId()));
        }
        if (getStorageDomain().getStorageDomainType() == StorageDomainType.Master) {
            calcStoragePoolStatusByDomainsStatus();
        }
    }
    setSucceeded(true);
}
Also used : IrsBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters) DetachStorageDomainVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DetachStorageDomainVDSCommandParameters) ReconstructMasterParameters(org.ovirt.engine.core.common.action.ReconstructMasterParameters)

Example 2 with ReconstructMasterParameters

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

the class VdsEventListener method masterDomainNotOperational.

@Override
public EventResult masterDomainNotOperational(Guid storageDomainId, Guid storagePoolId, boolean isReconstructToInactiveDomains, boolean canReconstructToCurrentMaster) {
    ActionParametersBase parameters = new ReconstructMasterParameters(storagePoolId, storageDomainId, true, isReconstructToInactiveDomains, canReconstructToCurrentMaster);
    boolean isSucceeded = backend.runInternalAction(ActionType.ReconstructMasterDomain, parameters, ExecutionHandler.createInternalJobContext()).getSucceeded();
    return new EventResult(isSucceeded, EventType.RECONSTRUCT);
}
Also used : EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ReconstructMasterParameters(org.ovirt.engine.core.common.action.ReconstructMasterParameters)

Example 3 with ReconstructMasterParameters

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

the class ReconstructMasterDomainCommandTest method setUp.

@Before
public void setUp() {
    cmd = spy(new ReconstructMasterDomainCommand<>(new ReconstructMasterParameters(), null));
    initializeStorageDomains();
    initializeStoragePool();
    initializeStoragePoolValidator();
    doReturn(true).when(cmd).initializeVds();
}
Also used : ReconstructMasterParameters(org.ovirt.engine.core.common.action.ReconstructMasterParameters) Before(org.junit.Before)

Example 4 with ReconstructMasterParameters

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

the class DataCenterListModel method onRecover.

public void onRecover() {
    final ConfirmationModel windowModel = (ConfirmationModel) getWindow();
    if (!windowModel.validate()) {
        return;
    }
    AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(storageDomainList -> {
        for (StorageDomain a : storageDomainList) {
            if (a.getStorageDomainType() == StorageDomainType.Master) {
                break;
            }
        }
        List<StorageDomain> items = new ArrayList<>();
        for (Object item : windowModel.getItems()) {
            EntityModel<StorageDomain> a = (EntityModel<StorageDomain>) item;
            if (a.getIsSelected()) {
                items.add(a.getEntity());
            }
        }
        if (items.size() > 0) {
            if (windowModel.getProgress() != null) {
                return;
            }
            ArrayList<ActionParametersBase> parameters = new ArrayList<>();
            for (StorageDomain a : items) {
                parameters.add(new ReconstructMasterParameters(getSelectedItem().getId(), a.getId()));
            }
            windowModel.startProgress();
            Frontend.getInstance().runMultipleAction(ActionType.RecoveryStoragePool, parameters, result -> {
                ConfirmationModel localModel = (ConfirmationModel) result.getState();
                localModel.stopProgress();
                cancel();
            }, windowModel);
        } else {
            cancel();
        }
    }), getSelectedItem().getId());
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) Arrays(java.util.Arrays) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Inject(com.google.inject.Inject) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) NameQueryParameters(org.ovirt.engine.core.common.queries.NameQueryParameters) List(java.util.List) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) ReconstructMasterParameters(org.ovirt.engine.core.common.action.ReconstructMasterParameters) DataCenterCpuQosListModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.qos.DataCenterCpuQosListModel) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) DataCenterHostNetworkQosListModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.qos.DataCenterHostNetworkQosListModel) Frontend(org.ovirt.engine.ui.frontend.Frontend) DataCenterStorageQosListModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.qos.DataCenterStorageQosListModel) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) VersionStorageFormatUtil(org.ovirt.engine.core.common.utils.VersionStorageFormatUtil) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Quota(org.ovirt.engine.core.common.businessentities.Quota) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ReconstructMasterParameters(org.ovirt.engine.core.common.action.ReconstructMasterParameters)

Aggregations

ReconstructMasterParameters (org.ovirt.engine.core.common.action.ReconstructMasterParameters)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Before (org.junit.Before)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 StoragePoolManagementParameter (org.ovirt.engine.core.common.action.StoragePoolManagementParameter)1 StoragePoolParametersBase (org.ovirt.engine.core.common.action.StoragePoolParametersBase)1 Quota (org.ovirt.engine.core.common.businessentities.Quota)1 QuotaEnforcementTypeEnum (org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StorageDomainSharedStatus (org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus)1 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)1 StorageFormatType (org.ovirt.engine.core.common.businessentities.StorageFormatType)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 StoragePoolStatus (org.ovirt.engine.core.common.businessentities.StoragePoolStatus)1