]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: handle /dev/foo/bar devices throughout 369/head
authorSage Weil <sage@inktank.com>
Tue, 18 Jun 2013 23:21:48 +0000 (16:21 -0700)
committerSage Weil <sage@inktank.com>
Tue, 2 Jul 2013 21:00:15 +0000 (14:00 -0700)
Assume the last component is the unique device name, even if it appears
under a subdir of /dev.

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

index 13f434882c8d7d300dd044d952a9904e2464f421..39fcc4216da09bcfd68c91795067e29e65b43ace 100755 (executable)
@@ -288,7 +288,7 @@ def is_held(dev):
     """
     assert os.path.exists(dev)
     dev = os.path.realpath(dev)
-    base = dev[5:]
+    base = dev.split('/')[-1]
 
     # full disk?
     directory = '/sys/block/{base}/holders'.format(base=base)
@@ -2003,7 +2003,7 @@ def is_suppressed(path):
     try:
         if not disk.startswith('/dev/') or not stat.S_ISBLK(os.lstat(path).st_mode):
             return False
-        base = disk[5:]
+        base = disk.split('/')[-1]
         while len(base):
             if os.path.exists(SUPPRESS_PREFIX + base):
                 return True
@@ -2017,7 +2017,7 @@ def set_suppress(path):
         raise Error('does not exist', path)
     if not stat.S_ISBLK(os.lstat(path).st_mode):
         raise Error('not a block device', path)
-    base = disk[5:]
+    base = disk.split('/')[-1]
 
     with file(SUPPRESS_PREFIX + base, 'w') as f:
         pass
@@ -2030,7 +2030,7 @@ def unset_suppress(path):
     if not stat.S_ISBLK(os.lstat(path).st_mode):
         raise Error('not a block device', path)
     assert disk.startswith('/dev/')
-    base = disk[5:]
+    base = disk.split('/')[-1]
 
     fn = SUPPRESS_PREFIX + base
     if not os.path.exists(fn):