Snapshot

Snapshot can be utilised at the Filesystem, creating a PixStor ‘global snapshot’ or at the Fileset level, creating a localised snapshot.

Root fileset snapshots

By default, snapshots returned for fileset ‘root’ (e.g. fs.filesets['root'].snapshots) will be global snapshots.

However, it is possible to create a snapshot of the ‘root’ fileset specifically. Unlike a global snapshot, this root fileset snapshot will not include any other independent filesets on the filesystem.

To use root fileset snapshots, one can use the setRootFilesetSnapshots pragma function.

Whether this pragma is enabled or not, global snapshot can always be accessed on the Filesystem object (e.g. fs.snapshots).

Warning

The current default behaviour of returning global snapshots is considered deprecated as of version 1.8.0.

In a future release, the behaviour will be switched so that root fileset snapshots are returned instead of global snapshots.

Any code which assumes global snapshots should be updated to the new behaviour, using the setRootFilesetSnapshots pragma as a stepping stone.

Description

arcapix.fs.gpfs.snapshot.setRootFilesetSnapshots(enable=True)

When enabled, snapshots for fileset name ‘root’ will be of the root fileset.

When disabled (default) snapshots for fileset ‘root’ will be global snapshots.

The current default behaviour of returning global snapshots is deprecated as of version 1.8.0, and will be changed to return root fileset snapshots in a future release. Any code which depends on global snapshots being returned should be updated to use ``Filesystem(…).snapshots` instead.

class arcapix.fs.gpfs.snapshot.Snapshot(filesystemName, snapshot_name, fileset_name=None, **kwargs)

Represents a snapshot on the filesystem.

Snapshots can be either global or per (Independent) Fileset. Therefore there a collections of snapshots on both Filesystem and Fileset Objects.

Parameters:
  • filesystemName (str) – The name of the filesystem to create the snapshot on
  • snapshot_name (str) – The name of the snapshot to create
  • fileset_name (str) – The name of the fileset to which this snapshot will/does apply. If None (or the magic value (root), a global snapshot is performed
id

Returns the numerical snapshot ID

Return type:int
status

Returns the status of the snapshot.

Typical values include ‘Valid’ and TBC

Return type:str

:raises GPFSExecuteException

name

Returns the name of the snapshot.

Return type:str
Raises:GPFSExecuteException
filesetName

Returns the name of the fileset which this snapshot relates to.

Returns None for global snapshots

Raises:GPFSExecuteException
Return type:str
filesystemName

Returns the name of the filesystem on which this snapshot is taken.

Return type:str
created

Returns the date and time the snapshot was created.

Raises:GPFSExecuteException
Return type:datetime
dataInKB

Returns the amount of data storage used by the snapshot.

Size in kilobytes

Return type:int
metadataInKB

Returns the amount of metadata storage used by the snapshot.

Size in kilobytes

Return type:int
location

Returns the directory location of the snapshot.

Raises:GPFSError if snapshot of an unlinked fileset
Return type:str
create()

Creates a snapshot based on the values stored in the object.

You must have created/set the object minimally with a filesystem name and a snapshot name, a fileset name is optional

Raises:GPFSExecuteException
delete(qosClass=None, nodes=None)

Deletes the snapshot from disk.

Parameters:
  • qosClass (str) – Quality of Service class to which the operation should be assigned. One of ‘maintenance’ (default) or ‘other’. (GPFS version 4.2+ only)
  • nodes (str or list) – Nodes to participate in delete (default=all or defaultHelperNodes)
Raises:

GPFSExecuteException

change(**kwargs)

Change attributes of the object when this is supported.

Note: Snapshots cannot really be changed post creation, but we provide a method to set the attributes before creation if for some reason you have not provided them in the constructor.

You can specify one or more of the folling named parameters:

Parameters:
  • name (str) – The new name for the snapshot
  • filesetName (str) – The name of the fileset to which this snapshot will apply
  • filesystemName (str) – The name of the file system to which this snapshot will apply
Raises:

ValueError: Attempt to modify a snapshot which is on disk. Only in-memory snapshot objects (i.e. not yet ‘created’) can be modified.

Examples

Utilising Snapshot from the Cluster Object

>>> from arcapix.fs.gpfs import Filesystem
>>>
>>> # Load the 'mmfs1' Filesystem
... fs = Filesystem('mmfs1')
>>>
>>> # Create a global snapshot of the filesystem
... fs.snapshots.new('global-snapshot1')
>>>
>>> # Create a snapshot for a specific independent fileset
... fsnap = fs.filesets['sata1-cg-projects'].snapshots.new('indep-snapshot1')
>>>
>>> # Check the status of the snapshot
... print(fsnap.status)
Valid
>>>
>>> # Delete the snapshot
... fsnap.delete()
>>>
>>> # Check the status of the snapshot
... print(fsnap.status)
Deleted

Utilising Snapshot directly

>>> from arcapix.fs.gpfs import Snapshot
>>>
>>> # Create a snapshot of a specific, existing independent fileset
... mysnap = Snapshot('mmfs1', 'fset-snap', 'sata1-cg-projects')
>>> mysnap.create()
>>>
>>> # Check the status of the snapshot
... print(mysnap.status)
Valid
>>> # Delete the snapshot
... mysnap.delete()
>>>
>>> # Check the status of the snapshot
... print(mysnap.status)
Deleted

Create a root fileset snapshot

>>> from arcapix.fs.gpfs import Filesystem
>>> from arcapix.fs.gpfs.snapshot import setRootFilesetSnapshots
>>>
>>> # enabled root fileset snapshot support
>>> setRootFilesetSnapshots()
>>>
>>> fs = Filesystem('mmfs1')
>>>
>>> # create a snapshot of the root fileset
>>> fs.filesets['root'].snapshots.new('root-snapshot1')
>>>
>>> # create a global snapshot
>>> fs.snapshots.new('global-snapshot1')