protected List<LUNs> setUpLuns() { LUNs lun = new LUNs(); lun.setLUNId(GUIDS[2].toString()); List<LUNs> luns = new ArrayList<>(); luns.add(lun); return luns; }
@Override protected LUNs generateNewEntity() { LUNs newLUN = new LUNs(); newLUN.setLUNId("oicu812"); newLUN.setVolumeGroupId(""); return newLUN; }
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; }
@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; }
/** * 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; }
@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); }
@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()); }