Class: CephStorage::Cluster

Inherits:
ClusterFactory show all
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

Instance Method Summary collapse

Methods included from ClusterWrapper

wrap_me

Methods inherited from ClusterFactory

build

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

#clusterObject (readonly)

Configure default values for this object



8
9
10
# File 'lib/ceph_storage/cluster.rb', line 8

def cluster
  @cluster
end

#cluster_fdObject (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_dirObject (readonly)

Configure default values for this object



8
9
10
# File 'lib/ceph_storage/cluster.rb', line 8

def config_dir
  @config_dir
end

#flagsObject (readonly)

Configure default values for this object



8
9
10
# File 'lib/ceph_storage/cluster.rb', line 8

def flags
  @flags
end

#userObject (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_openObject



55
56
57
58
# File 'lib/ceph_storage/cluster.rb', line 55

def ensure_open
  return if open?
  open
end

#openObject



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

Returns:

  • (Boolean)


51
52
53
# File 'lib/ceph_storage/cluster.rb', line 51

def open?
  !@cluster_fd.nil? && !@cluster_fd.handle.nil?
end

#pathObject



67
68
69
# File 'lib/ceph_storage/cluster.rb', line 67

def path
  "ceph://#{cluster}"
end

#pool(name) {|p| ... } ⇒ Object

Yields:

  • (p)


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

#poolsObject



41
42
43
# File 'lib/ceph_storage/cluster.rb', line 41

def pools
  CephStorage::PoolEnumerator.new(self)
end

#rados_cluster {|@cluster_fd| ... } ⇒ Object

Yields:



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

#shutdownObject



45
46
47
48
49
# File 'lib/ceph_storage/cluster.rb', line 45

def shutdown
  return unless open?
  log('shutdown')
  @cluster_fd.shutdown
end