]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: add get_dev_name, path helpers
authorSage Weil <sage@inktank.com>
Wed, 3 Jul 2013 17:52:29 +0000 (10:52 -0700)
committerSage Weil <sage@inktank.com>
Tue, 16 Jul 2013 22:51:43 +0000 (15:51 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/ceph-disk

index cb9d510cf97362e28c9ac55435bd0c8514237e26..3f7f9d53bac66e27385748859044c830a6c3ff32 100755 (executable)
@@ -198,6 +198,9 @@ def maybe_mkdir(*a, **kw):
             raise
 
 
+# a device "name" is something like
+#  sdb
+#  cciss!c0d1
 def list_all_partitions():
     """
     Return a list of devices and partitions
@@ -220,6 +223,28 @@ def list_all_partitions():
                 dev_part_list[dev] = []
     return dev_part_list
 
+def get_dev_name(path):
+    """
+    get device name from path.  e.g., /dev/sda -> sdas, /dev/cciss/c0d1 -> cciss!c0d1
+    """
+    assert path.startswith('/dev/')
+    base = path[5:]
+    return base.replace('/', '!')
+
+# a device "path" is something like
+#  /dev/sdb
+#  /dev/cciss/c0d1
+def get_dev_path(name):
+    """
+    get a path (/dev/...) from a name (cciss!c0d1)
+    """
+    return '/dev/' + name.replace('!', '/')
+
+def get_dev_relpath(name):
+    """
+    get a relative path to /dev from a name (cciss!c0d1)
+    """
+    return name.replace('!', '/')
 
 def list_partitions(disk):
     """