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
snapId1is older thansnapId21 if
snapId1is newer thansnapId2
e.g. to test if
snapId1is older thansnapId2>>> if cmp_fssnapid(snapId1, snapId2) == -1: ... ...
- arcapix.fs.gpfs.clib.fssnap.free_fssnaphandle(fssnap_handle fssnap)
Free an fssnap_handle.
fssnap_handles are automatically freed on deallocation/garbage collecton.
However, if you create a lot of handles in quick succession (e.g. when using multiprocessing), they may not be freed fast enough. In that case, you should free them manually, or else you might get errors when trying to create new handles.
- class arcapix.fs.gpfs.clib.fssnap.fssnap_handle
Wrapper class for the
gpfs_fssnap_handle_tstructure.fssnap_handlesare 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_tstructure.fssnap_idobjects can’t be instantiated directly. Create via fssnap_handle usingget_fssnapid_from_fssnaphandle()The main use of
fssnap_idobjects 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
- arcapix.fs.gpfs.clib.fssnap.get_fssnaphandle_by_fssnapid(fssnap_id id)
Creates a new
fssnap_handlefrom anfssnap_idobject.- Parameters
id (fssnap_id) – an
fssnap_idrepresenting a filesystem or snapshot- Return type
- arcapix.fs.gpfs.clib.fssnap.get_fssnaphandle_by_name(fsName, snapName=None, fsetName=None)
Get an
fssnap_handlefor a filesystem or snapshot by name.- Parameters
- Return type
- arcapix.fs.gpfs.clib.fssnap.get_fssnaphandle_by_path(pathname)
Get an
fssnap_handlefor 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_handlefor- Return type
- arcapix.fs.gpfs.clib.fssnap.get_fssnapid_from_fssnaphandle(fssnap_handle fssnap)
Get the
fssnap_idfor the snapshot or filesystem.- Parameters
fssnap (fssnap_handle) –
- Return type
- 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
- 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
- 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
- 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
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'