Search in sources :

Example 1 with CiscoVnmcResourceResponse

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

the class ListCiscoVnmcResourcesCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<CiscoVnmcControllerVO> ciscoVnmcResources = _ciscoVnmcElementService.listCiscoVnmcResources(this);
        ListResponse<CiscoVnmcResourceResponse> response = new ListResponse<CiscoVnmcResourceResponse>();
        List<CiscoVnmcResourceResponse> ciscoVnmcResourcesResponse = new ArrayList<CiscoVnmcResourceResponse>();
        if (ciscoVnmcResources != null && !ciscoVnmcResources.isEmpty()) {
            for (CiscoVnmcController ciscoVnmcResourceVO : ciscoVnmcResources) {
                CiscoVnmcResourceResponse ciscoVnmcResourceResponse = _ciscoVnmcElementService.createCiscoVnmcResourceResponse(ciscoVnmcResourceVO);
                ciscoVnmcResourceResponse.setObjectName("CiscoVnmcResource");
                ciscoVnmcResourcesResponse.add(ciscoVnmcResourceResponse);
            }
        }
        response.setResponses(ciscoVnmcResourcesResponse);
        response.setResponseName(getCommandName());
        this.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 : CiscoVnmcResourceResponse(com.cloud.api.response.CiscoVnmcResourceResponse) 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) CiscoVnmcController(com.cloud.network.cisco.CiscoVnmcController) CiscoVnmcControllerVO(com.cloud.network.cisco.CiscoVnmcControllerVO)

Example 2 with CiscoVnmcResourceResponse

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

the class AddCiscoVnmcResourceCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        CiscoVnmcController CiscoVnmcResourceVO = _ciscoVnmcElementService.addCiscoVnmcResource(this);
        if (CiscoVnmcResourceVO != null) {
            CiscoVnmcResourceResponse response = _ciscoVnmcElementService.createCiscoVnmcResourceResponse(CiscoVnmcResourceVO);
            response.setObjectName("CiscoVnmcResource");
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Cisco VNMC controller 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 : CiscoVnmcResourceResponse(com.cloud.api.response.CiscoVnmcResourceResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) CiscoVnmcController(com.cloud.network.cisco.CiscoVnmcController)

Example 3 with CiscoVnmcResourceResponse

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

the class CiscoVnmcElement method createCiscoVnmcResourceResponse.

@Override
public CiscoVnmcResourceResponse createCiscoVnmcResourceResponse(CiscoVnmcController ciscoVnmcResourceVO) {
    HostVO ciscoVnmcHost = _hostDao.findById(ciscoVnmcResourceVO.getHostId());
    CiscoVnmcResourceResponse response = new CiscoVnmcResourceResponse();
    response.setId(ciscoVnmcResourceVO.getUuid());
    response.setPhysicalNetworkId(ciscoVnmcResourceVO.getPhysicalNetworkId());
    response.setProviderName(ciscoVnmcResourceVO.getProviderName());
    response.setResourceName(ciscoVnmcHost.getName());
    return response;
}
Also used : CiscoVnmcResourceResponse(com.cloud.api.response.CiscoVnmcResourceResponse) HostVO(com.cloud.host.HostVO)

Aggregations

CiscoVnmcResourceResponse (com.cloud.api.response.CiscoVnmcResourceResponse)3 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 CiscoVnmcController (com.cloud.network.cisco.CiscoVnmcController)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 HostVO (com.cloud.host.HostVO)1 CiscoVnmcControllerVO (com.cloud.network.cisco.CiscoVnmcControllerVO)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1