Class: GlusterFS::Volume
- Inherits:
-
Object
- Object
- GlusterFS::Volume
- Defined in:
- lib/glusterfs/volume.rb
Instance Attribute Summary collapse
-
#fs ⇒ Object
readonly
Returns the value of attribute fs.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#mounted ⇒ Object
readonly
Returns the value of attribute mounted.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Instance Method Summary collapse
- #delete_dir(path) ⇒ Object
- #delete_file(path) ⇒ Object
-
#initialize(name) ⇒ Volume
constructor
A new instance of Volume.
- #list(path) ⇒ Object
- #lstat(path) ⇒ Object
- #mount(host, port = 24007, protocol = 'tcp') ⇒ Object
- #mounted? ⇒ Boolean
- #unmount ⇒ Object
Constructor Details
Instance Attribute Details
#fs ⇒ Object (readonly)
Returns the value of attribute fs.
2 3 4 |
# File 'lib/glusterfs/volume.rb', line 2 def fs @fs end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
2 3 4 |
# File 'lib/glusterfs/volume.rb', line 2 def host @host end |
#mounted ⇒ Object (readonly)
Returns the value of attribute mounted.
2 3 4 |
# File 'lib/glusterfs/volume.rb', line 2 def mounted @mounted end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/glusterfs/volume.rb', line 2 def name @name end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
2 3 4 |
# File 'lib/glusterfs/volume.rb', line 2 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
2 3 4 |
# File 'lib/glusterfs/volume.rb', line 2 def protocol @protocol end |
Instance Method Details
#delete_dir(path) ⇒ Object
39 40 41 42 |
# File 'lib/glusterfs/volume.rb', line 39 def delete_dir(path) check_mounted GlusterFS.rmdir(@fs, path) end |
#delete_file(path) ⇒ Object
34 35 36 37 |
# File 'lib/glusterfs/volume.rb', line 34 def delete_file(path) check_mounted GlusterFS.unlink(@fs, path) end |
#list(path) ⇒ Object
29 30 31 32 |
# File 'lib/glusterfs/volume.rb', line 29 def list(path) dir = Directory.new(volume, path) dir.list end |
#lstat(path) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/glusterfs/volume.rb', line 22 def lstat(path) check_mounted data = GlusterFS::Stat.new GlusterFS.lstat(@fs, path, data) data end |
#mount(host, port = 24007, protocol = 'tcp') ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/glusterfs/volume.rb', line 10 def mount(host, port = 24007, protocol = 'tcp') raise GlusterFS::Error, "Already mounted: #{self}" if mounted? GlusterFS.set_volfile_server(@fs, protocol, host, port) result = GlusterFS.init(@fs) raise GlusterFS::Error, "Failed to mount volume #{self}" if result != 0 @mounted = true @host = host @protocol = protocol @port = port self end |
#mounted? ⇒ Boolean
44 45 46 |
# File 'lib/glusterfs/volume.rb', line 44 def mounted? @mounted end |
#unmount ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/glusterfs/volume.rb', line 48 def unmount if mounted? GlusterFS.fini(@fs) @mounted = false true end end |