Search in sources :

Example 11 with SnapshotPolicyVO

use of com.cloud.storage.SnapshotPolicyVO in project cloudstack by apache.

the class SnapshotManagerImpl method findRecurringSnapshotSchedule.

@Override
public List<SnapshotScheduleVO> findRecurringSnapshotSchedule(ListRecurringSnapshotScheduleCmd cmd) {
    Long volumeId = cmd.getVolumeId();
    Long policyId = cmd.getSnapshotPolicyId();
    Account account = CallContext.current().getCallingAccount();
    // Verify parameters
    VolumeVO volume = _volsDao.findById(volumeId);
    if (volume == null) {
        throw new InvalidParameterValueException("Failed to list snapshot schedule, unable to find a volume with id " + volumeId);
    }
    if (account != null) {
        long volAcctId = volume.getAccountId();
        if (_accountMgr.isAdmin(account.getId())) {
            Account userAccount = _accountDao.findById(Long.valueOf(volAcctId));
            if (!_domainDao.isChildDomain(account.getDomainId(), userAccount.getDomainId())) {
                throw new PermissionDeniedException("Unable to list snapshot schedule for volume " + volumeId + ", permission denied.");
            }
        } else if (account.getId() != volAcctId) {
            throw new PermissionDeniedException("Unable to list snapshot schedule, account " + account.getAccountName() + " does not own volume id " + volAcctId);
        }
    }
    // List only future schedules, not past ones.
    List<SnapshotScheduleVO> snapshotSchedules = new ArrayList<SnapshotScheduleVO>();
    if (policyId == null) {
        List<SnapshotPolicyVO> policyInstances = listPoliciesforVolume(volumeId);
        for (SnapshotPolicyVO policyInstance : policyInstances) {
            SnapshotScheduleVO snapshotSchedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, policyInstance.getId(), false);
            snapshotSchedules.add(snapshotSchedule);
        }
    } else {
        snapshotSchedules.add(_snapshotScheduleDao.getCurrentSchedule(volumeId, policyId, false));
    }
    return snapshotSchedules;
}
Also used : Account(com.cloud.user.Account) VolumeVO(com.cloud.storage.VolumeVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) PermissionDeniedException(com.cloud.exception.PermissionDeniedException) SnapshotScheduleVO(com.cloud.storage.SnapshotScheduleVO) SnapshotPolicyVO(com.cloud.storage.SnapshotPolicyVO)

Example 12 with SnapshotPolicyVO

use of com.cloud.storage.SnapshotPolicyVO in project cloudstack by apache.

the class SnapshotSchedulerImpl method scheduleNextSnapshotJob.

private Date scheduleNextSnapshotJob(final SnapshotScheduleVO snapshotSchedule) {
    if (snapshotSchedule == null) {
        return null;
    }
    final Long policyId = snapshotSchedule.getPolicyId();
    if (policyId.longValue() == Snapshot.MANUAL_POLICY_ID) {
        // Don't need to schedule the next job for this.
        return null;
    }
    final SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findById(policyId);
    if (snapshotPolicy == null) {
        _snapshotScheduleDao.expunge(snapshotSchedule.getId());
    }
    return scheduleNextSnapshotJob(snapshotPolicy);
}
Also used : SnapshotPolicyVO(com.cloud.storage.SnapshotPolicyVO)

Example 13 with SnapshotPolicyVO

use of com.cloud.storage.SnapshotPolicyVO in project cloudstack by apache.

the class SnapshotTestWithFakeData method createSnapshotPolicy.

protected SnapshotPolicyVO createSnapshotPolicy(Long volId) {
    SnapshotPolicyVO policyVO = new SnapshotPolicyVO(volId, "jfkd", "fdfd", DateUtil.IntervalType.DAILY, 8);
    policyVO = snapshotPolicyDao.persist(policyVO);
    return policyVO;
}
Also used : SnapshotPolicyVO(com.cloud.storage.SnapshotPolicyVO)

Aggregations

SnapshotPolicyVO (com.cloud.storage.SnapshotPolicyVO)13 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 VolumeVO (com.cloud.storage.VolumeVO)4 IntervalType (com.cloud.utils.DateUtil.IntervalType)4 ResourceType (com.cloud.configuration.Resource.ResourceType)2 ActionEvent (com.cloud.event.ActionEvent)2 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)2 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)2 ResourceObjectType (com.cloud.server.ResourceTag.ResourceObjectType)2 ScopeType (com.cloud.storage.ScopeType)2 Type (com.cloud.storage.Snapshot.Type)2 SnapshotScheduleVO (com.cloud.storage.SnapshotScheduleVO)2 DB (com.cloud.utils.db.DB)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)2 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)1 SnapshotVO (com.cloud.storage.SnapshotVO)1 VMTemplateVO (com.cloud.storage.VMTemplateVO)1