Search in sources :

Example 6 with ResponseView

use of com.cloud.api.ResponseObject.ResponseView in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method searchForVolumes.

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

Example 7 with ResponseView

use of com.cloud.api.ResponseObject.ResponseView in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method searchForAccounts.

@Override
public ListResponse<AccountResponse> searchForAccounts(final ListAccountsCmd cmd) {
    final Pair<List<AccountJoinVO>, Integer> result = searchForAccountsInternal(cmd);
    final ListResponse<AccountResponse> response = new ListResponse<>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListAccountsCmdByAdmin) {
        respView = ResponseView.Full;
    }
    final List<AccountResponse> accountResponses = ViewResponseHelper.createAccountResponse(respView, result.first().toArray(new AccountJoinVO[result.first().size()]));
    response.setResponses(accountResponses, result.second());
    return response;
}
Also used : ResponseView(com.cloud.api.ResponseObject.ResponseView) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ProjectAccountResponse(com.cloud.api.response.ProjectAccountResponse) AccountResponse(com.cloud.api.response.AccountResponse) ListAccountsCmdByAdmin(com.cloud.api.command.admin.account.ListAccountsCmdByAdmin) ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) UserAccountJoinVO(com.cloud.api.query.vo.UserAccountJoinVO) AccountJoinVO(com.cloud.api.query.vo.AccountJoinVO)

Aggregations

ResponseView (com.cloud.api.ResponseObject.ResponseView)7 ListResponse (com.cloud.api.response.ListResponse)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 TemplateJoinVO (com.cloud.api.query.vo.TemplateJoinVO)2 TemplateResponse (com.cloud.api.response.TemplateResponse)2 ListAccountsCmdByAdmin (com.cloud.api.command.admin.account.ListAccountsCmdByAdmin)1 ListDomainsCmdByAdmin (com.cloud.api.command.admin.domain.ListDomainsCmdByAdmin)1 ListIsosCmdByAdmin (com.cloud.api.command.admin.iso.ListIsosCmdByAdmin)1 ListTemplatesCmdByAdmin (com.cloud.api.command.admin.template.ListTemplatesCmdByAdmin)1 ListVMsCmdByAdmin (com.cloud.api.command.admin.vm.ListVMsCmdByAdmin)1 ListVolumesCmdByAdmin (com.cloud.api.command.admin.volume.ListVolumesCmdByAdmin)1 ListZonesCmdByAdmin (com.cloud.api.command.admin.zone.ListZonesCmdByAdmin)1 AccountJoinVO (com.cloud.api.query.vo.AccountJoinVO)1 DataCenterJoinVO (com.cloud.api.query.vo.DataCenterJoinVO)1 DomainJoinVO (com.cloud.api.query.vo.DomainJoinVO)1 ProjectAccountJoinVO (com.cloud.api.query.vo.ProjectAccountJoinVO)1 UserAccountJoinVO (com.cloud.api.query.vo.UserAccountJoinVO)1 UserVmJoinVO (com.cloud.api.query.vo.UserVmJoinVO)1 VolumeJoinVO (com.cloud.api.query.vo.VolumeJoinVO)1