diff options
author | Andy Grover <agrover@redhat.com> | 2016-08-11 10:26:20 -0700 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2016-08-11 10:26:20 -0700 |
commit | 8277306b4d30e93b6985302c25910550d4172fff (patch) | |
tree | a5166edc0a8b6ca4677f821cfb4248d2d59d2cfa | |
parent | f2046d721df5f1d2f1ec0844a3e2ee22ea965698 (diff) | |
download | rtslib-fb-8277306b4d30e93b6985302c25910550d4172fff.tar.gz |
Handle if LIO components are compiled in the kernel
Attempt to do the thing that would require the module first, and if it
fails then attempt to load the module and retry. This should handle all
combinations of modules, compiled-in etc. and return an error if a needed
component is neither compiled in or as a module.
Fixes #64
Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | rtslib/fabric.py | 7 | ||||
-rw-r--r-- | rtslib/root.py | 15 |
2 files changed, 16 insertions, 6 deletions
diff --git a/rtslib/fabric.py b/rtslib/fabric.py index b5cc4d9..885727e 100644 --- a/rtslib/fabric.py +++ b/rtslib/fabric.py @@ -152,8 +152,11 @@ class _BaseFabricModule(CFSNode): def _check_self(self): if not self.exists: - modprobe(self.kernel_module) - self._create_in_cfs_ine('any') + try: + self._create_in_cfs_ine('any') + except RTSLibError: + modprobe(self.kernel_module) + self._create_in_cfs_ine('any') super(_BaseFabricModule, self)._check_self() def has_feature(self, feature): diff --git a/rtslib/root.py b/rtslib/root.py index 083a2c2..b65825f 100644 --- a/rtslib/root.py +++ b/rtslib/root.py @@ -62,10 +62,17 @@ class RTSRoot(CFSNode): base kernel modules (tcm) ''' super(RTSRoot, self).__init__() - modprobe('configfs') - mount_configfs() - modprobe('target_core_mod') - self._create_in_cfs_ine('any') + try: + mount_configfs() + except RTSLibError: + modprobe('configfs') + mount_configfs() + + try: + self._create_in_cfs_ine('any') + except RTSLibError: + modprobe('target_core_mod') + self._create_in_cfs_ine('any') def _list_targets(self): self._check_self() |