Search in sources :

Example 1 with TrafficTypeResponse

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

the class UpdateTrafficTypeCmd method execute.

@Override
public void execute() {
    PhysicalNetworkTrafficType result = _networkService.updatePhysicalNetworkTrafficType(getId(), getXenLabel(), getKvmLabel(), getVmwareLabel());
    if (result != null) {
        TrafficTypeResponse response = _responseGenerator.createTrafficTypeResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update traffic type");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) TrafficTypeResponse(com.cloud.api.response.TrafficTypeResponse) PhysicalNetworkTrafficType(com.cloud.network.PhysicalNetworkTrafficType)

Example 2 with TrafficTypeResponse

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

the class ListTrafficTypesCmd method execute.

@Override
public void execute() {
    List<? extends PhysicalNetworkTrafficType> trafficTypes = _networkService.listTrafficTypes(getPhysicalNetworkId());
    ListResponse<TrafficTypeResponse> response = new ListResponse<TrafficTypeResponse>();
    List<TrafficTypeResponse> trafficTypesResponses = new ArrayList<TrafficTypeResponse>();
    for (PhysicalNetworkTrafficType trafficType : trafficTypes) {
        TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
        trafficTypesResponses.add(trafficTypeResponse);
    }
    response.setResponses(trafficTypesResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) TrafficTypeResponse(com.cloud.api.response.TrafficTypeResponse) ArrayList(java.util.ArrayList) PhysicalNetworkTrafficType(com.cloud.network.PhysicalNetworkTrafficType)

Example 3 with TrafficTypeResponse

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

the class AddTrafficTypeCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("TrafficType Id: " + getEntityId());
    PhysicalNetworkTrafficType result = _networkService.getPhysicalNetworkTrafficType(getEntityId());
    if (result != null) {
        TrafficTypeResponse response = _responseGenerator.createTrafficTypeResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add traffic type to physical network");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) TrafficTypeResponse(com.cloud.api.response.TrafficTypeResponse) PhysicalNetworkTrafficType(com.cloud.network.PhysicalNetworkTrafficType)

Aggregations

TrafficTypeResponse (com.cloud.api.response.TrafficTypeResponse)3 PhysicalNetworkTrafficType (com.cloud.network.PhysicalNetworkTrafficType)3 ServerApiException (com.cloud.api.ServerApiException)2 ListResponse (com.cloud.api.response.ListResponse)1 ArrayList (java.util.ArrayList)1