????

Your IP : 18.216.126.33


Current Path : /lib/Acronis/PyTools/commands/
Upload File :
Current File : //lib/Acronis/PyTools/commands/retention_specs.py

import time

SECONDS_IN_DAY = 86400
ACTIVITY_COMPLETED_STATE = 5


def get_days_before_time(days):
    return int(time.time()) - SECONDS_IN_DAY * days


def completed_activities_by_amount(amount, days):
    return {
        'pattern': [
            ('^Is', 'string', 'Tol::History::Plain::Activity'),
            ('.State', 'dword', ACTIVITY_COMPLETED_STATE),
            ('.Period.FinishTime', 'sqword', 0),
            ('.Period.FinishTime^Less', 'sqword', get_days_before_time(days)),
        ],
        'historical_order': True,
        'objects_count_limit': amount,
    }


def completed_activities_by_age_in_days(days):
    return {
        'pattern': [
            ('^Is', 'string', 'Tol::History::Plain::Activity'),
            ('.State', 'dword', ACTIVITY_COMPLETED_STATE),
            ('.Period.FinishTime', 'sqword', 0),
            ('.Period.FinishTime^Less', 'sqword', get_days_before_time(days)),
        ],
        'historical_order': True,
        'objects_count_limit': 0,
    }


RETENTION_SPECS_CLOUD = [
    completed_activities_by_age_in_days(60),
    completed_activities_by_amount(10000, 7)
]


RETENTION_SPECS_ONPREM = [
    completed_activities_by_age_in_days(60),
    completed_activities_by_amount(10000, 7)
]