Blob Blame History Raw
From 9637223b9d8cee3abc527f58fc9e14a1bcbe4b29 Mon Sep 17 00:00:00 2001
From: Mike Christie <mchristi@redhat.com>
Date: Wed, 7 Mar 2018 19:47:34 -0600
Subject: [PATCH] tcmu: add control constructor arg

Add format control constructor arg so user does not have to hack
in extra settings through the config option.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
 rtslib/tcm.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/rtslib/tcm.py b/rtslib/tcm.py
index 1aeea23..efe685a 100644
--- a/rtslib/tcm.py
+++ b/rtslib/tcm.py
@@ -787,7 +787,7 @@ class UserBackedStorageObject(StorageObject):
     '''
 
     def __init__(self, name, config=None, size=None, wwn=None,
-                 hw_max_sectors=None):
+                 hw_max_sectors=None, control=None):
         '''
         @param name: The name of the UserBackedStorageObject.
         @type name: string
@@ -800,6 +800,9 @@ class UserBackedStorageObject(StorageObject):
         @type wwn: string
         @hw_max_sectors: Max sectors per command limit to export to initiators.
         @type hw_max_sectors: int
+        @control: String of control=value tuples separate by a ',' that will
+            passed to the kernel control file.
+        @type: string
         @return: A UserBackedStorageObject object.
         '''
 
@@ -812,14 +815,14 @@ class UserBackedStorageObject(StorageObject):
                                   "from its configuration string")
             super(UserBackedStorageObject, self).__init__(name, 'create')
             try:
-                self._configure(config, size, wwn, hw_max_sectors)
+                self._configure(config, size, wwn, hw_max_sectors, control)
             except:
                 self.delete()
                 raise
         else:
             super(UserBackedStorageObject, self).__init__(name, 'lookup')
 
-    def _configure(self, config, size, wwn, hw_max_sectors):
+    def _configure(self, config, size, wwn, hw_max_sectors, control):
         self._check_self()
 
         if ':' in config:
@@ -828,6 +831,8 @@ class UserBackedStorageObject(StorageObject):
         self._control("dev_size=%d" % size)
         if hw_max_sectors is not None:
             self._control("hw_max_sectors=%s" % hw_max_sectors)
+        if control is not None:
+            self._control(control)
         self._enable()
 
         super(UserBackedStorageObject, self)._configure(wwn)
-- 
1.8.3.1