Search in sources :

Example 6 with DataStoreDriver

use of org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver in project cloudstack by apache.

the class QueryManagerImpl method searchForVolumes.

@Override
public ListResponse<VolumeResponse> searchForVolumes(ListVolumesCmd cmd) {
    Pair<List<VolumeJoinVO>, Integer> result = searchForVolumesInternal(cmd);
    ListResponse<VolumeResponse> response = new ListResponse<VolumeResponse>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListVolumesCmdByAdmin) {
        respView = ResponseView.Full;
    }
    List<VolumeResponse> volumeResponses = ViewResponseHelper.createVolumeResponse(respView, result.first().toArray(new VolumeJoinVO[result.first().size()]));
    for (VolumeResponse vr : volumeResponses) {
        String poolId = vr.getStoragePoolId();
        if (poolId == null) {
            continue;
        }
        DataStore store = dataStoreManager.getPrimaryDataStore(poolId);
        if (store == null) {
            continue;
        }
        DataStoreDriver driver = store.getDriver();
        if (driver == null) {
            continue;
        }
        Map<String, String> caps = driver.getCapabilities();
        if (caps != null) {
            boolean quiescevm = Boolean.parseBoolean(caps.get(DataStoreCapabilities.VOLUME_SNAPSHOT_QUIESCEVM.toString()));
            vr.setNeedQuiescevm(quiescevm);
        }
    }
    response.setResponses(volumeResponses, result.second());
    return response;
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) DataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver) ListVolumesCmdByAdmin(org.apache.cloudstack.api.command.admin.volume.ListVolumesCmdByAdmin) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) List(java.util.List) VolumeJoinVO(com.cloud.api.query.vo.VolumeJoinVO)

Aggregations

DataStoreDriver (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver)6 DataStoreProvider (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider)4 PrimaryDataStoreDriver (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)2 StoragePoolJoinVO (com.cloud.api.query.vo.StoragePoolJoinVO)1 VolumeJoinVO (com.cloud.api.query.vo.VolumeJoinVO)1 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)1 ListVolumesCmdByAdmin (org.apache.cloudstack.api.command.admin.volume.ListVolumesCmdByAdmin)1 StoragePoolResponse (org.apache.cloudstack.api.response.StoragePoolResponse)1 VolumeResponse (org.apache.cloudstack.api.response.VolumeResponse)1 TemplateInfo (org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo)1 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)1