Search in sources :

Example 1 with BackupSchedule

use of org.apache.cloudstack.backup.BackupSchedule 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 2 with BackupSchedule

use of org.apache.cloudstack.backup.BackupSchedule 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

CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 BackupScheduleResponse (org.apache.cloudstack.api.response.BackupScheduleResponse)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