private OVFDiskController getControllerType(final NodeList itemList, final String diskId) { for (int k = 0; k < itemList.getLength(); k++) { Element item = (Element)itemList.item(k); NodeList cn = item.getChildNodes(); for (int l = 0; l < cn.getLength(); l++) { if (cn.item(l) instanceof Element) { Element el = (Element)cn.item(l); if ("rasd:HostResource".equals(el.getNodeName()) && (el.getTextContent().contains("ovf:/file/" + diskId) || el.getTextContent().contains("ovf:/disk/" + diskId))) { Element oe = getParentNode(itemList, item); Element voe = oe; while (oe != null) { voe = oe; oe = getParentNode(itemList, voe); } return getController(voe); } } } } return null; }
virtualSize = Long.parseLong(disk.getAttribute("ovf:capacity")); String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits"); virtualSize = OVFHelper.getDiskVirtualSize(virtualSize, allocationUnits, ovfFilePath); break;
OVFHelper ovfHelper = new OVFHelper(); List<DatadiskTO> disks = ovfHelper.getOVFVolumeInfo(ovfFile); } catch (Exception e) { s_logger.info("The ovf file " + ovfFile + " is invalid ", e);
OVFHelper ovfHelper = new OVFHelper(); ovfHelper.rewriteOVFFile(ovfFilePath + ".orig", newOvfFilePath, diskName);
od._controller = getControllerType(items, od._diskId); vd.add(od); throw new CloudRuntimeException("The ovf file info has incomplete file info"); OVFDisk cdisk = getDisk(of._id, vd); if (cdisk == null && !of.isIso){ s_logger.error("The ovf file info has incomplete disk info");
OVFHelper ovfHelper = new OVFHelper(); List<DatadiskTO> disks = ovfHelper.getOVFVolumeInfo(ovfFilePath); return new GetDatadisksAnswer(disks); } catch (Exception e) {
public long getTemplateVirtualSize(String templatePath, String templateName) throws InternalErrorException { // get the virtual size from the OVF file meta data long virtualSize = 0; String templateFileFullPath = templatePath.endsWith(File.separator) ? templatePath : templatePath + File.separator; templateFileFullPath += templateName.endsWith(ImageFormat.OVA.getFileExtension()) ? templateName : templateName + "." + ImageFormat.OVA.getFileExtension(); String ovfFileName = getOVFFilePath(templateFileFullPath); if (ovfFileName == null) { String msg = "Unable to locate OVF file in template package directory: " + templatePath; s_logger.error(msg); throw new InternalErrorException(msg); } try { Document ovfDoc = null; ovfDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(ovfFileName)); Element disk = (Element)ovfDoc.getElementsByTagName("Disk").item(0); virtualSize = Long.parseLong(disk.getAttribute("ovf:capacity")); String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits"); virtualSize = OVFHelper.getDiskVirtualSize(virtualSize, allocationUnits, ovfFileName); return virtualSize; } catch (Exception e) { String msg = "getTemplateVirtualSize: Unable to parse OVF XML document " + templatePath + " to get the virtual disk " + templateName + " size due to " + e; s_logger.error(msg); throw new InternalErrorException(msg); } }