use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class BackendStorageDomainsResource method getLunsWithInitializedStorageType.
private List<StorageServerConnections> getLunsWithInitializedStorageType(List<LUNs> luns, StorageType storageType) {
List<StorageServerConnections> existingStorageServerConnections = new ArrayList<>();
for (LUNs lun : luns) {
for (StorageServerConnections storageServerConnection : lun.getLunConnections()) {
storageServerConnection.setStorageType(storageType);
existingStorageServerConnections.add(storageServerConnection);
}
}
return existingStorageServerConnections;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs 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.LUNs in project ovirt-engine by oVirt.
the class AttachStorageConnectionToStorageDomainCommand method createDummyLun.
private LUNs createDummyLun() {
final LUNs dummyLun = new LUNs();
dummyLun.setLUNId(BusinessEntitiesDefinitions.DUMMY_LUN_ID_PREFIX + getStorageDomainId());
dummyLun.setVolumeGroupId(getStorageDomain().getStorage());
return dummyLun;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class ConnectAllHostsToLunCommand method connectVdsToLun.
/**
* The following method will connect all provided lund to all running host in pool
*
* @param luns
* - the luns which should be connected
* @return the map where the key is true/false value which means if connection successes/not successes and value is
* map of luns Ids -> connected hosts
*/
private Pair<Boolean, Map<String, List<Guid>>> connectVdsToLun(List<LUNs> luns) {
Map<String, List<Guid>> resultMap = new HashMap<>();
for (VDS vds : getAllRunningVdssInPool()) {
// try to connect vds to luns and getDeviceList in order to refresh them
for (LUNs lun : luns) {
if (!connectStorageToLunByVdsId(vds, lun)) {
log.error("Could not connect host '{}' to lun '{}'", vds.getName(), lun.getLUNId());
setVds(vds);
handleFailure(vds, lun);
return new Pair<>(Boolean.FALSE, resultMap);
} else {
List<Guid> hosts = resultMap.get(lun.getLUNId());
if (hosts == null) {
hosts = new ArrayList<>();
resultMap.put(lun.getLUNId(), hosts);
}
hosts.add(vds.getId());
}
}
// Refresh all connected luns to host
if (!validateConnectedLuns(vds, getParameters().getLunIds())) {
return new Pair<>(Boolean.FALSE, resultMap);
}
}
return new Pair<>(Boolean.TRUE, resultMap);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVmLunDisksData.
public static Map<String, LUNs> buildVmLunDisksData(Map<String, Object> struct) {
Map<String, Object> disks = (Map<String, Object>) struct.get(VdsProperties.vm_disks);
if (disks == null) {
return Collections.emptyMap();
}
Map<String, LUNs> lunsMap = new HashMap<>();
for (Object diskAsObj : disks.values()) {
Map<String, Object> disk = (Map<String, Object>) diskAsObj;
String lunGuidString = assignStringValue(disk, VdsProperties.lun_guid);
if (!StringUtils.isEmpty(lunGuidString)) {
LUNs lun = new LUNs();
lun.setLUNId(lunGuidString);
if (disk.containsKey(VdsProperties.disk_true_size)) {
long sizeInBytes = assignLongValue(disk, VdsProperties.disk_true_size);
int sizeInGB = SizeConverter.convert(sizeInBytes, SizeConverter.SizeUnit.BYTES, SizeConverter.SizeUnit.GiB).intValue();
lun.setDeviceSize(sizeInGB);
}
lunsMap.put(lunGuidString, lun);
}
}
return lunsMap;
}
Aggregations