Search in sources :

Example 1 with PhysicalNetworkResponse

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");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Example 2 with PhysicalNetworkResponse

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");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with PhysicalNetworkResponse

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);
    }
}
Also used : PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Example 4 with PhysicalNetworkResponse

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;
}
Also used : DataCenter(com.cloud.dc.DataCenter) PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) Domain(com.cloud.domain.Domain)

Aggregations

PhysicalNetworkResponse (org.apache.cloudstack.api.response.PhysicalNetworkResponse)4 PhysicalNetwork (com.cloud.network.PhysicalNetwork)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 DataCenter (com.cloud.dc.DataCenter)1 Domain (com.cloud.domain.Domain)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1