use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class RecoveryStoragePoolCommand method executeCommand.
@Override
protected void executeCommand() {
StorageDomain newMasterDomain = loadTargetedMasterDomain();
if (storageHelperDirector.getItem(newMasterDomain.getStorageType()).connectStorageToDomainByVdsId(newMasterDomain, getVds().getId())) {
getEventQueue().submitEventSync(new Event(getParameters().getStoragePoolId(), getParameters().getNewMasterDomainId(), null, EventType.RECOVERY, ""), () -> {
getParameters().setStorageDomainId(getMasterDomainIdFromDb());
StoragePoolIsoMap domainPoolMap = new StoragePoolIsoMap(getParameters().getNewMasterDomainId(), getParameters().getStoragePoolId(), StorageDomainStatus.Active);
storagePoolIsoMapDao.save(domainPoolMap);
getParameters().setVdsId(getVds().getId());
ActionReturnValue returnVal = runInternalAction(ActionType.ReconstructMasterDomain, getParameters(), cloneContextAndDetachFromParent());
boolean reconstructVerbExecuted = (returnVal.getActionReturnValue() != null) ? (Boolean) returnVal.getActionReturnValue() : false;
storagePoolDao.updateStatus(getStoragePool().getId(), StoragePoolStatus.NonResponsive);
if (!reconstructVerbExecuted) {
storagePoolIsoMapDao.remove(domainPoolMap.getId());
}
if (returnVal.getSucceeded()) {
updateStorageDomainFormatIfNeeded(loadTargetedMasterDomain());
}
setSucceeded(returnVal.getSucceeded());
return new EventResult(reconstructVerbExecuted, EventType.RECONSTRUCT);
});
} else {
getReturnValue().setFault(new EngineFault(new EngineException(EngineError.StorageServerConnectionError, "Failed to connect storage"), EngineError.StorageServerConnectionError));
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class ReconstructMasterDomainCommand method reconstructMaster.
protected boolean reconstructMaster() {
isLastMaster = proceedStorageDomainTreatmentByDomainType(getNewMasterStorageDomain(), false);
// To issue a reconstructMaster you need to set the domain inactive unless the selected domain is the current master
if (getParameters().isInactive() && !getStorageDomain().getId().equals(getNewMasterStorageDomainId())) {
executeInNewTransaction(() -> {
setStorageDomainStatus(StorageDomainStatus.Inactive, getCompensationContext());
calcStoragePoolStatusByDomainsStatus();
getCompensationContext().stateChanged();
return null;
});
}
if (isLastMaster) {
return stopSpm();
}
boolean commandSucceeded = stopSpm();
if (commandSucceeded) {
commandSucceeded = runVdsCommand(VDSCommandType.DisconnectStoragePool, new DisconnectStoragePoolVDSCommandParameters(getVds().getId(), getStoragePool().getId(), getVds().getVdsSpmId())).getSucceeded();
}
if (!commandSucceeded) {
return false;
}
List<StoragePoolIsoMap> domains = storagePoolIsoMapDao.getAllForStoragePool(getStoragePool().getId());
// set to true here in case of failure in executing/getting answer from the reconstruct vds command,
// unless we know that the command failed we assume that it succeeded (use by RecoveryStoragePool command in
// order to avoid detaching domain that is already part of the pool in vdsm).
setActionReturnValue(true);
return runVdsCommand(VDSCommandType.ReconstructMaster, new ReconstructMasterVDSCommandParameters(getVds().getId(), getVds().getVdsSpmId(), getStoragePool().getId(), getStoragePool().getName(), getNewMasterStorageDomainId(), domains, getStoragePool().getMasterDomainVersion())).getSucceeded();
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class StoragePoolIsoMapDaoTest method testGetAllStoragePoolIsoMapsForStoragePool.
@Test
public void testGetAllStoragePoolIsoMapsForStoragePool() {
List<StoragePoolIsoMap> result = dao.getAllForStoragePool(FixturesTool.DATA_CENTER);
assertNotNull(result);
assertFalse(result.isEmpty());
for (StoragePoolIsoMap mapping : result) {
assertEquals(FixturesTool.DATA_CENTER, mapping.getStoragePoolId());
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommandTest method updateConnectionOfDomains.
@Test
public void updateConnectionOfDomains() {
StorageServerConnections iscsiConnection = createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "3260", "user1", "mypassword123");
LUNs lun1 = new LUNs();
lun1.setLUNId("3600144f09dbd05000000517e730b1212");
lun1.setStorageDomainName("storagedomain4");
Guid storageDomainId = Guid.newGuid();
lun1.setStorageDomainId(storageDomainId);
lun1.setVolumeGroupId(Guid.newGuid().toString());
List<LUNs> luns = Collections.singletonList(lun1);
parameters.setStorageServerConnection(iscsiConnection);
when(storageConnDao.get(iscsiConnection.getId())).thenReturn(iscsiConnection);
doReturn(luns).when(command).getLuns();
StorageDomain domain1 = new StorageDomain();
domain1.setStorage(iscsiConnection.getConnection());
domain1.setStatus(StorageDomainStatus.Active);
domain1.setStorageDomainSharedStatus(StorageDomainSharedStatus.Active);
domain1.setId(storageDomainId);
domain1.setStorageName("storagedomain4");
when(storageDomainDao.get(storageDomainId)).thenReturn(domain1);
when(storagePoolIsoMapDao.getAllForStorage(storageDomainId)).thenReturn(Collections.singletonList(new StoragePoolIsoMap(storageDomainId, Guid.newGuid(), StorageDomainStatus.Active)));
List<String> messages = ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
assertTrue(messages.contains("$domainNames storagedomain4"));
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommandTest method failUpdateStats.
@Test
public void failUpdateStats() {
StorageServerConnections newNFSConnection = createNFSConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data2", StorageType.NFS, NfsVersion.V4, 300, 0);
parameters.setStorageServerConnection(newNFSConnection);
VDSReturnValue returnValueUpdate = new VDSReturnValue();
returnValueUpdate.setSucceeded(false);
StorageDomain domain = createDomain();
initDomainListForConnection(newNFSConnection.getId(), domain);
StorageDomainDynamic domainDynamic = new StorageDomainDynamic();
StoragePoolIsoMap map = new StoragePoolIsoMap();
doReturn(Collections.singletonList(map)).when(command).getStoragePoolIsoMap(domain);
doReturn(returnValueUpdate).when(command).getStatsForDomain(domain);
doReturn(true).when(command).connectToStorage();
doNothing().when(command).changeStorageDomainStatusInTransaction(StorageDomainStatus.Locked);
doNothing().when(command).disconnectFromStorage();
command.executeCommand();
CommandAssertUtils.checkSucceeded(command, true);
verify(storageDomainDynamicDao, never()).update(domainDynamic);
}
Aggregations