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

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