Class: CephStorage::Cluster
- Inherits:
-
CephRuby::Cluster
- Object
- CephRuby::Cluster
- CephStorage::Cluster
- Extended by:
- ClusterWrapper
- Includes:
- Multiton
- Defined in:
- lib/ceph_storage/cluster.rb
Overview
Create a cluster object Returns only a single cluster object for given settings
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cluster ⇒ Object
readonly
Configure default values for this object.
-
#cluster_fd ⇒ Object
readonly
Configure default values for this object.
-
#config_dir ⇒ Object
readonly
Configure default values for this object.
-
#flags ⇒ Object
readonly
Configure default values for this object.
-
#user ⇒ Object
readonly
Configure default values for this object.
Instance Method Summary collapse
- #ensure_open ⇒ Object
-
#initialize(config_dir: CONFIG_DIR, cluster: CLUSTER, user: USER, flags: FLAGS) ⇒ Cluster
constructor
Create a new object.
- #open ⇒ Object
- #open? ⇒ Boolean
- #path ⇒ Object
- #pool(name) {|p| ... } ⇒ Object
- #pools ⇒ Object
- #rados_cluster {|@cluster_fd| ... } ⇒ Object
- #shutdown ⇒ Object
Methods included from ClusterWrapper
Constructor Details
#initialize(config_dir: CONFIG_DIR, cluster: CLUSTER, user: USER, flags: FLAGS) ⇒ Cluster
Create a new object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ceph_storage/cluster.rb', line 21 def initialize(config_dir: CONFIG_DIR, cluster: CLUSTER, user: USER, flags: FLAGS) CephRuby.logger = CephStorage.logger init(config_dir, cluster, user, flags) log("init config_dir #{config_dir}, cluster #{cluster}, user: #{user}") open yield(@cluster_fd) if block_given? rescue StandardError log("unable to open cluster #{cluster}") raise end |
Instance Attribute Details
#cluster ⇒ Object (readonly)
Configure default values for this object
8 9 10 |
# File 'lib/ceph_storage/cluster.rb', line 8 def cluster @cluster end |
#cluster_fd ⇒ Object (readonly)
Configure default values for this object
8 9 10 |
# File 'lib/ceph_storage/cluster.rb', line 8 def cluster_fd @cluster_fd end |
#config_dir ⇒ Object (readonly)
Configure default values for this object
8 9 10 |
# File 'lib/ceph_storage/cluster.rb', line 8 def config_dir @config_dir end |
#flags ⇒ Object (readonly)
Configure default values for this object
8 9 10 |
# File 'lib/ceph_storage/cluster.rb', line 8 def flags @flags end |
#user ⇒ Object (readonly)
Configure default values for this object
8 9 10 |
# File 'lib/ceph_storage/cluster.rb', line 8 def user @user end |
Instance Method Details
#ensure_open ⇒ Object
61 62 63 64 |
# File 'lib/ceph_storage/cluster.rb', line 61 def ensure_open return if open? open end |
#open ⇒ Object
66 67 68 69 70 71 |
# File 'lib/ceph_storage/cluster.rb', line 66 def open return if open? log('open') fd_init unless @cluster_fd @cluster_fd.connect unless open? end |
#open? ⇒ Boolean
57 58 59 |
# File 'lib/ceph_storage/cluster.rb', line 57 def open? !@cluster_fd.nil? && !@cluster_fd.handle.nil? end |
#path ⇒ Object
73 74 75 |
# File 'lib/ceph_storage/cluster.rb', line 73 def path "ceph://#{cluster}" end |
#pool(name) {|p| ... } ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ceph_storage/cluster.rb', line 40 def pool(name) ensure_open p = CephStorage::PoolFactory.build(self, name) yield(p) if block_given? p end |
#pools ⇒ Object
47 48 49 |
# File 'lib/ceph_storage/cluster.rb', line 47 def pools CephStorage::PoolEnumerator.new(self) end |
#rados_cluster {|@cluster_fd| ... } ⇒ Object
35 36 37 38 |
# File 'lib/ceph_storage/cluster.rb', line 35 def rados_cluster return @cluster_fd unless block_given? yield(@cluster_fd) end |
#shutdown ⇒ Object
51 52 53 54 55 |
# File 'lib/ceph_storage/cluster.rb', line 51 def shutdown return unless open? log('shutdown') @cluster_fd.shutdown end |