use of org.apache.cloudstack.api.response.PhysicalNetworkResponse in project cloudstack by apache.
the class CreatePhysicalNetworkCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
CallContext.current().setEventDetails("Physical Network Id: " + getEntityId());
PhysicalNetwork result = _networkService.getCreatedPhysicalNetwork(getEntityId());
if (result != null) {
PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create physical network");
}
}
use of org.apache.cloudstack.api.response.PhysicalNetworkResponse in project cloudstack by apache.
the class ListPhysicalNetworksCmd method execute.
@Override
public void execute() {
Pair<List<? extends PhysicalNetwork>, Integer> result = _networkService.searchPhysicalNetworks(getId(), getZoneId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getNetworkName());
if (result != null) {
ListResponse<PhysicalNetworkResponse> response = new ListResponse<PhysicalNetworkResponse>();
List<PhysicalNetworkResponse> networkResponses = new ArrayList<PhysicalNetworkResponse>();
for (PhysicalNetwork network : result.first()) {
PhysicalNetworkResponse networkResponse = _responseGenerator.createPhysicalNetworkResponse(network);
networkResponses.add(networkResponse);
}
response.setResponses(networkResponses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to search for physical networks");
}
}
use of org.apache.cloudstack.api.response.PhysicalNetworkResponse in project cloudstack by apache.
the class UpdatePhysicalNetworkCmd method execute.
@Override
public void execute() {
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(), getNetworkSpeed(), getTags(), getVlan(), getState());
if (result != null) {
PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}
use of org.apache.cloudstack.api.response.PhysicalNetworkResponse in project cloudstack by apache.
the class ApiResponseHelper method createPhysicalNetworkResponse.
@Override
public PhysicalNetworkResponse createPhysicalNetworkResponse(PhysicalNetwork result) {
PhysicalNetworkResponse response = new PhysicalNetworkResponse();
DataCenter zone = ApiDBUtils.findZoneById(result.getDataCenterId());
if (zone != null) {
response.setZoneId(zone.getUuid());
}
response.setNetworkSpeed(result.getSpeed());
response.setVlan(result.getVnetString());
if (result.getDomainId() != null) {
Domain domain = ApiDBUtils.findDomainById(result.getDomainId());
if (domain != null) {
response.setDomainId(domain.getUuid());
}
}
response.setId(result.getUuid());
if (result.getBroadcastDomainRange() != null) {
response.setBroadcastDomainRange(result.getBroadcastDomainRange().toString());
}
response.setIsolationMethods(result.getIsolationMethods());
response.setTags(result.getTags());
if (result.getState() != null) {
response.setState(result.getState().toString());
}
response.setName(result.getName());
response.setObjectName("physicalnetwork");
return response;
}
Aggregations