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