/** * lunDisk is: /dev/mapper/[lun id] * * @param lun * - The lun disk which will be used to create the mapper string. * @return - Represented guid of the lun mapper. */ public static String createLunFile(LunDisk lun) { if (lun.getId() != null) { return lun.getId().toString(); } return Guid.Empty.toString(); }
@Override public void buildDisk() { XmlNodeList list = selectNodes(_document, "//*/Section/Disk"); for (XmlNode node : list) { Guid guid = new Guid(node.attributes.get("ovf:diskId").getValue()); _images.stream().filter(d -> d.getImageId().equals(guid)).findFirst().ifPresent(img -> readDisk(node, img)); luns.stream().filter(d -> d.getId().equals(guid)).findFirst().ifPresent(lun -> readLunDisk(node, lun)); } }
@Override public String getValue(EntityModel object) { LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk(); return disk.getId().toString(); } };
private void fixDiskVmElements() { // In the time of disk creation the VM ID is an empty Guid, this is changed to the real ID only after the // reading of the OS properties which comes after the disks creation so the disk VM elements are set to // the wrong VM ID this part sets them to the correct VM ID for (DiskImage disk : _images) { disk.getDiskVmElements().forEach(dve -> dve.setId(new VmDeviceId(disk.getId(), vmBase.getId()))); disk.setDiskVmElements(disk.getDiskVmElements()); } for (LunDisk lunDisk : luns) { lunDisk.getDiskVmElements().forEach(dve -> dve.setId(new VmDeviceId(lunDisk.getId(), vmBase.getId()))); lunDisk.setDiskVmElements(lunDisk.getDiskVmElements()); } }
@Override protected void writeFileForLunDisk(LunDisk lun) { // Lun disk does not have image id, therefor the id will be preserved with the disk ID as identifier. _writer.writeAttributeString(getOvfUri(), "id", lun.getId().toString()); _writer.writeAttributeString(getOvfUri(), "href", OvfParser.createLunFile(lun)); _writer.writeAttributeString(getOvfUri(), "disk_storage_type", lun.getDiskStorageType().name()); }
@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 protected void writeLunDisk(LunDisk lun) { _writer.writeAttributeString(getOvfUri(), "diskId", lun.getId().toString()); DiskVmElement dve = lun.getDiskVmElementForVm(vmBase.getId()); if (lun.getDiskAlias() != null) {