Search in sources :

Example 1 with VmwareDatacenter

use of com.cloud.hypervisor.vmware.VmwareDatacenter 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

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