Class: GlusterFS::Volume

Inherits:
Object
  • Object
show all
Defined in:
lib/glusterfs/volume.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Volume

Returns a new instance of Volume.



4
5
6
7
# File 'lib/glusterfs/volume.rb', line 4

def initialize(name)
  @name = name
  @fs = GlusterFS.new(@name)
end

Instance Attribute Details

#fsObject (readonly)

Returns the value of attribute fs.



2
3
4
# File 'lib/glusterfs/volume.rb', line 2

def fs
  @fs
end

#mountedObject (readonly)

Returns the value of attribute mounted.



2
3
4
# File 'lib/glusterfs/volume.rb', line 2

def mounted
  @mounted
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/glusterfs/volume.rb', line 2

def name
  @name
end

Instance Method Details

#mount(host, port = 24007, protocol = 'tcp') ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/glusterfs/volume.rb', line 9

def mount(host, port = 24007, protocol = 'tcp')
  GlusterFS.set_volfile_server(@fs, protocol, host, port)
  result = GlusterFS.init(@fs)
  if result != 0
    raise GlusterFS::Error,
      "Failed to mount volume '#{volume_name}' on #{protocol}://#{host}:#{port}"
  end
  @mounted = true
end

#mounted?Boolean

Returns:



19
20
21
# File 'lib/glusterfs/volume.rb', line 19

def mounted?
  @mounted
end

#unmountObject



23
24
25
26
27
28
29
# File 'lib/glusterfs/volume.rb', line 23

def unmount
  if mounted?
    GlusterFS.fini(@fs)
    @mounted = false
    true
  end
end