Search in sources :

Example 1 with TrafficTypeResponse

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

the class ApiResponseHelper method createTrafficTypeResponse.

@Override
public TrafficTypeResponse createTrafficTypeResponse(PhysicalNetworkTrafficType result) {
    TrafficTypeResponse response = new TrafficTypeResponse();
    response.setId(result.getUuid());
    PhysicalNetwork pnet = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
    if (pnet != null) {
        response.setPhysicalNetworkId(pnet.getUuid());
    }
    if (result.getTrafficType() != null) {
        response.setTrafficType(result.getTrafficType().toString());
    }
    response.setXenLabel(result.getXenNetworkLabel());
    response.setKvmLabel(result.getKvmNetworkLabel());
    response.setVmwareLabel(result.getVmwareNetworkLabel());
    response.setHypervLabel(result.getHypervNetworkLabel());
    response.setOvm3Label(result.getOvm3NetworkLabel());
    response.setObjectName("traffictype");
    return response;
}
Also used : PhysicalNetwork(com.cloud.network.PhysicalNetwork) TrafficTypeResponse(org.apache.cloudstack.api.response.TrafficTypeResponse)

Example 2 with TrafficTypeResponse

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

the class AddTrafficTypeCmd method execute.

@Override
public void execute() {
    CallContext.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(ApiErrorCode.INTERNAL_ERROR, "Failed to add traffic type to physical network");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) TrafficTypeResponse(org.apache.cloudstack.api.response.TrafficTypeResponse) PhysicalNetworkTrafficType(com.cloud.network.PhysicalNetworkTrafficType)

Example 3 with TrafficTypeResponse

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

the class ListTrafficTypesCmd method execute.

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

Example 4 with TrafficTypeResponse

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

the class UpdateTrafficTypeCmd method execute.

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

Aggregations

TrafficTypeResponse (org.apache.cloudstack.api.response.TrafficTypeResponse)4 PhysicalNetworkTrafficType (com.cloud.network.PhysicalNetworkTrafficType)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1