Search in sources :

Example 6 with PhysicalNetworkServiceProvider

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

the class AddNetworkServiceProviderCmd method create.

@Override
public void create() throws ResourceAllocationException {
    PhysicalNetworkServiceProvider result = _networkService.addProviderToPhysicalNetwork(getPhysicalNetworkId(), getProviderName(), getDestinationPhysicalNetworkId(), getEnabledServices());
    if (result != null) {
        setEntityId(result.getId());
        setEntityUuid(result.getUuid());
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 7 with PhysicalNetworkServiceProvider

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

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(ApiErrorCode.INTERNAL_ERROR, "Failed to update service provider");
    }
}
Also used : ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 8 with PhysicalNetworkServiceProvider

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

the class ListNetworkServiceProvidersCmd method execute.

@Override
public void execute() {
    Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> 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.first()) {
        ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
        serviceProvidersResponses.add(serviceProviderResponse);
    }
    response.setResponses(serviceProvidersResponses, serviceProviders.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 9 with PhysicalNetworkServiceProvider

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

the class RouterDeploymentDefinition method findVirtualProvider.

protected void findVirtualProvider() {
    // Check if providers are supported in the physical networks
    final Type type = Type.VirtualRouter;
    final Long physicalNetworkId = networkModel.getPhysicalNetworkId(guestNetwork);
    final PhysicalNetworkServiceProvider provider = physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
    if (provider == null) {
        throw new CloudRuntimeException(String.format("Cannot find service provider %s in physical network %s", type.toString(), physicalNetworkId));
    }
    vrProvider = vrProviderDao.findByNspIdAndType(provider.getId(), type);
    if (vrProvider == null) {
        throw new CloudRuntimeException(String.format("Cannot find virtual router provider %s as service provider %s", type.toString(), provider.getId()));
    }
}
Also used : Type(com.cloud.network.VirtualRouterProvider.Type) TrafficType(com.cloud.network.Networks.TrafficType) NetworkType(com.cloud.dc.DataCenter.NetworkType) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 10 with PhysicalNetworkServiceProvider

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

the class AddNetworkServiceProviderCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("Network ServiceProvider Id: " + getEntityId());
    PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
    if (result != null) {
        ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.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)

Aggregations

PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)19 ArrayList (java.util.ArrayList)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 ProviderResponse (org.apache.cloudstack.api.response.ProviderResponse)4 ProviderResponse (com.cloud.api.response.ProviderResponse)3 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)3 List (java.util.List)3 ServerApiException (com.cloud.api.ServerApiException)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 TrafficType (com.cloud.network.Networks.TrafficType)2 PhysicalNetwork (com.cloud.network.PhysicalNetwork)2 Type (com.cloud.network.VirtualRouterProvider.Type)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 VMTemplateVO (com.cloud.storage.VMTemplateVO)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 OvsProviderResponse (org.apache.cloudstack.api.response.OvsProviderResponse)2 VirtualRouterProviderResponse (org.apache.cloudstack.api.response.VirtualRouterProviderResponse)2 ListResponse (com.cloud.api.response.ListResponse)1 NetworkType (com.cloud.dc.DataCenter.NetworkType)1 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)1