Search in sources :

Example 1 with BigSwitchBcfDeviceResponse

use of com.cloud.api.response.BigSwitchBcfDeviceResponse in project cloudstack by apache.

the class ListBigSwitchBcfDevicesCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        final List<BigSwitchBcfDeviceVO> bigswitchDevices = bigswitchBcfElementService.listBigSwitchBcfDevices(this);
        final ListResponse<BigSwitchBcfDeviceResponse> response = new ListResponse<BigSwitchBcfDeviceResponse>();
        final List<BigSwitchBcfDeviceResponse> bigswitchDevicesResponse = new ArrayList<BigSwitchBcfDeviceResponse>();
        if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) {
            for (final BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) {
                final BigSwitchBcfDeviceResponse bigswitchDeviceResponse = bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO);
                bigswitchDevicesResponse.add(bigswitchDeviceResponse);
            }
        }
        response.setResponses(bigswitchDevicesResponse);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) BigSwitchBcfDeviceResponse(com.cloud.api.response.BigSwitchBcfDeviceResponse) BigSwitchBcfDeviceVO(com.cloud.network.BigSwitchBcfDeviceVO)

Example 2 with BigSwitchBcfDeviceResponse

use of com.cloud.api.response.BigSwitchBcfDeviceResponse in project cloudstack by apache.

the class BigSwitchBcfElement method createBigSwitchBcfDeviceResponse.

@Override
public BigSwitchBcfDeviceResponse createBigSwitchBcfDeviceResponse(BigSwitchBcfDeviceVO bigswitchBcfDeviceVO) {
    HostVO bigswitchBcfHost = _hostDao.findById(bigswitchBcfDeviceVO.getHostId());
    _hostDao.loadDetails(bigswitchBcfHost);
    BigSwitchBcfDeviceResponse response = new BigSwitchBcfDeviceResponse();
    response.setDeviceName(bigswitchBcfDeviceVO.getDeviceName());
    PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(bigswitchBcfDeviceVO.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    response.setId(bigswitchBcfDeviceVO.getUuid());
    response.setProviderName(bigswitchBcfDeviceVO.getProviderName());
    response.setHostName(bigswitchBcfHost.getDetail("hostname"));
    response.setObjectName("bigswitchbcfdevice");
    return response;
}
Also used : PhysicalNetwork(com.cloud.network.PhysicalNetwork) BigSwitchBcfDeviceResponse(com.cloud.api.response.BigSwitchBcfDeviceResponse) HostVO(com.cloud.host.HostVO)

Example 3 with BigSwitchBcfDeviceResponse

use of com.cloud.api.response.BigSwitchBcfDeviceResponse in project cloudstack by apache.

the class AddBigSwitchBcfDeviceCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        final BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = bcfElementService.addBigSwitchBcfDevice(this);
        if (bigswitchBcfDeviceVO == null) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch BCF Controller device due to internal error.");
        }
        final BigSwitchBcfDeviceResponse response = bcfElementService.createBigSwitchBcfDeviceResponse(bigswitchBcfDeviceVO);
        response.setObjectName("bigswitchbcfdevice");
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) BigSwitchBcfDeviceResponse(com.cloud.api.response.BigSwitchBcfDeviceResponse) BigSwitchBcfDeviceVO(com.cloud.network.BigSwitchBcfDeviceVO)

Aggregations

BigSwitchBcfDeviceResponse (com.cloud.api.response.BigSwitchBcfDeviceResponse)3 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 BigSwitchBcfDeviceVO (com.cloud.network.BigSwitchBcfDeviceVO)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 HostVO (com.cloud.host.HostVO)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1