f8c3097b3b
- Merge RBD support from non-fb version (bsc#1079329) + Split-out-blockdev-readonly-state-detection-helper.patch + rbd-support.patch (SLE/Leap only, due to LIO kernel dependency) + Add explicit Provides for "python-rtslib-rbd" - Detect write-protected block devices (bsc#1070815) + Auto-detect-readonly-state-for-iblock-devices.patch + Use-signed-char-instead-of-char.patch - Automatically generate version string from upstream tag + Retain current fb-removed version format used + Rename targetcli-fb-2.1.fb47.tar.xz to targetcli-fb-2.1.47.tar.xzar.xz and cleanup hardcoded duplicate name/version values in spec OBS-URL: https://build.opensuse.org/request/show/596386 OBS-URL: https://build.opensuse.org/package/show/Base:System/targetcli-fb?expand=0&rev=18
109 lines
3.7 KiB
Diff
109 lines
3.7 KiB
Diff
From dc250fa879939702bdf69e561cb9041a57f997ea Mon Sep 17 00:00:00 2001
|
|
From: Mike Christie <mchristi@redhat.com>
|
|
Date: Tue, 10 Apr 2018 17:31:32 +0200
|
|
Subject: [PATCH 4/4] rbd support
|
|
|
|
targetcli-fb-rbd.patch obtained from:
|
|
https://marc.info/?l=ceph-devel&m=143816209010058
|
|
|
|
[ddiss@suse.de: accept and propagate wwn parameter]
|
|
Reviewed-by: David Disseldorp <ddiss@suse.de>
|
|
---
|
|
targetcli/ui_backstore.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 59 insertions(+)
|
|
|
|
diff --git a/targetcli/ui_backstore.py b/targetcli/ui_backstore.py
|
|
index 57dedb1..d576122 100644
|
|
--- a/targetcli/ui_backstore.py
|
|
+++ b/targetcli/ui_backstore.py
|
|
@@ -29,6 +29,7 @@ import dbus
|
|
from configshell_fb import ExecutionError
|
|
from rtslib_fb import BlockStorageObject, FileIOStorageObject
|
|
from rtslib_fb import PSCSIStorageObject, RDMCPStorageObject, UserBackedStorageObject
|
|
+from rtslib_fb import RBDStorageObject
|
|
from rtslib_fb import ALUATargetPortGroup
|
|
from rtslib_fb import RTSLibError
|
|
from rtslib_fb import RTSRoot
|
|
@@ -269,6 +270,7 @@ class UIBackstores(UINode):
|
|
UIRDMCPBackstore(self)
|
|
UIFileIOBackstore(self)
|
|
UIBlockBackstore(self)
|
|
+ UIRBDBackstore(self)
|
|
|
|
for name, iface, prop_dict in self._user_backstores():
|
|
UIUserBackedBackstore(self, name, iface, prop_dict)
|
|
@@ -572,6 +574,48 @@ class UIBlockBackstore(UIBackstore):
|
|
completions = [completions[0] + ' ']
|
|
return completions
|
|
|
|
+class UIRBDBackstore(UIBackstore):
|
|
+ '''
|
|
+ RBD backstore UI.
|
|
+ '''
|
|
+ def __init__(self, parent):
|
|
+ self.so_cls = UIRBDStorageObject
|
|
+ UIBackstore.__init__(self, 'rbd', parent)
|
|
+
|
|
+ def ui_command_create(self, name, dev, readonly=None, wwn=None):
|
|
+ '''
|
|
+ Creates an RBD Storage object. I{dev} is the path to the RBD
|
|
+ block device to use.
|
|
+ '''
|
|
+ self.assert_root()
|
|
+
|
|
+ ro_string = self.ui_eval_param(readonly, 'string', None)
|
|
+ if ro_string == None:
|
|
+ # attempt to detect block device readonly state via ioctl
|
|
+ readonly = blk_dev_ro_check(dev)
|
|
+ else:
|
|
+ readonly = self.ui_eval_param(readonly, 'bool', False)
|
|
+
|
|
+ wwn = self.ui_eval_param(wwn, 'string', None)
|
|
+
|
|
+ so = RBDStorageObject(name, dev, readonly=readonly, wwn=wwn)
|
|
+ ui_so = UIRBDStorageObject(so, self)
|
|
+ self.setup_model_alias(so)
|
|
+ self.shell.log.info("Created RBD storage object %s using %s."
|
|
+ % (name, dev))
|
|
+ return self.new_node(ui_so)
|
|
+
|
|
+ def ui_complete_create(self, parameters, text, current_param):
|
|
+ '''
|
|
+ Auto-completes the device name
|
|
+ '''
|
|
+ if current_param != 'dev':
|
|
+ return []
|
|
+ completions = complete_path(text, stat.S_ISBLK)
|
|
+ if len(completions) == 1 and not completions[0].endswith('/'):
|
|
+ completions = [completions[0] + ' ']
|
|
+ return completions
|
|
+
|
|
|
|
class UIUserBackedBackstore(UIBackstore):
|
|
'''
|
|
@@ -739,6 +783,21 @@ class UIBlockStorageObject(UIStorageObject):
|
|
return ("%s (%s) %s%s %s" % (so.udev_path, bytes_to_human(so.size),
|
|
ro_str, wb_str, so.status), True)
|
|
|
|
+class UIRBDStorageObject(UIStorageObject):
|
|
+ def summary(self):
|
|
+ so = self.rtsnode
|
|
+
|
|
+ if so.write_back:
|
|
+ wb_str = "write-back"
|
|
+ else:
|
|
+ wb_str = "write-thru"
|
|
+
|
|
+ ro_str = ""
|
|
+ if so.readonly:
|
|
+ ro_str = "ro "
|
|
+
|
|
+ return ("%s (%s) %s%s %s" % (so.udev_path, bytes_to_human(so.size),
|
|
+ ro_str, wb_str, so.status), True)
|
|
|
|
class UIUserBackedStorageObject(UIStorageObject):
|
|
def summary(self):
|
|
--
|
|
2.13.6
|
|
|