Search in sources :

Example 1 with BackupResponse

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

the class ListBackupsCmd method setupResponseBackupList.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
protected void setupResponseBackupList(final List<Backup> backups, final Integer count) {
    final List<BackupResponse> responses = new ArrayList<>();
    for (Backup backup : backups) {
        if (backup == null) {
            continue;
        }
        BackupResponse backupResponse = _responseGenerator.createBackupResponse(backup);
        responses.add(backupResponse);
    }
    final ListResponse<BackupResponse> response = new ListResponse<>();
    response.setResponses(responses, count);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) Backup(org.apache.cloudstack.backup.Backup) ArrayList(java.util.ArrayList) BackupResponse(org.apache.cloudstack.api.response.BackupResponse)

Example 2 with BackupResponse

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

the class BackupDaoImpl method newBackupResponse.

@Override
public BackupResponse newBackupResponse(Backup backup) {
    VMInstanceVO vm = vmInstanceDao.findByIdIncludingRemoved(backup.getVmId());
    AccountVO account = accountDao.findByIdIncludingRemoved(vm.getAccountId());
    DomainVO domain = domainDao.findByIdIncludingRemoved(vm.getDomainId());
    DataCenterVO zone = dataCenterDao.findByIdIncludingRemoved(vm.getDataCenterId());
    BackupOffering offering = backupOfferingDao.findByIdIncludingRemoved(vm.getBackupOfferingId());
    BackupResponse response = new BackupResponse();
    response.setId(backup.getUuid());
    response.setVmId(vm.getUuid());
    response.setVmName(vm.getHostName());
    response.setExternalId(backup.getExternalId());
    response.setType(backup.getType());
    response.setDate(backup.getDate());
    response.setSize(backup.getSize());
    response.setProtectedSize(backup.getProtectedSize());
    response.setStatus(backup.getStatus());
    response.setVolumes(new Gson().toJson(vm.getBackupVolumeList().toArray(), Backup.VolumeInfo[].class));
    response.setBackupOfferingId(offering.getUuid());
    response.setBackupOffering(offering.getName());
    response.setAccountId(account.getUuid());
    response.setAccount(account.getAccountName());
    response.setDomainId(domain.getUuid());
    response.setDomain(domain.getName());
    response.setZoneId(zone.getUuid());
    response.setZone(zone.getName());
    response.setObjectName("backup");
    return response;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) DomainVO(com.cloud.domain.DomainVO) BackupOffering(org.apache.cloudstack.backup.BackupOffering) Backup(org.apache.cloudstack.backup.Backup) VMInstanceVO(com.cloud.vm.VMInstanceVO) Gson(com.google.gson.Gson) BackupResponse(org.apache.cloudstack.api.response.BackupResponse) AccountVO(com.cloud.user.AccountVO)

Aggregations

BackupResponse (org.apache.cloudstack.api.response.BackupResponse)2 Backup (org.apache.cloudstack.backup.Backup)2 DataCenterVO (com.cloud.dc.DataCenterVO)1 DomainVO (com.cloud.domain.DomainVO)1 AccountVO (com.cloud.user.AccountVO)1 VMInstanceVO (com.cloud.vm.VMInstanceVO)1 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 BackupOffering (org.apache.cloudstack.backup.BackupOffering)1