Ramesh N has uploaded a new change for review.

Change subject: gluster: fix size conversion issues in brick create
......................................................................

gluster: fix size conversion issues in brick create

 There is change in blivet API device.size.convertTo(spec).
spec was a string parameter in older versions of blivet but its changed
to constants in newer versions. This patch address this issue
in a generic way so that it can run on all releases.

Change-Id: I576b1a8c880ef6f355157225c7b763378d8cf46d
Signed-off-by: Ramesh Nachimuthu <[email protected]>
---
M vdsm/gluster/storagedev.py
1 file changed, 17 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/50705/1

diff --git a/vdsm/gluster/storagedev.py b/vdsm/gluster/storagedev.py
index ff39b80..9844cb0 100644
--- a/vdsm/gluster/storagedev.py
+++ b/vdsm/gluster/storagedev.py
@@ -65,6 +65,20 @@
 DEFAULT_MOUNT_OPTIONS = "inode64,noatime"
 
 
+def _getDeviceSize(device, unitType=None):
+    if hasattr(blivet.size, 'MiB'):
+        if unitType == 'KiB':
+            return device.size.convertTo(blivet.size.KiB)
+        else:
+            return device.size.convertTo(blivet.size.MiB)
+    else:
+        if unitType == 'KiB':
+            return device.size.convertTo(spec='KiB')
+        else:
+            return device.size.convertTo(spec='MiB')
+    return 0
+
+
 def _getDeviceDict(device, createBrick=False):
     info = {'name': device.name,
             'devPath': device.path,
@@ -76,7 +90,7 @@
             'uuid': '',
             'createBrick': createBrick}
     if isinstance(device.size, blivet.size.Size):
-        info['size'] = '%s' % device.size.convertTo(spec="MiB")
+        info['size'] = '%s' % _getDeviceSize(device)
     else:
         info['size'] = '%s' % device.size
     if not info['bus'] and device.parents:
@@ -252,8 +266,8 @@
     # and create data LV (poolDataSize) that has a size which is
     # a multiple of stripe width
     # For JBOD, this adjustment is not necessary
-    vgSizeKib = int(vg.size.convertTo(spec="KiB"))
-    if vg.size.convertTo(spec='MiB') < MIN_VG_SIZE:
+    vgSizeKib = int(_getDeviceSize(vg, 'KiB'))
+    if  _getDeviceSize(vg) < MIN_VG_SIZE:
         metaDataSize = vgSizeKib * MIN_METADATA_PERCENT
     poolDataSize = vgSizeKib - metaDataSize
 


-- 
To view, visit https://gerrit.ovirt.org/50705
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I576b1a8c880ef6f355157225c7b763378d8cf46d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ramesh N <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to