Search in sources :

Example 6 with ProviderResponse

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

the class ApiResponseHelper method createNetworkServiceProviderResponse.

@Override
public ProviderResponse createNetworkServiceProviderResponse(final PhysicalNetworkServiceProvider result) {
    final ProviderResponse response = new ProviderResponse();
    response.setId(result.getUuid());
    response.setName(result.getProviderName());
    final PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    final PhysicalNetwork dnw = ApiDBUtils.findPhysicalNetworkById(result.getDestinationPhysicalNetworkId());
    if (dnw != null) {
        response.setDestinationPhysicalNetworkId(dnw.getUuid());
    }
    response.setState(result.getState().toString());
    // set enabled services
    final List<String> services = new ArrayList<>();
    for (final Service service : result.getEnabledServices()) {
        services.add(service.getName());
    }
    response.setServices(services);
    final Provider serviceProvider = Provider.getProvider(result.getProviderName());
    final boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
    response.setCanEnableIndividualServices(canEnableIndividualServices);
    response.setObjectName("networkserviceprovider");
    return response;
}
Also used : VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ProviderResponse(com.cloud.api.response.ProviderResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 7 with ProviderResponse

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

the class ApiResponseHelper method getServiceResponses.

private List<ServiceResponse> getServiceResponses(final Map<Service, Set<Provider>> serviceProviderMap) {
    final List<ServiceResponse> serviceResponses = new ArrayList<>();
    for (final Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet()) {
        final Service service = entry.getKey();
        final Set<Provider> serviceProviders = entry.getValue();
        final ServiceResponse svcRsp = new ServiceResponse();
        // skip gateway service
        if (service == Service.Gateway) {
            continue;
        }
        svcRsp.setName(service.getName());
        final List<ProviderResponse> providers = getProviderResponses(serviceProviders);
        svcRsp.setProviders(providers);
        serviceResponses.add(svcRsp);
    }
    return serviceResponses;
}
Also used : ServiceResponse(com.cloud.api.response.ServiceResponse) EnumSet(java.util.EnumSet) HashSet(java.util.HashSet) Set(java.util.Set) VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ProviderResponse(com.cloud.api.response.ProviderResponse) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) Map(java.util.Map) HashMap(java.util.HashMap) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 8 with ProviderResponse

use of com.cloud.api.response.ProviderResponse 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)

Example 9 with ProviderResponse

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

the class ApiResponseHelper method createServiceProviderResponse.

private ProviderResponse createServiceProviderResponse(final Provider serviceProvider) {
    final ProviderResponse response = new ProviderResponse();
    response.setName(serviceProvider.getName());
    final boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
    response.setCanEnableIndividualServices(canEnableIndividualServices);
    return response;
}
Also used : VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ProviderResponse(com.cloud.api.response.ProviderResponse)

Example 10 with ProviderResponse

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

the class ApiResponseHelper method createNetworkServiceResponse.

@Override
public ServiceResponse createNetworkServiceResponse(final Service service) {
    final ServiceResponse response = new ServiceResponse();
    response.setName(service.getName());
    // set list of capabilities required for the service
    final List<CapabilityResponse> capabilityResponses = new ArrayList<>();
    final Capability[] capabilities = service.getCapabilities();
    for (final Capability cap : capabilities) {
        final CapabilityResponse capabilityResponse = new CapabilityResponse();
        capabilityResponse.setName(cap.getName());
        capabilityResponse.setObjectName("capability");
        if (cap.getName().equals(Capability.SupportedLBIsolation.getName()) || cap.getName().equals(Capability.SupportedSourceNatTypes.getName()) || cap.getName().equals(Capability.RedundantRouter.getName())) {
            capabilityResponse.setCanChoose(true);
        } else {
            capabilityResponse.setCanChoose(false);
        }
        capabilityResponses.add(capabilityResponse);
    }
    response.setCapabilities(capabilityResponses);
    // set list of providers providing this service
    final List<? extends Network.Provider> serviceProviders = ApiDBUtils.getProvidersForService(service);
    final List<ProviderResponse> serviceProvidersResponses = new ArrayList<>();
    for (final Network.Provider serviceProvider : serviceProviders) {
        // return only Virtual Router/JuniperSRX/CiscoVnmc as a provider for the firewall
        if (service == Service.Firewall && serviceProvider != Provider.VirtualRouter) {
            continue;
        }
        final ProviderResponse serviceProviderResponse = createServiceProviderResponse(serviceProvider);
        serviceProvidersResponses.add(serviceProviderResponse);
    }
    response.setProviders(serviceProvidersResponses);
    response.setObjectName("networkservice");
    return response;
}
Also used : ServiceResponse(com.cloud.api.response.ServiceResponse) VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ProviderResponse(com.cloud.api.response.ProviderResponse) Capability(com.cloud.network.Network.Capability) Provider(com.cloud.network.Network.Provider) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) CapabilityResponse(com.cloud.api.response.CapabilityResponse)

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