use of com.cloud.network.dao.ExternalLoadBalancerDeviceVO in project cloudstack by apache.
the class ConfigureNetscalerLoadBalancerCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
ExternalLoadBalancerDeviceVO lbDeviceVO = _netsclarLbService.configureNetscalerLoadBalancer(this);
if (lbDeviceVO != null) {
NetscalerLoadBalancerResponse response = _netsclarLbService.createNetscalerLoadBalancerResponse(lbDeviceVO);
response.setObjectName("netscalerloadbalancer");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure netscaler load balancer due to internal error.");
}
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
use of com.cloud.network.dao.ExternalLoadBalancerDeviceVO in project cloudstack by apache.
the class AddNetscalerLoadBalancerCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
ExternalLoadBalancerDeviceVO lbDeviceVO = _netsclarLbService.addNetscalerLoadBalancer(this);
if (lbDeviceVO != null) {
NetscalerLoadBalancerResponse response = _netsclarLbService.createNetscalerLoadBalancerResponse(lbDeviceVO);
response.setObjectName("netscalerloadbalancer");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add netscaler load balancer due to internal error.");
}
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
use of com.cloud.network.dao.ExternalLoadBalancerDeviceVO in project cloudstack by apache.
the class NetscalerElement method listNetscalerLoadBalancers.
@Override
public List<ExternalLoadBalancerDeviceVO> listNetscalerLoadBalancers(ListNetscalerLoadBalancersCmd cmd) {
Long physcialNetworkId = cmd.getPhysicalNetworkId();
Long lbDeviceId = cmd.getLoadBalancerDeviceId();
PhysicalNetworkVO pNetwork = null;
List<ExternalLoadBalancerDeviceVO> lbDevices = new ArrayList<ExternalLoadBalancerDeviceVO>();
if (physcialNetworkId == null && lbDeviceId == null) {
throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
}
if (lbDeviceId != null) {
ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
if (lbDeviceVo == null || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
throw new InvalidParameterValueException("Could not find Netscaler load balancer device with ID: " + lbDeviceId);
}
lbDevices.add(lbDeviceVo);
return lbDevices;
}
if (physcialNetworkId != null) {
pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
if (pNetwork == null) {
throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
}
lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.Netscaler.getName());
return lbDevices;
}
return null;
}
use of com.cloud.network.dao.ExternalLoadBalancerDeviceVO in project cloudstack by apache.
the class NetscalerElement method listNetworks.
@Override
public List<? extends Network> listNetworks(ListNetscalerLoadBalancerNetworksCmd cmd) {
Long lbDeviceId = cmd.getLoadBalancerDeviceId();
List<NetworkVO> networks = new ArrayList<NetworkVO>();
ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
if (lbDeviceVo == null || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
throw new InvalidParameterValueException("Could not find Netscaler load balancer device with ID " + lbDeviceId);
}
List<NetworkExternalLoadBalancerVO> networkLbMaps = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
if (networkLbMaps != null && !networkLbMaps.isEmpty()) {
for (NetworkExternalLoadBalancerVO networkLbMap : networkLbMaps) {
NetworkVO network = _networkDao.findById(networkLbMap.getNetworkId());
networks.add(network);
}
}
return networks;
}
use of com.cloud.network.dao.ExternalLoadBalancerDeviceVO 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