Search in sources :

Example 16 with NetworkResponse

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

the class ListPaloAltoFirewallNetworksCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<? extends Network> networks = _paFwService.listNetworks(this);
        ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
        List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
        if (networks != null && !networks.isEmpty()) {
            for (Network network : networks) {
                NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network);
                networkResponses.add(networkResponse);
            }
        }
        response.setResponses(networkResponses);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Network(com.cloud.network.Network) NetworkResponse(org.apache.cloudstack.api.response.NetworkResponse) ArrayList(java.util.ArrayList)

Aggregations

NetworkResponse (org.apache.cloudstack.api.response.NetworkResponse)16 Network (com.cloud.network.Network)14 ServerApiException (org.apache.cloudstack.api.ServerApiException)11 ArrayList (java.util.ArrayList)10 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)9 ListResponse (org.apache.cloudstack.api.response.ListResponse)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)6 PhysicalNetworkResponse (org.apache.cloudstack.api.response.PhysicalNetworkResponse)5 DataCenter (com.cloud.dc.DataCenter)2 Provider (com.cloud.network.Network.Provider)2 Service (com.cloud.network.Network.Service)2 OvsProvider (com.cloud.network.OvsProvider)2 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)2 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)2 ResourceTag (com.cloud.server.ResourceTag)2 Account (com.cloud.user.Account)2 EnumSet (java.util.EnumSet)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2