Search in sources :

Example 1 with VsphereStoragePoliciesResponse

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

the class ImportVsphereStoragePoliciesCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    final DataCenter dataCenter = _resourceService.getZone(getZoneId());
    if (dataCenter == null) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId());
    }
    List<? extends VsphereStoragePolicy> storagePolicies = _vmwareDatacenterService.importVsphereStoragePolicies(this);
    final ListResponse<VsphereStoragePoliciesResponse> responseList = new ListResponse<>();
    final List<VsphereStoragePoliciesResponse> storagePoliciesResponseList = new ArrayList<>();
    for (VsphereStoragePolicy storagePolicy : storagePolicies) {
        final VsphereStoragePoliciesResponse storagePoliciesResponse = new VsphereStoragePoliciesResponse();
        storagePoliciesResponse.setZoneId(dataCenter.getUuid());
        storagePoliciesResponse.setId(storagePolicy.getUuid());
        storagePoliciesResponse.setName(storagePolicy.getName());
        storagePoliciesResponse.setPolicyId(storagePolicy.getPolicyId());
        storagePoliciesResponse.setDescription(storagePolicy.getDescription());
        storagePoliciesResponse.setObjectName("StoragePolicy");
        storagePoliciesResponseList.add(storagePoliciesResponse);
    }
    responseList.setResponses(storagePoliciesResponseList);
    responseList.setResponseName(getCommandName());
    setResponseObject(responseList);
}
Also used : VsphereStoragePoliciesResponse(org.apache.cloudstack.api.response.VsphereStoragePoliciesResponse) DataCenter(com.cloud.dc.DataCenter) ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) VsphereStoragePolicy(com.cloud.dc.VsphereStoragePolicy)

Example 2 with VsphereStoragePoliciesResponse

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

the class ListVsphereStoragePoliciesCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    final DataCenter dataCenter = _resourceService.getZone(getZoneId());
    if (dataCenter == null) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId());
    }
    List<? extends VsphereStoragePolicy> storagePolicies = _vmwareDatacenterService.listVsphereStoragePolicies(this);
    final ListResponse<VsphereStoragePoliciesResponse> responseList = new ListResponse<>();
    final List<VsphereStoragePoliciesResponse> storagePoliciesResponseList = new ArrayList<>();
    for (VsphereStoragePolicy storagePolicy : storagePolicies) {
        final VsphereStoragePoliciesResponse storagePoliciesResponse = new VsphereStoragePoliciesResponse();
        storagePoliciesResponse.setZoneId(dataCenter.getUuid());
        storagePoliciesResponse.setId(storagePolicy.getUuid());
        storagePoliciesResponse.setName(storagePolicy.getName());
        storagePoliciesResponse.setPolicyId(storagePolicy.getPolicyId());
        storagePoliciesResponse.setDescription(storagePolicy.getDescription());
        storagePoliciesResponse.setObjectName("StoragePolicy");
        storagePoliciesResponseList.add(storagePoliciesResponse);
    }
    responseList.setResponses(storagePoliciesResponseList);
    responseList.setResponseName(getCommandName());
    setResponseObject(responseList);
}
Also used : VsphereStoragePoliciesResponse(org.apache.cloudstack.api.response.VsphereStoragePoliciesResponse) DataCenter(com.cloud.dc.DataCenter) ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) VsphereStoragePolicy(com.cloud.dc.VsphereStoragePolicy)

Aggregations

DataCenter (com.cloud.dc.DataCenter)2 VsphereStoragePolicy (com.cloud.dc.VsphereStoragePolicy)2 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 VsphereStoragePoliciesResponse (org.apache.cloudstack.api.response.VsphereStoragePoliciesResponse)2