Skip to content

Commit

Permalink
zfs-vol: base infrastructure
Browse files Browse the repository at this point in the history
Bare minimum for a plugin, no operation implemented.

Signed-off-by: Yann Dirson <[email protected]>
  • Loading branch information
ydirson committed Apr 2, 2024
1 parent 2b6fb6c commit 1b058fc
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions plugins/volume/org.xen.xapi.storage.zfs-vol/plugin.py
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 27 additions & 0 deletions plugins/volume/org.xen.xapi.storage.zfs-vol/sr.py
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 32 additions & 0 deletions plugins/volume/org.xen.xapi.storage.zfs-vol/volume.py
Original file line number Diff line number Diff line change
@@ -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()
5 changes: 5 additions & 0 deletions plugins/volume/org.xen.xapi.storage.zfs-vol/zfs-vol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os.path
import xapi.storage.libs.libcow.callbacks

class Callbacks(xapi.storage.libs.libcow.callbacks.Callbacks):
"ZFS-vol callbacks"

0 comments on commit 1b058fc

Please sign in to comment.