def _init(self): from mgr_module import ceph_state ctx_capsule = ceph_state.get_context() self.log.info("Constructing Rados") cluster = rados.Rados(context=ctx_capsule) cluster.connect() self.log.info("Constructing IOCtx") self.ioctx = cluster.open_ioctx("rbd") self.log.info("Constructing RBD") self.rbd = rbd.RBD()
def rados(self): """ A librados instance to be shared by any classes within this mgr module that want one. """ if self._rados: return self._rados from mgr_module import ceph_state ctx_capsule = ceph_state.get_context() self._rados = rados.Rados(context=ctx_capsule) self._rados.connect() return self._rados
def _get(self): from mgr_module import ceph_state ctx_capsule = ceph_state.get_context() osd_map = self._module.get_sync_object(OsdMap).data osd_pools = [pool['pool_name'] for pool in osd_map['pools']] rbd_pools = [] for pool in osd_pools: self.log.debug("Constructing IOCtx " + pool) try: ioctx = self._module.rados.open_ioctx(pool) ioctx.stat("rbd_directory") rbd_pools.append(pool) except (rados.PermissionError, rados.ObjectNotFound): self.log.debug("No RBD directory in " + pool) except: self.log.exception("Failed to open pool " + pool) return rbd_pools