Skip to content

Commit fc07f87

Browse files
committed
Fix is_open call for many drivers (#25)
Ensure all shared drivers are imported in `_is_open` definition to register them in the driver list. Otherwise this function always fails with a SRUnknownType exception. Also, we must add two fake mandatory parameters to make MooseFS happy: `masterhost` and `rootpath`. Same for CephFS with: `serverpath`. (NFS driver is directly patched to ensure there is no usage of the `serverpath` param because its value is equal to None.) `location` param is required to use ZFS, to be more precise, in the parent class: `FileSR`. Signed-off-by: Ronan Abhamon <[email protected]>
1 parent fb8fd63 commit fc07f87

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

drivers/GlusterFSSR.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def load(self, sr_uuid):
9696
self.driver_config = DRIVER_CONFIG
9797
if 'server' not in self.dconf:
9898
raise xs_errors.XenError('ConfigServerMissing')
99-
self.remoteserver = self.dconf['server']
99+
# Can be None => on-slave plugin hack (is_open function).
100+
self.remoteserver = self.dconf['server'] or ''
100101
if self.sr_ref and self.session is not None:
101102
self.sm_config = self.session.xenapi.SR.get_sm_config(self.sr_ref)
102103
else:

drivers/NFSSR.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ def load(self, sr_uuid):
8787
self.sm_config = self.srcmd.params.get('sr_sm_config') or {}
8888
self.other_config = self.srcmd.params.get('sr_other_config') or {}
8989
self.nosubdir = self.sm_config.get('nosubdir') == "true"
90-
if 'serverpath' in self.dconf:
91-
self.remotepath = os.path.join(self.dconf['serverpath'],
92-
not self.nosubdir and sr_uuid or "").encode('utf-8')
90+
serverpath = self.dconf.get('serverpath')
91+
if serverpath is not None:
92+
self.remotepath = os.path.join(
93+
serverpath,
94+
not self.nosubdir and sr_uuid or ""
95+
).encode('utf-8')
9396
self.path = os.path.join(SR.MOUNT_BASE, sr_uuid)
9497

9598
# Handle optional dconf attributes
@@ -101,7 +104,8 @@ def load(self, sr_uuid):
101104
self.options = ''
102105

103106
def validate_remotepath(self, scan):
104-
if 'serverpath' not in self.dconf:
107+
serverpath = self.dconf.get('serverpath')
108+
if serverpath is None:
105109
if scan:
106110
try:
107111
self.scan_exports(self.dconf['server'])

drivers/on_slave.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,14 @@ def _is_open(session, args):
7676
"""Check if VDI <args["vdiUuid"]> is open by a tapdisk on this host"""
7777
import SRCommand
7878
import SR
79-
import NFSSR
79+
import CephFSSR
8080
import EXTSR
81+
import GlusterFSSR
8182
import LVHDSR
83+
import MooseFSSR
84+
import NFSSR
85+
import XFSSR
86+
import ZFSSR
8287
import blktap2
8388

8489
util.SMlog("on-slave.is_open: %s" % args)
@@ -93,7 +98,15 @@ def _is_open(session, args):
9398
srType = "lvhd"
9499
cmd = SRCommand.SRCommand(None)
95100
cmd.driver_info = {"capabilities": None}
96-
cmd.dconf = {"server": None, "device": "/HACK"}
101+
cmd.dconf = {
102+
"server": None,
103+
"device": "/HACK",
104+
# Hack for custom XCP-ng drivers.
105+
"masterhost": None, # MooseFS
106+
"rootpath": None, # MooseFS
107+
"serverpath": None, # CephFS
108+
"location": "/HACK" # ZFS
109+
}
97110
cmd.params = {"command": None}
98111

99112
driver = SR.driver(srType)

0 commit comments

Comments
 (0)