Search in sources :

Example 1 with PhysicalNetworkResponse

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

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);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update physical network");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkResponse(com.cloud.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Example 2 with PhysicalNetworkResponse

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

the class ListPhysicalNetworksCmd method execute.

@Override
public void execute() {
    List<? extends PhysicalNetwork> 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) {
            PhysicalNetworkResponse networkResponse = _responseGenerator.createPhysicalNetworkResponse(network);
            networkResponses.add(networkResponse);
        }
        response.setResponses(networkResponses);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to search for physical networks");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkResponse(com.cloud.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList)

Example 3 with PhysicalNetworkResponse

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

the class CreatePhysicalNetworkCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    UserContext.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(BaseCmd.INTERNAL_ERROR, "Failed to create physical network");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkResponse(com.cloud.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Aggregations

ServerApiException (com.cloud.api.ServerApiException)3 PhysicalNetworkResponse (com.cloud.api.response.PhysicalNetworkResponse)3 PhysicalNetwork (com.cloud.network.PhysicalNetwork)3 ListResponse (com.cloud.api.response.ListResponse)1 ArrayList (java.util.ArrayList)1