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