Search in sources :

Example 1 with ProviderResponse

use of com.cloud.api.response.ProviderResponse in project CloudStack-archive by CloudStack-extras.

the class UpdateNetworkServiceProviderCmd method execute.

@Override
public void execute() {
    PhysicalNetworkServiceProvider result = _networkService.updateNetworkServiceProvider(getId(), getState(), getEnabledServices());
    if (result != null) {
        ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service provider");
    }
}
Also used : ProviderResponse(com.cloud.api.response.ProviderResponse) ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 2 with ProviderResponse

use of com.cloud.api.response.ProviderResponse in project CloudStack-archive by CloudStack-extras.

the class ListNetworkServiceProvidersCmd method execute.

@Override
public void execute() {
    List<? extends PhysicalNetworkServiceProvider> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId(), getName(), getState(), this.getStartIndex(), this.getPageSizeVal());
    ListResponse<ProviderResponse> response = new ListResponse<ProviderResponse>();
    List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
    for (PhysicalNetworkServiceProvider serviceProvider : serviceProviders) {
        ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
        serviceProvidersResponses.add(serviceProviderResponse);
    }
    response.setResponses(serviceProvidersResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ProviderResponse(com.cloud.api.response.ProviderResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 3 with ProviderResponse

use of com.cloud.api.response.ProviderResponse in project cosmic by MissionCriticalCloud.

the class AddNetworkServiceProviderCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    CallContext.current().setEventDetails("Network ServiceProvider Id: " + getEntityId());
    final PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
    if (result != null) {
        final ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add service provider to physical network");
    }
}
Also used : ProviderResponse(com.cloud.api.response.ProviderResponse) ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 4 with ProviderResponse

use of com.cloud.api.response.ProviderResponse in project cosmic by MissionCriticalCloud.

the class ListNetworkServiceProvidersCmd method execute.

@Override
public void execute() {
    final Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId(), getName(), getState(), this.getStartIndex(), this.getPageSizeVal());
    final ListResponse<ProviderResponse> response = new ListResponse<>();
    final List<ProviderResponse> serviceProvidersResponses = new ArrayList<>();
    for (final PhysicalNetworkServiceProvider serviceProvider : serviceProviders.first()) {
        final ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
        serviceProvidersResponses.add(serviceProviderResponse);
    }
    response.setResponses(serviceProvidersResponses, serviceProviders.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ProviderResponse(com.cloud.api.response.ProviderResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 5 with ProviderResponse

use of com.cloud.api.response.ProviderResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method getProviderResponses.

private List<ProviderResponse> getProviderResponses(final Set<Provider> srvc_providers) {
    final List<ProviderResponse> providers = new ArrayList<>();
    for (final Provider provider : srvc_providers) {
        if (provider != null) {
            final ProviderResponse providerRsp = new ProviderResponse();
            providerRsp.setName(provider.getName());
            providers.add(providerRsp);
        }
    }
    return providers;
}
Also used : VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ProviderResponse(com.cloud.api.response.ProviderResponse) ArrayList(java.util.ArrayList) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) Provider(com.cloud.network.Network.Provider)

Aggregations

ProviderResponse (com.cloud.api.response.ProviderResponse)12 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)10 ArrayList (java.util.ArrayList)7 VirtualRouterProviderResponse (com.cloud.api.response.VirtualRouterProviderResponse)6 Provider (com.cloud.network.Network.Provider)5 ServerApiException (com.cloud.api.ServerApiException)4 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)4 ServiceResponse (com.cloud.api.response.ServiceResponse)3 Service (com.cloud.network.Network.Service)3 CapabilityResponse (com.cloud.api.response.CapabilityResponse)2 ListResponse (com.cloud.api.response.ListResponse)2 PhysicalNetwork (com.cloud.network.PhysicalNetwork)2 EnumSet (java.util.EnumSet)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 NetworkOfferingResponse (com.cloud.api.response.NetworkOfferingResponse)1 Network (com.cloud.network.Network)1