diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d676db..45dc2fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ set(DATAPATH_PLUGINS ) set(VOLUME_PLUGINS + org.xen.xapi.storage.zfs-vol org.xen.xapi.storage.ext4-ng org.xen.xapi.storage.filebased org.xen.xapi.storage.nfs-ng diff --git a/plugins/volume/org.xen.xapi.storage.zfs-vol/plugin.py b/plugins/volume/org.xen.xapi.storage.zfs-vol/plugin.py new file mode 100755 index 0000000..0952ddd --- /dev/null +++ b/plugins/volume/org.xen.xapi.storage.zfs-vol/plugin.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import os +import sys +import xapi.storage.api.v5.plugin +from xapi.storage import log + +class Implementation(xapi.storage.api.v5.plugin.Plugin_skeleton): + + def diagnostics(self, dbg): + return "No diagnostic data to report" + + def query(self, dbg): + return { + "plugin": "zfs-vol", + "name": "ZFS Volume plugin", + "description": ("This plugin manages ZFS volumes"), + "vendor": "None", + "copyright": "(C) 2021-2024 Vates", + "version": "3.0", + "required_api_version": "5.0", + "features": [ + ], + "configuration": {}, + "required_cluster_stack": []} + + +if __name__ == "__main__": + log.log_call_argv() + cmd = xapi.storage.api.v5.plugin.Plugin_commandline(Implementation()) + base = os.path.basename(sys.argv[0]) + if base == 'Plugin.diagnostics': + cmd.diagnostics() + elif base == 'Plugin.Query': + cmd.query() + else: + raise xapi.storage.api.v5.plugin.Unimplemented(base) diff --git a/plugins/volume/org.xen.xapi.storage.zfs-vol/sr.py b/plugins/volume/org.xen.xapi.storage.zfs-vol/sr.py new file mode 100755 index 0000000..33ebbdb --- /dev/null +++ b/plugins/volume/org.xen.xapi.storage.zfs-vol/sr.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import importlib +import os +import os.path +import sys +import urlparse + +from xapi.storage import log +from xapi.storage.libs import util +from xapi.storage.common import call +from xapi.storage.libs.libcow.volume import COWVolume +import xapi.storage.api.v5.volume + + +@util.decorate_all_routines(util.log_exceptions_in_function) +class Implementation(xapi.storage.api.v5.volume.SR_skeleton): + "SR driver to provide volumes from zvol's" + +if __name__ == '__main__': + log.log_call_argv() + cmd = xapi.storage.api.v5.volume.SR_commandline(Implementation()) + + call("zfs-vol.sr", ['modprobe', 'zfs']) + + base = os.path.basename(sys.argv[0]) + raise xapi.storage.api.v5.volume.Unimplemented(base) diff --git a/plugins/volume/org.xen.xapi.storage.zfs-vol/volume.py b/plugins/volume/org.xen.xapi.storage.zfs-vol/volume.py new file mode 100755 index 0000000..b2edac6 --- /dev/null +++ b/plugins/volume/org.xen.xapi.storage.zfs-vol/volume.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import importlib +import os +import sys +import urlparse +import uuid +import xapi.storage.api.v5.volume + +from xapi.storage import log +from xapi.storage.libs import util +from xapi.storage.libs.libcow.callbacks import VolumeContext +from xapi.storage.libs.libcow.imageformat import ImageFormat +from xapi.storage.libs.libcow.lock import PollLock +from xapi.storage.libs.libcow.volume_implementation import Implementation as \ + DefaultImplementation + +@util.decorate_all_routines(util.log_exceptions_in_function) +class Implementation(DefaultImplementation): + "Volume driver to provide raw volumes from zvol's" + +def call_volume_command(): + """Parse the arguments and call the required command""" + log.log_call_argv() + fsp = importlib.import_module("zfs-vol") + cmd = xapi.storage.api.v5.volume.Volume_commandline( + Implementation(fsp.Callbacks())) + base = os.path.basename(sys.argv[0]) + raise xapi.storage.api.v5.volume.Unimplemented(base) + +if __name__ == "__main__": + call_volume_command() diff --git a/plugins/volume/org.xen.xapi.storage.zfs-vol/zfs-vol.py b/plugins/volume/org.xen.xapi.storage.zfs-vol/zfs-vol.py new file mode 100755 index 0000000..fe520cb --- /dev/null +++ b/plugins/volume/org.xen.xapi.storage.zfs-vol/zfs-vol.py @@ -0,0 +1,5 @@ +import os.path +import xapi.storage.libs.libcow.callbacks + +class Callbacks(xapi.storage.libs.libcow.callbacks.Callbacks): + "ZFS-vol callbacks"