Search in sources :

Example 6 with LUNStorageServerConnectionMap

use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.

the class SyncLunsInfoForBlockStorageDomainCommand method refreshLunsConnections.

protected void refreshLunsConnections(List<LUNs> lunsFromVgInfo) {
    for (LUNs lunFromVgInfo : lunsFromVgInfo) {
        // Update lun connections map
        for (StorageServerConnections connection : lunFromVgInfo.getLunConnections()) {
            StorageServerConnections connectionFromDb = storageServerConnectionDao.getForIqn(connection.getIqn());
            if (connectionFromDb == null) {
                // Shouldn't happen
                continue;
            }
            LUNStorageServerConnectionMap lunConnection = new LUNStorageServerConnectionMap(lunFromVgInfo.getLUNId(), connectionFromDb.getId());
            if (storageServerConnectionLunMapDao.get(lunConnection.getId()) == null) {
                storageServerConnectionLunMapDao.save(lunConnection);
            }
        }
    }
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)

Example 7 with LUNStorageServerConnectionMap

use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.

the class LunHelper method proceedLUNInDb.

public void proceedLUNInDb(final LUNs lun, StorageType storageType, String volumeGroupId) {
    lun.setVolumeGroupId(volumeGroupId);
    if (lunDao.get(lun.getLUNId()) == null) {
        lunDao.save(lun);
    } else if (!volumeGroupId.isEmpty()) {
        lunDao.update(lun);
    }
    if (storageType == StorageType.FCP) {
        // No need to handle connections (FCP storage doesn't utilize connections).
        return;
    }
    for (StorageServerConnections connection : lun.getLunConnections()) {
        StorageServerConnections dbConnection = iscsiStorageHelper.findConnectionWithSameDetails(connection);
        if (dbConnection == null) {
            connection.setId(Guid.newGuid().toString());
            connection.setStorageType(storageType);
            storageServerConnectionDao.save(connection);
        } else {
            connection.setId(dbConnection.getId());
        }
        if (storageServerConnectionLunMapDao.get(new LUNStorageServerConnectionMapId(lun.getLUNId(), connection.getId())) == null) {
            storageServerConnectionLunMapDao.save(new LUNStorageServerConnectionMap(lun.getLUNId(), connection.getId()));
        }
    }
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LUNStorageServerConnectionMapId(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMapId) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)

Example 8 with LUNStorageServerConnectionMap

use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.

the class StorageServerConnectionLunMapDaoTest method testGetAllByLunId.

@Test
public void testGetAllByLunId() {
    List<LUNStorageServerConnectionMap> result = dao.getAll(existingEntity.getId().lunId);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (LUNStorageServerConnectionMap mapping : result) {
        assertEquals(existingEntity.getId().lunId, mapping.getId().lunId);
    }
}
Also used : LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap) Test(org.junit.Test)

Example 9 with LUNStorageServerConnectionMap

use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.

the class AttachStorageServerConnectionToStorageDomainCommandTest method executeCommandNotFirstDummyLun.

@Test
public void executeCommandNotFirstDummyLun() {
    LUNs dummyLun = new LUNs();
    dummyLun.setLUNId(BusinessEntitiesDefinitions.DUMMY_LUN_ID_PREFIX + domain.getId());
    when(lunDao.get(dummyLun.getLUNId())).thenReturn(dummyLun);
    List<StorageServerConnections> connectionsForDomain = new ArrayList<>();
    StorageServerConnections connection = new StorageServerConnections();
    connection.setId(Guid.newGuid().toString());
    connection.setStorageType(StorageType.ISCSI);
    connection.setIqn("iqn.1.2.3.4.com");
    connection.setConnection("123.345.266.255");
    connectionsForDomain.add(connection);
    when(connectionDao.getAllForDomain(domain.getId())).thenReturn(connectionsForDomain);
    // dummy lun already exists, thus no need to save
    verify(lunDao, never()).save(dummyLun);
    verify(lunMapDao, never()).save(new LUNStorageServerConnectionMap());
    command.executeCommand();
    CommandAssertUtils.checkSucceeded(command, true);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Aggregations

LUNStorageServerConnectionMap (org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)9 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)6 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)6 ArrayList (java.util.ArrayList)4 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)3 Test (org.junit.Test)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 ConnectHostToStoragePoolServersParameters (org.ovirt.engine.core.common.action.ConnectHostToStoragePoolServersParameters)1 HostStoragePoolParametersBase (org.ovirt.engine.core.common.action.HostStoragePoolParametersBase)1