vagrant-libvirt 0.0.33 → 0.0.35

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fe4ab377dd5768297a0cb9741ee25e889b2d57b
4
- data.tar.gz: 3aa4b4af095858c8fdf2b44860c4435d0a42ad19
3
+ metadata.gz: c8abd22d000a07d146f95e4aeeb4a806af4f7e59
4
+ data.tar.gz: fea80cb50af868fca9b6da0cbb83573fc6074476
5
5
  SHA512:
6
- metadata.gz: 05011cb3bd79c255dc215abfd05726738b95fa4c81cfecbe3a30c0d93b56ab3a898bca198502464440a7677345a60494a5d1a264dffdf1e5b05cad20a5aa2d72
7
- data.tar.gz: ad8badd8f73e38d599a7ca614e362efa2202da9226c5c99f885178687873f3108b0dd3ca0749062bbff273e6bb804470ebf5759a280ea117f6db1c3a0168dbd1
6
+ metadata.gz: 5e44a15f9091cd6053e7d64d6bf1bfef267c713ca5d6d65cf11b68ca019d74c1aeb1056a2b985668bc47a8abc4fc03cb7739dc5ecb63e0e9c4cc1d7352da7b52
7
+ data.tar.gz: d333eb8139e414857a6cf9e40972142604581695f0fc2e48b8e527e871435f0f0d071b0531fcccb789249bced4c16d12ed85a2df62114054689ff6ce442f2178
@@ -0,0 +1,37 @@
1
+ <!--
2
+ Thank you for reporting issues to vagrant-libvirt.
3
+
4
+ To make it possible for us to help you quickly, we kindly request that you use the template below to report issues. If the issue you are reporting does not fit the template (a feature request for example) please feel free to adapt it to your needs.
5
+
6
+ Please be aware that we are not actively testing previous versions of both Vagrant and Vagrant-libvirt, so before reporting an issue, please install the latest Vagrant version from Vagrantup.com, run `vagrant plugin update` and reproduce the issue.
7
+ -->
8
+ ### Steps to reproduce
9
+ 1.
10
+ 2.
11
+ 3.
12
+
13
+ ### Expected behaviour
14
+ Tell us what should happen
15
+
16
+ ### Actual behaviour
17
+ Tell us what happens instead
18
+
19
+ ### System configuration
20
+ **OS/Distro version:**:
21
+
22
+ **Libvirt version:**
23
+
24
+ **Output of `vagrant version; vagrant plugin list`:**
25
+
26
+ **Output of `VAGRANT_LOG=debug vagrant ... --provider=libvirt`**
27
+ ```
28
+ Insert debug output inside quotes here (replace ... with whatever command you use to trigger the issue)
29
+ ```
30
+
31
+ **A Vagrantfile to reproduce the issue:**
32
+ ```
33
+ Insert Vagrantfile inside quotes here (remove sensitive data if needed)
34
+ ```
35
+
36
+ **Are you using upstream vagrant package or your distros package?**
37
+ Upstream / Distro
data/.travis.yml CHANGED
@@ -10,12 +10,19 @@ script: bundle _${BUNDLER_VERSION}_ exec rspec --color --format documentation
10
10
  notifications:
11
11
  email: false
12
12
  rvm:
13
- - 2.0.0
13
+ - 2.2.3
14
14
  env:
15
15
  global:
16
16
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
17
17
  matrix:
18
- - VAGRANT_VERSION=v1.5.4 BUNDLER_VERSION=1.5.3
19
- - VAGRANT_VERSION=v1.6.5 BUNDLER_VERSION=1.6.9
20
- - VAGRANT_VERSION=v1.7.0 BUNDLER_VERSION=1.7.9
21
- - VAGRANT_VERSION= BUNDLER_VERSION=1.7.9
18
+ - VAGRANT_VERSION=v1.8.4 BUNDLER_VERSION=1.12.5
19
+ matrix:
20
+ include:
21
+ - env: VAGRANT_VERSION=master BUNDLER_VERSION=1.12.5
22
+ rvm: 2.2.3
23
+ - env: VAGRANT_VERSION=v1.7.4 BUNDLER_VERSION=1.7.9
24
+ rvm: 2.0.0
25
+ allow_failures:
26
+ - env: VAGRANT_VERSION=master BUNDLER_VERSION=1.12.5
27
+ rvm: 2.2.3
28
+
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Vagrant Libvirt Provider
2
- [![Build Status](https://travis-ci.org/pradels/vagrant-libvirt.svg)](https://travis-ci.org/pradels/vagrant-libvirt)
2
+ [![Build Status](https://travis-ci.org/vagrant-libvirt/vagrant-libvirt.svg)](https://travis-ci.org/vagrant-libvirt/vagrant-libvirt)
3
3
 
4
4
  This is a [Vagrant](http://www.vagrantup.com) plugin that adds an
5
5
  [Libvirt](http://libvirt.org) provider to Vagrant, allowing Vagrant to
@@ -60,13 +60,13 @@ welcome and can help a lot :-)
60
60
 
61
61
  ## Future work
62
62
 
63
- * Take a look at [open issues](https://github.com/pradels/vagrant-libvirt/issues?state=open).
63
+ * Take a look at [open issues](https://github.com/vagrant-libvirt/vagrant-libvirt/issues?state=open).
64
64
 
65
65
  ## Installation
66
66
 
67
- First, you should have libvirt installed if you plan to run VMs on your local system. For instructions, refer to your linux distribution's documentation,
67
+ First, you should have both qemu and libvirt installed if you plan to run VMs on your local system. For instructions, refer to your linux distribution's documentation. *Before you start using Vagrant-libvirt, please make sure your libvirt and qemu installation is working correctly and you are able to create qemu or kvm type virtual machines with `virsh` or `virt-manager`.*
68
68
 
69
- Next, you must have [Vagrant installed](http://docs.vagrantup.com/v2/installation/index.html). Vagrant-libvirt supports Vagrant 1.5, 1.6 and 1.7.
69
+ Next, you must have [Vagrant installed](http://docs.vagrantup.com/v2/installation/index.html). Vagrant-libvirt supports Vagrant 1.5, 1.6, 1.7 and 1.8.
70
70
 
71
71
  Now you're ready to install vagrant-libvirt using standard [Vagrant plugin](http://docs.vagrantup.com/v2/plugins/usage.html) installation methods.
72
72
 
@@ -103,8 +103,9 @@ sudo ln -fs /usr/bin/ld.gold /usr/bin/ld
103
103
  After installing the plugin (instructions above), the quickest way to get
104
104
  started is to add Libvirt box and specify all the details manually within
105
105
  a `config.vm.provider` block. So first, add Libvirt box using any name you
106
- want. This is just an example of Libvirt CentOS 7 box available in
107
- https://atlas.hashicorp.com :
106
+ want. You can find more libvirt ready boxes at https://atlas.hashicorp.com/boxes/search?provider=libvirt
107
+
108
+ Some examples:
108
109
 
109
110
  ```
110
111
  vagrant init fedora/23-cloud-base
@@ -186,7 +187,7 @@ end
186
187
 
187
188
  ### Domain Specific Options
188
189
 
189
- * `disk_bus` - The type of disk device to emulate. Defaults to virtio if not set. Possible values are documented in libvirt's [description for _target_](http://libvirt.org/formatdomain.html#elementsDisks).
190
+ * `disk_bus` - The type of disk device to emulate. Defaults to virtio if not set. Possible values are documented in libvirt's [description for _target_](http://libvirt.org/formatdomain.html#elementsDisks). NOTE: this option applies only to disks associated with a box image. To set the bus type on additional disks, see the [Additional Disks](#additional-disks) section.
190
191
  * `nic_model_type` - parameter specifies the model of the network adapter when you create a domain value by default virtio KVM believe possible values, see the [documentation for libvirt](https://libvirt.org/formatdomain.html#elementsNICSModel).
191
192
  * `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
192
193
  * `cpus` - Number of virtual cpus. Defaults to 1 if not set.
@@ -222,7 +223,7 @@ end
222
223
  * `tpm_path` - The path to the TPM device on the host system.
223
224
  * `dtb` - The device tree blob file, mostly used for non-x86 platforms. In case the device tree isn't added in-line to the kernel, it can be manually specified here.
224
225
  * `autostart` - Automatically start the domain when the host boots. Defaults to 'false'.
225
-
226
+ * `channel` - [libvirt channels](https://libvirt.org/formatdomain.html#elementCharChannel). Configure a private communication channel between the host and guest, e.g. for use by the [qemu guest agent](http://wiki.libvirt.org/page/Qemu_guest_agent) and the Spice/QXL graphics type.
226
227
 
227
228
  Specific domain settings can be set for each domain separately in multi-VM
228
229
  environment. Example below shows a part of Vagrantfile, where specific options
@@ -412,8 +413,8 @@ starts with 'libvirt__' string. Here is a list of those options:
412
413
  the interface xml configuration. _(This feature only works in libvirt 1.2.20 and higher)_
413
414
  * `:libvirt__guest_ipv6` - Enable or disable guest-to-guest IPv6 communication.
414
415
  See [here](https://libvirt.org/formatnetwork.html#examplesPrivate6), and [here](http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=705e67d40b09a905cd6a4b8b418d5cb94eaa95a8) for for more information.
415
- * `:libvirt__iface_name` - Define a name for the private network interface. With this feature one can [simulate physical link failures](https://github.com/pradels/vagrant-libvirt/pull/498)
416
- * `:mac` - MAC address for the interface.
416
+ * `:libvirt__iface_name` - Define a name for the private network interface. With this feature one can [simulate physical link failures](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498)
417
+ * `:mac` - MAC address for the interface. *Note: specify this in lowercase since Vagrant network scripts assume it will be!*
417
418
  * `:model_type` - parameter specifies the model of the network adapter when you create a domain value by default virtio KVM believe possible values, see the documentation for libvirt
418
419
 
419
420
 
@@ -430,6 +431,8 @@ virtual network.
430
431
  Default mode is 'bridge'.
431
432
  * `:type` - is type of interface.(`<interface type="#{@type}">`)
432
433
  * `:mac` - MAC address for the interface.
434
+ * `:network_name` - Name of libvirt network to connect to.
435
+ * `:portgroup` - Name of libvirt portgroup to connect to.
433
436
  * `:ovs` - Support to connect to an open vSwitch bridge device. Default is 'false'.
434
437
 
435
438
  ### Management Network
@@ -715,9 +718,71 @@ Vagrant.configure("2") do |config|
715
718
  end
716
719
  ```
717
720
 
721
+ ## Libvirt communication channels
722
+
723
+ For certain functionality to be available within a guest, a private
724
+ communication channel must be established with the host. Two notable examples of
725
+ this are the qemu guest agent, and the Spice/QXL graphics type.
726
+
727
+ Below is a simple example which exposes a virtio serial channel to the guest. Note: in a multi-VM environment, the channel would be created for all VMs.
728
+
729
+ ```ruby
730
+ vagrant.configure(2) do |config|
731
+ config.vm.provider :libvirt do |libvirt|
732
+ libvirt.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
733
+ end
734
+ end
735
+ ```
736
+
737
+ Below is the syntax for creating a spicevmc channel for use by a qxl graphics card.
738
+
739
+ ```ruby
740
+ vagrant.configure(2) do |config|
741
+ config.vm.provider :libvirt do |libvirt|
742
+ libvirt.channel :type => 'spicevmc', :target_name => 'com.redhat.spice.0', :target_type => 'virtio'
743
+ end
744
+ end
745
+ ```
746
+
747
+ These settings can be specified on a per-VM basis, however the per-guest settings will OVERRIDE any global 'config' setting. In the following example, we create 3 VM with the following configuration:
748
+
749
+ master: No channel settings specified, so we default to the provider setting of a single virtio guest agent channel.
750
+ node1: Override the channel setting, setting both the guest agent channel, and a spicevmc channel
751
+ node2: Override the channel setting, setting both the guest agent channel, and a 'guestfwd' channel. TCP traffic sent by the guest to the given IP address and port is forwarded to the host socket /tmp/foo. Note: this device must be unique for each VM.
752
+
753
+ Example
754
+
755
+ ```ruby
756
+ Vagrant.configure(2) do |config|
757
+ config.vm.box = "fedora/23-cloud-base"
758
+ config.vm.provider :libvirt do |libvirt|
759
+ libvirt.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
760
+ end
761
+
762
+ config.vm.define "master" do |master|
763
+ master.vm.provider :libvirt do |domain|
764
+ domain.memory = 1024
765
+ end
766
+ end
767
+ config.vm.define "node1" do |node1|
768
+ node1.vm.provider :libvirt do |domain|
769
+ domain.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
770
+ domain.channel :type => 'spicevmc', :target_name => 'com.redhat.spice.0', :target_type => 'virtio'
771
+ end
772
+ end
773
+ config.vm.define "node2" do |node2|
774
+ node2.vm.provider :libvirt do |domain|
775
+ domain.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
776
+ domain.channel :type => 'unix', :target_type => 'guestfwd', :target_address => '192.0.2.42', :target_port => '4242',
777
+ :source_path => '/tmp/foo'
778
+ end
779
+ end
780
+ end
781
+ ```
782
+
718
783
  ## Box Format
719
784
 
720
- You can view an example box in the [example_box/directory](https://github.com/pradels/vagrant-libvirt/tree/master/example_box). That directory also contains instructions on how to build a box.
785
+ You can view an example box in the [example_box/directory](https://github.com/vagrant-libvirt/vagrant-libvirt/tree/master/example_box). That directory also contains instructions on how to build a box.
721
786
 
722
787
  The box is a tarball containing:
723
788
 
@@ -740,7 +805,7 @@ To work on the `vagrant-libvirt` plugin, clone this repository out, and use
740
805
  [Bundler](http://gembundler.com) to get the dependencies:
741
806
 
742
807
  ```
743
- $ git clone https://github.com/pradels/vagrant-libvirt.git
808
+ $ git clone https://github.com/vagrant-libvirt/vagrant-libvirt.git
744
809
  $ cd vagrant-libvirt
745
810
  $ bundle install
746
811
  ```
@@ -13,5 +13,17 @@ module VagrantPlugins
13
13
  end
14
14
  end
15
15
 
16
+ begin
17
+ require 'vagrant'
18
+ rescue LoadError
19
+ raise 'The Vagrant Libvirt plugin must be run within Vagrant.'
20
+ end
21
+
22
+ # This is a sanity check to make sure no one is attempting to install
23
+ # this into an early Vagrant version.
24
+ if Vagrant::VERSION < '1.5.0'
25
+ raise 'The Vagrant Libvirt plugin is only compatible with Vagrant 1.5+'
26
+ end
27
+
16
28
  # make sure base module class defined before loading plugin
17
29
  require 'vagrant-libvirt/plugin'
@@ -79,6 +79,9 @@ module VagrantPlugins
79
79
  # Input
80
80
  @inputs = config.inputs
81
81
 
82
+ # Channels
83
+ @channels = config.channels
84
+
82
85
  # PCI device passthrough
83
86
  @pcis = config.pcis
84
87
 
@@ -205,6 +208,11 @@ module VagrantPlugins
205
208
  env[:ui].info(" -- INPUT: type=#{input[:type]}, bus=#{input[:bus]}")
206
209
  end
207
210
 
211
+ @channels.each do |channel|
212
+ env[:ui].info(" -- CHANNEL: type=#{channel[:type]}, mode=#{channel[:source_mode]}")
213
+ env[:ui].info(" -- CHANNEL: target_type=#{channel[:target_type]}, target_name=#{channel[:target_name]}")
214
+ end
215
+
208
216
  @pcis.each do |pci|
209
217
  env[:ui].info(" -- PCI passthrough: #{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
210
218
  end
@@ -77,6 +77,8 @@ module VagrantPlugins
77
77
  @mode = iface_configuration.fetch(:mode, 'bridge')
78
78
  @type = iface_configuration.fetch(:type, 'direct')
79
79
  @model_type = iface_configuration.fetch(:model_type, @nic_model_type)
80
+ @portgroup = iface_configuration.fetch(:portgroup, nil)
81
+ @network_name = iface_configuration.fetch(:network_name, @network_name)
80
82
  template_name = 'public_interface'
81
83
  @logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
82
84
  @ovs = iface_configuration.fetch(:ovs, false)
@@ -97,7 +99,7 @@ module VagrantPlugins
97
99
  else
98
100
  default_ip = '127.0.0.1'
99
101
  end
100
- @tunnel_ip = iface_configuration.fetch(:tunnel_address, default_ip)
102
+ @tunnel_ip = iface_configuration.fetch(:tunnel_ip, default_ip)
101
103
  @model_type = iface_configuration.fetch(:model_type, @nic_model_type)
102
104
  template_name = 'tunnel_interface'
103
105
  @logger.info("Setting up #{@type} tunnel interface using #{@tunnel_ip} port #{@tunnel_port}")
@@ -125,6 +127,8 @@ module VagrantPlugins
125
127
  if iface_configuration[:iface_type] == :public_network
126
128
  if @type == 'direct'
127
129
  @mac = xml.xpath("/domain/devices/interface[source[@dev='#{@device}']]/mac/@address")
130
+ elsif !@portgroup.nil?
131
+ @mac = xml.xpath("/domain/devices/interface[source[@network='#{@network_name}']]/mac/@address")
128
132
  else
129
133
  @mac = xml.xpath("/domain/devices/interface[source[@bridge='#{@device}']]/mac/@address")
130
134
  end
@@ -163,6 +167,7 @@ module VagrantPlugins
163
167
  :type => :static,
164
168
  :ip => options[:ip],
165
169
  :netmask => options[:netmask],
170
+ :gateway => options[:gateway],
166
171
  }.merge(network)
167
172
  else
168
173
  network[:type] = :dhcp
@@ -35,8 +35,10 @@ module VagrantPlugins
35
35
 
36
36
  domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
37
37
 
38
- if env[:machine].provider_config.disks.empty?
39
- # if using default configuration of disks
38
+ if env[:machine].provider_config.disks.empty? and
39
+ env[:machine].provider_config.cdroms.empty?
40
+ # if using default configuration of disks and cdroms
41
+ # cdroms are consider volumes, but cannot be destroyed
40
42
  domain.destroy(destroy_volumes: true)
41
43
  else
42
44
  domain.destroy(destroy_volumes: false)
@@ -77,7 +77,7 @@ module VagrantPlugins
77
77
 
78
78
  # Check if we can open a connection to the host
79
79
  def ping(host, timeout = 3)
80
- timeout(timeout) do
80
+ ::Timeout.timeout(timeout) do
81
81
  s = TCPSocket.new(host, 'echo')
82
82
  s.close
83
83
  end
@@ -36,7 +36,7 @@ module VagrantPlugins
36
36
  # Parse the XML and find each defined drive and network interfacee
37
37
  hd = xml.search("/domain/devices/disk[@device='disk']")
38
38
  cdrom = xml.search("/domain/devices/disk[@device='cdrom']")
39
- network = xml.search("/domain/devices/interface[@type='network']")
39
+ network = xml.search("/domain/devices/interface[@type='network' or @type='udp']")
40
40
 
41
41
  # Generate an array per device group and a flattened array from all of those
42
42
  devices = {"hd" => hd, "cdrom" => cdrom, "network" => network}
@@ -56,6 +56,7 @@ module VagrantPlugins
56
56
  # Domain specific settings used while creating new domain.
57
57
  attr_accessor :uuid
58
58
  attr_accessor :memory
59
+ attr_accessor :channel
59
60
  attr_accessor :cpus
60
61
  attr_accessor :cpu_mode
61
62
  attr_accessor :cpu_model
@@ -103,6 +104,9 @@ module VagrantPlugins
103
104
  # Inputs
104
105
  attr_accessor :inputs
105
106
 
107
+ # Channels
108
+ attr_accessor :channels
109
+
106
110
  # PCI device passthrough
107
111
  attr_accessor :pcis
108
112
 
@@ -177,6 +181,9 @@ module VagrantPlugins
177
181
  # Inputs
178
182
  @inputs = UNSET_VALUE
179
183
 
184
+ # Channels
185
+ @channels = UNSET_VALUE
186
+
180
187
  # PCI device passthrough
181
188
  @pcis = UNSET_VALUE
182
189
 
@@ -255,6 +262,32 @@ module VagrantPlugins
255
262
  })
256
263
  end
257
264
 
265
+ def channel(options={})
266
+ if options[:type].nil?
267
+ raise "Channel type must be specified."
268
+ elsif options[:type] == 'unix' && options[:target_type] == 'guestfwd'
269
+ # Guest forwarding requires a target (ip address) and a port
270
+ if options[:target_address].nil? || options[:target_port].nil? ||
271
+ options[:source_path].nil?
272
+ raise 'guestfwd requires target_address, target_port and source_path'
273
+ end
274
+ end
275
+
276
+ if @channels == UNSET_VALUE
277
+ @channels = []
278
+ end
279
+
280
+ @channels.push({
281
+ type: options[:type],
282
+ source_mode: options[:source_mode],
283
+ source_path: options[:source_path],
284
+ target_address: options[:target_address],
285
+ target_name: options[:target_name],
286
+ target_port: options[:target_port],
287
+ target_type: options[:target_type]
288
+ })
289
+ end
290
+
258
291
  def pci(options={})
259
292
  if options[:bus].nil? || options[:slot].nil? || options[:function].nil?
260
293
  raise 'Bus AND slot AND function must be specified. Check `lspci` for that numbers.'
@@ -465,6 +498,9 @@ module VagrantPlugins
465
498
  # Inputs
466
499
  @inputs = [{:type => "mouse", :bus => "ps2"}] if @inputs == UNSET_VALUE
467
500
 
501
+ # Channels
502
+ @channels = [ ] if @channels == UNSET_VALUE
503
+
468
504
  # PCI device passthrough
469
505
  @pcis = [] if @pcis == UNSET_VALUE
470
506
 
@@ -487,6 +523,12 @@ module VagrantPlugins
487
523
  end
488
524
  end
489
525
 
526
+ machine.config.vm.networks.each do |_type, opts|
527
+ if opts[:mac] && opts[:mac].downcase! && !(opts[:mac] =~ /\A([0-9a-f]{2}:){5}([0-9a-f]{2})\z/)
528
+ errors << "Configured NIC MAC '#{opts[:mac]}' is not in 'xx:xx:xx:xx:xx:xx' format"
529
+ end
530
+ end
531
+
490
532
  { "Libvirt Provider" => errors }
491
533
  end
492
534
 
@@ -4,12 +4,6 @@ rescue LoadError
4
4
  raise 'The Vagrant Libvirt plugin must be run within Vagrant.'
5
5
  end
6
6
 
7
- # This is a sanity check to make sure no one is attempting to install
8
- # this into an early Vagrant version.
9
- if Vagrant::VERSION < '1.5.0'
10
- raise 'The Vagrant Libvirt plugin is only compatible with Vagrant 1.5+'
11
- end
12
-
13
7
  # compatibility fix to define constant not available vagrant <1.6
14
8
  ::Vagrant::MachineState::NOT_CREATED_ID ||= :not_created
15
9
 
@@ -47,7 +41,7 @@ module VagrantPlugins
47
41
  end
48
42
 
49
43
  # lower priority than nfs or rsync
50
- # https://github.com/pradels/vagrant-libvirt/pull/170
44
+ # https://github.com/vagrant-libvirt/vagrant-libvirt/pull/170
51
45
  synced_folder("9p", 4) do
52
46
  require_relative "cap/synced_folder"
53
47
  VagrantPlugins::SyncedFolder9p::SyncedFolder
@@ -96,6 +96,27 @@
96
96
  <target port='0'/>
97
97
  </console>
98
98
 
99
+ <% @channels.each do |channel| %>
100
+ <channel type='<%= channel[:type] %>' >
101
+ <source mode='<%= channel[:source_mode] %>'
102
+ <% if channel[:source_path] %>
103
+ path="<%= channel[:source_path] %>"
104
+ <% end %>
105
+ />
106
+ <target type='<%= channel[:target_type] %>'
107
+ <% if channel[:target_name] %>
108
+ name="<%= channel[:target_name] %>"
109
+ <% end %>
110
+ <% if channel[:target_address] %>
111
+ address="<%= channel[:target_address] %>"
112
+ <% end %>
113
+ <% if channel[:target_port] %>
114
+ port="<%= channel[:target_port] %>"
115
+ <% end %>
116
+ />
117
+ </channel>
118
+ <% end %>
119
+
99
120
  <% @inputs.each do |input| %>
100
121
  <input type='<%= input[:type] %>' bus='<%= input[:bus] %>'/>
101
122
  <% end %>
@@ -4,6 +4,8 @@
4
4
  <% end %>
5
5
  <%if @type == 'direct'%>
6
6
  <source dev='<%= @device %>' mode='<%= @mode %>'/>
7
+ <% elsif !@portgroup.nil? %>
8
+ <source network='<%=@network_name%>' portgroup='<%=@portgroup%>'/>
7
9
  <% else %>
8
10
  <source bridge='<%=@device%>'/>
9
11
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProviderLibvirt
3
- VERSION = '0.0.33'
3
+ VERSION = '0.0.35'
4
4
  end
5
5
  end
@@ -3,12 +3,13 @@ require 'spec_helper'
3
3
  shared_context "unit" do
4
4
  include_context 'vagrant-unit'
5
5
 
6
- let(:test_env) do
7
- vagrantfile ||= <<-EOF
6
+ let(:vagrantfile) do <<-EOF
8
7
  Vagrant.configure('2') do |config|
9
8
  config.vm.define :test
10
9
  end
11
10
  EOF
11
+ end
12
+ let(:test_env) do
12
13
  test_env = isolated_environment
13
14
  test_env.vagrantfile vagrantfile
14
15
  test_env
@@ -0,0 +1,96 @@
1
+ require "spec_helper"
2
+ require "support/sharedcontext"
3
+ require "support/libvirt_context"
4
+
5
+ require "vagrant-libvirt/action/destroy_domain"
6
+
7
+ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
8
+
9
+ subject { described_class.new(app, env) }
10
+
11
+ include_context "unit"
12
+ include_context "libvirt"
13
+
14
+ let(:libvirt_domain) { double("libvirt_domain") }
15
+ let(:libvirt_client) { double("libvirt_client") }
16
+ let(:servers) { double("servers") }
17
+
18
+ describe "#call" do
19
+ before do
20
+ allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).
21
+ to receive(:connection).and_return(connection)
22
+ allow(connection).to receive(:client).and_return(libvirt_client)
23
+ allow(libvirt_client).to receive(:lookup_domain_by_uuid).
24
+ and_return(libvirt_domain)
25
+ allow(connection).to receive(:servers).and_return(servers)
26
+ allow(servers).to receive(:get).and_return(domain)
27
+ # always see this at the start of #call
28
+ expect(ui).to receive(:info).with("Removing domain...")
29
+ end
30
+
31
+ context "when no snapshots" do
32
+ let(:root_disk) { double("libvirt_root_disk") }
33
+
34
+ before do
35
+ allow(libvirt_domain).to receive(:list_snapshots).and_return([])
36
+ allow(libvirt_domain).to receive(:has_managed_save?).and_return(nil)
37
+ root_disk.stub(:name => "test.img")
38
+ end
39
+
40
+ context "when only has root disk" do
41
+ it "calls fog to destroy volumes" do
42
+ expect(domain).to receive(:destroy).with(:destroy_volumes => true)
43
+ expect(subject.call(env)).to be_nil
44
+ end
45
+ end
46
+
47
+ context "when has additional disks" do
48
+ let(:vagrantfile) { <<-EOF
49
+ Vagrant.configure('2') do |config|
50
+ config.vm.define :test
51
+ config.vm.provider :libvirt do |libvirt|
52
+ libvirt.storage :file
53
+ end
54
+ end
55
+ EOF
56
+ }
57
+
58
+ let(:extra_disk) { double("libvirt_extra_disk") }
59
+ before do
60
+ extra_disk.stub(:name => "test-vdb.qcow2")
61
+ end
62
+
63
+ it "destroys disks individually" do
64
+ allow(libvirt_domain).to receive(:name).and_return("test")
65
+ allow(domain).to receive(:volumes).and_return([extra_disk], [root_disk])
66
+
67
+ expect(domain).to receive(:destroy).with(:destroy_volumes => false)
68
+ expect(extra_disk).to receive(:destroy) # extra disk remove
69
+ expect(root_disk).to receive(:destroy) # root disk remove
70
+ expect(subject.call(env)).to be_nil
71
+ end
72
+ end
73
+
74
+ context "when has CDROMs attached" do
75
+ let(:vagrantfile) { <<-EOF
76
+ Vagrant.configure('2') do |config|
77
+ config.vm.define :test
78
+ config.vm.provider :libvirt do |libvirt|
79
+ libvirt.storage :file, :device => :cdrom
80
+ end
81
+ end
82
+ EOF
83
+ }
84
+
85
+ it "uses explicit removal of disks" do
86
+ allow(libvirt_domain).to receive(:name).and_return("test")
87
+ allow(domain).to receive(:volumes).and_return([root_disk])
88
+
89
+ expect(domain).to_not receive(:destroy).with(:destroy_volumes => true)
90
+ expect(root_disk).to receive(:destroy) # root disk remove
91
+ expect(subject.call(env)).to be_nil
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -8,7 +8,7 @@
8
8
  # After script has finished, nothing else than halting machine should be done.
9
9
 
10
10
  # For more info about creating custom box refer to
11
- # https://github.com/pradels/vagrant-libvirt/tree/master/example_box
11
+ # https://github.com/vagrant-libvirt/vagrant-libvirt/tree/master/example_box
12
12
 
13
13
  # We need to set a hostname.
14
14
  if [ $# -ne 1 ]; then
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.license = 'MIT'
8
8
  gem.description = %q{libvirt provider for Vagrant.}
9
9
  gem.summary = %q{libvirt provider for Vagrant.}
10
- gem.homepage = 'https://github.com/pradels/vagrant-libvirt'
10
+ gem.homepage = 'https://github.com/vagrant-libvirt/vagrant-libvirt'
11
11
 
12
12
  gem.files = `git ls-files`.split($\)
13
13
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-libvirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Stanek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-03-29 00:00:00.000000000 Z
13
+ date: 2016-08-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec-core
@@ -105,6 +105,7 @@ executables: []
105
105
  extensions: []
106
106
  extra_rdoc_files: []
107
107
  files:
108
+ - ".github/issue_template.md"
108
109
  - ".gitignore"
109
110
  - ".travis.yml"
110
111
  - CHANGELOG.md
@@ -176,12 +177,13 @@ files:
176
177
  - spec/support/environment_helper.rb
177
178
  - spec/support/libvirt_context.rb
178
179
  - spec/support/sharedcontext.rb
180
+ - spec/unit/action/destroy_domain_spec.rb
179
181
  - spec/unit/action/set_name_of_domain_spec.rb
180
182
  - spec/unit/action/wait_till_up_spec.rb
181
183
  - tools/create_box.sh
182
184
  - tools/prepare_redhat_for_box.sh
183
185
  - vagrant-libvirt.gemspec
184
- homepage: https://github.com/pradels/vagrant-libvirt
186
+ homepage: https://github.com/vagrant-libvirt/vagrant-libvirt
185
187
  licenses:
186
188
  - MIT
187
189
  metadata: {}
@@ -201,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
203
  version: '0'
202
204
  requirements: []
203
205
  rubyforge_project:
204
- rubygems_version: 2.4.8
206
+ rubygems_version: 2.5.1
205
207
  signing_key:
206
208
  specification_version: 4
207
209
  summary: libvirt provider for Vagrant.
@@ -210,5 +212,6 @@ test_files:
210
212
  - spec/support/environment_helper.rb
211
213
  - spec/support/libvirt_context.rb
212
214
  - spec/support/sharedcontext.rb
215
+ - spec/unit/action/destroy_domain_spec.rb
213
216
  - spec/unit/action/set_name_of_domain_spec.rb
214
217
  - spec/unit/action/wait_till_up_spec.rb