use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class F5ExternalLoadBalancerElement method listExternalLoadBalancers.
@Override
@Deprecated
public List<Host> listExternalLoadBalancers(ListExternalLoadBalancersCmd cmd) {
Long zoneId = cmd.getZoneId();
DataCenterVO zone = null;
PhysicalNetworkVO pNetwork = null;
if (zoneId != null) {
zone = _dcDao.findById(zoneId);
if (zone == null) {
throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
}
List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: " + zoneId + " to add this device.");
}
pNetwork = physicalNetworks.get(0);
return listExternalLoadBalancers(pNetwork.getId(), NetworkDevice.F5BigIpLoadBalancer.getName());
} else {
throw new InvalidParameterValueException("Zone Id must be specified to list the external load balancers");
}
}
use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class AddExternalLoadBalancerCmd method execute.
@Override
public void execute() {
try {
Host externalLoadBalancer = _f5DeviceManagerService.addExternalLoadBalancer(this);
ExternalLoadBalancerResponse response = _f5DeviceManagerService.createExternalLoadBalancerResponse(externalLoadBalancer);
response.setObjectName("externalloadbalancer");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}
use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class ConfigureF5LoadBalancerCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
ExternalLoadBalancerDeviceVO lbDeviceVO = _f5DeviceManagerService.configureF5LoadBalancer(this);
if (lbDeviceVO != null) {
F5LoadBalancerResponse response = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
response.setObjectName("f5loadbalancer");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure F5 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.exception.InvalidParameterValueException in project cloudstack by apache.
the class DeleteF5LoadBalancerCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
boolean result = _f5DeviceManagerService.deleteF5LoadBalancer(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete F5 load balancer.");
}
} 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.exception.InvalidParameterValueException in project cloudstack by apache.
the class LoadBalanceRuleHandler method deployLoadBalancerVM.
private DomainRouterVO deployLoadBalancerVM(final Long networkId, final IPAddressVO ipAddr) {
final NetworkVO network = _networkDao.findById(networkId);
final DataCenter dc = _dcDao.findById(network.getDataCenterId());
final Long podId = getPodIdForDirectIp(ipAddr);
final Pod pod = podId == null ? null : _podDao.findById(podId);
final Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
final Account owner = _accountService.getActiveAccountByName("system", new Long(1));
final DeployDestination dest = new DeployDestination(dc, pod, null, null);
s_logger.debug("About to deploy ELB vm ");
try {
final DomainRouterVO elbVm = deployELBVm(network, dest, owner, params);
if (elbVm == null) {
throw new InvalidParameterValueException("Could not deploy or find existing ELB VM");
}
s_logger.debug("Deployed ELB vm = " + elbVm);
return elbVm;
} catch (final Throwable t) {
s_logger.warn("Error while deploying ELB VM: ", t);
return null;
}
}
Aggregations