Class: CephRuby::Pool
Overview
Represents a Ceph pool
usage
pool = cluster.pool(‘name’)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from PoolHelper
<=>, by_id, create_with_all, create_with_rule, ensure_open, eql?, log, open?
Constructor Details
#initialize(cluster, name) ⇒ Pool
Returns a new instance of Pool.
11
12
13
14
15
16
17
18
19
|
# File 'lib/ceph-ruby/pool.rb', line 11
def initialize(cluster, name)
self.cluster = cluster
self.name = name
begin
yield(self)
ensure
close
end if block_given?
end
|
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
9
10
11
|
# File 'lib/ceph-ruby/pool.rb', line 9
def cluster
@cluster
end
|
#handle ⇒ Object
Returns the value of attribute handle.
9
10
11
|
# File 'lib/ceph-ruby/pool.rb', line 9
def handle
@handle
end
|
#name ⇒ Object
Returns the value of attribute name.
9
10
11
|
# File 'lib/ceph-ruby/pool.rb', line 9
def name
@name
end
|
Instance Method Details
#auid ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/ceph-ruby/pool.rb', line 44
def auid
log('auid')
ensure_open
auid_p = FFI::MemoryPointer.new(:uint64)
ret = Lib::Rados.rados_ioctx_pool_get_auid(handle, auid_p)
raise SystemCallError.new('get of auid for'\
" '#{name}' failed", -ret) if ret < 0
auid_p.get_uint64(0)
end
|
#auid=(dst_auid) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/ceph-ruby/pool.rb', line 36
def auid=(dst_auid)
log("auid=#{dst_auid}")
ensure_open
ret = Lib::Rados.rados_ioctx_pool_set_auid(handle, dst_auid)
raise SystemCallError.new('set of auid for'\
" '#{name}' failed", -ret) if ret < 0
end
|
#close ⇒ Object
64
65
66
67
68
69
|
# File 'lib/ceph-ruby/pool.rb', line 64
def close
return unless open?
log('close')
Lib::Rados.rados_ioctx_destroy(handle)
self.handle = nil
end
|
#create(auid: nil, rule_id: nil) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/ceph-ruby/pool.rb', line 86
def create(auid: nil, rule_id: nil)
log("create auid: #{auid}, rule: #{rule_id}")
rule_id ||= 0
return create_with_all(auid, rule_id) if auid
create_with_rule(rule_id)
close
end
|
#destroy ⇒ Object
94
95
96
97
98
|
# File 'lib/ceph-ruby/pool.rb', line 94
def destroy
ret = Lib::Rados.rados_pool_delete(cluster.handle, name)
raise SystemCallError.new('delete pool failed',
-ret) if ret < 0
end
|
#exists? ⇒ Boolean
Also known as:
exist?
21
22
23
24
25
26
27
|
# File 'lib/ceph-ruby/pool.rb', line 21
def exists?
log('exists?')
ret = Lib::Rados.rados_pool_lookup(cluster.handle, name)
return true if ret >= 0
return false if ret == -Errno::ENOENT::Errno
raise SystemCallError.new("lookup of '#{name}' failed", -ret) if ret < 0
end
|
#flush_aio ⇒ Object
110
111
112
113
114
115
|
# File 'lib/ceph-ruby/pool.rb', line 110
def flush_aio
ensure_open
ret = Lib::Rados.rados_aio_flush(handle)
raise SystemCallError.new('aio flush faield',
-ret) if ret < 0
end
|
#id ⇒ Object
31
32
33
34
|
# File 'lib/ceph-ruby/pool.rb', line 31
def id
ensure_open
Lib::Rados.rados_ioctx_get_id(handle)
end
|
#open ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/ceph-ruby/pool.rb', line 54
def open
return if open?
log('open')
handle_p = FFI::MemoryPointer.new(:pointer)
ret = Lib::Rados.rados_ioctx_create(cluster.handle, name, handle_p)
raise SystemCallError.new('creation of io context for'\
" '#{name}' failed", -ret) if ret < 0
self.handle = handle_p.get_pointer(0)
end
|
#rados_block_device(name, &block) ⇒ Object
81
82
83
84
|
# File 'lib/ceph-ruby/pool.rb', line 81
def rados_block_device(name, &block)
ensure_open
RadosBlockDevice.new(self, name, &block)
end
|
#rados_object(name, &block) ⇒ Object
71
72
73
74
|
# File 'lib/ceph-ruby/pool.rb', line 71
def rados_object(name, &block)
ensure_open
RadosObject.new(self, name, &block)
end
|
#rados_object_enumerator(&block) ⇒ Object
76
77
78
79
|
# File 'lib/ceph-ruby/pool.rb', line 76
def rados_object_enumerator(&block)
ensure_open
RadosObjectEnumerator.new(self, &block)
end
|
#stat ⇒ Object
100
101
102
103
104
105
106
107
108
|
# File 'lib/ceph-ruby/pool.rb', line 100
def stat
log('stat')
stat_s = Lib::Rados::PoolStatStruct.new
ensure_open
ret = Lib::Rados.rados_ioctx_pool_stat(handle, stat_s)
raise SystemCallError.new('stat failed',
-ret) if ret < 0
stat_s.to_hash
end
|