Search in sources :

Example 1 with ServiceResponse

use of com.cloud.api.response.ServiceResponse in project CloudStack-archive by CloudStack-extras.

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(com.cloud.api.response.ServiceResponse) ListResponse(com.cloud.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)

Aggregations

ListResponse (com.cloud.api.response.ListResponse)1 ServiceResponse (com.cloud.api.response.ServiceResponse)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 Network (com.cloud.network.Network)1 Service (com.cloud.network.Network.Service)1 ArrayList (java.util.ArrayList)1