@Override public TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName) throws InternalErrorException { if (format != null) { s_logger.debug("We currently don't handle conversion from " + format + " to QCOW2."); return null; } final String qcow2Path = templatePath + File.separator + templateName + "." + ImageFormat.QCOW2.toString().toLowerCase(); if (!this._storage.exists(qcow2Path)) { s_logger.debug("Unable to find the qcow2 file: " + qcow2Path); return null; } final TemplateFormatInfo info = new TemplateFormatInfo(); info.format = ImageFormat.QCOW2; info.filename = templateName + "." + ImageFormat.QCOW2.toString().toLowerCase(); final File qcow2File = this._storage.getFile(qcow2Path); info.size = this._storage.getSize(qcow2Path); try { info.virtualSize = getTemplateVirtualSize(qcow2File); } catch (final IOException e) { s_logger.error("Unable to get virtual size from " + qcow2File.getName()); throw new InternalErrorException("unable to get virtual size from qcow2 file"); } return info; }
@Override public TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName) throws InternalErrorException { if (format != null) { s_logger.debug("We currently don't handle conversion from " + format + " to VHD."); return null; } final String vhdPath = templatePath + File.separator + templateName + "." + ImageFormat.VHD.toString().toLowerCase(); if (!this._storage.exists(vhdPath)) { s_logger.debug("Unable to find the vhd file: " + vhdPath); return null; } final File vhdFile = this._storage.getFile(vhdPath); final TemplateFormatInfo info = new TemplateFormatInfo(); info.format = ImageFormat.VHD; info.filename = templateName + "." + ImageFormat.VHD.toString().toLowerCase(); info.size = this._storage.getSize(vhdPath); try { info.virtualSize = getTemplateVirtualSize(vhdFile); } catch (final IOException e) { s_logger.error("Unable to get the virtual size for " + vhdPath); throw new InternalErrorException("unable to get virtual size from vhd file"); } return info; }