Search in sources :

Example 1 with VmwareDatacenterResponse

use of org.apache.cloudstack.api.response.VmwareDatacenterResponse in project cloudstack by apache.

the class AddVmwareDcCmd method execute.

@Override
public void execute() {
    try {
        VmwareDatacenterResponse response = new VmwareDatacenterResponse();
        VmwareDatacenterVO result = _vmwareDatacenterService.addVmwareDatacenter(this);
        if (result != null) {
            response.setId(result.getUuid());
            response.setName(result.getVmwareDatacenterName());
            response.setResponseName(getCommandName());
            response.setObjectName("vmwaredc");
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add VMware Datacenter to zone.");
        }
        this.setResponseObject(response);
    } catch (DiscoveryException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (ResourceInUseException ex) {
        s_logger.warn("Exception: ", ex);
        ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
        for (String proxyObj : ex.getIdProxyList()) {
            e.addProxyObject(proxyObj);
        }
        throw e;
    } catch (IllegalArgumentException ex) {
        throw new IllegalArgumentException(ex.getMessage());
    } catch (CloudRuntimeException runtimeEx) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeEx.getMessage());
    }
}
Also used : VmwareDatacenterResponse(org.apache.cloudstack.api.response.VmwareDatacenterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) VmwareDatacenterVO(com.cloud.hypervisor.vmware.VmwareDatacenterVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceInUseException(com.cloud.exception.ResourceInUseException) DiscoveryException(com.cloud.exception.DiscoveryException)

Example 2 with VmwareDatacenterResponse

use of org.apache.cloudstack.api.response.VmwareDatacenterResponse in project cloudstack by apache.

the class ListVmwareDcsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    List<? extends VmwareDatacenter> vmwareDcList = null;
    try {
        vmwareDcList = _vmwareDatacenterService.listVmwareDatacenters(this);
    } catch (InvalidParameterValueException ie) {
        throw new InvalidParameterValueException("Invalid zone id " + getZoneId());
    } catch (Exception e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to find associated VMware DCs associated with zone " + getZoneId());
    }
    ListResponse<VmwareDatacenterResponse> response = new ListResponse<VmwareDatacenterResponse>();
    List<VmwareDatacenterResponse> vmwareDcResponses = new ArrayList<VmwareDatacenterResponse>();
    if (vmwareDcList != null && vmwareDcList.size() > 0) {
        for (VmwareDatacenter vmwareDc : vmwareDcList) {
            VmwareDatacenterResponse vmwareDcResponse = new VmwareDatacenterResponse();
            vmwareDcResponse.setId(vmwareDc.getUuid());
            vmwareDcResponse.setVcenter(vmwareDc.getVcenterHost());
            vmwareDcResponse.setName(vmwareDc.getVmwareDatacenterName());
            vmwareDcResponse.setZoneId(getZoneId());
            vmwareDcResponse.setObjectName("VMwareDC");
            vmwareDcResponses.add(vmwareDcResponse);
        }
    }
    response.setResponses(vmwareDcResponses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : VmwareDatacenterResponse(org.apache.cloudstack.api.response.VmwareDatacenterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) VmwareDatacenter(com.cloud.hypervisor.vmware.VmwareDatacenter) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Aggregations

ServerApiException (org.apache.cloudstack.api.ServerApiException)2 VmwareDatacenterResponse (org.apache.cloudstack.api.response.VmwareDatacenterResponse)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 DiscoveryException (com.cloud.exception.DiscoveryException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceInUseException (com.cloud.exception.ResourceInUseException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 VmwareDatacenter (com.cloud.hypervisor.vmware.VmwareDatacenter)1 VmwareDatacenterVO (com.cloud.hypervisor.vmware.VmwareDatacenterVO)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1