Search in sources :

Example 46 with ConfigurationException

use of javax.naming.ConfigurationException in project cloudstack by apache.

the class AgentShell method loadProperties.

void loadProperties() throws ConfigurationException {
    final File file = PropertiesUtil.findConfigFile("agent.properties");
    if (null == file) {
        throw new ConfigurationException("Unable to find agent.properties.");
    }
    s_logger.info("agent.properties found at " + file.getAbsolutePath());
    try {
        PropertiesUtil.loadFromFile(_properties, file);
    } catch (final FileNotFoundException ex) {
        throw new CloudRuntimeException("Cannot find the file: " + file.getAbsolutePath(), ex);
    } catch (final IOException ex) {
        throw new CloudRuntimeException("IOException in reading " + file.getAbsolutePath(), ex);
    }
}
Also used : ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File)

Example 47 with ConfigurationException

use of javax.naming.ConfigurationException in project cloudstack by apache.

the class LibvirtComputingResource method getDeveloperProperties.

private Map<String, Object> getDeveloperProperties() throws ConfigurationException {
    final File file = PropertiesUtil.findConfigFile("developer.properties");
    if (file == null) {
        throw new ConfigurationException("Unable to find developer.properties.");
    }
    s_logger.info("developer.properties found at " + file.getAbsolutePath());
    try {
        final Properties properties = PropertiesUtil.loadFromFile(file);
        final String startMac = (String) properties.get("private.macaddr.start");
        if (startMac == null) {
            throw new ConfigurationException("Developers must specify start mac for private ip range");
        }
        final String startIp = (String) properties.get("private.ipaddr.start");
        if (startIp == null) {
            throw new ConfigurationException("Developers must specify start ip for private ip range");
        }
        final Map<String, Object> params = PropertiesUtil.toMap(properties);
        String endIp = (String) properties.get("private.ipaddr.end");
        if (endIp == null) {
            endIp = getEndIpFromStartIp(startIp, 16);
            params.put("private.ipaddr.end", endIp);
        }
        return params;
    } catch (final FileNotFoundException ex) {
        throw new CloudRuntimeException("Cannot find the file: " + file.getAbsolutePath(), ex);
    } catch (final IOException ex) {
        throw new CloudRuntimeException("IOException in reading " + file.getAbsolutePath(), ex);
    }
}
Also used : ConfigurationException(javax.naming.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Properties(java.util.Properties) AgentProperties(com.cloud.agent.properties.AgentProperties) QemuImgFile(org.apache.cloudstack.utils.qemu.QemuImgFile) File(java.io.File)

Example 48 with ConfigurationException

use of javax.naming.ConfigurationException in project cloudstack by apache.

the class VmwareServerDiscoverer method reloadResource.

@Override
public ServerResource reloadResource(HostVO host) {
    String resourceName = host.getResource();
    ServerResource resource = getResource(resourceName);
    if (resource != null) {
        _hostDao.loadDetails(host);
        HashMap<String, Object> params = buildConfigParams(host);
        try {
            resource.configure(host.getName(), params);
        } catch (ConfigurationException e) {
            s_logger.warn("Unable to configure resource due to " + e.getMessage());
            return null;
        }
        if (!resource.start()) {
            s_logger.warn("Unable to start the resource");
            return null;
        }
    }
    return resource;
}
Also used : ConfigurationException(javax.naming.ConfigurationException) ServerResource(com.cloud.resource.ServerResource)

Example 49 with ConfigurationException

use of javax.naming.ConfigurationException in project cloudstack by apache.

the class CiscoVnmcResource method configure.

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    try {
        _name = (String) params.get("name");
        if (_name == null) {
            throw new ConfigurationException("Unable to find name");
        }
        _zoneId = (String) params.get("zoneId");
        if (_zoneId == null) {
            throw new ConfigurationException("Unable to find zone");
        }
        _physicalNetworkId = (String) params.get("physicalNetworkId");
        if (_physicalNetworkId == null) {
            throw new ConfigurationException("Unable to find physical network id in the configuration parameters");
        }
        _ip = (String) params.get("ip");
        if (_ip == null) {
            throw new ConfigurationException("Unable to find IP");
        }
        _username = (String) params.get("username");
        if (_username == null) {
            throw new ConfigurationException("Unable to find username");
        }
        _password = (String) params.get("password");
        if (_password == null) {
            throw new ConfigurationException("Unable to find password");
        }
        _guid = (String) params.get("guid");
        if (_guid == null) {
            throw new ConfigurationException("Unable to find the guid");
        }
        _numRetries = NumbersUtil.parseInt((String) params.get("numretries"), 1);
        NumbersUtil.parseInt((String) params.get("timeout"), 300);
        // Open a socket and login
        _connection = new CiscoVnmcConnectionImpl(_ip, _username, _password);
        if (!refreshVnmcConnection()) {
            throw new ConfigurationException("Unable to connect to VNMC, check if ip/username/password is valid.");
        }
        return true;
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    }
}
Also used : ConfigurationException(javax.naming.ConfigurationException) CiscoVnmcConnectionImpl(com.cloud.network.cisco.CiscoVnmcConnectionImpl) ExecutionException(com.cloud.utils.exception.ExecutionException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 50 with ConfigurationException

use of javax.naming.ConfigurationException in project cloudstack by apache.

the class ClusterManagerImpl method configure.

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Start configuring cluster manager : " + name);
    }
    final Properties dbProps = DbProperties.getDbProperties();
    _clusterNodeIP = dbProps.getProperty("cluster.node.IP");
    if (_clusterNodeIP == null) {
        _clusterNodeIP = "127.0.0.1";
    }
    _clusterNodeIP = _clusterNodeIP.trim();
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Cluster node IP : " + _clusterNodeIP);
    }
    if (!NetUtils.isLocalAddress(_clusterNodeIP)) {
        throw new ConfigurationException("cluster node IP should be valid local address where the server is running, please check your configuration");
    }
    for (int i = 0; i < DEFAULT_OUTGOING_WORKERS; i++) {
        _executor.execute(getClusterPduSendingTask());
    }
    // notification task itself in turn works as a task dispatcher
    _executor.execute(getClusterPduNotificationTask());
    if (_serviceAdapters == null) {
        throw new ConfigurationException("Unable to get cluster service adapters");
    }
    _currentServiceAdapter = _serviceAdapters.get(0);
    if (_currentServiceAdapter == null) {
        throw new ConfigurationException("Unable to set current cluster service adapter");
    }
    checkConflicts();
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Cluster manager is configured.");
    }
    return true;
}
Also used : ConfigurationException(javax.naming.ConfigurationException) Properties(java.util.Properties) DbProperties(com.cloud.utils.db.DbProperties)

Aggregations

ConfigurationException (javax.naming.ConfigurationException)168 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)57 IOException (java.io.IOException)44 HashMap (java.util.HashMap)39 File (java.io.File)23 Map (java.util.Map)21 InternalErrorException (com.cloud.exception.InternalErrorException)19 Properties (java.util.Properties)19 StorageLayer (com.cloud.storage.StorageLayer)18 Processor (com.cloud.storage.template.Processor)17 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)17 Answer (com.cloud.agent.api.Answer)16 ServerResource (com.cloud.resource.ServerResource)16 TemplateLocation (com.cloud.storage.template.TemplateLocation)16 Script (com.cloud.utils.script.Script)16 FormatInfo (com.cloud.storage.template.Processor.FormatInfo)14 FileNotFoundException (java.io.FileNotFoundException)14 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)13 Host (com.cloud.host.Host)11 TransactionStatus (com.cloud.utils.db.TransactionStatus)11