diff --git a/core/src/com/cloud/storage/template/DownloadManagerImpl.java b/core/src/com/cloud/storage/template/DownloadManagerImpl.java index 2ec957a6d8a..8d41e293e6a 100644 --- a/core/src/com/cloud/storage/template/DownloadManagerImpl.java +++ b/core/src/com/cloud/storage/template/DownloadManagerImpl.java @@ -781,6 +781,11 @@ public class DownloadManagerImpl implements DownloadManager { processor = new QCOW2Processor(); processor.configure("QCOW2 Processor", params); processors.add(processor); + + processor = new VmdkProcessor(); + processor.configure("VMDK Processor", params); + processors.add(processor); + // Add more processors here. threadPool = Executors.newFixedThreadPool(numInstallThreads); return true; diff --git a/core/src/com/cloud/storage/template/VmdkProcessor.java b/core/src/com/cloud/storage/template/VmdkProcessor.java new file mode 100644 index 00000000000..b8d037c3538 --- /dev/null +++ b/core/src/com/cloud/storage/template/VmdkProcessor.java @@ -0,0 +1,67 @@ +package com.cloud.storage.template; + +import java.io.File; +import java.util.Map; + +import javax.naming.ConfigurationException; + +import org.apache.log4j.Logger; + +import com.cloud.exception.InternalErrorException; +import com.cloud.storage.StorageLayer; +import com.cloud.storage.Storage.ImageFormat; + +public class VmdkProcessor implements Processor { + private static final Logger s_logger = Logger.getLogger(VmdkProcessor.class); + + String _name; + StorageLayer _storage; + + @Override + public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException { + if (format != null) { + s_logger.debug("We currently don't handle conversion from " + format + " to VMDK."); + return null; + } + + s_logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName); + String templateFilePath = templatePath + File.separator + templateName + ".tar.bz2"; + if (!_storage.exists(templateFilePath)) { + s_logger.debug("Unable to find the vmware template file: " + templateFilePath); + return null; + } + + FormatInfo info = new FormatInfo(); + info.format = ImageFormat.VMDK; + info.filename = templateName + ".tar.bz2"; + info.size = _storage.getSize(templateFilePath); + info.virtualSize = info.size; + return info; + } + + @Override + public boolean configure(String name, Map params) throws ConfigurationException { + _name = name; + _storage = (StorageLayer)params.get(StorageLayer.InstanceConfigKey); + if (_storage == null) { + throw new ConfigurationException("Unable to get storage implementation"); + } + + return true; + } + + @Override + public String getName() { + return _name; + } + + @Override + public boolean start() { + return true; + } + + @Override + public boolean stop() { + return true; + } +}