public TemplateLocation buildTemplateLocation(final StorageLayer storage, final String templatePath) { final TemplateLocation location = new TemplateLocation(storage, templatePath); return location; }
public boolean create(long id, boolean isPublic, String uniqueName) throws IOException { boolean result = load(); _props.setProperty("id", Long.toString(id)); _props.setProperty("public", Boolean.toString(isPublic)); _props.setProperty("uniquename", uniqueName); return result; }
public boolean addFormat(FormatInfo newInfo) { deleteFormat(newInfo.format); if (!checkFormatValidity(newInfo)) { s_logger.warn("Format is invalid"); s_logger.debug("Format: " + newInfo.format + " size: " + newInfo.size + " virtualsize: " + newInfo.virtualSize + " filename: " + newInfo.filename); s_logger.debug("format, filename cannot be null and size, virtual size should be > 0 "); return false; } _props.setProperty("virtualsize", Long.toString(newInfo.virtualSize)); _props.setProperty("size", Long.toString(newInfo.size)); _formats.add(newInfo); return true; }
FormatInfo info = processor.process(destPath, null, templateUuid); TemplateLocation loc = new TemplateLocation(_storage, destPath); loc.create(1, true, templateUuid); loc.addFormat(info); loc.save(); TemplateProp prop = loc.getTemplateInfo(); TemplateObjectTO newTemplate = new TemplateObjectTO(); newTemplate.setPath(destData.getPath() + File.separator + templateName);
for (String vol : vols) { String path = vol.substring(0, vol.lastIndexOf(File.separator)); TemplateLocation loc = new TemplateLocation(_storage, path); try { if (!loc.load()) { s_logger.warn("Post download installation was not completed for " + path); TemplateProp vInfo = loc.getTemplateInfo(); long vSize = vmdkProcessor.getTemplateVirtualSize(path, vInfo.getInstallPath().substring(vInfo.getInstallPath().lastIndexOf(File.separator) + 1)); vInfo.setSize(vSize); loc.updateVirtualSize(vSize); loc.save(); } catch (Exception e) { s_logger.error("Unable to get the virtual size of the volume: " + vInfo.getInstallPath() + " due to " + e.getMessage());
_formats.add(info); if (!checkFormatValidity(info)) { _isCorrupted = true; s_logger.warn("Cleaning up inconsistent information for " + format);
TemplateLocation loc = new TemplateLocation(_storage, destPath); loc.create(1, true, destData.getName()); loc.addFormat(info); loc.save(); TemplateProp prop = loc.getTemplateInfo(); TemplateObjectTO newTemplate = new TemplateObjectTO(); newTemplate.setPath(destData.getPath() + File.separator + fileName);
for (String tmplt : publicTmplts) { String path = tmplt.substring(0, tmplt.lastIndexOf(File.separator)); TemplateLocation loc = new TemplateLocation(_storage, path); try { if (!loc.load()) { s_logger.warn("Post download installation was not completed for " + path); TemplateProp tInfo = loc.getTemplateInfo(); long vSize = vmdkProcessor.getTemplateVirtualSize(path, tInfo.getInstallPath().substring(tInfo.getInstallPath().lastIndexOf(File.separator) + 1)); tInfo.setSize(vSize); loc.updateVirtualSize(vSize); loc.save(); } catch (Exception e) { s_logger.error("Unable to get the virtual size of the template: " + tInfo.getInstallPath() + " due to " + e.getMessage());
_storage.setWorldReadableAndWriteable(templateProperties); TemplateLocation loc = new TemplateLocation(_storage, resourcePath); try { loc.create(dnld.getId(), true, dnld.getTmpltName()); } catch (IOException e) { s_logger.warn("Something is wrong with template location " + resourcePath, e); loc.purge(); return "Unable to download due to " + e.getMessage(); if(!loc.addFormat(info)) { loc.purge(); return "Unable to install due to invalid file format"; if (!loc.save()) { s_logger.warn("Cleaning up because we're unable to save the formats"); loc.purge();
TemplateLocation loc = new TemplateLocation(storageLayer, tmpltPath); loc.create(1, true, templateName); loc.addFormat(info); loc.save();
_storage.setWorldReadableAndWriteable(templateProperties); TemplateLocation loc = new TemplateLocation(_storage, resourcePath); try { loc.create(uploadEntity.getEntityId(), true, uploadEntity.getFilename()); } catch (IOException e) { s_logger.warn("Something is wrong with template location " + resourcePath, e); loc.purge(); return "Unable to upload due to " + e.getMessage(); loc.addFormat(info); uploadEntity.setVirtualSize(info.virtualSize); uploadEntity.setPhysicalSize(info.size); if (!loc.save()) { s_logger.warn("Cleaning up because we're unable to save the formats"); loc.purge();
final TemplateLocation loc = new TemplateLocation(storageLayer, tmpltPath); loc.create(1, true, templateName); loc.addFormat(info); loc.save();
final TemplateLocation loc = new TemplateLocation(storage, tmpltPath); loc.create(1, true, command.getUniqueName()); loc.addFormat(info); loc.save();