Filesystem Snapshot Identifiers

The fssnap module provides objects that uniquely identify Filesystems and Snapshots. These are typically passed to other functions.

They also provide convenient, efficient, methods for converting between Filesystem and Snapshot identifiers.

Note

These objects require root permission to create

Description

arcapix.fs.gpfs.clib.fssnap.cmp_fssnapid(fssnap_id snapId1, fssnap_id snapId2)

Compare the ages of two snapshots.

Returns:0 if snap ids are identical

-1 if snapId1 is older than snapId2

1 if snapId1 is newer than snapId2

e.g. to test if snapId1 is older than snapId2

>>> if cmp_fssnapid(snapId1, snapId2) == -1:
...     ...
class arcapix.fs.gpfs.clib.fssnap.fssnap_handle

Wrapper class for the gpfs_fssnap_handle_t structure.

fssnap_handles are typically passed to other methods as a convenient way of identifying a particular filesystem or snapshot.

class arcapix.fs.gpfs.clib.fssnap.fssnap_id

Wrapper class for the gpfs_fssnap_id_t structure.

fssnap_id objects can’t be instantiated directly. Create via fssnap_handle using get_fssnapid_from_fssnaphandle()

The main use of fssnap_id objects is as a parameter to specify a previous snapId for inode scans

arcapix.fs.gpfs.clib.fssnap.get_fsname_from_fssnaphandle(fssnap_handle fssnap)

Get the filesystem name for the fsfnap_handle.

Parameters:fssnap (fssnap_handle) –
Return type:str
arcapix.fs.gpfs.clib.fssnap.get_fssnaphandle_by_fssnapid(fssnap_id id)

Creates a new fssnap_handle from an fssnap_id object.

Parameters:id (fssnap_id) – an fssnap_id representing a filesystem or snapshot
Return type:fssnap_handle
arcapix.fs.gpfs.clib.fssnap.get_fssnaphandle_by_name(const char *fsName, const char *snapName=NULL, const char *fsetName=NULL)

Get an fssnap_handle for a filesystem or snapshot by name.

Parameters:
  • fsName (str) – name of a filesystem
  • snapName (str) – name of a snapshot within the filesystem
  • fsetName (str) – For a fileset snapshot, the name of the fileset the snapshot belongs to
Return type:

fssnap_handle

arcapix.fs.gpfs.clib.fssnap.get_fssnaphandle_by_path(const char *pathname)

Get an fssnap_handle for a filesystem or snapshot that a particular file or directory belongs to.

Parameters:pathname (str) – path to a file or directory you’d like to create an fssnap_handle for
Return type:fssnap_handle
arcapix.fs.gpfs.clib.fssnap.get_fssnapid_from_fssnaphandle(fssnap_handle fssnap)

Get the fssnap_id for the snapshot or filesystem.

Parameters:fssnap (fssnap_handle) –
Return type:fssnap_id
arcapix.fs.gpfs.clib.fssnap.get_pathname_from_fssnaphandle(fssnap_handle fssnap)

Get the path to the snapshot or filesystem.

Parameters:fssnap (fssnap_handle) –
Return type:str
arcapix.fs.gpfs.clib.fssnap.get_snapdirname(fssnap_handle fssnap)

Get the name of the snapshot directory (typically .snapshot)

Parameters:fssnap (fssnap_handle) –
Return type:str
arcapix.fs.gpfs.clib.fssnap.get_snapid_from_fssnaphandle(fssnap_handle fssnap)

Get the numeric snapshot id of the snapshot.

Parameters:fssnap (fssnap_handle) –
Return type:int
arcapix.fs.gpfs.clib.fssnap.get_snapname_from_fssnaphandle(fssnap_handle fssnap)

Get the name of the snapshot for the fssnap_handle.

Parameters:fssnap (fssnap_handle) –
Return type:str

Examples

Find the directory of a snapshot

>>> from arcapix.fs.gpfs.clib.fssnap import get_fssnaphandle_by_name, get_pathname_from_fssnaphandle
>>>
>>> # Create fssnap_handle object
... fs = get_fssnaphandle_by_name('mmfs1', 'global-snapshot1')
>>>
>>> # Get pathname
... print get_pathname_from_fssnaphandle(fs)
'/mmfs1/.snapshots/global-snaphots1'

Find the name of the Filesystem a file belongs to

>>> from arcapix.fs.gpfs.clib.fssnap import get_fssnaphandle_by_path, get_fsname_from_fssnaphandle
>>>
>>> # Create FssnapHandle object
... fs = get_fssnaphandle_by_path('/gpfs/fs1/testfile.txt')
>>>
>>> # Get Filesystem name
... print get_fsname_from_fssnaphandle(fs)
'fs1'