Search in sources :

Example 11 with VirtualRouterProvider

use of com.cloud.network.VirtualRouterProvider in project CloudStack-archive by CloudStack-extras.

the class CreateVirtualRouterElementCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("Virtual router element Id: " + getEntityId());
    VirtualRouterProvider result = _service.getCreatedElement(getEntityId());
    if (result != null) {
        VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
    }
}
Also used : VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ServerApiException(com.cloud.api.ServerApiException) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider)

Example 12 with VirtualRouterProvider

use of com.cloud.network.VirtualRouterProvider 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 13 with VirtualRouterProvider

use of com.cloud.network.VirtualRouterProvider 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)

Example 14 with VirtualRouterProvider

use of com.cloud.network.VirtualRouterProvider 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 15 with VirtualRouterProvider

use of com.cloud.network.VirtualRouterProvider in project cloudstack by apache.

the class ConfigureVirtualRouterElementCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    CallContext.current().setEventDetails("Virtual router element: " + id);
    VirtualRouterProvider result = _service.get(0).configure(this);
    if (result != null) {
        VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
        if (routerResponse != null) {
            routerResponse.setResponseName(getCommandName());
            this.setResponseObject(routerResponse);
        }
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the virtual router provider");
    }
}
Also used : VirtualRouterProviderResponse(org.apache.cloudstack.api.response.VirtualRouterProviderResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider)

Aggregations

VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)19 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)6 ServerApiException (org.apache.cloudstack.api.ServerApiException)6 DomainRouterVO (com.cloud.vm.DomainRouterVO)5 ArrayList (java.util.ArrayList)5 Provider (com.cloud.network.Network.Provider)4 NicProfile (com.cloud.vm.NicProfile)4 VirtualRouterProviderResponse (com.cloud.api.response.VirtualRouterProviderResponse)3 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)3 InternalLoadBalancerElementResponse (org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse)3 VirtualRouterProviderResponse (org.apache.cloudstack.api.response.VirtualRouterProviderResponse)3 AggregationControlCommand (com.cloud.agent.api.routing.AggregationControlCommand)2 ServerApiException (com.cloud.api.ServerApiException)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 Network (com.cloud.network.Network)2 NetworkOffering (com.cloud.offering.NetworkOffering)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 Test (org.junit.Test)2 Command (com.cloud.agent.api.Command)1 NetworkUsageCommand (com.cloud.agent.api.NetworkUsageCommand)1