Search in sources :

Example 26 with Service

use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createVpcOfferingResponse.

@Override
public VpcOfferingResponse createVpcOfferingResponse(final VpcOffering offering) {
    final VpcOfferingResponse response = new VpcOfferingResponse();
    response.setId(offering.getUuid());
    response.setName(offering.getName());
    response.setDisplayText(offering.getDisplayText());
    response.setIsDefault(offering.isDefault());
    response.setState(offering.getState().name());
    final ServiceOffering serviceOffering = this._serviceOfferingDao.findById(offering.getServiceOfferingId());
    if (serviceOffering != null) {
        response.setServiceOfferingId(serviceOffering.getUuid());
        response.setServiceOfferingName(serviceOffering.getName());
    }
    final ServiceOffering secondaryServiceOffering = this._serviceOfferingDao.findById(offering.getSecondaryServiceOfferingId());
    if (secondaryServiceOffering != null) {
        response.setSecondaryServiceOfferingId(secondaryServiceOffering.getUuid());
        response.setSecondaryServiceOfferingName(secondaryServiceOffering.getName());
    }
    final Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
    final List<ServiceResponse> serviceResponses = getServiceResponses(serviceProviderMap);
    response.setServices(serviceResponses);
    response.setObjectName("vpcoffering");
    return response;
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ServiceResponse(com.cloud.api.response.ServiceResponse) EnumSet(java.util.EnumSet) HashSet(java.util.HashSet) Set(java.util.Set) ServiceOffering(com.cloud.offering.ServiceOffering) Service(com.cloud.legacymodel.network.Network.Service)

Example 27 with Service

use of com.cloud.legacymodel.network.Network.Service 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.legacymodel.network.Network.Service) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) Provider(com.cloud.legacymodel.network.Network.Provider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 28 with Service

use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.

the class LoadBalancingRulesManagerImpl method getLBCapability.

// Will return a string. For LB Stickiness this will be a json
@Override
public String getLBCapability(final long networkid, final String capabilityName) {
    final Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkModel.getNetworkCapabilities(networkid);
    if (serviceCapabilitiesMap != null) {
        for (final Service service : serviceCapabilitiesMap.keySet()) {
            final ServiceResponse serviceResponse = new ServiceResponse();
            serviceResponse.setName(service.getName());
            if ("Lb".equalsIgnoreCase(service.getName())) {
                final Map<Capability, String> serviceCapabilities = serviceCapabilitiesMap.get(service);
                if (serviceCapabilities != null) {
                    for (final Capability capability : serviceCapabilities.keySet()) {
                        if (capabilityName.equals(capability.getName())) {
                            return serviceCapabilities.get(capability);
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : ServiceResponse(com.cloud.api.response.ServiceResponse) Capability(com.cloud.legacymodel.network.Network.Capability) NetworkOrchestrationService(com.cloud.engine.orchestration.service.NetworkOrchestrationService) Service(com.cloud.legacymodel.network.Network.Service) Map(java.util.Map) HashMap(java.util.HashMap)

Example 29 with Service

use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.

the class ListSupportedNetworkServicesCmd method execute.

@Override
public void execute() {
    final List<? extends Network.Service> services;
    if (getServiceName() != null) {
        Network.Service service = null;
        if (serviceName != null) {
            service = Network.Service.getService(serviceName);
            if (service == null) {
                throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
            }
        }
        final List<Network.Service> serviceList = new ArrayList<>();
        serviceList.add(service);
        services = serviceList;
    } else {
        services = _networkService.listNetworkServices(getProviderName());
    }
    final ListResponse<ServiceResponse> response = new ListResponse<>();
    final List<ServiceResponse> servicesResponses = new ArrayList<>();
    for (final Network.Service service : services) {
        // skip gateway service
        if (service == Service.Gateway) {
            continue;
        }
        final ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service);
        servicesResponses.add(serviceResponse);
    }
    response.setResponses(servicesResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ServiceResponse(com.cloud.api.response.ServiceResponse) ListResponse(com.cloud.api.response.ListResponse) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) Network(com.cloud.legacymodel.network.Network) ArrayList(java.util.ArrayList) Service(com.cloud.legacymodel.network.Network.Service) Service(com.cloud.legacymodel.network.Network.Service)

Example 30 with Service

use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.

the class NetworkOfferingServiceMapDaoImpl method areServicesSupportedByNetworkOffering.

@Override
public boolean areServicesSupportedByNetworkOffering(final long networkOfferingId, final Service... services) {
    final SearchCriteria<NetworkOfferingServiceMapVO> sc = MultipleServicesSearch.create();
    sc.setParameters("networkOfferingId", networkOfferingId);
    if (services != null) {
        final String[] servicesStr = new String[services.length];
        int i = 0;
        for (final Service service : services) {
            servicesStr[i] = service.getName();
            i++;
        }
        sc.setParameters("service", (Object[]) servicesStr);
    }
    final List<NetworkOfferingServiceMapVO> offeringServices = listBy(sc);
    if (services != null) {
        if (offeringServices.size() == services.length) {
            return true;
        }
    } else if (!offeringServices.isEmpty()) {
        return true;
    }
    return false;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) Service(com.cloud.legacymodel.network.Network.Service)

Aggregations

Service (com.cloud.legacymodel.network.Network.Service)62 HashMap (java.util.HashMap)31 NetworkOrchestrationService (com.cloud.engine.orchestration.service.NetworkOrchestrationService)29 Provider (com.cloud.legacymodel.network.Network.Provider)29 ArrayList (java.util.ArrayList)29 HashSet (java.util.HashSet)29 ResourceLimitService (com.cloud.user.ResourceLimitService)27 Set (java.util.Set)24 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)18 Map (java.util.Map)15 Network (com.cloud.legacymodel.network.Network)14 NetworkElement (com.cloud.network.element.NetworkElement)14 NetworkService (com.cloud.network.NetworkService)13 SortedSet (java.util.SortedSet)12 Capability (com.cloud.legacymodel.network.Network.Capability)11 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)11 Test (org.junit.Test)11 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)10 ExecutorService (java.util.concurrent.ExecutorService)10 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)9