[node-patches] Change in ovirt-node[master]: installer: Use different size source

fabiand at redhat.com fabiand at redhat.com
Tue Dec 23 17:29:52 UTC 2014


Fabian Deutsch has uploaded a new change for review.

Change subject: installer: Use different size source
......................................................................

installer: Use different size source

Previously sfdisk was used to determin the size of disks. This could
fail if the disk contained a GPT label (sfdisk does not support GPT),
this does actually not matter (what label is used) because we only need
the size of the disk, but we still used sfdisk.
Now lsblk is used, which only looks at the disk itself, and does not
take the label into account.

Change-Id: I913ee34a50f9a79e51d4a8b073318c4966576dd3
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1174146
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirtnode/storage.py
1 file changed, 9 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/65/36365/1

diff --git a/src/ovirtnode/storage.py b/src/ovirtnode/storage.py
index 1f0c39f..a81cdff 100644
--- a/src/ovirtnode/storage.py
+++ b/src/ovirtnode/storage.py
@@ -175,13 +175,20 @@
 
     def get_drive_size(self, drive):
         logger.debug("Getting Drive Size For: %s" % drive)
-        size_cmd = "sfdisk -s " + drive + " 2>/dev/null"
+        size_cmd = "lsblk -bn -o SIZE " + drive + " 2>/dev/null | head -n1"
         size_popen = _functions.subprocess_closefds(size_cmd, shell=True,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)
         size, size_err = size_popen.communicate()
         size = size.strip()
-        size = int(int(size) / 1024)
+        try:
+            # Size is bytes, calculate MB
+            size = int(int(size) / 1024 / 1024)
+        except Exception as e:
+            logger.debug(str(e))
+            logger.debug(drive)
+            logger.debug(size)
+            raise RuntimeError("Failed to determin disk size: %s" % drive)
         logger.debug(size)
         return size
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I913ee34a50f9a79e51d4a8b073318c4966576dd3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list