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>
This commit is contained in:
Amartey Pearson 2017-02-07 12:37:31 -06:00
commit e54d50d732
1 changed files with 7 additions and 1 deletions

View File

@ -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, RTSLibALUANotSupported, modprobe, mount_configfs
from .utils import dict_remove, set_attributes
from .alua import ALUATargetPortGroup
@ -290,6 +290,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,