Search in sources :

Example 1 with F5LoadBalancerResponse

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());
    }
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) F5LoadBalancerResponse(com.cloud.api.response.F5LoadBalancerResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 2 with F5LoadBalancerResponse

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());
    }
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) ListResponse(org.apache.cloudstack.api.response.ListResponse) F5LoadBalancerResponse(com.cloud.api.response.F5LoadBalancerResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList)

Example 3 with F5LoadBalancerResponse

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;
}
Also used : F5LoadBalancerResponse(com.cloud.api.response.F5LoadBalancerResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Host(com.cloud.host.Host)

Example 4 with F5LoadBalancerResponse

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());
    }
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) F5LoadBalancerResponse(com.cloud.api.response.F5LoadBalancerResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

F5LoadBalancerResponse (com.cloud.api.response.F5LoadBalancerResponse)4 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)3 ExternalLoadBalancerDeviceVO (com.cloud.network.dao.ExternalLoadBalancerDeviceVO)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)3 Host (com.cloud.host.Host)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1