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;
}
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");
}
}
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);
}
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");
}
}
Aggregations