Skip to content

Commit

Permalink
Merge pull request #351 from ccaum/improve_libvirt_support
Browse files Browse the repository at this point in the history
Improve libvirt support
  • Loading branch information
jedi4ever committed Aug 6, 2012
2 parents 86eef83 + 332daf6 commit b047eaf
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions bin/veewee
@@ -1,4 +1,9 @@
#!/usr/bin/env ruby
begin
require 'rubygems'
rescue LoadError
end

require 'veewee'

env = Veewee::Environment.new
Expand Down
4 changes: 2 additions & 2 deletions lib/veewee/provider/core/box/build.rb
Expand Up @@ -70,7 +70,7 @@ def build(options={})
# This needs to be done after the kickstart:
# As the dhcp request will likely occur just before the kickstart fetch
until !self.ip_address.nil?
env.logger.info "wait for Ip addres"
env.logger.info "wait for Ip address"
sleep 2
end

Expand Down Expand Up @@ -119,7 +119,7 @@ def filter_postinstall_files(options)
unless options["postinstall_exclude"].nil?
options["postinstall_exclude"].each do |p|
env.logger.info "Exclude pattern #{p}"
new_definition.postinstall_files.collect! { |f| f.match(p) ? f.gsub(/^/,"_"): f}
new_definition.postinstall_files.reject! { |f| f.match(p) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/veewee/provider/core/box/scp.rb
Expand Up @@ -10,7 +10,7 @@ def scp(localfile,remotefile,options={})
new_options=ssh_options.merge(options)
self.when_ssh_login_works(self.ip_address,new_options) do
begin
env.logger.info "About to transfer #{localfile} to #{remotefile} to the box #{name} - #{self.ip_address} - #{new_options}"
env.logger.info "About to transfer #{localfile} to #{remotefile} to the box #{name} - #{self.ip_address} - #{new_options.inspect}"
self.ssh_transfer_file(self.ip_address,localfile,remotefile,new_options)
rescue RuntimeError => ex
ui.error("Error transfering file #{localfile} failed, possible not enough permissions to write? #{ex}",:prefix => false)
Expand Down
4 changes: 2 additions & 2 deletions lib/veewee/provider/kvm/box/create.rb
Expand Up @@ -21,8 +21,8 @@ def create_server(options)
:memory_size => definition.memory_size.to_i*1024,
:cpus => definition.cpu_count.to_i,
:volume_capacity => "#{definition.disk_size}M",
:network_interface_type => "nat",
:domain_type => options['use_emulation'] ? 'qemu': 'kvm',
:network_interface_type => "network",
:iso_file => definition.iso_file,
:arch => definition.os_type_id.end_with?("_64") ? "x86_64" : "i686",
:iso_dir => env.config.veewee.iso_dir
Expand Down Expand Up @@ -64,7 +64,7 @@ def add_floppy
# Get the raw xml of the changed document
new_xml=domain_doc.to_xml

# Undefine the existing domain
# Undefine the existing domain
s.undefine

# Re-define the domain
Expand Down
6 changes: 3 additions & 3 deletions lib/veewee/provider/kvm/box/helper/console_type.rb
Expand Up @@ -8,9 +8,9 @@ module Kvm
module BoxCommand
# Type on the console
def console_type(sequence,type_options={})
vnc_port=@connection.servers.all(:name => name).first.vnc_port
display_port=vnc_port.to_i - 5900
ui.success "Sending keystrokes to VNC port :#{display_port} - TCP port: #{vnc_port}"
tcp_port=@connection.servers.all(:name => name).first.display[:port]
display_port=tcp_port.to_i - 5900
ui.success "Sending keystrokes to VNC port :#{display_port} - TCP port: #{tcp_port}"
vnc_type(sequence,"127.0.0.1",display_port)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/veewee/provider/kvm/box/helper/ip.rb
Expand Up @@ -3,7 +3,7 @@ module Provider
module Kvm
module BoxCommand
def ip_address
ip=@connection.servers.all(:name => "#{name}").first.addresses[:public]
ip=@connection.servers.all(:name => "#{name}").first.public_ip_address
return ip.first unless ip.nil?
return ip
end
Expand Down
4 changes: 2 additions & 2 deletions lib/veewee/provider/kvm/box/helper/status.rb
Expand Up @@ -15,11 +15,11 @@ def exists?
end

def exists_volume?
!@connection.volumes.all(:name => "#{name}.img").nil?
@connection.list_volumes.find { |v| v[:name] == "#{name}.img" }
end

def exists_vm?
!@connection.servers.all(:name => name).nil?
@connection.list_domains.find { |d| d[:name] == name }
end

end # End Module
Expand Down
2 changes: 1 addition & 1 deletion lib/veewee/provider/kvm/provider.rb
Expand Up @@ -42,7 +42,7 @@ def check_requirements
# 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.libversion
libvirt_version=conn.version
if libvirt_version < 8003
raise Veewee::Error,"You need at least libvirt version 0.8.3 or higher "
end
Expand Down

0 comments on commit b047eaf

Please sign in to comment.