Search in sources :

Example 1 with BackupScheduleResponse

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

the class BackupScheduleDaoImpl method newBackupScheduleResponse.

@Override
public BackupScheduleResponse newBackupScheduleResponse(BackupSchedule schedule) {
    VMInstanceVO vm = vmInstanceDao.findByIdIncludingRemoved(schedule.getVmId());
    BackupScheduleResponse response = new BackupScheduleResponse();
    response.setVmId(vm.getUuid());
    response.setVmName(vm.getHostName());
    response.setIntervalType(schedule.getScheduleType());
    response.setSchedule(schedule.getSchedule());
    response.setTimezone(schedule.getTimezone());
    response.setObjectName("backupschedule");
    return response;
}
Also used : VMInstanceVO(com.cloud.vm.VMInstanceVO) BackupScheduleResponse(org.apache.cloudstack.api.response.BackupScheduleResponse)

Example 2 with BackupScheduleResponse

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

the class ListBackupScheduleCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        BackupSchedule schedule = backupManager.listBackupSchedule(getVmId());
        if (schedule != null) {
            BackupScheduleResponse response = _responseGenerator.createBackupScheduleResponse(schedule);
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new CloudRuntimeException("No backup schedule exists for the VM");
        }
    } catch (Exception e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) BackupSchedule(org.apache.cloudstack.backup.BackupSchedule) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) BackupScheduleResponse(org.apache.cloudstack.api.response.BackupScheduleResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 3 with BackupScheduleResponse

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

the class CreateBackupScheduleCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ServerApiException {
    try {
        BackupSchedule schedule = backupManager.configureBackupSchedule(this);
        if (schedule != null) {
            BackupScheduleResponse response = _responseGenerator.createBackupScheduleResponse(schedule);
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new CloudRuntimeException("Error while creating backup schedule of VM");
        }
    } catch (Exception e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) BackupSchedule(org.apache.cloudstack.backup.BackupSchedule) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) BackupScheduleResponse(org.apache.cloudstack.api.response.BackupScheduleResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

BackupScheduleResponse (org.apache.cloudstack.api.response.BackupScheduleResponse)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 BackupSchedule (org.apache.cloudstack.backup.BackupSchedule)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 VMInstanceVO (com.cloud.vm.VMInstanceVO)1