Search in sources :

Example 1 with IsoProcessor

use of com.cloud.common.storageprocessor.IsoProcessor in project cosmic by MissionCriticalCloud.

the class DownloadManagerImpl method configure.

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    this._name = name;
    String value = null;
    this._storage = (StorageLayer) params.get(StorageLayer.InstanceConfigKey);
    if (this._storage == null) {
        value = (String) params.get(StorageLayer.ClassConfigKey);
        if (value == null) {
            throw new ConfigurationException("Unable to find the storage layer");
        }
        final Class<StorageLayer> clazz;
        try {
            clazz = (Class<StorageLayer>) Class.forName(value);
            this._storage = clazz.newInstance();
        } catch (final ClassNotFoundException e) {
            throw new ConfigurationException("Unable to instantiate " + value);
        } catch (final InstantiationException e) {
            throw new ConfigurationException("Unable to instantiate " + value);
        } catch (final IllegalAccessException e) {
            throw new ConfigurationException("Unable to instantiate " + value);
        }
    }
    value = (String) params.get("install.timeout.pergig");
    this.installTimeoutPerGig = NumbersUtil.parseInt(value, 15 * 60) * 1000;
    value = (String) params.get("install.numthreads");
    final int numInstallThreads = NumbersUtil.parseInt(value, 10);
    String scriptsDir = (String) params.get("template.scripts.dir");
    if (scriptsDir == null) {
        scriptsDir = "scripts/storage/secondary";
    }
    this.listTmpltScr = Script.findScript(scriptsDir, "listvmtmplt.sh");
    if (this.listTmpltScr == null) {
        throw new ConfigurationException("Unable to find the listvmtmplt.sh");
    }
    s_logger.info("listvmtmplt.sh found in " + this.listTmpltScr);
    this.createTmpltScr = Script.findScript(scriptsDir, "createtmplt.sh");
    if (this.createTmpltScr == null) {
        throw new ConfigurationException("Unable to find createtmplt.sh");
    }
    s_logger.info("createtmplt.sh found in " + this.createTmpltScr);
    this.listVolScr = Script.findScript(scriptsDir, "listvolume.sh");
    if (this.listVolScr == null) {
        throw new ConfigurationException("Unable to find the listvolume.sh");
    }
    s_logger.info("listvolume.sh found in " + this.listVolScr);
    this.createVolScr = Script.findScript(scriptsDir, "createvolume.sh");
    if (this.createVolScr == null) {
        throw new ConfigurationException("Unable to find createvolume.sh");
    }
    s_logger.info("createvolume.sh found in " + this.createVolScr);
    this._processors = new HashMap<>();
    Processor processor = new VhdProcessor();
    processor.configure("VHD Processor", params);
    this._processors.put("VHD Processor", processor);
    processor = new IsoProcessor();
    processor.configure("ISO Processor", params);
    this._processors.put("ISO Processor", processor);
    processor = new QCOW2Processor();
    processor.configure("QCOW2 Processor", params);
    this._processors.put("QCOW2 Processor", processor);
    processor = new RawImageProcessor();
    processor.configure("Raw Image Processor", params);
    this._processors.put("Raw Image Processor", processor);
    processor = new TARProcessor();
    processor.configure("TAR Processor", params);
    this._processors.put("TAR Processor", processor);
    this._templateDir = (String) params.get("public.templates.root.dir");
    if (this._templateDir == null) {
        this._templateDir = TemplateConstants.DEFAULT_TMPLT_ROOT_DIR;
    }
    this._templateDir += File.separator + TemplateConstants.DEFAULT_TMPLT_FIRST_LEVEL_DIR;
    this._volumeDir = TemplateConstants.DEFAULT_VOLUME_ROOT_DIR + File.separator;
    // Add more processors here.
    this.threadPool = Executors.newFixedThreadPool(numInstallThreads);
    return true;
}
Also used : IsoProcessor(com.cloud.common.storageprocessor.IsoProcessor) StorageLayer(com.cloud.utils.storage.StorageLayer) IsoProcessor(com.cloud.common.storageprocessor.IsoProcessor) QCOW2Processor(com.cloud.common.storageprocessor.QCOW2Processor) RawImageProcessor(com.cloud.common.storageprocessor.RawImageProcessor) TARProcessor(com.cloud.common.storageprocessor.TARProcessor) VhdProcessor(com.cloud.common.storageprocessor.VhdProcessor) Processor(com.cloud.common.storageprocessor.Processor) RawImageProcessor(com.cloud.common.storageprocessor.RawImageProcessor) QCOW2Processor(com.cloud.common.storageprocessor.QCOW2Processor) ConfigurationException(javax.naming.ConfigurationException) VhdProcessor(com.cloud.common.storageprocessor.VhdProcessor) TARProcessor(com.cloud.common.storageprocessor.TARProcessor)

Aggregations

IsoProcessor (com.cloud.common.storageprocessor.IsoProcessor)1 Processor (com.cloud.common.storageprocessor.Processor)1 QCOW2Processor (com.cloud.common.storageprocessor.QCOW2Processor)1 RawImageProcessor (com.cloud.common.storageprocessor.RawImageProcessor)1 TARProcessor (com.cloud.common.storageprocessor.TARProcessor)1 VhdProcessor (com.cloud.common.storageprocessor.VhdProcessor)1 StorageLayer (com.cloud.utils.storage.StorageLayer)1 ConfigurationException (javax.naming.ConfigurationException)1