Search in sources :

Example 1 with InternalLoadBalancerElementResponse

use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.

the class ApiResponseHelper method createInternalLbElementResponse.

@Override
public InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result) {
    if (result.getType() != VirtualRouterProvider.Type.InternalLbVm) {
        return null;
    }
    InternalLoadBalancerElementResponse response = new InternalLoadBalancerElementResponse();
    response.setId(result.getUuid());
    PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
    if (nsp != null) {
        response.setNspId(nsp.getUuid());
    }
    response.setEnabled(result.isEnabled());
    response.setObjectName("internalloadbalancerelement");
    return response;
}
Also used : InternalLoadBalancerElementResponse(org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 2 with InternalLoadBalancerElementResponse

use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.

the class ConfigureInternalLoadBalancerElementCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    CallContext.current().setEventDetails("Internal load balancer element: " + id);
    VirtualRouterProvider result = _service.get(0).configureInternalLoadBalancerElement(getId(), getEnabled());
    if (result != null) {
        InternalLoadBalancerElementResponse routerResponse = _responseGenerator.createInternalLbElementResponse(result);
        routerResponse.setResponseName(getCommandName());
        this.setResponseObject(routerResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the internal load balancer element");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) InternalLoadBalancerElementResponse(org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse)

Example 3 with InternalLoadBalancerElementResponse

use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.

the class CreateInternalLoadBalancerElementCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Virtual router element Id: " + getEntityId());
    VirtualRouterProvider result = _service.get(0).getInternalLoadBalancerElement(getEntityId());
    if (result != null) {
        InternalLoadBalancerElementResponse response = _responseGenerator.createInternalLbElementResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) InternalLoadBalancerElementResponse(org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse)

Example 4 with InternalLoadBalancerElementResponse

use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.

the class ListInternalLoadBalancerElementsCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    List<? extends VirtualRouterProvider> providers = _service.searchForInternalLoadBalancerElements(getId(), getNspId(), getEnabled());
    ListResponse<InternalLoadBalancerElementResponse> response = new ListResponse<InternalLoadBalancerElementResponse>();
    List<InternalLoadBalancerElementResponse> providerResponses = new ArrayList<InternalLoadBalancerElementResponse>();
    for (VirtualRouterProvider provider : providers) {
        InternalLoadBalancerElementResponse providerResponse = _responseGenerator.createInternalLbElementResponse(provider);
        providerResponses.add(providerResponse);
    }
    response.setResponses(providerResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) InternalLoadBalancerElementResponse(org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse) ArrayList(java.util.ArrayList)

Aggregations

InternalLoadBalancerElementResponse (org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse)4 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1