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);
}
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);
}
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();
}
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());
}
Aggregations