Blame SOURCES/0005-Remove-hba-only-directories-in-clear_existing.patch

71285d
From 12e626b649ef4a928aa95e60d8b8c58b20bd3372 Mon Sep 17 00:00:00 2001
71285d
From: Andy Grover <agrover@redhat.com>
71285d
Date: Thu, 21 Sep 2017 16:45:30 -0700
71285d
Subject: [PATCH] Remove hba-only directories in clear_existing()
71285d
71285d
rtslib never creates hba directories without a storage object within it,
71285d
but if under some circumstance these existed then clear_existing() wouldn't
71285d
remove them, since StorageObject::all()'s glob ignores them.
71285d
71285d
Add code to ensure these are also removed.
71285d
71285d
Signed-off-by: Andy Grover <agrover@redhat.com>
71285d
---
71285d
 rtslib/root.py | 6 ++++++
71285d
 1 file changed, 6 insertions(+)
71285d
71285d
diff --git a/rtslib/root.py b/rtslib/root.py
71285d
index 0c3c231..72c0299 100644
71285d
--- a/rtslib/root.py
71285d
+++ b/rtslib/root.py
71285d
@@ -21,6 +21,7 @@ under the License.
71285d
 import os
71285d
 import stat
71285d
 import json
71285d
+import glob
71285d
 
71285d
 from .node import CFSNode
71285d
 from .target import Target
71285d
@@ -206,6 +207,11 @@ class RTSRoot(CFSNode):
71285d
         for so in self.storage_objects:
71285d
             so.delete()
71285d
 
71285d
+        # If somehow some hbas still exist (no storage object within?) clean
71285d
+        # them up too.
71285d
+        for hba_dir in glob.glob("%s/core/*_*" % self.configfs_dir):
71285d
+            os.rmdir(hba_dir)
71285d
+
71285d
     def restore(self, config, clear_existing=False, abort_on_error=False):
71285d
         '''
71285d
         Takes a dict generated by dump() and reconfigures the target to match.
71285d
-- 
71285d
1.8.3.1
71285d