Simone Tiraboschi has uploaded a new change for review.

Change subject: archive: reorganizing the final tarball archive
......................................................................

archive: reorganizing the final tarball archive

Adding a top level directory to the tarball archive to avoid
any other element in the tarball root

Change-Id: If14717e8a9bc790e12c84c1fbaa968d786bed96f
Bug-Url: https://bugzilla.redhat.com/1168660
Signed-off-by: Simone Tiraboschi <stira...@redhat.com>
---
M src/__main__.py
1 file changed, 30 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-log-collector 
refs/changes/51/35751/1

diff --git a/src/__main__.py b/src/__main__.py
index 4f80b74..3252a89 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -895,7 +895,7 @@
         self.configuration["sos_options"] = self.build_options()
         self.caller.call(
             "sosreport --batch --build \
-            --tmp-dir='%(local_tmp_dir)s' -o %(reports)s %(sos_options)s"
+            --tmp-dir='%(local_working_dir)s' -o %(reports)s %(sos_options)s"
         )
 
 
@@ -1024,9 +1024,20 @@
             'compressed_report': self.conf['path'],
             'compressor': compressor,
             'directory': self.conf["local_tmp_dir"],
+            'rname': os.path.basename(self.conf['path']).split('.')[0],
         }
         caller.configuration = config
-        caller.call("tar -cf '%(report)s' -C '%(directory)s' .")
+        shutil.move(
+            os.path.join(
+                self.conf["local_tmp_dir"],
+                'working'
+            ),
+            os.path.join(
+                self.conf["local_tmp_dir"],
+                config["rname"]
+            ),
+        )
+        caller.call("tar -cf '%(report)s' -C '%(directory)s' '%(rname)s'")
         shutil.rmtree(self.conf["local_tmp_dir"])
         caller.call("%(compressor)s -1 '%(report)s'")
         os.chmod(self.conf["path"], stat.S_IRUSR | stat.S_IWUSR)
@@ -1701,7 +1712,7 @@
             conf['pg_pass'] = pg_pass
         collector = LogCollector(conf)
 
-        # We must ensure that the working directory exits before
+        # We must ensure that the directory exits before
         # we start doing anything.
         if os.path.exists(conf["local_tmp_dir"]):
             if not os.path.isdir(conf["local_tmp_dir"]):
@@ -1716,12 +1727,27 @@
             )
             os.makedirs(conf["local_tmp_dir"])
 
+        # We need to make a temporary working directory
+        conf["local_working_dir"] = os.path.join(
+            conf["local_tmp_dir"],
+            'working'
+        )
+        if not os.path.exists(conf["local_working_dir"]):
+            os.makedirs(conf["local_working_dir"])
+        else:
+            if len(os.listdir(conf["local_working_dir"])) != 0:
+                raise Exception("""the working directory is not empty.
+It should be empty so that reports from a prior invocation of the log collector
+are not collected again.
+The directory is: %s'""" % (conf["local_working_dir"]))
+
+
         # We need to make a temporary scratch directory wherein
         # all of the output from VDSM and PostgreSQL SOS plug-ins
         # will be dumped.  The contents of this directory will be included in
         # a single .xz or .bz2 file report.
         conf["local_scratch_dir"] = os.path.join(
-            conf["local_tmp_dir"],
+            conf["local_working_dir"],
             'log-collector-data'
         )
         if not os.path.exists(conf["local_scratch_dir"]):


-- 
To view, visit http://gerrit.ovirt.org/35751
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If14717e8a9bc790e12c84c1fbaa968d786bed96f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-log-collector
Gerrit-Branch: master
Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to