Search in sources :

Example 36 with StoragePoolIsoMap

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));
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) EngineException(org.ovirt.engine.core.common.errors.EngineException) Event(org.ovirt.engine.core.common.eventqueue.Event)

Example 37 with StoragePoolIsoMap

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();
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ReconstructMasterVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ReconstructMasterVDSCommandParameters) DisconnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters)

Example 38 with StoragePoolIsoMap

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());
    }
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Test(org.junit.Test)

Example 39 with StoragePoolIsoMap

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"));
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 40 with StoragePoolIsoMap

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);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Test(org.junit.Test)

Aggregations

StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)40 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15 Guid (org.ovirt.engine.core.compat.Guid)14 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)9 Test (org.junit.Test)8 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)8 ArrayList (java.util.ArrayList)6 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)6 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Pair (org.ovirt.engine.core.common.utils.Pair)4 HashMap (java.util.HashMap)3 List (java.util.List)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 StorageDomainDynamic (org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Event (org.ovirt.engine.core.common.eventqueue.Event)3 EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)3 ConnectStoragePoolVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)3