From ef02e8f21cd9117f774ab77cb7edfce4020533c7 Mon Sep 17 00:00:00 2001 From: Yanhu Cao Date: Fri, 21 Jul 2017 10:02:39 +0800 Subject: [PATCH] mgr/dashboard: rbd image show features Signed-off-by: Yanhu Cao --- src/pybind/mgr/dashboard/rbd_ls.py | 26 ++++++++++++++++++++++++++ src/pybind/mgr/dashboard/rbd_pool.html | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/pybind/mgr/dashboard/rbd_ls.py b/src/pybind/mgr/dashboard/rbd_ls.py index e03d78ed1ad..6588766a7da 100644 --- a/src/pybind/mgr/dashboard/rbd_ls.py +++ b/src/pybind/mgr/dashboard/rbd_ls.py @@ -50,6 +50,9 @@ class RbdLs(RemoteViewCache): i = rbd.Image(self.ioctx, name) stat = i.stat() stat['name'] = name + features = i.features() + stat['features'] = features + stat['features_name'] = self._format_bitmask(features) try: parent_info = i.parent_info() @@ -61,3 +64,26 @@ class RbdLs(RemoteViewCache): pass result.append(stat) return result + + def _format_bitmask(self, features): + names = "" + RBD_FEATURES_NAME_MAPPING = { + rbd.RBD_FEATURE_LAYERING: "layering", + rbd.RBD_FEATURE_STRIPINGV2: "striping", + rbd.RBD_FEATURE_EXCLUSIVE_LOCK: "exclusive-lock", + rbd.RBD_FEATURE_OBJECT_MAP: "object-map", + rbd.RBD_FEATURE_FAST_DIFF: "fast-diff", + rbd.RBD_FEATURE_DEEP_FLATTEN: "deep-flatten", + rbd.RBD_FEATURE_JOURNALING: "journaling", + rbd.RBD_FEATURE_DATA_POOL: "data-pool", + } + + for key in RBD_FEATURES_NAME_MAPPING.keys(): + if (key & features == 0): + continue + + if names: + names = names + ", " + names = names + RBD_FEATURES_NAME_MAPPING.get(key) + + return names diff --git a/src/pybind/mgr/dashboard/rbd_pool.html b/src/pybind/mgr/dashboard/rbd_pool.html index 4aaef0242ab..973bc3717d8 100644 --- a/src/pybind/mgr/dashboard/rbd_pool.html +++ b/src/pybind/mgr/dashboard/rbd_pool.html @@ -51,6 +51,7 @@ Size Objects Object size + Features Parent @@ -60,6 +61,7 @@ {image.size | dimless_binary} {image.num_objs | dimless} {image.obj_size | dimless_binary} + {image.features_name} {image.parent} -- 2.39.5