Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (38 sloc) 2.12 KB
require 'veewee/provider/core/provider'
module Veewee
module Provider
module Kvm
class Provider < Veewee::Provider::Core::Provider
def check_requirements
require 'fog' "Falling back to qemu:///system for libvirt URI if no value is specified in the .fog config file"
Fog.credentials[:libvirt_uri] ||= "qemu:///system" "Setting libvirt IP Command if not already defined in .fog config file"
Fog.credentials[:libvirt_ip_command] ||= "arp -an |grep $mac|cut -d '(' -f 2 | cut -d ')' -f 1" "Opening a libvirt connection using"
conn = Fog::Compute[:libvirt]
rescue Exception => ex
raise Veewee::Error, "There was a problem opening a connection to libvirt: #{ex}"
end "Libvirt connection established"
env.logger.debug "Found capabilities:"
env.logger.debug "#{conn.client.capabilities}" "Checking libvirt version"
# format major * 1,000,000 + minor * 1,000 + release
conn.client.libversion > 8003 or raise Veewee::Error, "You need at least libvirt version 0.8.3 or higher " "Checking available networks"
conn.networks.any? or raise Veewee::Error, "You need at least one (active) network defined in #{Fog.credentials[:libvirt_uri]}." "Checking available storagepools"
conn.pools.any? or raise Veewee::Error, "You need at least one (active) storage pool defined in #{Fog.credentials[:libvirt_uri]}." "Checking availability of the arp utility"
shell_exec("arp") or raise Veewee::Error, "Could not execute the arp command. This is required to find the IP address of the VM"
def build(definition_name, box_name, options)
super(definition_name, box_name, options)
end #End Class
end # End Module
end # End Module
end # End Module
Something went wrong with that request. Please try again.