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());
}
}
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());
}
}
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;
}
Aggregations