Class: CephStorage::Cluster
- Inherits:
-
ClusterFactory
- Object
- CephRuby::Cluster
- ClusterFactory
- 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
Constant Summary
Constants inherited from ClusterFactory
CephStorage::ClusterFactory::CLUSTER, CephStorage::ClusterFactory::CONFIG_DIR, CephStorage::ClusterFactory::FLAGS, CephStorage::ClusterFactory::USER
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
Methods inherited from ClusterFactory
Constructor Details
#initialize(config_dir: CONFIG_DIR, cluster: CLUSTER, user: USER, flags: FLAGS) ⇒ Cluster
Create a new object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ceph_storage/cluster.rb', line 15 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
55 56 57 58 |
# File 'lib/ceph_storage/cluster.rb', line 55 def ensure_open return if open? open end |
#open ⇒ Object
60 61 62 63 64 65 |
# File 'lib/ceph_storage/cluster.rb', line 60 def open return if open? log('open') fd_init unless @cluster_fd @cluster_fd.connect unless open? end |
#open? ⇒ Boolean
51 52 53 |
# File 'lib/ceph_storage/cluster.rb', line 51 def open? !@cluster_fd.nil? && !@cluster_fd.handle.nil? end |
#path ⇒ Object
67 68 69 |
# File 'lib/ceph_storage/cluster.rb', line 67 def path "ceph://#{cluster}" end |
#pool(name) {|p| ... } ⇒ Object
34 35 36 37 38 39 |
# File 'lib/ceph_storage/cluster.rb', line 34 def pool(name) ensure_open p = CephStorage::PoolFactory.build(self, name) yield(p) if block_given? p end |
#pools ⇒ Object
41 42 43 |
# File 'lib/ceph_storage/cluster.rb', line 41 def pools CephStorage::PoolEnumerator.new(self) end |
#rados_cluster {|@cluster_fd| ... } ⇒ Object
29 30 31 32 |
# File 'lib/ceph_storage/cluster.rb', line 29 def rados_cluster return @cluster_fd unless block_given? yield(@cluster_fd) end |
#shutdown ⇒ Object
45 46 47 48 49 |
# File 'lib/ceph_storage/cluster.rb', line 45 def shutdown return unless open? log('shutdown') @cluster_fd.shutdown end |