Class: CephStorage::Cluster

Inherits:
CephRuby::Cluster
  • Object
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

Direct Known Subclasses

ClusterFactory

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClusterWrapper

wrap_me

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

#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



61
62
63
64
# File 'lib/ceph_storage/cluster.rb', line 61

def ensure_open
  return if open?
  open
end

#openObject



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

Returns:

  • (Boolean)


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

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

#pathObject



73
74
75
# File 'lib/ceph_storage/cluster.rb', line 73

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

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

Yields:

  • (p)


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

#poolsObject



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

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

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

Yields:



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

#shutdownObject



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

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