summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmartey Pearson <apearson@us.ibm.com>2017-01-22 11:48:44 -0600
committerAmartey Pearson <apearson@us.ibm.com>2017-01-23 11:27:28 -0600
commit6453b0d484f4a5b63439a69de4620b498b5c108a (patch)
treebbcef24877ab212fad943864ea09048d374b5dfe
parent572e9b41bae87023e5e5845786a15409246253aa (diff)
downloadrtslib-fb-6453b0d484f4a5b63439a69de4620b498b5c108a.tar.gz
Add ability to invalidate caches
For efficiency, rtslib may have caches (today for the data in configfs). A client may need to clear out these caches such as via the refresh option in targetcli. * Add new invalidate_caches method to RTSRoot. While this only has a single cache today, it gives the ability to extend to any future caches. * While bs_cache really should be private, it probably shouldn't be changed given that this is a library and may be used elsewhere. Signed-off-by: Amartey Pearson <apearson@us.ibm.com>
-rw-r--r--rtslib/root.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/rtslib/root.py b/rtslib/root.py
index 3cc6fbf..44bb459 100644
--- a/rtslib/root.py
+++ b/rtslib/root.py
@@ -25,7 +25,7 @@ import json
from .node import CFSNode
from .target import Target
from .fabric import FabricModule
-from .tcm import so_mapping, StorageObject
+from .tcm import so_mapping, bs_cache, StorageObject
from .utils import RTSLibError, modprobe, mount_configfs
from .utils import dict_remove, set_attributes
from .alua import ALUATargetPortGroup
@@ -287,6 +287,12 @@ class RTSRoot(CFSNode):
return self.restore(config, clear_existing=clear_existing,
abort_on_error=abort_on_error)
+ def invalidate_caches(self):
+ '''
+ Invalidate any caches used throughout the hierarchy
+ '''
+ bs_cache.clear()
+
targets = property(_list_targets,
doc="Get the list of Target objects.")
tpgs = property(_list_tpgs,