use of com.cloud.api.response.F5LoadBalancerResponse 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.api.response.F5LoadBalancerResponse in project cloudstack by apache.
the class ListF5LoadBalancersCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
List<ExternalLoadBalancerDeviceVO> lbDevices = _f5DeviceManagerService.listF5LoadBalancers(this);
ListResponse<F5LoadBalancerResponse> response = new ListResponse<F5LoadBalancerResponse>();
List<F5LoadBalancerResponse> lbDevicesResponse = new ArrayList<F5LoadBalancerResponse>();
if (lbDevices != null && !lbDevices.isEmpty()) {
for (ExternalLoadBalancerDeviceVO lbDeviceVO : lbDevices) {
F5LoadBalancerResponse lbdeviceResponse = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
lbDevicesResponse.add(lbdeviceResponse);
}
}
response.setResponses(lbDevicesResponse);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} 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.api.response.F5LoadBalancerResponse in project cloudstack by apache.
the class F5ExternalLoadBalancerElement method createF5LoadBalancerResponse.
@Override
public F5LoadBalancerResponse createF5LoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO) {
F5LoadBalancerResponse response = new F5LoadBalancerResponse();
Host lbHost = _hostDao.findById(lbDeviceVO.getHostId());
Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVO.getHostId());
response.setId(lbDeviceVO.getUuid());
response.setIpAddress(lbHost.getPrivateIpAddress());
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(lbDeviceVO.getPhysicalNetworkId());
if (pnw != null) {
response.setPhysicalNetworkId(pnw.getUuid());
}
response.setPublicInterface(lbDetails.get("publicInterface"));
response.setPrivateInterface(lbDetails.get("privateInterface"));
response.setDeviceName(lbDeviceVO.getDeviceName());
if (lbDeviceVO.getCapacity() == 0) {
long defaultLbCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalLoadBalancerCapacity.key()), 50);
response.setDeviceCapacity(defaultLbCapacity);
} else {
response.setDeviceCapacity(lbDeviceVO.getCapacity());
}
response.setDedicatedLoadBalancer(lbDeviceVO.getIsDedicatedDevice());
response.setProvider(lbDeviceVO.getProviderName());
response.setDeviceState(lbDeviceVO.getState().name());
response.setObjectName("f5loadbalancer");
return response;
}
use of com.cloud.api.response.F5LoadBalancerResponse in project cloudstack by apache.
the class AddF5LoadBalancerCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
ExternalLoadBalancerDeviceVO lbDeviceVO = _f5DeviceManagerService.addF5LoadBalancer(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 add F5 Big IP 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());
}
}
Aggregations