Sha256: c6dfceb438d5929ae591b452159d0874ce94f99dca9e476939aa2bba7c9e3158
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require 'erb' module VagrantMutate module Converter class Kvm < Converter def generate_metadata metadata = { 'provider' => @output_box.provider_name, } end def generate_vagrantfile " config.vm.base_mac = '#{@input_box.mac_address}'" end def write_specific_files template_path = VagrantMutate.source_root.join('templates', 'kvm', 'box.xml.erb') template = File.read(template_path) uuid = nil gui = true disk_bus = @input_box.disk_interface image_type = @output_box.image_format disk = @output_box.image_name name = @input_box.name memory = @input_box.memory / 1024 # convert bytes to kib cpus = @input_box.cpus mac = format_mac( @input_box.mac_address ) arch = @input_box.architecture qemu_bin = find_kvm File.open( File.join( @output_box.dir, 'box.xml'), 'w') do |f| f.write( ERB.new(template).result(binding) ) end end private def find_kvm qemu_bin_list = [ '/usr/bin/qemu-system-x86_64', '/usr/bin/qemu-system-i386', '/usr/bin/qemu-kvm', '/usr/libexec/qemu-kvm', '/usr/bin/kvm' ] qemu_bin = qemu_bin_list.detect { |binary| File.exists? binary } unless qemu_bin raise Errors::QemuNotFound end return qemu_bin end # convert to format with colons def format_mac(mac) mac.scan(/(.{2})/).join(':') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-mutate-0.2.6 | lib/vagrant-mutate/converter/kvm.rb |