[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[sos-devel] [PATCH 1/2] [plugin] allow reverse ordering in add_copy_spec_limit



Added parameter to add_copy_spec_limit for allowing
to use reverse ordering while collecting files.
Without this time-stamped log files will be collected
always starting from oldest so most recent logs wasn't
in the report.

Change-Id: I8dfd0dd3936ae99ea19d975c092a1b275b5e3f4f
Signed-off-by: Sandro Bonazzola <sbonazzo redhat com>
---
 sos/plugins/__init__.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 1e5e26f..3b0a993 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -407,16 +407,19 @@ class Plugin(object):
         except Exception:
             return default
 
-    def add_copy_spec_limit(self, copyspec, sizelimit=None, tailit=True):
+    def add_copy_spec_limit(self, copyspec, sizelimit=None, tailit=True,
+                            reverse_order=False):
         """Add a file or glob but limit it to sizelimit megabytes. If fname is
         a single file the file will be tailed to meet sizelimit. If the first
         file in a glob is too large it will be tailed to meet the sizelimit.
+        If you are collecting time-stamped files you may want to get only
+        latest. In such case you need to reverse the ordering
         """
         if not (copyspec and len(copyspec)):
             return False
 
         files = glob.glob(copyspec)
-        files.sort()
+        files.sort(reverse=reverse_order)
         if len(files) == 0:
             return
         current_size = 0
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]