use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class GetUnregisteredBlockStorageDomainsQuery method getStorageDomainsByVolumeGroupIds.
/**
* Create StorageDomain objects according to the specified VG-IDs list.
*
* @param vgIDs the VG-IDs list
*
* @return storage domains list
*/
@SuppressWarnings("unchecked")
protected List<StorageDomain> getStorageDomainsByVolumeGroupIds(List<String> vgIDs) {
List<StorageDomain> storageDomains = new ArrayList<>();
// Get existing PhysicalVolumes.
Set<String> existingLunIds = lunDao.getAll().stream().map(LUNs::getId).collect(Collectors.toSet());
for (String vgID : vgIDs) {
VDSReturnValue returnValue;
try {
returnValue = executeGetVGInfo(new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), vgID));
} catch (RuntimeException e) {
log.error("Could not get info for VG ID: '{}': {}", vgID, e.getMessage());
log.debug("Exception", e);
continue;
}
ArrayList<LUNs> luns = (ArrayList<LUNs>) returnValue.getReturnValue();
if (luns.stream().anyMatch(l -> existingLunIds.contains(l.getId()))) {
log.info("There are existing luns in the system which are part of VG id '{}'", vgID);
continue;
}
// Get storage domain ID by a representative LUN
LUNs lun = luns.get(0);
Guid storageDomainId = lun.getStorageDomainId();
// Get storage domain using GetStorageDomainInfo
StorageDomain storageDomain = getStorageDomainById(storageDomainId);
if (storageDomain != null) {
storageDomains.add(storageDomain);
}
}
return storageDomains;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class ImportHostedEngineStorageDomainCommand method discoverBlockConnectionDetails.
private void discoverBlockConnectionDetails() {
// get device list
VDSReturnValue getDeviceList = runVdsCommand(VDSCommandType.GetDeviceList, new GetDeviceListVDSCommandParameters(getParameters().getVdsId(), heStorageDomain.getStorageType()));
if (getDeviceList.getSucceeded() && getDeviceList.getReturnValue() != null && heStorageDomain.getStorageStaticData().getStorage() != null) {
for (LUNs lun : (ArrayList<LUNs>) getDeviceList.getReturnValue()) {
// match a lun vgid to the domain vgid.
if (heStorageDomain.getStorage().equals(lun.getVolumeGroupId())) {
// found a lun. Use its connection details
heStorageDomain.getStorageStaticData().setConnection(lun.getLunConnections().get(0));
setSucceeded(true);
break;
}
}
if (!getSucceeded()) {
log.error("There are no luns with VG that match the SD VG '{}'." + " Connections details are missing. completing this automatic import");
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class GetDeviceListQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
if (getParameters().isValidateHostStatus() && !isActiveVds()) {
return;
}
List<LUNs> returnValue = new ArrayList<>();
// Get Device List
GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(getParameters().getId(), getParameters().getStorageType(), getParameters().isCheckStatus(), getParameters().getLunIds());
List<LUNs> luns = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
// Get LUNs from DB
List<LUNs> lunsFromDb = lunDao.getAll();
Map<String, LUNs> lunsFromDbById = lunsFromDb.stream().collect(Collectors.toMap(LUNs::getLUNId, Function.identity()));
for (LUNs lun : luns) {
if (lunsFromDbById.containsKey(lun.getLUNId())) {
LUNs lunFromDb = lunsFromDbById.get(lun.getLUNId());
lun.setDiskId(lunFromDb.getDiskId());
lun.setDiskAlias(lunFromDb.getDiskAlias());
lun.setStorageDomainId(lunFromDb.getStorageDomainId());
lun.setStorageDomainName(lunFromDb.getStorageDomainName());
}
returnValue.add(lun);
}
getQueryReturnValue().setReturnValue(returnValue);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs 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);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class GetLunsByVgIdQuery method getLunsFromDeviceMap.
protected Map<String, LUNs> getLunsFromDeviceMap(StorageType storageType) {
Map<String, LUNs> lunsMap = new HashMap<>();
if (getParameters().getId() == null) {
return lunsMap;
}
GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(getParameters().getId(), storageType);
List<LUNs> lunsList = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
for (LUNs lun : lunsList) {
lunsMap.put(lun.getLUNId(), lun);
}
return lunsMap;
}
Aggregations