Search in sources :

Example 1 with SMTPMailSender

use of org.apache.cloudstack.utils.mailing.SMTPMailSender in project cloudstack by apache.

the class AlertManagerImpl method configure.

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    Map<String, String> configs = _configDao.getConfiguration("management-server", params);
    // set up the email system for alerts
    String emailAddressList = configs.get("alert.email.addresses");
    if (emailAddressList != null) {
        recipients = emailAddressList.split(",");
    }
    senderAddress = configs.get("alert.email.sender");
    String namespace = "alert.smtp";
    String timeoutConfig = String.format("%s.timeout", namespace);
    String connectionTimeoutConfig = String.format("%s.connectiontimeout", namespace);
    int smtpTimeout = NumberUtils.toInt(configs.get(timeoutConfig), 30000);
    int smtpConnectionTimeout = NumberUtils.toInt(configs.get(connectionTimeoutConfig), 30000);
    configs.put(timeoutConfig, String.valueOf(smtpTimeout));
    configs.put(connectionTimeoutConfig, String.valueOf(smtpConnectionTimeout));
    mailSender = new SMTPMailSender(configs, namespace);
    String publicIPCapacityThreshold = _configDao.getValue(Config.PublicIpCapacityThreshold.key());
    String privateIPCapacityThreshold = _configDao.getValue(Config.PrivateIpCapacityThreshold.key());
    String secondaryStorageCapacityThreshold = _configDao.getValue(Config.SecondaryStorageCapacityThreshold.key());
    String vlanCapacityThreshold = _configDao.getValue(Config.VlanCapacityThreshold.key());
    String directNetworkPublicIpCapacityThreshold = _configDao.getValue(Config.DirectNetworkPublicIpCapacityThreshold.key());
    String localStorageCapacityThreshold = _configDao.getValue(Config.LocalStorageCapacityThreshold.key());
    if (publicIPCapacityThreshold != null) {
        _publicIPCapacityThreshold = Double.parseDouble(publicIPCapacityThreshold);
    }
    if (privateIPCapacityThreshold != null) {
        _privateIPCapacityThreshold = Double.parseDouble(privateIPCapacityThreshold);
    }
    if (secondaryStorageCapacityThreshold != null) {
        _secondaryStorageCapacityThreshold = Double.parseDouble(secondaryStorageCapacityThreshold);
    }
    if (vlanCapacityThreshold != null) {
        _vlanCapacityThreshold = Double.parseDouble(vlanCapacityThreshold);
    }
    if (directNetworkPublicIpCapacityThreshold != null) {
        _directNetworkPublicIpCapacityThreshold = Double.parseDouble(directNetworkPublicIpCapacityThreshold);
    }
    if (localStorageCapacityThreshold != null) {
        _localStorageCapacityThreshold = Double.parseDouble(localStorageCapacityThreshold);
    }
    _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP, _publicIPCapacityThreshold);
    _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_PRIVATE_IP, _privateIPCapacityThreshold);
    _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_SECONDARY_STORAGE, _secondaryStorageCapacityThreshold);
    _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_VLAN, _vlanCapacityThreshold);
    _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP, _directNetworkPublicIpCapacityThreshold);
    _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_LOCAL_STORAGE, _localStorageCapacityThreshold);
    String capacityCheckPeriodStr = configs.get("capacity.check.period");
    if (capacityCheckPeriodStr != null) {
        _capacityCheckPeriod = Long.parseLong(capacityCheckPeriodStr);
        if (_capacityCheckPeriod <= 0) {
            _capacityCheckPeriod = Long.parseLong(Config.CapacityCheckPeriod.getDefaultValue());
        }
    }
    _timer = new Timer("CapacityChecker");
    return true;
}
Also used : Timer(java.util.Timer) SMTPMailSender(org.apache.cloudstack.utils.mailing.SMTPMailSender)

Example 2 with SMTPMailSender

use of org.apache.cloudstack.utils.mailing.SMTPMailSender in project cloudstack by apache.

the class QuotaAlertManagerImpl method configure.

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    super.configure(name, params);
    Map<String, String> configs = _configDao.getConfiguration(params);
    if (params != null) {
        mergeConfigs(configs, params);
    }
    senderAddress = configs.get(QuotaConfig.QuotaSmtpSender.key());
    _lockAccountEnforcement = BooleanUtils.toBoolean(configs.get(QuotaConfig.QuotaEnableEnforcement.key()));
    String smtpUsername = configs.get(QuotaConfig.QuotaSmtpUser.key());
    String namespace = "quota.usage.smtp";
    configs.put(String.format("%s.debug", namespace), String.valueOf(_smtpDebug));
    configs.put(String.format("%s.username", namespace), smtpUsername);
    mailSender = new SMTPMailSender(configs, namespace);
    return true;
}
Also used : SMTPMailSender(org.apache.cloudstack.utils.mailing.SMTPMailSender)

Example 3 with SMTPMailSender

use of org.apache.cloudstack.utils.mailing.SMTPMailSender in project cloudstack by apache.

the class UsageAlertManagerImpl method configure.

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    Map<String, String> configs = _configDao.getConfiguration("management-server", params);
    senderAddress = configs.get("alert.email.sender");
    String emailAddressList = configs.get("alert.email.addresses");
    recipients = null;
    if (emailAddressList != null) {
        recipients = emailAddressList.split(",");
    }
    String namespace = "alert.smtp";
    mailSender = new SMTPMailSender(configs, namespace);
    return true;
}
Also used : SMTPMailSender(org.apache.cloudstack.utils.mailing.SMTPMailSender)

Example 4 with SMTPMailSender

use of org.apache.cloudstack.utils.mailing.SMTPMailSender in project cloudstack by apache.

the class ProjectManagerImpl method configure.

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    Map<String, String> configs = _configDao.getConfiguration(params);
    _invitationRequired = BooleanUtils.toBoolean(configs.get(Config.ProjectInviteRequired.key()));
    String value = configs.get(Config.ProjectInvitationExpirationTime.key());
    _invitationTimeOut = Long.parseLong(value != null ? value : "86400") * 1000;
    _allowUserToCreateProject = BooleanUtils.toBoolean(configs.get(Config.AllowUserToCreateProject.key()));
    senderAddress = configs.get("project.email.sender");
    String namespace = "project.smtp";
    mailSender = new SMTPMailSender(configs, namespace);
    _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Project-ExpireInvitations"));
    return true;
}
Also used : NamedThreadFactory(com.cloud.utils.concurrency.NamedThreadFactory) SMTPMailSender(org.apache.cloudstack.utils.mailing.SMTPMailSender)

Aggregations

SMTPMailSender (org.apache.cloudstack.utils.mailing.SMTPMailSender)4 NamedThreadFactory (com.cloud.utils.concurrency.NamedThreadFactory)1 Timer (java.util.Timer)1