vagrant-libvirt 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +32 -3
- data/lib/vagrant-libvirt.rb +1 -1
- data/lib/vagrant-libvirt/action.rb +1 -1
- data/lib/vagrant-libvirt/action/connect_libvirt.rb +9 -5
- data/lib/vagrant-libvirt/action/create_domain.rb +5 -3
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +4 -4
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +20 -19
- data/lib/vagrant-libvirt/action/create_networks.rb +3 -3
- data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/destroy_networks.rb +1 -1
- data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/handle_box_image.rb +3 -3
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +3 -3
- data/lib/vagrant-libvirt/action/is_created.rb +1 -1
- data/lib/vagrant-libvirt/action/is_running.rb +1 -1
- data/lib/vagrant-libvirt/action/is_suspended.rb +1 -1
- data/lib/vagrant-libvirt/action/message_already_created.rb +1 -1
- data/lib/vagrant-libvirt/action/message_not_created.rb +1 -1
- data/lib/vagrant-libvirt/action/message_not_running.rb +1 -1
- data/lib/vagrant-libvirt/action/message_not_suspended.rb +1 -1
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +1 -1
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +1 -1
- data/lib/vagrant-libvirt/action/read_ssh_info.rb +4 -4
- data/lib/vagrant-libvirt/action/read_state.rb +1 -1
- data/lib/vagrant-libvirt/action/resume_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/set_name_of_domain.rb +2 -2
- data/lib/vagrant-libvirt/action/share_folders.rb +1 -1
- data/lib/vagrant-libvirt/action/start_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/suspend_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/sync_folders.rb +1 -1
- data/lib/vagrant-libvirt/action/timed_provision.rb +1 -1
- data/lib/vagrant-libvirt/action/wait_till_up.rb +1 -1
- data/lib/vagrant-libvirt/config.rb +4 -1
- data/lib/vagrant-libvirt/errors.rb +1 -1
- data/lib/vagrant-libvirt/plugin.rb +5 -5
- data/lib/vagrant-libvirt/provider.rb +3 -3
- data/lib/vagrant-libvirt/templates/domain.xml.erb +5 -4
- data/lib/vagrant-libvirt/templates/interface.xml.erb +3 -0
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +7 -0
- data/lib/vagrant-libvirt/util.rb +1 -1
- data/lib/vagrant-libvirt/util/collection.rb +1 -1
- data/lib/vagrant-libvirt/util/erb_template.rb +1 -1
- data/lib/vagrant-libvirt/util/libvirt_util.rb +1 -1
- data/lib/vagrant-libvirt/util/timer.rb +1 -1
- data/lib/vagrant-libvirt/version.rb +2 -2
- data/vagrant-libvirt.gemspec +5 -4
- metadata +10 -5
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -103,6 +103,7 @@ This provider exposes quite a few provider-specific configuration options:
|
|
103
103
|
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
|
104
104
|
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
|
105
105
|
* `nested` - [Enable nested virtualization](https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/nested-vmx.txt). Default is false.
|
106
|
+
* `volume_cache` - Controls the cache mechanism. Possible values are "default", "none", "writethrough", "writeback", "directsync" and "unsafe". [See driver->cache in libvirt documentation](http://libvirt.org/formatdomain.html#elementsDisks).
|
106
107
|
|
107
108
|
Specific domain settings can be set for each domain separately in multi-VM
|
108
109
|
environment. Example below shows a part of Vagrantfile, where specific options
|
@@ -116,6 +117,7 @@ Vagrant.configure("2") do |config|
|
|
116
117
|
domain.memory = 2048
|
117
118
|
domain.cpus = 2
|
118
119
|
domain.nested = true
|
120
|
+
domain.volume_cache = 'none'
|
119
121
|
end
|
120
122
|
end
|
121
123
|
|
@@ -152,14 +154,25 @@ Vagrant goes through steps below when creating new project:
|
|
152
154
|
## Networks
|
153
155
|
|
154
156
|
Networking features in the form of `config.vm.network` support private networks
|
155
|
-
concept.
|
156
|
-
|
157
|
+
concept. Port Forwarding is currently not supported.
|
158
|
+
|
159
|
+
Public Network interfaces are currently implemented using the macvtap driver. The macvtap
|
160
|
+
driver is only available with the Linux Kernel version >= 2.6.24. See the following libvirt
|
161
|
+
documentation for the details of the macvtap usage.
|
162
|
+
|
163
|
+
http://www.libvirt.org/formatdomain.html#elementsNICSDirect
|
157
164
|
|
158
165
|
An examples of network interface definitions:
|
159
166
|
|
160
167
|
```ruby
|
168
|
+
# Private network
|
161
169
|
config.vm.define :test_vm1 do |test_vm1|
|
162
|
-
test_vm1.vm.network :private_network, :ip => "10.20.30.40"
|
170
|
+
test_vm1.vm.network :private_network, :ip => "10.20.30.40"
|
171
|
+
end
|
172
|
+
|
173
|
+
# Public Network
|
174
|
+
config.vm.define :test_vm1 do |test_vm1|
|
175
|
+
test_vm1.vm.network :public_network, :dev => "eth0", :mode => 'bridge'
|
163
176
|
end
|
164
177
|
```
|
165
178
|
|
@@ -174,8 +187,16 @@ created networks are NATed to outside world, so your VM will be able to connect
|
|
174
187
|
to the internet (if hypervisor can). And by default, DHCP is offering addresses
|
175
188
|
on newly created networks.
|
176
189
|
|
190
|
+
The second interface is created and bridged into the physical device 'eth0'.
|
191
|
+
This mechanism uses the macvtap Kernel driver and therefore does not require
|
192
|
+
an existing bridge device. This configuration assumes that DHCP and DNS services
|
193
|
+
are being provided by the public network. This public interface should be reachable
|
194
|
+
by anyone with access to the public network.
|
195
|
+
|
177
196
|
### Private Network Options
|
178
197
|
|
198
|
+
*Note: These options are not applicable to public network interfaces.*
|
199
|
+
|
179
200
|
There is a way to pass specific options for libvirt provider when using
|
180
201
|
`config.vm.network` to configure new network interface. Each parameter name
|
181
202
|
starts with 'libvirt__' string. Here is a list of those options:
|
@@ -196,6 +217,14 @@ starts with 'libvirt__' string. Here is a list of those options:
|
|
196
217
|
* `:libvirt__forward_device` - Name of interface/device, where network should
|
197
218
|
be forwarded (NATed or routed). Used only when creating new network. By
|
198
219
|
default, all physical interfaces are used.
|
220
|
+
* `:mac` - MAC address for the interface.
|
221
|
+
|
222
|
+
### Public Network Options
|
223
|
+
* `:dev` - Physical device that the public interface should use. Default is 'eth0'
|
224
|
+
* `:mode` - The mode in which the public interface should operate in. Supported
|
225
|
+
modes are available from the [libvirt documentation](http://www.libvirt.org/formatdomain.html#elementsNICSDirect).
|
226
|
+
Default mode is 'bridge'.
|
227
|
+
* `:mac` - MAC address for the interface.
|
199
228
|
|
200
229
|
## Obtaining Domain IP Address
|
201
230
|
|
data/lib/vagrant-libvirt.rb
CHANGED
@@ -2,7 +2,7 @@ require 'pathname'
|
|
2
2
|
require 'vagrant-libvirt/plugin'
|
3
3
|
|
4
4
|
module VagrantPlugins
|
5
|
-
module
|
5
|
+
module ProviderLibvirt
|
6
6
|
lib_path = Pathname.new(File.expand_path("../vagrant-libvirt", __FILE__))
|
7
7
|
autoload :Action, lib_path.join("action")
|
8
8
|
autoload :Errors, lib_path.join("errors")
|
@@ -2,11 +2,11 @@ require 'fog'
|
|
2
2
|
require 'log4r'
|
3
3
|
|
4
4
|
module VagrantPlugins
|
5
|
-
module
|
5
|
+
module ProviderLibvirt
|
6
6
|
module Action
|
7
7
|
class ConnectLibvirt
|
8
8
|
def initialize(app, env)
|
9
|
-
@logger = Log4r::Logger.new(
|
9
|
+
@logger = Log4r::Logger.new('vagrant_libvirt::action::connect_libvirt')
|
10
10
|
@app = app
|
11
11
|
end
|
12
12
|
|
@@ -14,8 +14,8 @@ module VagrantPlugins
|
|
14
14
|
|
15
15
|
# If already connected to libvirt, just use it and don't connect
|
16
16
|
# again.
|
17
|
-
if
|
18
|
-
env[:libvirt_compute] =
|
17
|
+
if ProviderLibvirt.libvirt_connection
|
18
|
+
env[:libvirt_compute] = ProviderLibvirt.libvirt_connection
|
19
19
|
return @app.call(env)
|
20
20
|
end
|
21
21
|
|
@@ -39,7 +39,11 @@ module VagrantPlugins
|
|
39
39
|
uri << '://'
|
40
40
|
uri << config.host if config.host
|
41
41
|
end
|
42
|
+
|
42
43
|
uri << '/system?no_verify=1'
|
44
|
+
# set ssh key for access to libvirt host
|
45
|
+
home_dir = `echo ${HOME}`.chomp
|
46
|
+
uri << "&keyfile=#{home_dir}/.ssh/id_rsa"
|
43
47
|
|
44
48
|
conn_attr = {}
|
45
49
|
conn_attr[:provider] = 'libvirt'
|
@@ -64,7 +68,7 @@ module VagrantPlugins
|
|
64
68
|
raise Errors::FogLibvirtConnectionError,
|
65
69
|
:error_message => e.message
|
66
70
|
end
|
67
|
-
|
71
|
+
ProviderLibvirt.libvirt_connection = env[:libvirt_compute]
|
68
72
|
|
69
73
|
@app.call(env)
|
70
74
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'log4r'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
module
|
4
|
+
module ProviderLibvirt
|
5
5
|
module Action
|
6
6
|
|
7
7
|
class CreateDomain
|
8
|
-
include VagrantPlugins::
|
8
|
+
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
9
9
|
|
10
10
|
def initialize(app, env)
|
11
11
|
@logger = Log4r::Logger.new("vagrant_libvirt::action::create_domain")
|
@@ -21,6 +21,7 @@ module VagrantPlugins
|
|
21
21
|
@cpus = config.cpus
|
22
22
|
@nested = config.nested
|
23
23
|
@memory_size = config.memory*1024
|
24
|
+
@domain_volume_cache = config.volume_cache
|
24
25
|
|
25
26
|
# TODO get type from driver config option
|
26
27
|
@domain_type = 'kvm'
|
@@ -28,7 +29,7 @@ module VagrantPlugins
|
|
28
29
|
@os_type = 'hvm'
|
29
30
|
|
30
31
|
# Get path to domain image.
|
31
|
-
domain_volume =
|
32
|
+
domain_volume = ProviderLibvirt::Util::Collection.find_matching(
|
32
33
|
env[:libvirt_compute].volumes.all, "#{@name}.img")
|
33
34
|
raise Errors::DomainVolumeExists if domain_volume == nil
|
34
35
|
@domain_volume_path = domain_volume.path
|
@@ -42,6 +43,7 @@ module VagrantPlugins
|
|
42
43
|
env[:ui].info(" -- Base box: #{env[:machine].box.name}")
|
43
44
|
env[:ui].info(" -- Storage pool: #{env[:machine].provider_config.storage_pool_name}")
|
44
45
|
env[:ui].info(" -- Image: #{@domain_volume_path}")
|
46
|
+
env[:ui].info(" -- Volume Cache: #{@domain_volume_cache}")
|
45
47
|
|
46
48
|
# Create libvirt domain.
|
47
49
|
# Is there a way to tell fog to create new domain with already
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'log4r'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
module
|
4
|
+
module ProviderLibvirt
|
5
5
|
module Action
|
6
6
|
|
7
7
|
# Create a snapshot of base box image. This new snapshot is just new
|
8
8
|
# cow image with backing storage pointing to base box image. Use this
|
9
9
|
# image as new domain volume.
|
10
10
|
class CreateDomainVolume
|
11
|
-
include VagrantPlugins::
|
11
|
+
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
12
12
|
|
13
13
|
def initialize(app, env)
|
14
14
|
@logger = Log4r::Logger.new("vagrant_libvirt::action::create_domain_volume")
|
@@ -25,12 +25,12 @@ module VagrantPlugins
|
|
25
25
|
@name = "#{env[:domain_name]}.img"
|
26
26
|
|
27
27
|
# Verify the volume doesn't exist already.
|
28
|
-
domain_volume =
|
28
|
+
domain_volume = ProviderLibvirt::Util::Collection.find_matching(
|
29
29
|
env[:libvirt_compute].volumes.all, @name)
|
30
30
|
raise Errors::DomainVolumeExists if domain_volume
|
31
31
|
|
32
32
|
# Get path to backing image - box volume.
|
33
|
-
box_volume =
|
33
|
+
box_volume = ProviderLibvirt::Util::Collection.find_matching(
|
34
34
|
env[:libvirt_compute].volumes.all, env[:box_volume_name])
|
35
35
|
@backing_file = box_volume.path
|
36
36
|
|
@@ -3,14 +3,14 @@ require 'vagrant/util/network_ip'
|
|
3
3
|
require 'vagrant/util/scoped_hash_override'
|
4
4
|
|
5
5
|
module VagrantPlugins
|
6
|
-
module
|
6
|
+
module ProviderLibvirt
|
7
7
|
module Action
|
8
8
|
|
9
9
|
# Create network interfaces for domain, before domain is running.
|
10
10
|
# Networks for connecting those interfaces should be already prepared.
|
11
11
|
class CreateNetworkInterfaces
|
12
|
-
include VagrantPlugins::
|
13
|
-
include VagrantPlugins::
|
12
|
+
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
13
|
+
include VagrantPlugins::ProviderLibvirt::Util::LibvirtUtil
|
14
14
|
include Vagrant::Util::NetworkIP
|
15
15
|
include Vagrant::Util::ScopedHashOverride
|
16
16
|
|
@@ -32,28 +32,16 @@ module VagrantPlugins
|
|
32
32
|
# Setup list of interfaces before creating them.
|
33
33
|
adapters = []
|
34
34
|
|
35
|
-
#
|
36
|
-
# Use network 'default' as network for ssh connecting and
|
37
|
-
# machine provisioning.
|
38
|
-
#
|
39
|
-
# TODO Network name with DHCP for first interface should be
|
40
|
-
# configurable.
|
41
|
-
adapters[0] = {
|
42
|
-
:network_name => 'default'
|
43
|
-
}
|
35
|
+
# Vagrant gives you adapter 0 by default
|
44
36
|
|
45
37
|
# Assign interfaces to slots.
|
46
38
|
env[:machine].config.vm.networks.each do |type, options|
|
47
|
-
# Only private network is supported now. Port forwarding and public
|
48
|
-
# network are not supported via libvirt API, so they are not
|
49
|
-
# implemented in this provider.
|
50
|
-
next if type != :private_network
|
51
39
|
|
52
40
|
# Get options for this interface. Options can be specified in
|
53
41
|
# Vagrantfile in short format (:ip => ...), or provider format
|
54
42
|
# (:libvirt__network_name => ...).
|
55
43
|
options = scoped_hash_override(options, :libvirt)
|
56
|
-
options = { :netmask => '255.255.255.0' }.merge(options)
|
44
|
+
options = { :netmask => '255.255.255.0', :iface_type => type }.merge(options)
|
57
45
|
|
58
46
|
# TODO fill first ifaces with adapter option specified.
|
59
47
|
if options[:adapter]
|
@@ -63,7 +51,7 @@ module VagrantPlugins
|
|
63
51
|
|
64
52
|
free_slot = options[:adapter].to_i
|
65
53
|
else
|
66
|
-
free_slot = find_empty(adapters
|
54
|
+
free_slot = find_empty(adapters)
|
67
55
|
raise Errors::InterfaceSlotNotAvailable if free_slot == nil
|
68
56
|
end
|
69
57
|
|
@@ -77,13 +65,26 @@ module VagrantPlugins
|
|
77
65
|
adapters.each_with_index do |iface_configuration, slot_number|
|
78
66
|
@iface_number = slot_number
|
79
67
|
@network_name = iface_configuration[:network_name]
|
68
|
+
@mac = iface_configuration.fetch(:mac, false)
|
69
|
+
template_name = 'interface'
|
70
|
+
|
71
|
+
# Configuration for public interfaces which use the macvtap driver
|
72
|
+
if iface_configuration[:iface_type] == :public_network
|
73
|
+
template_name = 'public_interface'
|
74
|
+
@device = iface_configuration.fetch(:dev, 'eth0')
|
75
|
+
@mode = iface_configuration.fetch(:mode, 'bridge')
|
76
|
+
@logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
|
77
|
+
end
|
80
78
|
|
81
79
|
message = "Creating network interface eth#{@iface_number}"
|
82
80
|
message << " connected to network #{@network_name}."
|
81
|
+
if @mac
|
82
|
+
message << " Using MAC address: #{@mac}"
|
83
|
+
end
|
83
84
|
@logger.info(message)
|
84
85
|
|
85
86
|
begin
|
86
|
-
domain.attach_device(to_xml(
|
87
|
+
domain.attach_device(to_xml(template_name))
|
87
88
|
rescue => e
|
88
89
|
raise Errors::AttachDeviceError,
|
89
90
|
:error_message => e.message
|
@@ -4,14 +4,14 @@ require 'vagrant/util/scoped_hash_override'
|
|
4
4
|
require 'ipaddr'
|
5
5
|
|
6
6
|
module VagrantPlugins
|
7
|
-
module
|
7
|
+
module ProviderLibvirt
|
8
8
|
module Action
|
9
9
|
# Prepare all networks needed for domain connections.
|
10
10
|
class CreateNetworks
|
11
11
|
include Vagrant::Util::NetworkIP
|
12
12
|
include Vagrant::Util::ScopedHashOverride
|
13
|
-
include VagrantPlugins::
|
14
|
-
include VagrantPlugins::
|
13
|
+
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
14
|
+
include VagrantPlugins::ProviderLibvirt::Util::LibvirtUtil
|
15
15
|
|
16
16
|
def initialize(app, env)
|
17
17
|
@logger = Log4r::Logger.new("vagrant_libvirt::action::create_networks")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'log4r'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
module
|
4
|
+
module ProviderLibvirt
|
5
5
|
module Action
|
6
6
|
class HandleBoxImage
|
7
7
|
def initialize(app, env)
|
@@ -35,7 +35,7 @@ module VagrantPlugins
|
|
35
35
|
env[:box_volume_name] << '_vagrant_box_image.img'
|
36
36
|
|
37
37
|
# Don't continue if image already exists in storage pool.
|
38
|
-
return @app.call(env) if
|
38
|
+
return @app.call(env) if ProviderLibvirt::Util::Collection.find_matching(
|
39
39
|
env[:libvirt_compute].volumes.all, env[:box_volume_name])
|
40
40
|
|
41
41
|
# Box is not available as a storage pool volume. Create and upload
|
@@ -97,7 +97,7 @@ module VagrantPlugins
|
|
97
97
|
stream = env[:libvirt_compute].client.stream
|
98
98
|
volume.upload(stream, offset=0, length=image_size)
|
99
99
|
|
100
|
-
# Exception
|
100
|
+
# Exception ProviderLibvirt::RetrieveError can be raised if buffer is
|
101
101
|
# longer than length accepted by API send function.
|
102
102
|
#
|
103
103
|
# TODO: How to find out if buffer is too large and what is the
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'log4r'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
module
|
4
|
+
module ProviderLibvirt
|
5
5
|
module Action
|
6
6
|
class HandleStoragePool
|
7
|
-
include VagrantPlugins::
|
7
|
+
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
8
8
|
|
9
9
|
def initialize(app, env)
|
10
10
|
@logger = Log4r::Logger.new("vagrant_libvirt::action::handle_storage_pool")
|
@@ -16,7 +16,7 @@ module VagrantPlugins
|
|
16
16
|
config = env[:machine].provider_config
|
17
17
|
|
18
18
|
# Check for storage pool, where box image should be created
|
19
|
-
fog_pool =
|
19
|
+
fog_pool = ProviderLibvirt::Util::Collection.find_matching(
|
20
20
|
env[:libvirt_compute].pools.all, config.storage_pool_name)
|
21
21
|
return @app.call(env) if fog_pool
|
22
22
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "log4r"
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
module
|
4
|
+
module ProviderLibvirt
|
5
5
|
module Action
|
6
6
|
# This action reads the SSH info for the machine and puts it into the
|
7
7
|
# `:machine_ssh_info` key in the environment.
|
@@ -12,8 +12,8 @@ module VagrantPlugins
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(env)
|
15
|
-
env[:machine_ssh_info] = read_ssh_info(
|
16
|
-
|
15
|
+
env[:machine_ssh_info] = read_ssh_info(env[:libvirt_compute],
|
16
|
+
env[:machine])
|
17
17
|
|
18
18
|
@app.call(env)
|
19
19
|
end
|
@@ -53,7 +53,7 @@ module VagrantPlugins
|
|
53
53
|
end
|
54
54
|
|
55
55
|
ssh_info
|
56
|
-
end
|
56
|
+
end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module VagrantPlugins
|
2
|
-
module
|
2
|
+
module ProviderLibvirt
|
3
3
|
module Action
|
4
4
|
|
5
5
|
# Setup name for domain and domain volumes.
|
@@ -14,7 +14,7 @@ module VagrantPlugins
|
|
14
14
|
env[:domain_name] << "_#{Time.now.to_i}"
|
15
15
|
|
16
16
|
# Check if the domain name is not already taken
|
17
|
-
domain =
|
17
|
+
domain = ProviderLibvirt::Util::Collection.find_matching(
|
18
18
|
env[:libvirt_compute].servers.all, env[:domain_name])
|
19
19
|
if domain != nil
|
20
20
|
raise Vagrant::Errors::DomainNameExists,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'vagrant'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
module
|
4
|
+
module ProviderLibvirt
|
5
5
|
class Config < Vagrant.plugin('2', :config)
|
6
6
|
# A hypervisor name to access via Libvirt.
|
7
7
|
attr_accessor :driver
|
@@ -26,6 +26,7 @@ module VagrantPlugins
|
|
26
26
|
attr_accessor :memory
|
27
27
|
attr_accessor :cpus
|
28
28
|
attr_accessor :nested
|
29
|
+
attr_accessor :volume_cache
|
29
30
|
|
30
31
|
def initialize
|
31
32
|
@driver = UNSET_VALUE
|
@@ -39,6 +40,7 @@ module VagrantPlugins
|
|
39
40
|
@memory = UNSET_VALUE
|
40
41
|
@cpus = UNSET_VALUE
|
41
42
|
@nested = UNSET_VALUE
|
43
|
+
@volume_cache = UNSET_VALUE
|
42
44
|
end
|
43
45
|
|
44
46
|
def finalize!
|
@@ -53,6 +55,7 @@ module VagrantPlugins
|
|
53
55
|
@memory = 512 if @memory == UNSET_VALUE
|
54
56
|
@cpus = 1 if @cpus == UNSET_VALUE
|
55
57
|
@nested = false if @nested == UNSET_VALUE
|
58
|
+
@volume_cache = 'default' if @volume_cache == UNSET_VALUE
|
56
59
|
end
|
57
60
|
|
58
61
|
def validate(machine)
|
@@ -12,16 +12,16 @@ if Vagrant::VERSION < '1.1.0'
|
|
12
12
|
end
|
13
13
|
|
14
14
|
module VagrantPlugins
|
15
|
-
module
|
15
|
+
module ProviderLibvirt
|
16
16
|
class Plugin < Vagrant.plugin('2')
|
17
|
-
name
|
17
|
+
name 'libvirt'
|
18
18
|
description <<-DESC
|
19
19
|
Vagrant plugin to manage VMs in libvirt.
|
20
20
|
DESC
|
21
21
|
|
22
22
|
|
23
|
-
config(
|
24
|
-
require_relative
|
23
|
+
config('libvirt', :provider) do
|
24
|
+
require_relative 'config'
|
25
25
|
Config
|
26
26
|
end
|
27
27
|
|
@@ -37,7 +37,7 @@ module VagrantPlugins
|
|
37
37
|
|
38
38
|
# This initializes the internationalization strings.
|
39
39
|
def self.setup_i18n
|
40
|
-
I18n.load_path << File.expand_path("locales/en.yml",
|
40
|
+
I18n.load_path << File.expand_path("locales/en.yml", ProviderLibvirt.source_root)
|
41
41
|
I18n.reload!
|
42
42
|
end
|
43
43
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'vagrant'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
module
|
4
|
+
module ProviderLibvirt
|
5
5
|
|
6
6
|
# This is the base class for a provider for the V2 API. A provider
|
7
7
|
# is responsible for creating compute resources to match the
|
@@ -45,7 +45,7 @@ module VagrantPlugins
|
|
45
45
|
# :username => "mitchellh",
|
46
46
|
# :private_key_path => "/path/to/my/key"
|
47
47
|
#}
|
48
|
-
env = @machine.action(
|
48
|
+
env = @machine.action('read_ssh_info')
|
49
49
|
env[:machine_ssh_info]
|
50
50
|
end
|
51
51
|
|
@@ -55,7 +55,7 @@ module VagrantPlugins
|
|
55
55
|
# Run a custom action we define called "read_state" which does
|
56
56
|
# what it says. It puts the state in the `:machine_state_id`
|
57
57
|
# key in the environment.
|
58
|
-
env = @machine.action(
|
58
|
+
env = @machine.action('read_state')
|
59
59
|
|
60
60
|
state_id = env[:machine_state_id]
|
61
61
|
|
@@ -4,9 +4,10 @@
|
|
4
4
|
<vcpu><%= @cpus %></vcpu>
|
5
5
|
|
6
6
|
<% if @nested %>
|
7
|
-
<cpu
|
8
|
-
<model>
|
9
|
-
<feature policy='
|
7
|
+
<cpu mode='host-passthrough'>
|
8
|
+
<model fallback='allow'>qemu64</model>
|
9
|
+
<feature policy='optional' name='vmx'/>
|
10
|
+
<feature policy='optional' name='svm'/>
|
10
11
|
</cpu>
|
11
12
|
<% end %>
|
12
13
|
|
@@ -22,7 +23,7 @@
|
|
22
23
|
<clock offset='utc'/>
|
23
24
|
<devices>
|
24
25
|
<disk type='file' device='disk'>
|
25
|
-
<driver name='qemu' type='qcow2'/>
|
26
|
+
<driver name='qemu' type='qcow2' cache='<%= @domain_volume_cache %>'/>
|
26
27
|
<source file='<%= @domain_volume_path %>'/>
|
27
28
|
<%# we need to ensure a unique target dev -%>
|
28
29
|
<target dev='vda' bus='virtio'/>
|
data/lib/vagrant-libvirt/util.rb
CHANGED
data/vagrant-libvirt.gemspec
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
require File.expand_path('../lib/vagrant-libvirt/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = [
|
6
|
-
gem.email = [
|
5
|
+
gem.authors = ['Lukas Stanek','Dima Vasilets']
|
6
|
+
gem.email = ['ls@elostech.cz','pronix.service@gmail.com']
|
7
|
+
gem.license = 'MIT'
|
7
8
|
gem.description = %q{Vagrant provider for libvirt.}
|
8
9
|
gem.summary = %q{Vagrant provider for libvirt.}
|
9
10
|
gem.homepage = "https://github.com/pradels/vagrant-libvirt"
|
@@ -13,9 +14,9 @@ Gem::Specification.new do |gem|
|
|
13
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
15
|
gem.name = "vagrant-libvirt"
|
15
16
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = VagrantPlugins::
|
17
|
+
gem.version = VagrantPlugins::ProviderLibvirt::VERSION
|
17
18
|
|
18
|
-
gem.add_runtime_dependency "fog", "
|
19
|
+
gem.add_runtime_dependency "fog", "1.10.0"
|
19
20
|
gem.add_runtime_dependency "ruby-libvirt", "~> 0.4.0"
|
20
21
|
|
21
22
|
gem.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lukas Stanek
|
9
|
+
- Dima Vasilets
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: fog
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
|
-
- -
|
20
|
+
- - '='
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 1.10.0
|
22
23
|
type: :runtime
|
@@ -24,7 +25,7 @@ dependencies:
|
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
27
|
requirements:
|
27
|
-
- -
|
28
|
+
- - '='
|
28
29
|
- !ruby/object:Gem::Version
|
29
30
|
version: 1.10.0
|
30
31
|
- !ruby/object:Gem::Dependency
|
@@ -62,6 +63,7 @@ dependencies:
|
|
62
63
|
description: Vagrant provider for libvirt.
|
63
64
|
email:
|
64
65
|
- ls@elostech.cz
|
66
|
+
- pronix.service@gmail.com
|
65
67
|
executables: []
|
66
68
|
extensions: []
|
67
69
|
extra_rdoc_files: []
|
@@ -114,6 +116,7 @@ files:
|
|
114
116
|
- lib/vagrant-libvirt/templates/domain.xml.erb
|
115
117
|
- lib/vagrant-libvirt/templates/interface.xml.erb
|
116
118
|
- lib/vagrant-libvirt/templates/private_network.xml.erb
|
119
|
+
- lib/vagrant-libvirt/templates/public_interface.xml.erb
|
117
120
|
- lib/vagrant-libvirt/templates/volume_snapshot.xml.erb
|
118
121
|
- lib/vagrant-libvirt/util.rb
|
119
122
|
- lib/vagrant-libvirt/util/collection.rb
|
@@ -125,7 +128,8 @@ files:
|
|
125
128
|
- tools/prepare_redhat_for_box.sh
|
126
129
|
- vagrant-libvirt.gemspec
|
127
130
|
homepage: https://github.com/pradels/vagrant-libvirt
|
128
|
-
licenses:
|
131
|
+
licenses:
|
132
|
+
- MIT
|
129
133
|
post_install_message:
|
130
134
|
rdoc_options: []
|
131
135
|
require_paths:
|
@@ -149,3 +153,4 @@ signing_key:
|
|
149
153
|
specification_version: 3
|
150
154
|
summary: Vagrant provider for libvirt.
|
151
155
|
test_files: []
|
156
|
+
has_rdoc:
|