|
|
|
@ -1,71 +1,40 @@ |
|
|
|
|
''' ZFS implementation ''' |
|
|
|
|
|
|
|
|
|
from typing import Any, Tuple, Set, Mapping, Callable |
|
|
|
|
from typing import Any, Tuple, Set, Mapping, Callable |
|
|
|
|
|
|
|
|
|
from ..filesystem import FilesystemRegistry, FilesystemBase, FilesystemT, \ |
|
|
|
|
SnapshotKeyT, DispatcherMixin |
|
|
|
|
from zasd.filesystem import FilesystemRegistry, FilesystemBase, FilesystemT, \ |
|
|
|
|
SnapshotKeyT, DispatcherMixin |
|
|
|
|
|
|
|
|
|
class ZFSFilesystem(DispatcherMixin, FilesystemBase): |
|
|
|
|
''' ZFS filesystem implementation. ''' |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def key(cls) -> str: |
|
|
|
|
''' Retrieve the registry key for this filesystem class. ''' |
|
|
|
|
|
|
|
|
|
# Filesystem classes must add themselves to the filesystem registry as |
|
|
|
|
# soon as they are imported. |
|
|
|
|
return 'zfs' |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
async def filesystems(cls) -> Mapping[str, FilesystemT]: |
|
|
|
|
''' Retrieve a dictionary of labels to filesystems managed by this |
|
|
|
|
filesystem class. ''' |
|
|
|
|
return dict() |
|
|
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
|
super().__init__() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def configure(cls) -> Tuple[Mapping[str, Any], Callable[[Any], None]]: |
|
|
|
|
''' Retrieve tuple for configuring the filesystem. ''' |
|
|
|
|
glo = dict() |
|
|
|
|
|
|
|
|
|
# This method returns a tuple (global_scope, callback), consisting of |
|
|
|
|
# a dictionary and a callback function. It is called each time a |
|
|
|
|
# configuration file has loaded, before it is executed. |
|
|
|
|
# |
|
|
|
|
# The dictionary consists of variables to be deep copied and exposed |
|
|
|
|
# on the global execution scope of the configuration file. This may be |
|
|
|
|
# used by the Filesystem class to provide constants, functions and |
|
|
|
|
# variables that the user will need in order to configure filesystems |
|
|
|
|
# of this class. |
|
|
|
|
def configure(options): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
# The callback is invoked as callback(options) once execution has |
|
|
|
|
# completed. Options are retrived from a variable Filesystem.key() on |
|
|
|
|
# the local execution scope of the configuration file and will equal |
|
|
|
|
# None if no such variable was assigned by the user. The variable is |
|
|
|
|
# typically a dictionary, but may be of any type, and may be used by |
|
|
|
|
# the Filesystem class to retrieve configuration options the user has |
|
|
|
|
# set in order to configure filesystems of this class. ''' |
|
|
|
|
return (glo, configure) |
|
|
|
|
|
|
|
|
|
def label(self) -> str: |
|
|
|
|
''' Retrieve the filesystem label.''' |
|
|
|
|
|
|
|
|
|
# Labels must allow users to easily identify the underlying |
|
|
|
|
# filesystems. Device names, drive letters, volume labels and |
|
|
|
|
# mountpoints should be avoided, since these are not persistent and do |
|
|
|
|
# not uniquely identify a filesystem. If the underlying filesystem |
|
|
|
|
# does not provide labels that satisfy these criteria, a means for the |
|
|
|
|
# user to map unique labels to unique filesystem identifiers must be |
|
|
|
|
# provided in the configuration file. |
|
|
|
|
|
|
|
|
|
async def children(self) -> Mapping[str, FilesystemT]: |
|
|
|
|
''' Get a dictionary of labels to filesystems that are children of this |
|
|
|
|
filesystem. ''' |
|
|
|
|
|
|
|
|
|
# Some filesystem classes allow hierarchical filesystem labels, |
|
|
|
|
# permitting recursive snapshots to be taken on a filesystem and its |
|
|
|
|
# children. An empty dictionary may be returned if this feature is not |
|
|
|
|
# supported. |
|
|
|
|
|
|
|
|
|
async def snapshots(self) -> Set[SnapshotKeyT]: |
|
|
|
|
''' Get a set of keys for snapshots managed by this filesystem |
|
|
|
|
object. Snapshots taken on any children of the filesystem, |
|
|
|
@ -82,4 +51,4 @@ class ZFSFilesystem(DispatcherMixin, FilesystemBase): |
|
|
|
|
a tag and a timestamp equal to that of the parent snapshot are |
|
|
|
|
deleted recursively. ''' |
|
|
|
|
|
|
|
|
|
FilesystemRegistry.register(ZFSFilesystem) |
|
|
|
|
FilesystemRegistry.register(ZFSFilesystem) |