use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class SanStorageModelBase method getUsedLunsMessages.
public ArrayList<String> getUsedLunsMessages(List<LUNs> luns) {
ArrayList<String> usedLunsMessages = new ArrayList<>();
UIMessages messages = ConstantsManager.getInstance().getMessages();
for (LUNs lun : luns) {
if (lun.getStatus() == LunStatus.Used) {
String reason = null;
if (lun.getVolumeGroupId() != null && !lun.getVolumeGroupId().isEmpty()) {
reason = messages.lunUsedByVG(lun.getVolumeGroupId());
}
usedLunsMessages.add(reason == null ? lun.getLUNId() : messages.usedLunIdReason(lun.getLUNId(), reason));
}
}
return usedLunsMessages;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs 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.LUNs in project ovirt-engine by oVirt.
the class RefreshLunsSizeCommand method updateLunsInDb.
private void updateLunsInDb(List<LUNs> lunsToUpdateInDb) {
TransactionSupport.executeInNewTransaction(() -> {
CompensationContext context = getCompensationContext();
context.snapshotEntities(getParameters().getLunsList());
lunDao.updateAllInBatch(lunsToUpdateInDb);
context.stateChanged();
return null;
});
log.debug("LUNs with IDs: [" + lunsToUpdateInDb.stream().map(LUNs::getLUNId).collect(Collectors.joining(", ")) + "] were updated in the DB.");
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class BackendStorageDomainResourceTest method setUpLuns.
protected List<LUNs> setUpLuns() {
LUNs lun = new LUNs();
lun.setLUNId(GUIDS[2].toString());
List<LUNs> luns = new ArrayList<>();
luns.add(lun);
return luns;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class GetDeviceListVDSCommand method parseLun.
protected static LUNs parseLun(Map<String, Object> xlun, Version compatibilityVersion) {
LUNs lun = new LUNs();
if (xlun.containsKey("GUID")) {
lun.setLUNId(xlun.get("GUID").toString());
}
if (xlun.containsKey("pvUUID")) {
lun.setPhysicalVolumeId(xlun.get("pvUUID").toString());
}
if (xlun.containsKey("vgUUID")) {
lun.setVolumeGroupId(xlun.get("vgUUID").toString());
} else {
lun.setVolumeGroupId("");
}
if (xlun.containsKey("vgName")) {
lun.setStorageDomainId(Guid.createGuidFromString(xlun.get("vgName").toString()));
}
if (xlun.containsKey("serial")) {
lun.setSerial(xlun.get("serial").toString());
}
if (xlun.containsKey(PATHSTATUS)) {
Object[] temp = (Object[]) xlun.get(PATHSTATUS);
Map<String, Object>[] pathStatus = null;
if (temp != null) {
lun.setPathsDictionary(new HashMap<>());
lun.setPathsCapacity(new HashMap<>());
pathStatus = new Map[temp.length];
for (int i = 0; i < temp.length; i++) {
pathStatus[i] = (Map<String, Object>) temp[i];
}
for (Map xcon : pathStatus) {
if (xcon.containsKey(LUN_FIELD)) {
lun.setLunMapping(Integer.parseInt(xcon.get(LUN_FIELD).toString()));
}
if (xcon.containsKey(PHYSICAL_DEVICE_FIELD) && xcon.containsKey(DEVICE_STATE_FIELD)) {
// set name and state - if active true, otherwise false
lun.getPathsDictionary().put(xcon.get(PHYSICAL_DEVICE_FIELD).toString(), DEVICE_ACTIVE_VALUE.equals(xcon.get(DEVICE_STATE_FIELD).toString()));
}
if (xcon.containsKey(PHYSICAL_DEVICE_FIELD) && xcon.containsKey(DEVICE_PATH_CAPACITY_FIELD)) {
// set name and capacity
Long size = IrsBrokerCommand.assignLongValue(xcon, DEVICE_PATH_CAPACITY_FIELD);
if (size != null) {
lun.getPathsCapacity().put(xcon.get(PHYSICAL_DEVICE_FIELD).toString(), SizeConverter.convert(size, SizeConverter.SizeUnit.BYTES, SizeConverter.SizeUnit.GiB).intValue());
}
}
}
}
}
if (xlun.containsKey("vendorID")) {
lun.setVendorId(xlun.get("vendorID").toString());
}
if (xlun.containsKey("productID")) {
lun.setProductId(xlun.get("productID").toString());
}
lun.setLunConnections(new ArrayList<>());
if (xlun.containsKey("pathlist")) {
Object[] temp = (Object[]) xlun.get("pathlist");
Map[] pathList = null;
if (temp != null) {
pathList = new Map[temp.length];
for (int i = 0; i < temp.length; i++) {
pathList[i] = (Map<String, Object>) temp[i];
}
for (Map xcon : pathList) {
lun.getLunConnections().add(parseConnection(xcon));
}
}
}
Long size = IrsBrokerCommand.assignLongValue(xlun, "devcapacity");
if (size == null) {
size = IrsBrokerCommand.assignLongValue(xlun, "capacity");
}
if (size != null) {
lun.setDeviceSize((int) (size / SizeConverter.BYTES_IN_GB));
}
if (xlun.containsKey("pvsize")) {
String pvSizeStr = (String) xlun.get("pvsize");
if (!StringUtils.isEmpty(pvSizeStr)) {
Long pvSize = IrsBrokerCommand.assignLongValue(xlun, "pvsize");
if (pvSize != null) {
lun.setPvSize(SizeConverter.convert(pvSize, SizeConverter.SizeUnit.BYTES, SizeConverter.SizeUnit.GiB).intValue());
}
}
}
if (xlun.containsKey("pe_count")) {
lun.setPeCount(IrsBrokerCommand.assignLongValue(xlun, "pe_count"));
}
if (xlun.containsKey("pe_alloc_count")) {
lun.setPeAllocatedCount(IrsBrokerCommand.assignLongValue(xlun, "pe_alloc_count"));
}
if (FeatureSupported.passDiscardSupported(compatibilityVersion)) {
if (xlun.containsKey("discard_max_bytes")) {
lun.setDiscardMaxSize(((Number) xlun.get("discard_max_bytes")).longValue());
}
}
if (xlun.containsKey("vendorID")) {
lun.setVendorName(xlun.get("vendorID").toString());
}
if (xlun.containsKey(DEVTYPE_FIELD)) {
String devtype = xlun.get(DEVTYPE_FIELD).toString();
if (DEVTYPE_VALUE_FCP.equalsIgnoreCase(devtype)) {
lun.setLunType(StorageType.FCP);
} else {
lun.setLunType(StorageType.ISCSI);
}
}
if (xlun.containsKey(STATUS)) {
String status = xlun.get(STATUS).toString();
lun.setStatus(EnumUtils.valueOf(LunStatus.class, status, true));
}
return lun;
}
Aggregations