summaryrefslogtreecommitdiff
path: root/targetcli
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2012-08-06 13:11:22 -0700
committerAndy Grover <agrover@redhat.com>2012-08-06 13:11:22 -0700
commit5bc981f743a28c1c13146e5bf8772578cd63e177 (patch)
tree85d789f031e0243c3037df61d83eb0dbff4ae7d5 /targetcli
parentd78d5bdfa4e686b8143506f7be230ab26e232934 (diff)
downloadtargetcli-5bc981f743a28c1c13146e5bf8772578cd63e177.tar.gz
Return human sizes in 2^10 units (gibi, mebi etc)
Label them as such. Return more info for Block storage objects too. Signed-off-by: Andy Grover <agrover@redhat.com>
Diffstat (limited to 'targetcli')
-rw-r--r--targetcli/ui_backstore.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/targetcli/ui_backstore.py b/targetcli/ui_backstore.py
index 5c93516..95682b8 100644
--- a/targetcli/ui_backstore.py
+++ b/targetcli/ui_backstore.py
@@ -64,8 +64,9 @@ def human_to_bytes(hsize, kilo=1024):
return size * (int(kilo) ** power)
-def bytes_to_human(size, kilo=1024.0):
- for x in ['bytes','K','M','G','T']:
+def bytes_to_human(size):
+ kilo = 1024.0
+ for x in ['bytes','KiB','MiB','GiB','TiB', 'PiB']:
if size < kilo:
return "%3.1f%s" % (size, x)
size /= kilo
@@ -389,4 +390,11 @@ class UIFileioStorageObject(UIStorageObject):
class UIBlockStorageObject(UIStorageObject):
def summary(self):
so = self.rtsnode
- return ("%s %s" % (so.udev_path, so.status), True)
+
+ if so.write_back:
+ wb_str = "write-back"
+ else:
+ wb_str = "write-thru"
+
+ return ("%s (%s) %s %s" % (so.udev_path, bytes_to_human(so.size),
+ wb_str, so.status), True)