Search in sources :

Example 1 with NetscalerLoadBalancerResponse

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

Example 2 with NetscalerLoadBalancerResponse

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

Example 3 with NetscalerLoadBalancerResponse

use of com.cloud.api.response.NetscalerLoadBalancerResponse in project cloudstack by apache.

the class NetscalerElement method createNetscalerLoadBalancerResponse.

@Override
public NetscalerLoadBalancerResponse createNetscalerLoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO) {
    NetscalerLoadBalancerResponse response = new NetscalerLoadBalancerResponse();
    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("netscalerloadbalancer");
    response.setGslbProvider(lbDeviceVO.getGslbProvider());
    response.setExclusiveGslbProvider(lbDeviceVO.getExclusiveGslbProvider());
    response.setGslbSitePublicIp(lbDeviceVO.getGslbSitePublicIP());
    response.setGslbSitePrivateIp(lbDeviceVO.getGslbSitePrivateIP());
    List<Long> associatedPods = new ArrayList<Long>();
    List<NetScalerPodVO> currentPodVOs = _netscalerPodDao.listByNetScalerDeviceId(lbDeviceVO.getId());
    if (currentPodVOs != null && currentPodVOs.size() > 0) {
        for (NetScalerPodVO nsPodVo : currentPodVOs) {
            associatedPods.add(nsPodVo.getPodId());
        }
    }
    response.setAssociatedPods(associatedPods);
    return response;
}
Also used : PhysicalNetwork(com.cloud.network.PhysicalNetwork) NetscalerLoadBalancerResponse(com.cloud.api.response.NetscalerLoadBalancerResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host) NetScalerPodVO(com.cloud.network.NetScalerPodVO)

Example 4 with NetscalerLoadBalancerResponse

use of com.cloud.api.response.NetscalerLoadBalancerResponse in project cloudstack by apache.

the class ListNetscalerLoadBalancersCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<ExternalLoadBalancerDeviceVO> lbDevices = _netsclarLbService.listNetscalerLoadBalancers(this);
        ListResponse<NetscalerLoadBalancerResponse> response = new ListResponse<NetscalerLoadBalancerResponse>();
        List<NetscalerLoadBalancerResponse> lbDevicesResponse = new ArrayList<NetscalerLoadBalancerResponse>();
        if (lbDevices != null && !lbDevices.isEmpty()) {
            for (ExternalLoadBalancerDeviceVO lbDeviceVO : lbDevices) {
                NetscalerLoadBalancerResponse lbdeviceResponse = _netsclarLbService.createNetscalerLoadBalancerResponse(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) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NetscalerLoadBalancerResponse(com.cloud.api.response.NetscalerLoadBalancerResponse) ArrayList(java.util.ArrayList)

Aggregations

NetscalerLoadBalancerResponse (com.cloud.api.response.NetscalerLoadBalancerResponse)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 ArrayList (java.util.ArrayList)2 Host (com.cloud.host.Host)1 NetScalerPodVO (com.cloud.network.NetScalerPodVO)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1