Revision 6321fedb snf-pithos-backend/pithos/backends/lib/hashfiler/radosblocker.py

b/snf-pithos-backend/pithos/backends/lib/hashfiler/radosblocker.py
48 48
    blocksize = None
49 49
    blockpool = None
50 50
    hashtype = None
51
    rados = None
52
    rados_ctx = None
53

  
54
    @classmethod
55
    def get_rados_ctx(cls, pool):
56
        if cls.rados_ctx is None:
57
            cls.rados = Rados(conffile=CEPH_CONF_FILE)
58
            cls.rados.connect()
59
            cls.rados_ctx = cls.rados.open_ioctx(pool)
60
        return cls.rados_ctx
51 61

  
52 62
    def __init__(self, **params):
53 63
        blocksize = params['blocksize']
54 64
        blockpool = params['blockpool']
55 65

  
56
        rados = Rados(conffile=CEPH_CONF_FILE)
57
        rados.connect()
58
        ioctx = rados.open_ioctx(blockpool)
59

  
60 66
        hashtype = params['hashtype']
61 67
        try:
62 68
            hasher = newhasher(hashtype)
......
69 75

  
70 76
        self.blocksize = blocksize
71 77
        self.blockpool = blockpool
72
        self.rados = rados
73
        self.ioctx = ioctx
78
        self.ioctx = RadosBlocker.get_rados_ctx(self.blockpool)
74 79
        self.hashtype = hashtype
75 80
        self.hashlen = len(emptyhash)
76 81
        self.emptyhash = emptyhash

Also available in: Unified diff