Class: QEMU::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/qemu/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options = {}) ⇒ Image

Returns a new instance of Image.



6
7
8
9
10
# File 'lib/qemu/image.rb', line 6

def initialize(file, options = {})
  self.file = file
  options = options.merge :format => "raw"
  options.each { |k,v| send "#{k}=", v }
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/qemu/image.rb', line 4

def file
  @file
end

#formatObject

Returns the value of attribute format.



4
5
6
# File 'lib/qemu/image.rb', line 4

def format
  @format
end

#sizeObject

Returns the value of attribute size.



4
5
6
# File 'lib/qemu/image.rb', line 4

def size
  @size
end

Instance Method Details

#convert(format, output_file = nil) ⇒ Object



16
17
18
19
# File 'lib/qemu/image.rb', line 16

def convert(format, output_file = nil)
  output_file ||= "#{file}.#{format}"
  system "qemu-img convert -O #{format} #{file} #{output_file}" and output_file
end

#createObject



12
13
14
# File 'lib/qemu/image.rb', line 12

def create
  system "qemu-img create -f #{format} #{file} #{size}"
end