Search in sources :

Example 1 with BrocadeVcsDeviceResponse

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

the class AddBrocadeVcsDeviceCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        BrocadeVcsDeviceVO brocadeVcsDeviceVO = brocadeVcsElementService.addBrocadeVcsDevice(this);
        if (brocadeVcsDeviceVO != null) {
            BrocadeVcsDeviceResponse response = brocadeVcsElementService.createBrocadeVcsDeviceResponse(brocadeVcsDeviceVO);
            response.setObjectName("brocadevcsdevice");
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Brocade VCS Switch due to internal error.");
        }
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : BrocadeVcsDeviceResponse(com.cloud.api.response.BrocadeVcsDeviceResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) BrocadeVcsDeviceVO(com.cloud.network.BrocadeVcsDeviceVO)

Example 2 with BrocadeVcsDeviceResponse

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

the class ListBrocadeVcsDevicesCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException {
    try {
        List<BrocadeVcsDeviceVO> brocadeDevices = brocadeVcsElementService.listBrocadeVcsDevices(this);
        ListResponse<BrocadeVcsDeviceResponse> response = new ListResponse<BrocadeVcsDeviceResponse>();
        List<BrocadeVcsDeviceResponse> brocadeDevicesResponse = new ArrayList<BrocadeVcsDeviceResponse>();
        if (brocadeDevices != null && !brocadeDevices.isEmpty()) {
            for (BrocadeVcsDeviceVO brocadeDeviceVO : brocadeDevices) {
                BrocadeVcsDeviceResponse brocadeDeviceResponse = brocadeVcsElementService.createBrocadeVcsDeviceResponse(brocadeDeviceVO);
                brocadeDevicesResponse.add(brocadeDeviceResponse);
            }
        }
        response.setResponses(brocadeDevicesResponse);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) BrocadeVcsDeviceResponse(com.cloud.api.response.BrocadeVcsDeviceResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) BrocadeVcsDeviceVO(com.cloud.network.BrocadeVcsDeviceVO)

Example 3 with BrocadeVcsDeviceResponse

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

the class BrocadeVcsElement method createBrocadeVcsDeviceResponse.

@Override
public BrocadeVcsDeviceResponse createBrocadeVcsDeviceResponse(BrocadeVcsDeviceVO brocadeVcsDeviceVO) {
    HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDeviceVO.getHostId());
    _hostDao.loadDetails(brocadeVcsHost);
    BrocadeVcsDeviceResponse response = new BrocadeVcsDeviceResponse();
    response.setDeviceName(brocadeVcsDeviceVO.getDeviceName());
    PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(brocadeVcsDeviceVO.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    response.setId(brocadeVcsDeviceVO.getUuid());
    response.setProviderName(brocadeVcsDeviceVO.getProviderName());
    response.setHostName(brocadeVcsHost.getDetail("ip"));
    response.setObjectName("brocadevcsdevice");
    return response;
}
Also used : BrocadeVcsDeviceResponse(com.cloud.api.response.BrocadeVcsDeviceResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) HostVO(com.cloud.host.HostVO)

Aggregations

BrocadeVcsDeviceResponse (com.cloud.api.response.BrocadeVcsDeviceResponse)3 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 BrocadeVcsDeviceVO (com.cloud.network.BrocadeVcsDeviceVO)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