Skip to content

Instantly share code, notes, and snippets.

@cholcombe973
Created June 14, 2018 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cholcombe973/8ea370c8ca37a50be17e8a900057cf0d to your computer and use it in GitHub Desktop.
Save cholcombe973/8ea370c8ca37a50be17e8a900057cf0d to your computer and use it in GitHub Desktop.
extern crate ceph;
extern crate ceph_rbd;
extern crate rayon;
use rayon::prelude::*;
fn main() {
let conn = ceph::ceph::connect_to_ceph("admin", "/etc/ceph/ceph.conf").unwrap();
let ioctx = conn.get_rados_ioctx("glance").unwrap();
// Tell rayon how many threads to use
rayon::ThreadPoolBuilder::new()
.num_threads(10)
.build_global()
.unwrap();
let r = ceph_rbd::rbd::Rbd;
let res = r.list(&ioctx).unwrap();
res.into_par_iter().for_each(|device| {
let conn = ceph::ceph::connect_to_ceph("admin", "/etc/ceph/ceph.conf").unwrap();
let ioctx = conn.get_rados_ioctx("glance").unwrap();
let img = ceph_rbd::rbd::RbdImage::open(&ioctx, &device, "").unwrap();
let s = img.stat().unwrap();
println!("s: {:?}", s);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment