Search in sources :

Example 6 with ServiceResponse

use of org.apache.cloudstack.api.response.ServiceResponse in project cloudstack by apache.

the class ListSupportedNetworkServicesCmd method execute.

@Override
public void execute() {
    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);
            }
        }
        List<Network.Service> serviceList = new ArrayList<Network.Service>();
        serviceList.add(service);
        services = serviceList;
    } else {
        services = _networkService.listNetworkServices(getProviderName());
    }
    ListResponse<ServiceResponse> response = new ListResponse<ServiceResponse>();
    List<ServiceResponse> servicesResponses = new ArrayList<ServiceResponse>();
    for (Network.Service service : services) {
        //skip gateway service
        if (service == Service.Gateway) {
            continue;
        }
        ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service);
        servicesResponses.add(serviceResponse);
    }
    response.setResponses(servicesResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ServiceResponse(org.apache.cloudstack.api.response.ServiceResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) Service(com.cloud.network.Network.Service)

Example 7 with ServiceResponse

use of org.apache.cloudstack.api.response.ServiceResponse in project cloudstack by apache.

the class LoadBalancingRulesManagerImpl method getLBCapability.

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

Aggregations

ServiceResponse (org.apache.cloudstack.api.response.ServiceResponse)7 Service (com.cloud.network.Network.Service)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Provider (com.cloud.network.Network.Provider)4 HashSet (java.util.HashSet)4 OvsProviderResponse (org.apache.cloudstack.api.response.OvsProviderResponse)4 ProviderResponse (org.apache.cloudstack.api.response.ProviderResponse)4 VirtualRouterProviderResponse (org.apache.cloudstack.api.response.VirtualRouterProviderResponse)4 UsageService (org.apache.cloudstack.usage.UsageService)4 Network (com.cloud.network.Network)3 Capability (com.cloud.network.Network.Capability)3 OvsProvider (com.cloud.network.OvsProvider)3 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)3 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)3 EnumSet (java.util.EnumSet)3 Set (java.util.Set)3 CapabilityResponse (org.apache.cloudstack.api.response.CapabilityResponse)3 DataCenter (com.cloud.dc.DataCenter)2