List of usage examples for javax.naming ConfigurationException ConfigurationException
public ConfigurationException(String explanation)
From source file:com.cloud.storage.template.VhdProcessor.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _name = name;//from ww w . j a va 2 s . c om _storage = (StorageLayer) params.get(StorageLayer.InstanceConfigKey); if (_storage == null) { throw new ConfigurationException("Unable to get storage implementation"); } return true; }
From source file:com.cloud.baremetal.networkservice.BaremetalKickStartPxeResource.java
private Answer execute(VmDataCommand cmd) { com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); try {//from ww w . ja va 2s. co m List<String[]> vmData = cmd.getVmData(); StringBuilder sb = new StringBuilder(); for (String[] data : vmData) { String folder = data[0]; String file = data[1]; String contents = (data[2] == null) ? "none" : data[2]; sb.append(cmd.getVmIpAddress()); sb.append(","); sb.append(folder); sb.append(","); sb.append(file); sb.append(","); sb.append(contents); sb.append(";"); } String arg = StringUtils.stripEnd(sb.toString(), ";"); sshConnection.connect(null, 60000, 60000); if (!sshConnection.authenticateWithPassword(_username, _password)) { s_logger.debug("SSH Failed to authenticate"); throw new ConfigurationException( String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password)); } String script = String.format("python /usr/bin/baremetal_user_data.py '%s'", arg); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { return new Answer(cmd, false, "Failed to add user data, command:" + script); } return new Answer(cmd, true, "Success"); } catch (Exception e) { s_logger.debug("Prepare for creating baremetal template failed", e); return new Answer(cmd, false, e.getMessage()); } finally { if (sshConnection != null) { sshConnection.close(); } } }
From source file:com.cloud.network.resource.NccHttpCode.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { JSONObject jsonResponse = null;/*from w w w . j a v a 2s . co m*/ try { _name = (String) params.get("name"); if (_name == null) { throw new ConfigurationException("Unable to find name in the configuration parameters"); } _zoneId = (String) params.get("zoneId"); if (_zoneId == null) { throw new ConfigurationException("Unable to find zone Id in the configuration parameters"); } _ip = (String) params.get("ip"); if (_ip == null) { throw new ConfigurationException("Unable to find IP address in the configuration parameters"); } _username = (String) params.get("username"); if (_username == null) { throw new ConfigurationException("Unable to find username in the configuration parameters"); } _password = (String) params.get("password"); if (_password == null) { throw new ConfigurationException("Unable to find password in the configuration parameters"); } _numRetries = NumbersUtil.parseInt((String) params.get("numretries"), 2); _guid = (String) params.get("guid"); if (_guid == null) { throw new ConfigurationException("Unable to find the guid in the configuration parameters"); } _deviceName = (String) params.get("deviceName"); if (_deviceName == null) { throw new ConfigurationException("Unable to find the device name in the configuration parameters"); } _nccCmdTimeout = NumbersUtil.parseLong((String) params.get("numretries"), 600000); // validate device configuration parameters login(); return true; } catch (ConfigurationException e) { throw new ConfigurationException(e.getMessage()); } catch (ExecutionException e) { s_logger.debug("Execution Exception :" + e.getMessage()); throw new ConfigurationException( "Failed to add the device. Please check the device is NCC and It is reachable from Management Server."); } }
From source file:com.cloud.agent.vmdata.JettyVmDataServer.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { boolean success = true; try {/*from ww w .j a v a2 s .c o m*/ int vmDataPort = 80; int fileservingPort = 8000; _vmDataDir = (String) params.get("vm.data.dir"); String port = (String) params.get("vm.data.port"); if (port != null) { vmDataPort = Integer.parseInt(port); } port = (String) params.get("file.server.port"); if (port != null) { fileservingPort = Integer.parseInt(port); } _hostIp = (String) params.get("host.ip"); if (_vmDataDir == null) { _vmDataDir = "/var/www/html"; } success = _fs.mkdirs(_vmDataDir); success = success && buildIpVmMap(); if (success) { setupJetty(vmDataPort, fileservingPort); } } catch (Exception e) { s_logger.warn("Failed to configure jetty", e); throw new ConfigurationException("Failed to configure jetty!!"); } return success; }
From source file:com.cloud.bridge.service.core.ec2.EC2Engine.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { try {// ww w . j a v a2 s .c o m loadConfigValues(); } catch (IOException e) { logger.error("EC2Engine Configuration failure", e); throw new ConfigurationException("EC2Engine configuration failure"); } return true; }
From source file:com.cloud.baremetal.networkservice.BaremetalPingPxeResource.java
protected PreparePxeServerAnswer execute(PreparePxeServerCommand cmd) { com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); try {/*from w w w .j av a 2s. c om*/ sshConnection.connect(null, 60000, 60000); if (!sshConnection.authenticateWithPassword(_username, _password)) { s_logger.debug("SSH Failed to authenticate"); throw new ConfigurationException( String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password)); } String script = String.format( "python /usr/bin/prepare_tftp_bootfile.py restore %1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s %10$s %11$s", _tftpDir, cmd.getMac(), _storageServer, _share, _dir, cmd.getTemplate(), _cifsUserName, _cifsPassword, cmd.getIp(), cmd.getNetMask(), cmd.getGateWay()); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { return new PreparePxeServerAnswer(cmd, "prepare PING at " + _ip + " failed, command:" + script); } s_logger.debug("Prepare Ping PXE server successfully"); return new PreparePxeServerAnswer(cmd); } catch (Exception e) { s_logger.debug("Prepare PING pxe server failed", e); return new PreparePxeServerAnswer(cmd, e.getMessage()); } finally { if (sshConnection != null) { sshConnection.close(); } } }
From source file:com.cloud.hypervisor.kvm.storage.KVMStorageProcessor.java
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException { storageLayer = new JavaStorageLayer(); storageLayer.configure("StorageLayer", params); String storageScriptsDir = (String) params.get("storage.scripts.dir"); if (storageScriptsDir == null) { storageScriptsDir = getDefaultStorageScriptsDir(); }/*from w w w .j a va 2s . com*/ _createTmplPath = Script.findScript(storageScriptsDir, "createtmplt.sh"); if (_createTmplPath == null) { throw new ConfigurationException("Unable to find the createtmplt.sh"); } _manageSnapshotPath = Script.findScript(storageScriptsDir, "managesnapshot.sh"); if (_manageSnapshotPath == null) { throw new ConfigurationException("Unable to find the managesnapshot.sh"); } final String value = (String) params.get("cmds.timeout"); _cmdsTimeout = NumbersUtil.parseInt(value, 7200) * 1000; return true; }
From source file:com.wso2telco.dbUtil.DataBaseConnectUtils.java
/** * Update user details in Back Channeling Scenario : update oauth code * * @param code Auth code/*from w w w .jav a 2 s. co m*/ * @param correlationId unique ID of the request */ public static void updateCodeInBackChannel(String correlationId, String code) throws ConfigurationException, CommonAuthenticatorException { Connection connection = null; PreparedStatement preparedStatement = null; String updateUserDetailsQuery = null; updateUserDetailsQuery = "update backchannel_request_details set auth_code=? where correlation_id=?"; try { connection = getConnectDBConnection(); if (log.isDebugEnabled()) { log.debug("Executing the query " + updateUserDetailsQuery); } preparedStatement = connection.prepareStatement(updateUserDetailsQuery); preparedStatement.setString(1, code); preparedStatement.setString(2, correlationId); preparedStatement.executeUpdate(); } catch (SQLException e) { handleException("Error occurred while updating user details for : " + correlationId + "in " + "BackChannel Scenario.", e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection); } }
From source file:com.cloud.network.resource.NuageVspResourceConfiguration.java
private void verifyNotNull(String name, String value) throws ConfigurationException { if (value == null) { throw new ConfigurationException("Unable to find " + name); }/*from w ww . jav a2 s .c om*/ }
From source file:com.cloud.agent.Agent.java
public Agent(final IAgentShell shell, final int localAgentId, final ServerResource resource) throws ConfigurationException { _shell = shell;// w w w . j a va 2 s. com _resource = resource; _link = null; resource.setAgentControl(this); final String value = _shell.getPersistentProperty(getResourceName(), "id"); _id = value != null ? Long.parseLong(value) : null; s_logger.info("id is " + (_id != null ? _id : "")); final Map<String, Object> params = PropertiesUtil.toMap(_shell.getProperties()); // merge with properties from command line to let resource access command line parameters for (final Map.Entry<String, Object> cmdLineProp : _shell.getCmdLineProperties().entrySet()) { params.put(cmdLineProp.getKey(), cmdLineProp.getValue()); } if (!_resource.configure(getResourceName(), params)) { throw new ConfigurationException("Unable to configure " + _resource.getName()); } final String host = _shell.getHost(); _connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), this); // ((NioClient)_connection).setBindAddress(_shell.getPrivateIp()); s_logger.debug("Adding shutdown hook"); Runtime.getRuntime().addShutdownHook(new ShutdownThread(this)); _ugentTaskPool = new ThreadPoolExecutor(shell.getPingRetries(), 2 * shell.getPingRetries(), 10, TimeUnit.MINUTES, new SynchronousQueue<Runnable>(), new NamedThreadFactory("UgentTask")); _executor = new ThreadPoolExecutor(_shell.getWorkers(), 5 * _shell.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("agentRequest-Handler")); s_logger.info("Agent [id = " + (_id != null ? _id : "new") + " : type = " + getResourceName() + " : zone = " + _shell.getZone() + " : pod = " + _shell.getPod() + " : workers = " + _shell.getWorkers() + " : host = " + host + " : port = " + _shell.getPort()); }