targetcli-fb/rbd-support.patch
Lee Duncan 4a61c20fae Accepting request 643046 from home:lee_duncan:branches:Base:System
- Update to version 2.1.49:
  * version 2.1.fb49
  * targetcli-fb: Add support for media change
  * fix the parameter of define_config_group_param
  * saveconfig: handle backups with block-level delete
  * saveconfig: way for block-level save with delete command
  * create: add a way to set control string
  * fix amount of backup files in backup dir
  * config: add saveconfig command to StorageObject level
  * Allow to customize a home directory
  * Fix default max_backup_files in ui_command_saveconfig
  * MappedLuns and Luns max number is not the same anymore
  * Use signed char instead of char
  * version 2.1.fb48
  * remove wrong exit code from targetcli --version
  * backup: global option to tune max no. of backup conf files
  * config: rename key 'kept_backups' as 'max_backup_files'
  * config: backup when current config is different from recent backup copy
  * config: defend on '/etc/target/backup' directory
  * Auto-detect readonly state for iblock devices
  * Read number of backup files to keep from file
  * skip refreshing user backed storage object when it is null
  * Replace dbus-python with GObject Introspection
 This replaces targetcli-fb-2.1.47.tar.xz with targetcli-fb-2.1.49.tar.xz,
 and removes the following patches:
 * Auto-detect-readonly-state-for-iblock-devices.patch
 * Use-signed-char-instead-of-char.patch
 * targetcli-only-save-old-config-if-present.patch
 and updates the SPEC file.

OBS-URL: https://build.opensuse.org/request/show/643046
OBS-URL: https://build.opensuse.org/package/show/Base:System/targetcli-fb?expand=0&rev=22
2018-10-19 00:45:23 +00:00

104 lines
3.6 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(+)
--- a/targetcli/ui_backstore.py
+++ b/targetcli/ui_backstore.py
@@ -29,6 +29,7 @@ import stat
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
@@ -281,6 +282,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)
@@ -589,6 +591,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):
'''
@@ -791,6 +835,21 @@ class UIBlockStorageObject(UIStorageObje
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):