Project

General

Profile

test_volumes.py

Nikola Ciprich, 08/20/2019 04:07 PM

Download (842 Bytes)

 
1
import rbd
2
import rados
3

    
4
if __name__ == "__main__":
5
        counter = 0
6
        x = 0
7
        r = rbd.RBD()
8

    
9
        with rados.Rados(conffile='/etc/ceph/ceph.conf') as cluster:
10
                with cluster.open_ioctx("sata") as ioctx:
11
                        volumes = r.list(ioctx)
12

    
13
        while True:
14
                for volume in volumes:
15
                        if x >= 100:
16
                                counter += x
17
                                x = 0
18
                                print("Volumes counter: %s" % (counter))
19
                        try:
20
                                with rados.Rados(conffile='/etc/ceph/ceph.conf') as cluster:
21
                                        with cluster.open_ioctx("sata") as ioctx:
22
                                                try:
23
                                                        with rbd.Image(ioctx, name=volume, read_only=True) as rbdi:
24
                                                                x += 1
25
                                                except rbd.ImageNotFound:
26
                                                        print("%s volume not found" % (volume))
27
                                                except rbd.ImageBusy:
28
                                                        print("%s volume busy" % (volume))
29
                                                except Exception as err:
30
                                                        print("%s %s" % (volume, err))
31
                        except Exception as err:
32
                                print("%s %s" % (volume, err))