Search in sources :

Example 1 with VirtualRouterProviderResponse

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

the class CreateVirtualRouterElementCmd method execute.

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

Example 2 with VirtualRouterProviderResponse

use of org.apache.cloudstack.api.response.VirtualRouterProviderResponse 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)

Example 3 with VirtualRouterProviderResponse

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

the class ListVirtualRouterElementsCmd method execute.

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

Example 4 with VirtualRouterProviderResponse

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

the class ApiResponseHelper method createVirtualRouterProviderResponse.

@Override
public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
    // generate only response of the VR/VPCVR provider type
    if (!(result.getType() == VirtualRouterProvider.Type.VirtualRouter || result.getType() == VirtualRouterProvider.Type.VPCVirtualRouter)) {
        return null;
    }
    VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
    response.setId(result.getUuid());
    PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
    if (nsp != null) {
        response.setNspId(nsp.getUuid());
    }
    response.setEnabled(result.isEnabled());
    response.setObjectName("virtualrouterelement");
    return response;
}
Also used : VirtualRouterProviderResponse(org.apache.cloudstack.api.response.VirtualRouterProviderResponse) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Aggregations

VirtualRouterProviderResponse (org.apache.cloudstack.api.response.VirtualRouterProviderResponse)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