]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/rbd_ls.py
510a7777820368a9628b47588ab532219c340ec6
[ceph.git] / ceph / src / pybind / mgr / dashboard / rbd_ls.py
1
2 import rados
3 import rbd
4 from remote_view_cache import RemoteViewCache
5
6
7 class RbdLs(RemoteViewCache):
8 def __init__(self, module_inst, pool):
9 super(RbdLs, self).__init__(module_inst)
10
11 self.pool = pool
12
13 self.ioctx = None
14 self.rbd = None
15
16 def _init(self):
17 from mgr_module import ceph_state
18 ctx_capsule = ceph_state.get_context()
19
20 self.log.info("Constructing Rados")
21 cluster = rados.Rados(context=ctx_capsule)
22 cluster.connect()
23 self.log.info("Constructing IOCtx")
24 self.ioctx = cluster.open_ioctx("rbd")
25
26 self.log.info("Constructing RBD")
27 self.rbd = rbd.RBD()
28
29 def _get(self):
30 self.log.debug("rbd.list")
31 names = self.rbd.list(self.ioctx)
32 result = []
33 for name in names:
34 i = rbd.Image(self.ioctx, name)
35 stat = i.stat()
36 stat['name'] = name
37 result.append(stat)
38 return result