]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-disk: fix signed integer is greater than maximum when call major
authorSong Shun <song.shun3@zte.com.cn>
Tue, 28 Nov 2017 03:28:43 +0000 (11:28 +0800)
committerSong Shun <song.shun3@zte.com.cn>
Thu, 30 Nov 2017 05:51:59 +0000 (13:51 +0800)
  fix signed integer is greater than maximum when call os.major
  using python 2.7.5 in Centos 7

Signed-off-by: Song Shun <song.shun3@zte.com.cn>
src/ceph-disk/ceph_disk/main.py

index 69f4b595d44ab85d787346ec05fdde139a401ee8..25a590ad74df3c09cb69c09bc14ea1a9a21c15d7 100644 (file)
@@ -150,6 +150,13 @@ PTYPE = {
     },
 }
 
+try:
+    # see https://bugs.python.org/issue23098
+    os.major(0x80002b00)
+except OverflowError:
+    os.major = lambda devid: ((devid >> 8) & 0xfff) | ((devid >> 32) & ~0xfff)
+    os.minor = lambda devid: (devid & 0xff) | ((devid >> 12) & ~0xff)
+
 
 class Ptype(object):