From fed9ea24de9a265470dcaaeb3e907f7e8a9e4dc4 Mon Sep 17 00:00:00 2001
From: Nikos Skalkotos <skalkoto@grnet.gr>
Date: Fri, 12 Sep 2014 13:09:53 +0300
Subject: [PATCH] Reference disk.file in the begging of snapshot()

If you print the snapshotting message before disk.file is referenced,
you may end up outputting messages like this:

Snapshotting media source ... Examining source media `<image_file>' ...

Instead of:

Examining source media `<image_file>' ... looks like a block device
Snapshotting media source ... done
---
 image_creator/disk.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/image_creator/disk.py b/image_creator/disk.py
index 0b02d05..0f1fdc4 100644
--- a/image_creator/disk.py
+++ b/image_creator/disk.py
@@ -156,10 +156,13 @@ class Disk(object):
             self.out.warn("Snapshotting ignored for host bundling mode.")
             return self.file
 
+        # Examine media file
+        mode = os.stat(self.file).st_mode
+
         self.out.output("Snapshotting media source ...", False)
 
         # Create a qcow2 snapshot for image files
-        if not stat.S_ISBLK(os.stat(self.file).st_mode):
+        if not stat.S_ISBLK(mode):
             snapshot = create_snapshot(self.file, self.tmp)
             self._add_cleanup(os.unlink, snapshot)
             self.out.success('done')
-- 
GitLab