use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.
the class GetLunsByVgIdQuery method getStorageType.
private StorageType getStorageType(List<LUNs> luns) {
StorageType storageType = null;
if (!luns.isEmpty()) {
LUNs lun = luns.get(0);
List<LUNStorageServerConnectionMap> lunConnections = storageServerConnectionLunMapDao.getAll(lun.getLUNId());
if (!lunConnections.isEmpty()) {
StorageServerConnections connection = storageServerConnectionDao.get(lunConnections.get(0).getStorageServerConnection());
storageType = connection.getStorageType();
} else {
storageType = StorageType.FCP;
}
}
return storageType;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method isConnectSucceeded.
@Override
public boolean isConnectSucceeded(final Map<String, String> returnValue, List<StorageServerConnections> connections) {
boolean result = true;
List<String> failedConnectionsList = returnValue.keySet().stream().filter(a -> !"0".equals(returnValue.get(a))).collect(Collectors.toList());
for (String failedConnection : failedConnectionsList) {
List<LUNs> failedLuns = lunDao.getAllForStorageServerConnection(failedConnection);
if (!failedLuns.isEmpty()) {
for (LUNs lun : failedLuns) {
// TODO: check if LUNs in the same pool.
List<String> strings = storageServerConnectionLunMapDao.getAll(lun.getLUNId()).stream().map(LUNStorageServerConnectionMap::getStorageServerConnection).collect(Collectors.toList());
if (CollectionUtils.subtract(strings, failedConnectionsList).size() == 0) {
// At case of failure the appropriate log message will be
// added
log.info("The lun with id '{}' was reported as problematic", lun.getPhysicalVolumeId());
for (String connectionFailed : failedConnectionsList) {
String connectionField = addToAuditLogErrorMessage(connectionFailed, returnValue.get(connectionFailed), connections, lun);
printLog(log, connectionField, returnValue.get(connectionFailed));
}
return false;
}
}
} else {
result = false;
printLog(log, failedConnection, returnValue.get(failedConnection));
}
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.
the class GetLunsByVgIdQueryTest method expectGetLunsMap.
private void expectGetLunsMap(String lunId, String cnxId) {
List<LUNStorageServerConnectionMap> ret = new ArrayList<>();
LUNStorageServerConnectionMap map = new LUNStorageServerConnectionMap();
map.setLunId(lunId);
map.setStorageServerConnection(cnxId);
ret.add(map);
when(storageServerConnectionLunMapDao.getAll(lunId)).thenReturn(ret);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.
the class AttachStorageConnectionToStorageDomainCommand method executeCommand.
@Override
protected void executeCommand() {
// Create a dummy lun
LUNs dummyLun = createDummyLun();
// Create storage server connection mapping
LUNStorageServerConnectionMap connectionMapRecord = new LUNStorageServerConnectionMap(dummyLun.getLUNId(), getParameters().getStorageConnectionId());
List<StorageServerConnections> connectionsForDomain;
if (lunDao.get(dummyLun.getLUNId()) == null) {
lunDao.save(dummyLun);
// Save connection maps when creating the dummy lun for the first time
connectionsForDomain = storageServerConnectionDao.getAllForDomain(getStorageDomainId());
for (StorageServerConnections connection : connectionsForDomain) {
saveConnection(new LUNStorageServerConnectionMap(dummyLun.getLUNId(), connection.getId()));
}
}
// Save new connection map
saveConnection(connectionMapRecord);
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap in project ovirt-engine by oVirt.
the class GetLunsByVgIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
List<LUNs> luns = lunDao.getAllForVolumeGroup(getVgId());
List<LUNs> nonDummyLuns = new ArrayList<>(luns.size());
StorageType storageType = getStorageType(luns);
Map<String, LUNs> lunsFromDeviceMap = getLunsFromDeviceMap(storageType);
for (LUNs lun : luns) {
// Filter dummy luns
if (lun.getLUNId().startsWith(BusinessEntitiesDefinitions.DUMMY_LUN_ID_PREFIX)) {
continue;
}
nonDummyLuns.add(lun);
// Update LUN's connections
for (LUNStorageServerConnectionMap map : storageServerConnectionLunMapDao.getAll(lun.getLUNId())) {
addConnection(lun, storageServerConnectionDao.get(map.getStorageServerConnection()));
}
// Update LUN's 'PathsDictionary' by 'lunsFromDeviceList'
LUNs lunFromDeviceList = lunsFromDeviceMap.get(lun.getLUNId());
if (lunFromDeviceList != null) {
lun.setPathsDictionary(lunFromDeviceList.getPathsDictionary());
lun.setPathsCapacity(lunFromDeviceList.getPathsCapacity());
lun.setPvSize(lunFromDeviceList.getPvSize());
}
}
setReturnValue(nonDummyLuns);
}
Aggregations