Search in sources :

Example 1 with CiscoVnmcConnectionImpl

use of com.cloud.network.cisco.CiscoVnmcConnectionImpl 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)

Aggregations

CiscoVnmcConnectionImpl (com.cloud.network.cisco.CiscoVnmcConnectionImpl)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ExecutionException (com.cloud.utils.exception.ExecutionException)1 ConfigurationException (javax.naming.ConfigurationException)1