@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", getLUNId()) .append("physicalVolumeId", getPhysicalVolumeId()) .append("volumeGroupId", getVolumeGroupId()) .append("serial", getSerial()) .append("lunMapping", getLunMapping()) .append("vendorId", getVendorId()) .append("productId", getProductId()) .append("lunConnections", getLunConnections()) .append("deviceSize", getDeviceSize()) .append("pvSize", getPvSize()) .append("peCount", getPeCount()) .append("peAllocatedCount", getPeAllocatedCount()) .append("vendorName", getVendorName()) .append("pathsDictionary", getPathsDictionary()) .append("pathsCapacity", getPathsCapacity()) .append("lunType", getLunType()) .append("status", getStatus()) .append("diskId", getDiskId()) .append("diskAlias", getDiskAlias()) .append("storageDomainId", getStorageDomainId()) .append("storageDomainName", getStorageDomainName()) .append("discardMaxSize", getDiscardMaxSize()) .build(); }
@Override protected LUNs getEntity(int index) { LUNs entity = new LUNs(); entity.setLUNId(GUIDS[index].toString()); entity.setLunType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI); return entity; }
private int getAdditionalAvailableSize(LUNs lun) { int pvSize = lun.getPvSize(); if (pvSize == 0) { return 0; } // The PV size is always smaller by 1 GB from the device due to LVM metadata int additionalAvailableSize = lun.getDeviceSize() - pvSize - 1; if (additionalAvailableSize < 0) { additionalAvailableSize = 0; } return additionalAvailableSize; }
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; }
@Override protected LUNs generateNewEntity() { LUNs newLUN = new LUNs(); newLUN.setLUNId("oicu812"); newLUN.setVolumeGroupId(""); return newLUN; }
@Mapping(from = LUNs.class, to = LogicalUnit.class) public static LogicalUnit map(LUNs entity, LogicalUnit template) { LogicalUnit model = template != null ? template : new LogicalUnit(); model.setId(entity.getLUNId()); if (entity.getVendorId()!=null && !entity.getVendorId().isEmpty()) { model.setVendorId(entity.getVendorId()); if (entity.getProductId()!=null && !entity.getProductId().isEmpty()) { model.setProductId(entity.getProductId()); if (entity.getSerial()!=null && !entity.getSerial().isEmpty()) { model.setSerial(entity.getSerial()); if (entity.getLunMapping()!=null) { model.setLunMapping(entity.getLunMapping()); if (entity.getVolumeGroupId() != null && !entity.getVolumeGroupId().isEmpty()) { model.setVolumeGroupId(entity.getVolumeGroupId()); if (entity.getStorageDomainId() != null) { model.setStorageDomainId(entity.getStorageDomainId().toString()); if (entity.getDiskId() != null) { model.setDiskId(entity.getDiskId().toString()); if (entity.getStatus() != null) { model.setStatus(map(entity.getStatus(), null)); if (entity.getDiscardMaxSize() != null) { model.setDiscardMaxSize(entity.getDiscardMaxSize());
@Override protected MapSqlParameterSource createFullParametersMapper(LUNs lun) { return createIdParameterMapper(lun.getId()) .addValue("physical_volume_id", lun.getPhysicalVolumeId()) .addValue("volume_group_id", lun.getVolumeGroupId()) .addValue("serial", lun.getSerial()) .addValue("lun_mapping", lun.getLunMapping()) .addValue("vendor_id", lun.getVendorId()) .addValue("product_id", lun.getProductId()) .addValue("device_size", lun.getDeviceSize()) .addValue("discard_max_size", lun.getDiscardMaxSize()); } }
if (a.getLunType() == getType() || a.getLunType() == StorageType.UNKNOWN) { ArrayList<SanTargetModel> targets = createTargetModelList(a); lunModel.setLunId(a.getLUNId()); lunModel.setVendorId(a.getVendorId()); lunModel.setProductId(a.getProductId()); lunModel.setSerial(a.getSerial()); lunModel.setMultipathing(a.getPathCount()); lunModel.setTargets(targets); lunModel.setSize(a.getDeviceSize()); lunModel.setAdditionalAvailableSize(getAdditionalAvailableSize(a)); lunModel.setAdditionalAvailableSizeSelected(false); lunModel.setRemoveLunSelected(false); lunModel.setIsAccessible(a.getAccessible()); lunModel.setStatus(a.getStatus()); lunModel.setIsIncluded(lunModel.getIsIncluded() || isIncluded); lunModel.setIsSelected(containsLun(lunModel, selectedItems, isIncluded));
private void updateGrayedOut(boolean isInMaintenance, Set<String> metadataDevices, LunModel lunModel) { UIConstants constants = ConstantsManager.getInstance().getConstants(); UIMessages messages = ConstantsManager.getInstance().getMessages(); LUNs lun = lunModel.getEntity(); boolean nonEmpty = lun.getStorageDomainId() != null || lun.getDiskId() != null || lun.getStatus() == LunStatus.Unusable; // Graying out LUNs lunModel.setIsGrayedOut(isIgnoreGrayedOut() ? lun.getDiskId() != null : nonEmpty); // Adding 'GrayedOutReasons' if (lun.getDiskId() != null) { lunModel.getGrayedOutReasons().add( messages.lunUsedByDiskWarning(lun.getDiskAlias())); } else if (lun.getStorageDomainId() != null && !isInMaintenance) { lunModel.getGrayedOutReasons().add( messages.lunAlreadyPartOfStorageDomainWarning(lun.getStorageDomainName())); } else if (isInMaintenance && metadataDevices.contains(lun.getId())) { lunModel.getGrayedOutReasons().add( messages.lunIsMetadataDevice(lun.getStorageDomainName())); } else if (lun.getStatus() == LunStatus.Unusable) { lunModel.getGrayedOutReasons().add( constants.lunUnusable()); } }
protected List<LUNs> setUpLuns() { StorageServerConnections cnx = new StorageServerConnections(); cnx.setConnection(ADDRESSES[0]); cnx.setIqn(TARGET); cnx.setPort(Integer.toString(PORT)); LUNs lun = new LUNs(); lun.setLUNId(LUN); lun.setLunConnections(new ArrayList<>()); lun.getLunConnections().add(cnx); List<LUNs> luns = new ArrayList<>(); luns.add(lun); return luns; }
/** * This mapping exists for adding a lun-disk, and assumes that 'storage' entity contains exactly one lun. */ @Mapping(from = HostStorage.class, to = LUNs.class) public static LUNs map(HostStorage model, LUNs template) { LUNs entity = template != null ? template : new LUNs(); if (model.isSetLogicalUnits() && model.getLogicalUnits().isSetLogicalUnits()) { LogicalUnit logicalUnit = model.getLogicalUnits().getLogicalUnits().get(0); entity.setLUNId(logicalUnit.getId()); ArrayList<StorageServerConnections> connections = new ArrayList<>(); connections.add(map(logicalUnit, null)); entity.setLunConnections(connections); } if (model.isSetType()) { entity.setLunType(StorageDomainMapper.map(model.getType(), null)); } return entity; }
protected void updateSelectedLunWarning(LunModel lunModel) { LUNs lun = lunModel.getEntity(); String warning = constants.empty(); // Adding 'GrayedOutReasons' if (lun.getStorageDomainId() != null) { warning = messages.lunAlreadyPartOfStorageDomainWarning(lun.getStorageDomainName()); } else if (lun.getDiskId() != null) { warning = messages.lunUsedByDiskWarning(lun.getDiskAlias()); } model.setSelectedLunWarning(warning); }
@Test public void testOneWayMapping() { LUNs model = new LUNs(); model.setVendorId("vendor_id_1"); model.setProductId("product_id_1"); model.setLunMapping(5); model.setSerial("some_serial"); model.setVolumeGroupId("volume_group_id_1"); model.setStorageDomainId(Guid.Empty); model.setDiskId(Guid.Empty); model.setStatus(org.ovirt.engine.core.common.businessentities.storage.LunStatus.Free); LogicalUnit entity = StorageLogicalUnitMapper.map(model, (LogicalUnit) null); assertEquals("vendor_id_1", entity.getVendorId()); assertEquals("product_id_1", entity.getProductId()); assertEquals("some_serial", entity.getSerial()); assertEquals(Integer.valueOf(5), entity.getLunMapping()); assertEquals("volume_group_id_1", entity.getVolumeGroupId()); assertEquals(entity.getStorageDomainId(), Guid.Empty.toString()); assertEquals(entity.getDiskId(), Guid.Empty.toString()); assertEquals(LunStatus.FREE, entity.getStatus()); }
@Override protected void readLunDisk(XmlNode node, LunDisk lun) { lun.setDiskVmElements(Collections.singletonList(new DiskVmElement(lun.getId(), fullEntityOvfData.getVmBase().getId()))); LUNs luns = new LUNs(); consumeReadXmlAttribute(node, OVF_PREFIX + COLON + LUN_ID, val -> luns.setLUNId(val)); ArrayList<StorageServerConnections> lunConnections = new ArrayList<>(); for (XmlNode connNode : selectNodes(node, LUN_CONNECTION)) { StorageServerConnections conn = new StorageServerConnections(); consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_CONNECTION, val -> conn.setConnection(val)); consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_IQN, val -> conn.setIqn(val)); consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_PORT, val -> conn.setPort(val)); consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_STORAGE_TYPE, val -> conn.setStorageType(StorageType.valueOf(val))); consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_PORTAL, val -> conn.setPortal(val)); lunConnections.add(conn); } luns.setLunConnections(lunConnections); lun.setLun(luns); DiskVmElement dve = lun.getDiskVmElementForVm(fullEntityOvfData.getVmBase().getId()); initGeneralDiskAttributes(node, lun, dve); }
@Override public String getId() { return getLUNId(); }
@Override public long getSize() { return lun.getDeviceSize(); }
_writer.writeAttributeString(getOvfUri(), "scsi_reservation", String.valueOf(dve.isUsingScsiReservation())); _writer.writeAttributeString(getOvfUri(), "plugged", String.valueOf(dve.isPlugged())); _writer.writeAttributeString(getOvfUri(), LUN_ID, String.valueOf(lun.getLun().getLUNId())); if (lun.getLun().getLunConnections() != null) { for (StorageServerConnections conn : lun.getLun().getLunConnections()) { _writer.writeStartElement(LUN_CONNECTION); _writer.writeAttributeString(getOvfUri(), LUNS_CONNECTION, conn.getConnection());
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; }
@Mapping(from = LUNs.class, to = HostStorage.class) public static HostStorage map(LUNs entity, HostStorage template) { HostStorage model = template != null ? template : new HostStorage(); model.setId(entity.getLUNId()); model.setType(StorageDomainMapper.map(entity.getLunType(), null)); model.setLogicalUnits(new LogicalUnits()); model.getLogicalUnits().getLogicalUnits().add(map(entity, (LogicalUnit) null)); return model; }