summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-07-03 10:52:29 -0700
committerSage Weil <sage@inktank.com>2013-07-24 15:46:37 -0700
commitbe12811b4cb98ff1c2c691c67af7ad3586c436ff (patch)
treeecebc596a7b166d0b64a99660d6bb4a5cfffabc6
parentf46dbc462f623e9ab6c00394abb4d890e5d90890 (diff)
downloadceph-be12811b4cb98ff1c2c691c67af7ad3586c436ff.tar.gz
ceph-disk: add get_dev_name, path helpers
Signed-off-by: Sage Weil <sage@inktank.com> (cherry picked from commit e0401591e352ea9653e3276d66aebeb41801eeb3)
-rwxr-xr-xsrc/ceph-disk25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ceph-disk b/src/ceph-disk
index cb9d510cf97..3f7f9d53bac 100755
--- a/src/ceph-disk
+++ b/src/ceph-disk
@@ -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):
"""