Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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