Class: CephRuby::Cluster
- Inherits:
-
Object
- Object
- CephRuby::Cluster
- Defined in:
- lib/ceph-ruby/cluster.rb
Instance Attribute Summary collapse
-
#handle ⇒ Object
Returns the value of attribute handle.
Instance Method Summary collapse
-
#connect ⇒ Object
helper methods below.
-
#initialize(config_path = "/etc/ceph/ceph.conf") ⇒ Cluster
constructor
A new instance of Cluster.
- #log(message) ⇒ Object
- #pool(name, &block) ⇒ Object
- #setup_using_file(path) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(config_path = "/etc/ceph/ceph.conf") ⇒ Cluster
Returns a new instance of Cluster.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ceph-ruby/cluster.rb', line 5 def initialize(config_path = "/etc/ceph/ceph.conf") log("init lib rados #{Lib::Rados.version_string}, lib rbd #{Lib::Rbd.version_string}") handle_p = FFI::MemoryPointer.new(:pointer) ret = Lib::Rados.rados_create(handle_p, nil) raise SystemCallError.new("open of cluster failed", -ret) if ret < 0 self.handle = handle_p.get_pointer(0) setup_using_file(config_path) connect if block_given? yield(self) shutdown end end |
Instance Attribute Details
#handle ⇒ Object
Returns the value of attribute handle.
3 4 5 |
# File 'lib/ceph-ruby/cluster.rb', line 3 def handle @handle end |
Instance Method Details
#connect ⇒ Object
helper methods below
36 37 38 39 40 |
# File 'lib/ceph-ruby/cluster.rb', line 36 def connect log("connect") ret = Lib::Rados.rados_connect(handle) raise SystemCallError.new("connect to cluster failed", -ret) if ret < 0 end |
#log(message) ⇒ Object
48 49 50 |
# File 'lib/ceph-ruby/cluster.rb', line 48 def log() CephRuby.log("cluster #{}") end |
#pool(name, &block) ⇒ Object
30 31 32 |
# File 'lib/ceph-ruby/cluster.rb', line 30 def pool(name, &block) Pool.new(self, name, &block) end |
#setup_using_file(path) ⇒ Object
42 43 44 45 46 |
# File 'lib/ceph-ruby/cluster.rb', line 42 def setup_using_file(path) log("setup_using_file #{path}") ret = Lib::Rados.rados_conf_read_file(handle, path) raise SystemCallError.new("setup of cluster from config file '#{path}' failed", -ret) if ret < 0 end |