2018-04-16 22:19:01 +02:00
|
|
|
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>
|
|
|
|
---
|
2018-10-19 02:45:23 +02:00
|
|
|
targetcli/ui_backstore.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++
|
2018-04-16 22:19:01 +02:00
|
|
|
1 file changed, 59 insertions(+)
|
|
|
|
|
|
|
|
--- a/targetcli/ui_backstore.py
|
|
|
|
+++ b/targetcli/ui_backstore.py
|
2018-10-19 02:45:23 +02:00
|
|
|
@@ -29,6 +29,7 @@ import stat
|
2018-04-16 22:19:01 +02:00
|
|
|
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
|
2018-10-19 02:45:23 +02:00
|
|
|
@@ -281,6 +282,7 @@ class UIBackstores(UINode):
|
2018-04-16 22:19:01 +02:00
|
|
|
UIRDMCPBackstore(self)
|
|
|
|
UIFileIOBackstore(self)
|
|
|
|
UIBlockBackstore(self)
|
|
|
|
+ UIRBDBackstore(self)
|
|
|
|
|
|
|
|
for name, iface, prop_dict in self._user_backstores():
|
|
|
|
UIUserBackedBackstore(self, name, iface, prop_dict)
|
2018-10-19 02:45:23 +02:00
|
|
|
@@ -589,6 +591,48 @@ class UIBlockBackstore(UIBackstore):
|
2018-04-16 22:19:01 +02:00
|
|
|
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):
|
|
|
|
'''
|
2018-10-19 02:45:23 +02:00
|
|
|
@@ -791,6 +835,21 @@ class UIBlockStorageObject(UIStorageObje
|
2018-04-16 22:19:01 +02:00
|
|
|
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):
|