Class: Veewee::Provider::Kvm::Provider
- Inherits:
-
Core::Provider
- Object
- Core::Provider
- Veewee::Provider::Kvm::Provider
- Defined in:
- lib/veewee/provider/kvm/provider.rb
Instance Attribute Summary
Attributes inherited from Core::Provider
Instance Method Summary collapse
- #build(definition_name, box_name, options) ⇒ Object
-
#check_requirements ⇒ Object
Translate the definition ssh options to ssh options that can be passed to Net::Ssh calls We expect plain ssh for a connection.
Methods inherited from Core::Provider
available?, #gem_available?, #gems_available?, #get_box, #initialize, #ui
Methods included from Core::Helper::Shell
Constructor Details
This class inherits a constructor from Veewee::Provider::Core::Provider
Instance Method Details
#build(definition_name, box_name, options) ⇒ Object
61 62 63 64 65 |
# File 'lib/veewee/provider/kvm/provider.rb', line 61 def build(definition_name,box_name,) super(definition_name,box_name,) end |
#check_requirements ⇒ Object
Translate the definition ssh options to ssh options that can be passed to Net::Ssh calls We expect plain ssh for a connection
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/veewee/provider/kvm/provider.rb', line 11 def check_requirements ["ruby-libvirt","fog"].each do |gemname| unless gem_available?(gemname) raise Veewee::Error,"The kvm provider requires the gem '#{gemname}' to be installed\n" + "gem install #{gemname}" end end env.logger.info "Checking for version of libvirt" begin require 'libvirt' env.logger.info "Opening a libvirt connection to qemu:///system" conn = ::Libvirt::open("qemu:///system") env.logger.info "Libvirt connection established" env.logger.info "Found capabilities:" env.logger.info "#{conn.capabilities}" env.logger.info "Checking available storagepools" pools=conn.list_storage_pools env.logger.info "Storagepools: #{pools.join(',')}" if pools.count < 1 raise Veewee::Error,"You need at least one (active) storage pool defined. This needs to be available if you connect to qemu:///system" end #env.logger.info "Checking available networks" #networks=conn.list_networks #env.logger.info "Networks: #{networks.join(',')}" #if networks.count < 1 # raise Veewee::Error,"You need at least one (active) network defined. This needs to be available if you connect to qemu:///system" #end # http://www.libvirt.org/html/libvirt-libvirt.html#virGetVersion # format major * 1,000,000 + minor * 1,000 + release env.logger.info "Checking libvirt version" libvirt_version=conn.version if libvirt_version < 8003 raise Veewee::Error,"You need at least libvirt version 0.8.3 or higher " end conn.close rescue Exception => ex raise Veewee::Error, "There was a problem opening a connection to libvirt: #{ex}" end unless self.shell_exec("arp").status == 0 raise Veewee::Error,"Could not execute the arp command. This is required to find the IP address of the VM" end end |