Search in sources :

Example 1 with PhysicalNetworkServiceProvider

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

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

use of com.cloud.network.PhysicalNetworkServiceProvider 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 4 with PhysicalNetworkServiceProvider

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

the class InternalLoadBalancerElement method addInternalLoadBalancerElement.

@Override
public VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId) {
    VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(ntwkSvcProviderId, Type.InternalLbVm);
    if (element != null) {
        s_logger.debug("There is already an " + getName() + " with service provider id " + ntwkSvcProviderId);
        return null;
    }
    PhysicalNetworkServiceProvider provider = _pNtwkSvcProviderDao.findById(ntwkSvcProviderId);
    if (provider == null || !provider.getProviderName().equalsIgnoreCase(getName())) {
        throw new InvalidParameterValueException("Invalid network service provider is specified");
    }
    element = new VirtualRouterProviderVO(ntwkSvcProviderId, Type.InternalLbVm);
    element = _vrProviderDao.persist(element);
    return element;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) VirtualRouterProviderVO(com.cloud.network.element.VirtualRouterProviderVO) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 5 with PhysicalNetworkServiceProvider

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

the class InternalLoadBalancerVMManagerImpl method getInternalLbProviderId.

protected long getInternalLbProviderId(final Network guestNetwork) {
    final Type type = Type.InternalLbVm;
    final long physicalNetworkId = _ntwkModel.getPhysicalNetworkId(guestNetwork);
    final PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
    if (provider == null) {
        throw new CloudRuntimeException("Cannot find service provider " + type.toString() + " in physical network " + physicalNetworkId);
    }
    final VirtualRouterProvider internalLbProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), type);
    if (internalLbProvider == null) {
        throw new CloudRuntimeException("Cannot find provider " + type.toString() + " as service provider " + provider.getId());
    }
    return internalLbProvider.getId();
}
Also used : Type(com.cloud.network.VirtualRouterProvider.Type) TrafficType(com.cloud.network.Networks.TrafficType) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) 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