Snapshot List¶
Snapshot filtering is performed using the filter_
methods of curator.SnapshotList
- class curator.SnapshotList(client, repository=None)¶
Bases:
object
Snapshot list object
- client¶
An
Elasticsearch
client object passed from paramclient
- empty_list_check()¶
Raise exception if
snapshots
is empty
- filter_by_age(source='creation_date', direction=None, timestring=None, unit=None, unit_count=None, epoch=None, exclude=False)¶
Remove snapshots from
snapshots
by relative age calculations.- Parameters:
source – Source of snapshot age. Can be
name
, orcreation_date
.direction – Time to filter, either
older
oryounger
timestring – A
time.strftime()
string to match the datestamp in an snapshot name. Only used for snapshot filtering byname
.unit – One of
seconds
,minutes
,hours
,days
,weeks
,months
, oryears
.unit_count – The number of
unit
(s).unit_count
*unit
will be calculated out to the relative number of seconds.epoch – An epoch timestamp used in conjunction with
unit
andunit_count
to establish a point of reference for calculations. If not provided, the current time will be used.exclude – If
exclude=True
, this filter will remove matching snapshots fromsnapshots
. Ifexclude=False
, then only matching snapshots will be kept insnapshots
. Default isFalse
- filter_by_count(count=None, reverse=True, use_age=False, source='creation_date', timestring=None, exclude=True)¶
Remove snapshots from the actionable list beyond the number
count
, sorted reverse-alphabetically by default. If you setreverse=False
, it will be sorted alphabetically.The default is usually what you will want. If only one kind of snapshot is provided–for example, snapshots matching
curator-%Y%m%d%H%M%S
–then reverse alphabetical sorting will mean the oldest will remain in the list, because lower numbers in the dates mean older snapshots.By setting
reverse=False
, thensnapshot3
will be acted on beforesnapshot2
, which will be acted on beforesnapshot1
use_age
allows ordering snapshots by age. Age is determined by the snapshot creation date (as identified bystart_time_in_millis
) by default, but you can also specifysource=name
. Thename
source
requires the timestring argument.- Parameters:
count – Filter snapshots beyond
count
.reverse – The filtering direction. (default:
True
).use_age – Sort snapshots by age.
source
is required in this case.source – Source of snapshot age. Can be one of
name
, orcreation_date
. Default:creation_date
timestring – A
time.strftime()
string to match the datestamp in a snapshot name. Only used ifsource=name
.exclude – If
exclude=True
, this filter will remove matching snapshots fromsnapshots
. Ifexclude=False
, then only matching snapshots will be kept insnapshots
. Default isTrue
- filter_by_regex(kind=None, value=None, exclude=False)¶
Filter out snapshots not matching the pattern, or in the case of exclude, filter those matching the pattern.
- Parameters:
kind – Can be one of:
suffix
,prefix
,regex
, ortimestring
. This option defines what kind of filter you will be building.value – Depends on
kind
. It is thetime.strftime()
string ifkind
istimestring
. It’s used to build the regular expression for other kinds.exclude – If
exclude=True
, this filter will remove matching snapshots fromsnapshots
. Ifexclude=False
, then only matching snapshots will be kept insnapshots
. Default isFalse
- filter_by_state(state=None, exclude=False)¶
Filter out snapshots not matching
state
, or in the case of exclude, filter those matchingstate
.- Parameters:
state – The snapshot state to filter for. Must be one of
SUCCESS
,PARTIAL
,FAILED
, orIN_PROGRESS
.exclude – If
exclude=True
, this filter will remove matching snapshots fromsnapshots
. Ifexclude=False
, then only matching snapshots will be kept insnapshots
. Default isFalse
- filter_none()¶
No filter at all
- filter_period(period_type='relative', source='name', range_from=None, range_to=None, date_from=None, date_to=None, date_from_format=None, date_to_format=None, timestring=None, unit=None, week_starts_on='sunday', epoch=None, exclude=False)¶
Match
snapshots
with ages within a given period.- Parameters:
period_type – Can be either
absolute
orrelative
. Default isrelative
.date_from
anddate_to
are required when usingperiod_type='absolute'
.range_from
andrange_to
are required withperiod_type='relative'
.source – Source of snapshot age. Can be
name
, orcreation_date
.range_from – How many
unit
(s) in the past/future is the origin?range_to – How many
unit
(s) in the past/future is the end point?date_from – The simplified date for the start of the range
date_to – The simplified date for the end of the range. If this value is the same as
date_from
, the full value ofunit
will be extrapolated for the range. For example, ifunit=months
, anddate_from
anddate_to
are both2017.01
, then the entire month of January 2017 will be the absolute date range.date_from_format – The
time.strftime()
string used to parsedate_from
date_to_format – The
time.strftime()
string used to parsedate_to
timestring – An
time.strftime()
string to match the datestamp in an snapshot name. Only used for snapshot filtering byname
.unit – One of
hours
,days
,weeks
,months
, oryears
.week_starts_on – Either
sunday
ormonday
. Default issunday
epoch – An epoch timestamp used to establish a point of reference for calculations. If not provided, the current time will be used.
exclude – If
exclude=True
, this filter will remove matching indices fromindices
. Ifexclude=False
, then only matching indices will be kept inindices
. Default isFalse
- iterate_filters(config)¶
Iterate over the filters defined in
config
and execute them.- Parameters:
config – A dictionary of filters, as extracted from the YAML configuration file.
Note
config
should be a dictionary with the following form:{ 'filters' : [ { 'filtertype': 'the_filter_type', 'key1' : 'value1', ... 'keyN' : 'valueN' } ] }
- most_recent()¶
Return the most recent snapshot based on
start_time_in_millis
.
- repository¶
The value passed as
delete_aliases
- snapshot_info¶
Information extracted from snapshots, such as age, etc. Populated by internal method
__get_snapshots
at instance creation time. Type:dict
- snapshots¶
The running list of snapshots which will be used by an Action class. Populated by internal methods
__get_snapshots
at instance creation time. Type:list
- working_list()¶
Return the current value of
snapshots
as copy-by-value to prevent list stomping during iterations