Criteria

A Criteria object holds a collection of criteria, which specify what conditions a file must meet to be selected for the parent Rule.

The following files attributes are supported for criteria:

  • access_time
  • blocksize
  • change_time
  • clone_depth
  • clone_is_parent
  • clone_parent_fileset_id
  • clone_parent_inode
  • clone_parent_is_snap
  • clone_parent_snap_id
  • creation_time
  • device_id
  • directory_hash
  • expiration_time
  • file_heat
  • file_size
  • fileset_name
  • generation
  • group_id
  • inode
  • kb_allocated
  • mode
  • misc_attributes
  • modification_snapid
  • modification_time
  • name
  • nlink
  • path_name
  • pool_name
  • rdevice_id
  • user_id

The following short attributes are also supported:

  • access - days since the file was last accessed
  • change - days since the file was last changed
  • creation - days since the file was created
  • modification - days since the file was last modified
  • size - synonym for file_size
  • user - synonym for user_id
  • group - synonym for group_id
  • fileset - synonym for fileset_name
  • pool - synonym for pool_name
  • path - synonym for path_name

Attribute names are case insensitive, though the values of those attributes may not be.

Description

class arcapix.fs.gpfs.criteria.Criteria

Criteria are conditions that a file must match to be selected (or excluded) in a policy

new(*criterion)

Create a new Criterion

Multiple new criteria can be created at once

destroy(criterion)

Delete a Criterion

clear()

Delete all existing criteria

static Or(*criterion)

Combine multiple criteria with OR

static like(attr, pattern, exclude=False, caseInsensitive=False)

Match a file attribute to a (string) pattern

Parameters:
  • attr – file atribute to compare
  • pattern (str) – pattern to compare attribute against
  • exclude (bool) – exclude any files with attribute which matches pattern
  • caseInsensitive (bool) – ignore case when comparing attribute
static eq(attr, value, exclude=False)

Match a file attribute to a (integer) value

Parameters:
  • attr – file atribute to compare
  • value – value to compare attribute against
  • exclude – exclude any files with attribute which matches pattern
static gt(attr, value)

Compare a file attribute to a (integer) value

Parameters:
  • attr – file atribute to compare
  • value – value to compare attribute against
static lt(attr, value)

Compare a file attribute to a (interger) value

Parameters:
  • attr – file atribute to compare
  • value – value to compare attribute against
static regex(attr, pattern, exclude=False)

Match a file attribute to a regular expression

Parameters:
  • attr – file atribute to compare
  • pattern (str) – pattern to compare attribute against
  • exclude (bool) – exclude any files with attribute which matches pattern
static comment(string)

Create a criteria comment

validate(macros=None)

Check that the criteria file attributes are valid

toGpfsString(excludeComments=False, excludeDisabled=False)

Returns a GPFS policy file string of the collected criteria

Examples

Create a rule that deletes temporary files that haven’t been accessed in over 30 days

>>> from arcapix.fs.gpfs import DeleteRule, Criteria
>>>
>>> # Create new rule
... myrule = Rule(DeleteRule, name='del-temp', source='pool_1')
>>>
>>> # Set access age criteria
... myrule.criteria.new(Criteria.gt("access", 30))
>>>
>>> # Set criteria for filename OR directory match
... myrule.criteria.new(Criteria.Or(Criteria.like('name', '*.tmp', caseInsensitive=True), Criteria.like('path', '*/tmp/*')))
>>>
>>> print myrule.toGpfsString()

RULE 'del-temp' DELETE FROM POOL 'pool_1'
    WHERE DAYS(CURRENT_TIMESTAMP) – DAYS(ACCESS_TIME) > 30
    AND (lower(NAME) LIKE '%.tmp' OR PATH_NAME LIKE '%/tmp/%')

Create a rule with multiple options and two criteria created at once

>>> from arcapix.fs.gpfs import MigrateRule, Criteria
>>>
>>> # Create a migrate Rule
... r = Rule(MigrateRule, name="year-old", source="pool_x", target="pool_zz")
>>>
>>> # Set additional rule options
... r.change(threshold=(90,50), sort='KB_ALLOCATED')
>>>
>>> # Add criteria
... r.criteria.new(Criteria.gt("access", 365), Criteria.eq("user", 0, exclude=True))
>>>
>>> # Print GPFS string
... print r.toGpfsString()

RULE 'year-old' MIGRATE FROM POOL 'pool_x' TO POOL 'pool_zz'
    THRESHOLD(90,50)
    WEIGHT(KB_ALLOCATED)
    WHERE DAYS(CURRENT_TIMESTAMP) – DAYS(ACCESS_TIME) > 365
    AND NOT USER_ID=0