Search in sources :

Example 1 with UploadManagerImpl

use of com.cloud.storage.template.UploadManagerImpl in project cosmic by MissionCriticalCloud.

the class NfsSecondaryStorageResource method configure.

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    s_logger.info("Configuring resource {}", name);
    configurePrivateInterface(params);
    configuringPublicInterface(params);
    _hostname = (String) params.get("name");
    final String inSystemVM = (String) params.get("secondary.storage.vm");
    if (inSystemVM == null || "true".equalsIgnoreCase(inSystemVM)) {
        s_logger.debug("conf secondary.storage.vm is true, act as if executing in SSVM");
        _inSystemVM = true;
    }
    _storageIp = (String) params.get("storageip");
    if (_storageIp == null && _inSystemVM) {
        s_logger.warn("There is no storageip in /proc/cmdline, something wrong!");
    }
    _storageNetmask = (String) params.get("storagenetmask");
    _storageGateway = (String) params.get("storagegateway");
    super.configure(name, params);
    _params = params;
    final String value = (String) params.get("scripts.timeout");
    _timeout = NumbersUtil.parseInt(value, 1440) * 1000;
    _storage = (StorageLayer) params.get(StorageLayer.InstanceConfigKey);
    configureStorageLayerClass(params);
    if (_inSystemVM) {
        _storage.mkdirs(_parent);
    }
    _configSslScr = Script.findScript(getDefaultScriptsDir(), "config_ssl.sh");
    if (_configSslScr != null) {
        s_logger.info("config_ssl.sh found in " + _configSslScr);
    }
    _configAuthScr = Script.findScript(getDefaultScriptsDir(), "config_auth.sh");
    if (_configAuthScr != null) {
        s_logger.info("config_auth.sh found in " + _configAuthScr);
    }
    _configIpFirewallScr = Script.findScript(getDefaultScriptsDir(), "ipfirewall.sh");
    if (_configIpFirewallScr != null) {
        s_logger.info("_configIpFirewallScr found in " + _configIpFirewallScr);
    }
    createTemplateFromSnapshotXenScript = Script.findScript(getDefaultScriptsDir(), "create_privatetemplate_from_snapshot_xen.sh");
    if (createTemplateFromSnapshotXenScript == null) {
        throw new ConfigurationException("create_privatetemplate_from_snapshot_xen.sh not found in " + getDefaultScriptsDir());
    }
    _role = (String) params.get("role");
    if (_role == null) {
        _role = SecondaryStorageVm.Role.templateProcessor.toString();
    }
    s_logger.info("Secondary storage runs in role " + _role);
    _guid = (String) params.get("guid");
    if (_guid == null) {
        throw new ConfigurationException("Unable to find the guid");
    }
    _dc = (String) params.get("zone");
    if (_dc == null) {
        throw new ConfigurationException("Unable to find the zone");
    }
    _pod = (String) params.get("pod");
    _instance = (String) params.get("instance");
    if (!_inSystemVM) {
        _parent = (String) params.get("mount.path");
    }
    if (_inSystemVM) {
        _localgw = (String) params.get("localgw");
        if (_localgw != null) {
            // can only happen inside service vm
            final String mgmtHost = (String) params.get("host");
            addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, mgmtHost);
            final String internalDns1 = (String) params.get("internaldns1");
            if (internalDns1 == null) {
                s_logger.warn("No DNS entry found during configuration of NfsSecondaryStorage");
            } else {
                addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns1);
            }
            final String internalDns2 = (String) params.get("internaldns2");
            if (internalDns2 != null) {
                addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns2);
            }
        }
        startAdditionalServices();
        _params.put("install.numthreads", "50");
        _params.put("secondary.storage.vm", "true");
    }
    try {
        _params.put(StorageLayer.InstanceConfigKey, _storage);
        _dlMgr = new DownloadManagerImpl();
        _dlMgr.configure("DownloadManager", _params);
        _upldMgr = new UploadManagerImpl();
        _upldMgr.configure("UploadManager", params);
    } catch (final ConfigurationException e) {
        s_logger.warn("Caught problem while configuring DownloadManager", e);
        return false;
    }
    return true;
}
Also used : DownloadManagerImpl(com.cloud.storage.template.DownloadManagerImpl) ConfigurationException(javax.naming.ConfigurationException) UploadManagerImpl(com.cloud.storage.template.UploadManagerImpl)

Aggregations

DownloadManagerImpl (com.cloud.storage.template.DownloadManagerImpl)1 UploadManagerImpl (com.cloud.storage.template.UploadManagerImpl)1 ConfigurationException (javax.naming.ConfigurationException)1