From 72b12ad46665d774b144126e6ab6f7f2f2bbdf0e Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 11:55:28 -0700 Subject: [PATCH 1/9] Use rubygems if available Previous to this commit, rubygems wasn't being loaded before the veewee libraries were. This caused dependencies that were installed by gems to fail. This commit requires rubygems if it's available on the sytsem --- bin/veewee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/veewee b/bin/veewee index 6709efce..51a8fab3 100755 --- a/bin/veewee +++ b/bin/veewee @@ -1,4 +1,9 @@ #!/usr/bin/env ruby +begin + require 'rubygems' +rescue LoadError +end + require 'veewee' env = Veewee::Environment.new From 76fd16a8fc1086bab9cb936c70cb5e56db07515a Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:00:07 -0700 Subject: [PATCH 2/9] Remove postinstall files matching exclude regex Previous to this commit, postinstall files matching the provided exclude regex were not removed from the postinstall list, but rather were just prepended with '_'. This caused an error since the script '_' doesn't exist in the definition. This commit removes the files from the list of postinstall files if the filename matches the provided regex --- lib/veewee/provider/core/box/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/veewee/provider/core/box/build.rb b/lib/veewee/provider/core/box/build.rb index b4f6f7ef..24451d0e 100644 --- a/lib/veewee/provider/core/box/build.rb +++ b/lib/veewee/provider/core/box/build.rb @@ -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 From 53b148d0985c025a4d098df7da1c4ba07a8bab43 Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:03:34 -0700 Subject: [PATCH 3/9] Fix typo 'addres' should have been 'address' --- lib/veewee/provider/core/box/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/veewee/provider/core/box/build.rb b/lib/veewee/provider/core/box/build.rb index 24451d0e..ff461ed2 100644 --- a/lib/veewee/provider/core/box/build.rb +++ b/lib/veewee/provider/core/box/build.rb @@ -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 From 062e97730bda23b9f6e132e5ed2303a952bf6766 Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:04:16 -0700 Subject: [PATCH 4/9] Properly format options when doing an scp Previous to this commit, when printing the scp command to stdout, the options hash was converted to a string causing all the keys and values to concat as a single, spaceless, string. This commit calls Hash#inspect on the hash object to format it --- lib/veewee/provider/core/box/scp.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/veewee/provider/core/box/scp.rb b/lib/veewee/provider/core/box/scp.rb index aa3be312..26b0cb95 100644 --- a/lib/veewee/provider/core/box/scp.rb +++ b/lib/veewee/provider/core/box/scp.rb @@ -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) From d04496901a4bc246fdf2925c9681b8d2ad2a5bf6 Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:09:38 -0700 Subject: [PATCH 5/9] Replace network from 'nat' to 'network' Previous to the commit, a new libvirt instance was created with the 'nat' network type. However, Fog master/HEAD doesn't support this network type. This commit changes the network type from 'nat' to 'network', which Fog supports. --- lib/veewee/provider/kvm/box/create.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/veewee/provider/kvm/box/create.rb b/lib/veewee/provider/kvm/box/create.rb index a9ed0049..e276bc89 100644 --- a/lib/veewee/provider/kvm/box/create.rb +++ b/lib/veewee/provider/kvm/box/create.rb @@ -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 @@ -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 From cf15ff39bf55f0aec252171ed57ffb33e01704d6 Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:12:18 -0700 Subject: [PATCH 6/9] Use display port provided by Fog Previous to this commit, the VNC port was determined using the deprecated vnc_port method in Fog. This commit uses the display[:port] method. --- lib/veewee/provider/kvm/box/helper/console_type.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/veewee/provider/kvm/box/helper/console_type.rb b/lib/veewee/provider/kvm/box/helper/console_type.rb index 35aefa29..547f8ca3 100644 --- a/lib/veewee/provider/kvm/box/helper/console_type.rb +++ b/lib/veewee/provider/kvm/box/helper/console_type.rb @@ -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 From f81ef667bab8e0022b85e74aa431d0ae7771a835 Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:19:39 -0700 Subject: [PATCH 7/9] Use public Fog methods to get public IP address Previous to this commit, the private method #address was called to get the public IP address of an instance, which caused an exception. This commit calls the public #public_ip_address method instead --- lib/veewee/provider/kvm/box/helper/ip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/veewee/provider/kvm/box/helper/ip.rb b/lib/veewee/provider/kvm/box/helper/ip.rb index 240b703e..39ce0a6a 100644 --- a/lib/veewee/provider/kvm/box/helper/ip.rb +++ b/lib/veewee/provider/kvm/box/helper/ip.rb @@ -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 From d24641e0607b3f3839d10394784258a54c6f3384 Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:22:43 -0700 Subject: [PATCH 8/9] Properly determine if a volume or instance exists Preious to this commit, volumes were determined to exist or not by calling the Volumes#all method the :name parameter to filter only the volumes that matched the value of :name. This was not properly finding the volumes. This commit uses the #list_volumes method and calls #find on the array returned. Likewise for instances --- lib/veewee/provider/kvm/box/helper/status.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/veewee/provider/kvm/box/helper/status.rb b/lib/veewee/provider/kvm/box/helper/status.rb index 0c6d9e13..299402d8 100644 --- a/lib/veewee/provider/kvm/box/helper/status.rb +++ b/lib/veewee/provider/kvm/box/helper/status.rb @@ -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 From 332daf61e43a1fda395c16a6f86715d41b10e6a1 Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:25:14 -0700 Subject: [PATCH 9/9] Properly retrieve version of libvirt Previous to this commit, the non-existent LibVirt#libversion method was called to determine the version of libvirt. This commit calls the LibVirt#version method. --- lib/veewee/provider/kvm/provider.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/veewee/provider/kvm/provider.rb b/lib/veewee/provider/kvm/provider.rb index 20454807..f8296b8b 100644 --- a/lib/veewee/provider/kvm/provider.rb +++ b/lib/veewee/provider/kvm/provider.rb @@ -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