From 84fdc7d49ac5aa5711dbb92c2ad57c890344db35 Mon Sep 17 00:00:00 2001 From: Brian Pitts Date: Wed, 30 Oct 2013 14:32:12 -0500 Subject: [PATCH 1/8] Fix box metadata error keys --- lib/vagrant-libvirt/errors.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-libvirt/errors.rb b/lib/vagrant-libvirt/errors.rb index 4758083..e73e470 100644 --- a/lib/vagrant-libvirt/errors.rb +++ b/lib/vagrant-libvirt/errors.rb @@ -35,15 +35,15 @@ module VagrantPlugins end class NoBoxVirtualSizeSet < VagrantLibvirtError - error_key(:no_box_virtual_size_error) + error_key(:no_box_virtual_size) end class NoBoxFormatSet < VagrantLibvirtError - error_key(:no_box_format_error) + error_key(:no_box_format) end class WrongBoxFormatSet < VagrantLibvirtError - error_key(:wrong_box_format_error) + error_key(:wrong_box_format) end From 6492e0ae6340712194ae29aa5fef7fea2b0645b8 Mon Sep 17 00:00:00 2001 From: Mathilde Ffrench Date: Tue, 19 Nov 2013 19:22:11 +0100 Subject: [PATCH 2/8] add default network and ssk key file parameters --- lib/vagrant-libvirt/action/connect_libvirt.rb | 9 ++++++--- .../action/create_network_interfaces.rb | 5 +++-- lib/vagrant-libvirt/config.rb | 10 ++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/vagrant-libvirt/action/connect_libvirt.rb b/lib/vagrant-libvirt/action/connect_libvirt.rb index 1f089de..20f2cbc 100644 --- a/lib/vagrant-libvirt/action/connect_libvirt.rb +++ b/lib/vagrant-libvirt/action/connect_libvirt.rb @@ -53,9 +53,12 @@ module VagrantPlugins uri << virt_path uri << '?no_verify=1' - # set ssh key for access to libvirt host - home_dir = `echo ${HOME}`.chomp - uri << "&keyfile=#{home_dir}/.ssh/id_rsa" + + if config.id_ssh_key_file + # set ssh key for access to libvirt host + home_dir = `echo ${HOME}`.chomp + uri << "&keyfile=#{home_dir}/.ssh/"+config.id_ssh_key_file + end conn_attr = {} conn_attr[:provider] = 'libvirt' diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb index cae02cf..d74ea20 100644 --- a/lib/vagrant-libvirt/action/create_network_interfaces.rb +++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb @@ -16,6 +16,7 @@ module VagrantPlugins def initialize(app, env) @logger = Log4r::Logger.new('vagrant_libvirt::action::create_network_interfaces') + @default_network = env[:machine].provider_config.default_network; @app = app end @@ -58,7 +59,7 @@ module VagrantPlugins # We have slot for interface, fill it with interface configuration. adapters[free_slot] = options adapters[free_slot][:network_name] = interface_network( - env[:libvirt_compute].client, adapters[free_slot]) + env[:libvirt_compute].client, adapters[free_slot], ) end # Create each interface as new domain device. @@ -151,7 +152,7 @@ module VagrantPlugins end # TODO Network default can be missing or named different. - return 'default' + return @default_network; end end end diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 166c833..71e426d 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -18,10 +18,16 @@ module VagrantPlugins # Password for Libvirt connection. attr_accessor :password + # ID SSH key file + attr_accessor :id_ssh_key_file + # Libvirt storage pool name, where box image and instance snapshots will # be stored. attr_accessor :storage_pool_name + # Libvirt default network + attr_accessor :default_network + # Domain specific settings used while creating new domain. attr_accessor :memory attr_accessor :cpus @@ -34,7 +40,9 @@ module VagrantPlugins @connect_via_ssh = UNSET_VALUE @username = UNSET_VALUE @password = UNSET_VALUE + @id_ssh_key_file = UNSET_VALUE @storage_pool_name = UNSET_VALUE + @default_network = UNSET_VALUE # Domain specific settings. @memory = UNSET_VALUE @@ -49,7 +57,9 @@ module VagrantPlugins @connect_via_ssh = false if @connect_via_ssh == UNSET_VALUE @username = nil if @username == UNSET_VALUE @password = nil if @password == UNSET_VALUE + @id_ssh_key_file = nil if @id_ssh_key_file == UNSET_VALUE @storage_pool_name = 'default' if @storage_pool_name == UNSET_VALUE + @default_network = 'default' if @default_network == UNSET_VALUE # Domain specific settings. @memory = 512 if @memory == UNSET_VALUE From 149253acd44e8008bd23096a71310db075bafd9b Mon Sep 17 00:00:00 2001 From: Mathilde Ffrench Date: Tue, 19 Nov 2013 19:25:31 +0100 Subject: [PATCH 3/8] remove erronous , --- lib/vagrant-libvirt/action/create_network_interfaces.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb index d74ea20..3f51b41 100644 --- a/lib/vagrant-libvirt/action/create_network_interfaces.rb +++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb @@ -59,7 +59,7 @@ module VagrantPlugins # We have slot for interface, fill it with interface configuration. adapters[free_slot] = options adapters[free_slot][:network_name] = interface_network( - env[:libvirt_compute].client, adapters[free_slot], ) + env[:libvirt_compute].client, adapters[free_slot]) end # Create each interface as new domain device. From 6383297c8661790cf812a5c33f8cdd23410dd77f Mon Sep 17 00:00:00 2001 From: Mathilde Ffrench Date: Tue, 19 Nov 2013 19:41:29 +0100 Subject: [PATCH 4/8] Add new options descriptions in README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 178a93d..da426a8 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,9 @@ This provider exposes quite a few provider-specific configuration options: * `connect_via_ssh` - If use ssh tunnel to connect to Libvirt. * `username` - Username and password to access Libvirt. * `password` - Password to access Libvirt. -* `storage_pool_name` - Libvirt storage pool name, where box image and - instance snapshots will be stored. +* `id_ssh_key_file` - The id ssh key file name to access Libvirt (eg: id_dsa or id_rsa or ... in the user .ssh directory) +* `storage_pool_name` - Libvirt storage pool name, where box image and instance snapshots will be stored. +* `default_network` - Libvirt default network name. If not specified default network name is 'default'. ### Domain Specific Options From 1e35123584ed379560cfc5ccc8ad1aaab5bfd8f7 Mon Sep 17 00:00:00 2001 From: Brian Pitts Date: Thu, 21 Nov 2013 11:05:38 -0600 Subject: [PATCH 5/8] Mention vagrant-mutate --- README.md | 1 + example_box/README.md | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 178a93d..bda1675 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ welcome and can help a lot :-) * Provision domains with any built-in Vagrant provisioner. * Synced folder support via `rsync` or `nfs`. * Snapshots via [sahara](https://github.com/jedi4ever/sahara) +* Use boxes from other Vagrant providers via [vagrant-mutate](https://github.com/sciurus/vagrant-mutate) ## Future work diff --git a/example_box/README.md b/example_box/README.md index 50b519e..3210ac0 100644 --- a/example_box/README.md +++ b/example_box/README.md @@ -21,3 +21,9 @@ Libvirt box should define at least three data fields in `metadata.json` file. * format - Currently supported format is qcow2. * virtual_size - Virtual size of image in GBytes. +## Converting Boxes + +Instead of creating a box from scratch, you can use +[vagrant-mutate](https://github.com/sciurus/vagrant-mutate) +to take boxes created for other Vagrant providers and use them +with vagrant-libvirt. From 06aa627fff8a9bf7577d2ef20de1d7c8cae52908 Mon Sep 17 00:00:00 2001 From: Craig Vyvial Date: Thu, 21 Nov 2013 23:33:16 -0600 Subject: [PATCH 6/8] adding the nfs share on start the nfs shares were missing when starting a container back up after it was halted. --- lib/vagrant-libvirt/action.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vagrant-libvirt/action.rb b/lib/vagrant-libvirt/action.rb index ca9ee64..a41f573 100644 --- a/lib/vagrant-libvirt/action.rb +++ b/lib/vagrant-libvirt/action.rb @@ -59,6 +59,10 @@ module VagrantPlugins # VM is not running or suspended. Start it.. Machine should gain # IP address when comming up, so wait for dhcp lease and store IP # into machines data_dir. + b2.use NFS + b2.use PrepareNFSSettings + b2.use ShareFolders + b3.use StartDomain b3.use WaitTillUp end From afc6c3a8a5f7c882f3069c17a129fce3ceb3bf84 Mon Sep 17 00:00:00 2001 From: Rosario Di Somma Date: Fri, 29 Nov 2013 18:21:31 +0100 Subject: [PATCH 7/8] Fix wrong nfs methods call Change-Id: If2c9965ee437f444c7d62fb0758f573ed2facf89 Signed-off-by: Rosario Di Somma --- lib/vagrant-libvirt/action.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-libvirt/action.rb b/lib/vagrant-libvirt/action.rb index a41f573..1b9d955 100644 --- a/lib/vagrant-libvirt/action.rb +++ b/lib/vagrant-libvirt/action.rb @@ -59,9 +59,9 @@ module VagrantPlugins # VM is not running or suspended. Start it.. Machine should gain # IP address when comming up, so wait for dhcp lease and store IP # into machines data_dir. - b2.use NFS - b2.use PrepareNFSSettings - b2.use ShareFolders + b3.use NFS + b3.use PrepareNFSSettings + b3.use ShareFolders b3.use StartDomain b3.use WaitTillUp From f0614b144db515acf499d67b1af67b16ff4ed357 Mon Sep 17 00:00:00 2001 From: erik-smit Date: Tue, 3 Dec 2013 19:55:05 +0100 Subject: [PATCH 8/8] Proxy ssh through libvirt host, if libvirt is connected via ssh --- lib/vagrant-libvirt/action/read_ssh_info.rb | 2 ++ lib/vagrant-libvirt/action/sync_folders.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/vagrant-libvirt/action/read_ssh_info.rb b/lib/vagrant-libvirt/action/read_ssh_info.rb index 1b90b24..6d324bc 100644 --- a/lib/vagrant-libvirt/action/read_ssh_info.rb +++ b/lib/vagrant-libvirt/action/read_ssh_info.rb @@ -47,6 +47,8 @@ module VagrantPlugins :forward_agent => machine.config.ssh.forward_agent, :forward_x11 => machine.config.ssh.forward_x11, } + + ssh_info[:proxy_command] = "ssh '#{machine.provider_config.host}' -l '#{machine.provider_config.username}' nc %h %p" if machine.provider_config.connect_via_ssh if not ssh_info[:username] ssh_info[:username] = machine.config.ssh.default.username diff --git a/lib/vagrant-libvirt/action/sync_folders.rb b/lib/vagrant-libvirt/action/sync_folders.rb index df8a2f9..edd9908 100644 --- a/lib/vagrant-libvirt/action/sync_folders.rb +++ b/lib/vagrant-libvirt/action/sync_folders.rb @@ -19,6 +19,7 @@ module VagrantPlugins env[:machine].config.vm.synced_folders.each do |id, data| next if data[:nfs] + proxycommand = "-o ProxyCommand='#{ssh_info[:proxy_command]}'" if ssh_info[:proxy_command] hostpath = File.expand_path(data[:hostpath], env[:root_path]) guestpath = data[:guestpath] @@ -39,7 +40,7 @@ module VagrantPlugins command = [ "rsync", "--del", "--verbose", "--archive", "-z", "--exclude", ".vagrant/", - "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'", + "-e", "ssh -p #{ssh_info[:port]} #{proxycommand} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'", hostpath, "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]