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