Search in sources :

Example 1 with NetscalerResource

use of com.cloud.network.resource.NetscalerResource in project cloudstack by apache.

the class NetscalerElement method addNetscalerLoadBalancer.

@Override
public ExternalLoadBalancerDeviceVO addNetscalerLoadBalancer(AddNetscalerLoadBalancerCmd cmd) {
    String deviceName = cmd.getDeviceType();
    if (!isNetscalerDevice(deviceName)) {
        throw new InvalidParameterValueException("Invalid Netscaler device type");
    }
    URI uri;
    try {
        uri = new URI(cmd.getUrl());
    } catch (Exception e) {
        String msg = "Error parsing the url parameter specified in addNetscalerLoadBalancer command due to " + e.getMessage();
        s_logger.debug(msg);
        throw new InvalidParameterValueException(msg);
    }
    Map<String, String> configParams = new HashMap<String, String>();
    UrlUtil.parseQueryParameters(uri.getQuery(), false, configParams);
    boolean dedicatedUse = (configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED) != null) ? Boolean.parseBoolean(configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED)) : false;
    if (dedicatedUse && !deviceName.equals(NetworkDevice.NetscalerVPXLoadBalancer.getName())) {
        String msg = "Only Netscaler VPX load balancers can be specified for dedicated use";
        s_logger.debug(msg);
        throw new InvalidParameterValueException(msg);
    }
    if (cmd.isGslbProvider()) {
        if (!deviceName.equals(NetworkDevice.NetscalerVPXLoadBalancer.getName()) && !deviceName.equals(NetworkDevice.NetscalerMPXLoadBalancer.getName())) {
            String msg = "Only Netscaler VPX or MPX load balancers can be specified as GSLB service provider";
            s_logger.debug(msg);
            throw new InvalidParameterValueException(msg);
        }
        if (cmd.getSitePublicIp() == null || cmd.getSitePrivateIp() == null) {
            String msg = "Public and Privae IP needs to provided for NetScaler that will be GSLB provider";
            s_logger.debug(msg);
            throw new InvalidParameterValueException(msg);
        }
        if (dedicatedUse) {
            throw new InvalidParameterValueException("NetScaler provisioned to be GSLB service provider can only be configured for shared usage.");
        }
    }
    if (cmd.isExclusiveGslbProvider() && !cmd.isGslbProvider()) {
        throw new InvalidParameterValueException("NetScaler can be provisioned to be exclusive GSLB service provider" + " only if its being configured as GSLB service provider also.");
    }
    ExternalLoadBalancerDeviceVO lbDeviceVO = addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceName, new NetscalerResource(), cmd.isGslbProvider(), cmd.isExclusiveGslbProvider(), cmd.getSitePublicIp(), cmd.getSitePrivateIp());
    return lbDeviceVO;
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) HashMap(java.util.HashMap) NetscalerResource(com.cloud.network.resource.NetscalerResource) URI(java.net.URI) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) JSONException(org.json.JSONException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InsufficientNetworkCapacityException(com.cloud.exception.InsufficientNetworkCapacityException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InsufficientNetworkCapacityException (com.cloud.exception.InsufficientNetworkCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 ExternalLoadBalancerDeviceVO (com.cloud.network.dao.ExternalLoadBalancerDeviceVO)1 NetscalerResource (com.cloud.network.resource.NetscalerResource)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 ConfigurationException (javax.naming.ConfigurationException)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 JSONException (org.json.JSONException)1