]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: work around buggy rhel/centos parted
authorSage Weil <sage@inktank.com>
Fri, 14 Jun 2013 19:10:49 +0000 (12:10 -0700)
committerSage Weil <sage@inktank.com>
Fri, 14 Jun 2013 19:10:49 +0000 (12:10 -0700)
parted on RHEL/Centos prefixes the *machine readable output* with

 1b 5b 3f 31 30 33 34 68

Note that the same thing happens when you 'import readline' in python.

Work around it!

Signed-off-by: Sage Weil <sage@inktank.com>
src/ceph-disk

index 13d9f8203cef1e79f847064343dab11c7c27f1d0..1d1a1501e79e04cb8d86a910f5ad8bd6eb15c3a9 100755 (executable)
@@ -637,6 +637,11 @@ def get_free_partition_index(dev):
         raise Error('parted failed to output anything')
     lines = str(lines).splitlines(True)
 
+    # work around buggy libreadline(?) library in rhel/centos.
+    idiot_prefix = '\x1b\x5b\x3f\x31\x30\x33\x34\x68';
+    if lines[0].startswith(idiot_prefix):
+        lines[0] = lines[0][8:]
+
     if lines[0] not in ['CHS;\n', 'CYL;\n', 'BYT;\n']:
         raise Error('weird parted units', lines[0])
     del lines[0]