Class: Xen::VolumeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/xen/lvm.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, size) ⇒ VolumeGroup

Returns a new instance of VolumeGroup.



9
10
11
12
# File 'lib/xen/lvm.rb', line 9

def initialize(name, size)
  @name = name
  @size = size
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/xen/lvm.rb', line 7

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'lib/xen/lvm.rb', line 7

def size
  @size
end

Class Method Details

.find(name = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xen/lvm.rb', line 14

def self.find(name=nil)
  name ||= nil
  # XXX deal with not found error
  cmd = "vgs --options=vg_name,vg_size --separator=' ' --noheadings --units=g --nosuffix #{name}"
  begin
    output = Xen::Command.run cmd
    result = output.collect { |line|
      name, size = line.strip.split(' ')
      new name, size
    }
  rescue # don't die if `vgs` command missing
  end
  name ? result[0] : result
end

Instance Method Details

#freeObject



29
30
31
32
33
34
35
36
# File 'lib/xen/lvm.rb', line 29

def free
  cmd = "vgs --options=vg_free --separator=' ' --noheadings --units=g --nosuffix #{@name}"
  begin
    result = Xen::Command.run cmd
  rescue # don't die if `vgs` command missing
  end
  result
end