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);
}
}
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);
}
}
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;
}
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());
}
}
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;
}
Aggregations