vagrant-libvirt 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Gemfile +2 -2
- data/README.md +18 -0
- data/lib/vagrant-libvirt/action.rb +10 -1
- data/lib/vagrant-libvirt/action/create_domain.rb +7 -0
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +3 -3
- data/lib/vagrant-libvirt/action/read_ssh_info.rb +17 -8
- data/lib/vagrant-libvirt/action/remove_stale_volume.rb +49 -0
- data/lib/vagrant-libvirt/config.rb +10 -0
- data/lib/vagrant-libvirt/templates/domain.xml.erb +8 -1
- data/lib/vagrant-libvirt/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/spec/support/environment_helper.rb +1 -1
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NGEzYjM1YTYyZjE1ZGUxNDlhYzIzMDZhMDRjN2VhNjFlN2FjZjA5Yg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 354aaf9e080970fc3b9b0c6c2896f0a84bfc5c97
|
4
|
+
data.tar.gz: 7aca0e64a6714b9ef17456cda7ac91677fe6c9b1
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NTNjZDkxYTE0NjdjOGNhMWIxNjUxN2Y5YzQ0MzZmN2I0ZThmMTVkMTNmNTI2
|
11
|
-
YzgyOTQ3ZWVkYTNiZjhiYTVlMzVjMjI0NDA2NmZkMWQ5MDQ5MTY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NmYzNWExNWI2NjdkNGM4ZjliMTc4YzFmOWU0N2UyYjY0YjkyZGRlN2EzYmMw
|
14
|
-
NGI5Yjk4NjY5YTVhYzQ2NjhlYmNhYzhiZmQwMGE5ZDY2ZDc4ODNmOTAyMGQx
|
15
|
-
MGFlNjE4ZDgxM2ZlOGIzOWU5ODZiOGI2NjAyOWVmYTJiMTU0ZWI=
|
6
|
+
metadata.gz: a9e8b0f86701dd6ddfe6d060ce4c6c90c0e0a8ac78e3128f964c31a8bec2d44dc73ed56e0e6d6b114988fbe40c67953ee30b46cbf7e90ec3651d1c0637d7a365
|
7
|
+
data.tar.gz: 8b8b59bc7eb122a2d56fa72d1ea412fd59974152d76a00652a8782456dae65b229fbfc9c8a21775f10d1b8fd1115db1f9a5cf948d425c0fe386bf1d758590373
|
data/Gemfile
CHANGED
@@ -7,11 +7,11 @@ group :development do
|
|
7
7
|
# We depend on Vagrant for development, but we don't add it as a
|
8
8
|
# gem dependency because we expect to be installed within the
|
9
9
|
# Vagrant environment itself using `vagrant plugin`.
|
10
|
-
gem
|
10
|
+
gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant.git'
|
11
11
|
gem 'pry'
|
12
12
|
end
|
13
13
|
|
14
14
|
group :plugins do
|
15
|
-
gem
|
15
|
+
gem 'vagrant-libvirt', :path => '.'
|
16
16
|
end
|
17
17
|
|
data/README.md
CHANGED
@@ -170,6 +170,7 @@ end
|
|
170
170
|
* `video_vram` - Used by some graphics card types to vary the amount of RAM dedicated to video. Defaults to 9216.
|
171
171
|
* `machine` - Sets machine type. Equivalent to qemu `-machine`. Use `qemu-system-x86_64 -machine help` to get a list of supported machines.
|
172
172
|
* `machine_arch` - Sets machine architecture. This helps libvirt to determine the correct emulator type. Possible values depend on your version of qemu. For possible values, see which emulator executable `qemu-system-*` your system provides. Common examples are `aarch64`, `alpha`, `arm`, `cris`, `i386`, `lm32`, `m68k`, `microblaze`, `microblazeel`, `mips`, `mips64`, `mips64el`, `mipsel`, `moxie`, `or32`, `ppc`, `ppc64`, `ppcemb`, `s390x`, `sh4`, `sh4eb`, `sparc`, `sparc64`, `tricore`, `unicore32`, `x86_64`, `xtensa`, `xtensaeb`.
|
173
|
+
* `boot` - Change the boot order and enables the boot menu. Possible options are "hd" or "network". Defaults to "hd" with boot menu disabled.
|
173
174
|
|
174
175
|
|
175
176
|
Specific domain settings can be set for each domain separately in multi-VM
|
@@ -191,6 +192,23 @@ Vagrant.configure("2") do |config|
|
|
191
192
|
# ...
|
192
193
|
```
|
193
194
|
|
195
|
+
The following example shows part of a Vagrantfile that enables the VM to
|
196
|
+
boot from a network interface first and a hard disk second. This could be
|
197
|
+
used to run VMs that are meant to be a PXE booted machines.
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
Vagrant.configure("2") do |config|
|
201
|
+
config.vm.define :pxeclient do |pxeclient|
|
202
|
+
pxeclient.vm.box = "centos64"
|
203
|
+
pxeclient.vm.provider :libvirt do |domain|
|
204
|
+
domain.boot 'network'
|
205
|
+
domain.boot 'hd'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# ...
|
210
|
+
```
|
211
|
+
|
194
212
|
## Networks
|
195
213
|
|
196
214
|
Networking features in the form of `config.vm.network` support private networks
|
@@ -156,7 +156,14 @@ module VagrantPlugins
|
|
156
156
|
b.use ConfigValidate
|
157
157
|
b.use Call, IsCreated do |env, b2|
|
158
158
|
if !env[:result]
|
159
|
-
|
159
|
+
# Try to remove stale volumes anyway
|
160
|
+
b2.use ConnectLibvirt
|
161
|
+
b2.use SetNameOfDomain
|
162
|
+
b2.use RemoveStaleVolume
|
163
|
+
if !env[:result]
|
164
|
+
b2.use MessageNotCreated
|
165
|
+
end
|
166
|
+
|
160
167
|
next
|
161
168
|
end
|
162
169
|
|
@@ -338,6 +345,8 @@ module VagrantPlugins
|
|
338
345
|
autoload :MessageNotRunning, action_root.join('message_not_running')
|
339
346
|
autoload :MessageNotSuspended, action_root.join('message_not_suspended')
|
340
347
|
|
348
|
+
autoload :RemoveStaleVolume, action_root.join('remove_stale_volume')
|
349
|
+
|
341
350
|
autoload :PrepareNFSSettings, action_root.join('prepare_nfs_settings')
|
342
351
|
autoload :PrepareNFSValidIds, action_root.join('prepare_nfs_valid_ids')
|
343
352
|
autoload :PruneNFSExports, action_root.join('prune_nfs_exports')
|
@@ -54,6 +54,9 @@ module VagrantPlugins
|
|
54
54
|
@video_type = config.video_type
|
55
55
|
@video_vram = config.video_vram
|
56
56
|
@keymap = config.keymap
|
57
|
+
|
58
|
+
# Boot order
|
59
|
+
@boot_order = config.boot_order
|
57
60
|
|
58
61
|
# Storage
|
59
62
|
@storage_pool_name = config.storage_pool_name
|
@@ -124,6 +127,10 @@ module VagrantPlugins
|
|
124
127
|
env[:ui].info(" -- Video Type: #{@video_type}")
|
125
128
|
env[:ui].info(" -- Video VRAM: #{@video_vram}")
|
126
129
|
env[:ui].info(" -- Keymap: #{@keymap}")
|
130
|
+
|
131
|
+
@boot_order.each do |device|
|
132
|
+
env[:ui].info(" -- Boot device: #{device}")
|
133
|
+
end
|
127
134
|
|
128
135
|
if @disks.length > 0
|
129
136
|
env[:ui].info(" -- Disks: #{_disks_print(@disks)}")
|
@@ -19,8 +19,8 @@ module VagrantPlugins
|
|
19
19
|
|
20
20
|
if using_nfs?
|
21
21
|
@logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
|
22
|
-
env[:nfs_host_ip] = read_host_ip(env[:machine])
|
23
22
|
env[:nfs_machine_ip] = read_machine_ip(env[:machine])
|
23
|
+
env[:nfs_host_ip] = read_host_ip(env[:nfs_machine_ip])
|
24
24
|
|
25
25
|
@logger.info("host IP: #{env[:nfs_host_ip]} machine IP: #{env[:nfs_machine_ip]}")
|
26
26
|
|
@@ -39,9 +39,9 @@ module VagrantPlugins
|
|
39
39
|
#
|
40
40
|
# @param [Machine] machine
|
41
41
|
# @return [String]
|
42
|
-
def read_host_ip(
|
42
|
+
def read_host_ip(ip)
|
43
43
|
UDPSocket.open do |s|
|
44
|
-
s.connect(
|
44
|
+
s.connect(ip, 1)
|
45
45
|
s.addr.last
|
46
46
|
end
|
47
47
|
end
|
@@ -20,6 +20,7 @@ module VagrantPlugins
|
|
20
20
|
|
21
21
|
def read_ssh_info(libvirt, machine)
|
22
22
|
return nil if machine.id.nil?
|
23
|
+
return nil if machine.state.id != :running
|
23
24
|
|
24
25
|
# Find the machine
|
25
26
|
domain = libvirt.servers.get(machine.id)
|
@@ -32,15 +33,23 @@ module VagrantPlugins
|
|
32
33
|
|
33
34
|
# Get IP address from dnsmasq lease file.
|
34
35
|
ip_address = nil
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
begin
|
37
|
+
domain.wait_for(2) do
|
38
|
+
addresses.each_pair do |type, ip|
|
39
|
+
# Multiple leases are separated with a newline, return only
|
40
|
+
# the most recent address
|
41
|
+
ip_address = ip[0].split("\n").first if ip[0] != nil
|
42
|
+
end
|
43
|
+
ip_address != nil
|
40
44
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
rescue Fog::Errors::TimeoutError
|
46
|
+
@logger.info("Timeout at waiting for an ip address for machine %s" % machine.name)
|
47
|
+
end
|
48
|
+
|
49
|
+
if not ip_address
|
50
|
+
@logger.info("No lease found for machine %s" % machine.name)
|
51
|
+
return nil
|
52
|
+
end
|
44
53
|
|
45
54
|
ssh_info = {
|
46
55
|
:host => ip_address,
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
#require 'log4r/yamlconfigurator'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ProviderLibvirt
|
6
|
+
module Action
|
7
|
+
class RemoveStaleVolume
|
8
|
+
def initialize(app, _env)
|
9
|
+
|
10
|
+
# log4r_config= YAML.load_file(File.join(File.dirname(__FILE__),"log4r.yaml"))
|
11
|
+
# log_cfg = Log4r::YamlConfigurator
|
12
|
+
# log_cfg.decode_yaml( log4r_config['log4r_config'] )
|
13
|
+
|
14
|
+
@logger = Log4r::Logger.new('vagrant_libvirt::action::remove_stale_volume')
|
15
|
+
@app = app
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
# Remove stale server volume
|
20
|
+
env[:ui].info(I18n.t('vagrant_libvirt.remove_stale_volume'))
|
21
|
+
|
22
|
+
config = env[:machine].provider_config
|
23
|
+
# Check for storage pool, where box image should be created
|
24
|
+
fog_pool = ProviderLibvirt::Util::Collection.find_matching(
|
25
|
+
env[:libvirt_compute].pools.all, config.storage_pool_name)
|
26
|
+
@logger.debug("**** Pool #{fog_pool.name}")
|
27
|
+
|
28
|
+
# This is name of newly created image for vm.
|
29
|
+
name = "#{env[:domain_name]}.img"
|
30
|
+
@logger.debug("**** Volume name #{name}")
|
31
|
+
|
32
|
+
# remove root storage
|
33
|
+
box_volume = ProviderLibvirt::Util::Collection.find_matching(
|
34
|
+
env[:libvirt_compute].volumes.all, name)
|
35
|
+
if box_volume && box_volume.pool_name == fog_pool.name
|
36
|
+
@logger.info("Deleting volume #{box_volume.key}")
|
37
|
+
box_volume.destroy
|
38
|
+
env[:result] = box_volume
|
39
|
+
else
|
40
|
+
env[:result] = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
# Continue the middleware chain.
|
44
|
+
@app.call(env)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -55,6 +55,7 @@ module VagrantPlugins
|
|
55
55
|
attr_accessor :memory
|
56
56
|
attr_accessor :cpus
|
57
57
|
attr_accessor :cpu_mode
|
58
|
+
attr_accessor :boot_order
|
58
59
|
attr_accessor :machine_type
|
59
60
|
attr_accessor :machine_arch
|
60
61
|
attr_accessor :disk_bus
|
@@ -113,10 +114,16 @@ module VagrantPlugins
|
|
113
114
|
@video_vram = UNSET_VALUE
|
114
115
|
@keymap = UNSET_VALUE
|
115
116
|
|
117
|
+
# Boot order
|
118
|
+
@boot_order = []
|
116
119
|
# Storage
|
117
120
|
@disks = []
|
118
121
|
@cdroms = []
|
119
122
|
end
|
123
|
+
|
124
|
+
def boot(device)
|
125
|
+
@boot_order << device # append
|
126
|
+
end
|
120
127
|
|
121
128
|
def _get_device(disks)
|
122
129
|
# skip existing devices and also the first one (vda)
|
@@ -299,6 +306,9 @@ module VagrantPlugins
|
|
299
306
|
@video_type = 'cirrus' if @video_type == UNSET_VALUE
|
300
307
|
@video_vram = 9216 if @video_vram == UNSET_VALUE
|
301
308
|
@keymap = 'en-us' if @keymap == UNSET_VALUE
|
309
|
+
|
310
|
+
# Boot order
|
311
|
+
@boot_order = [] if @boot_order == UNSET_VALUE
|
302
312
|
|
303
313
|
# Storage
|
304
314
|
@disks = [] if @disks == UNSET_VALUE
|
@@ -27,7 +27,14 @@
|
|
27
27
|
<type>hvm</type>
|
28
28
|
<% end %>
|
29
29
|
<% end %>
|
30
|
-
|
30
|
+
<% if @boot_order.count >= 1 %>
|
31
|
+
<% @boot_order.each do |b| %>
|
32
|
+
<boot dev='<%= b %>'/>
|
33
|
+
<% end %>
|
34
|
+
<bootmenu enable='yes'/>
|
35
|
+
<% else %>
|
36
|
+
<boot dev='hd' />
|
37
|
+
<% end %>
|
31
38
|
<kernel><%= @kernel %></kernel>
|
32
39
|
<initrd><%= @initrd %></initrd>
|
33
40
|
<cmdline><%= @cmd_line %></cmdline>
|
data/locales/en.yml
CHANGED
@@ -19,7 +19,7 @@ class EnvironmentHelper
|
|
19
19
|
1024
|
20
20
|
end
|
21
21
|
|
22
|
-
%w(cpus cpu_mode machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
|
22
|
+
%w(cpus cpu_mode boot_order machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
|
23
23
|
define_method(name.to_sym) do
|
24
24
|
nil
|
25
25
|
end
|
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.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Stanek
|
@@ -10,90 +10,90 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec-core
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 2.12.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 2.12.2
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rspec-expectations
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 2.12.1
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 2.12.1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rspec-mocks
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 2.12.1
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ~>
|
54
|
+
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 2.12.1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: fog-libvirt
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - ~>
|
61
|
+
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: 0.0.1
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- - ~>
|
68
|
+
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 0.0.1
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: nokogiri
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - ~>
|
75
|
+
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.6.0
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - ~>
|
82
|
+
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: 1.6.0
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rake
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
description: libvirt provider for Vagrant.
|
@@ -105,7 +105,7 @@ executables: []
|
|
105
105
|
extensions: []
|
106
106
|
extra_rdoc_files: []
|
107
107
|
files:
|
108
|
-
- .gitignore
|
108
|
+
- ".gitignore"
|
109
109
|
- CHANGELOG.md
|
110
110
|
- Gemfile
|
111
111
|
- LICENSE
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/vagrant-libvirt/action/read_ssh_info.rb
|
143
143
|
- lib/vagrant-libvirt/action/read_state.rb
|
144
144
|
- lib/vagrant-libvirt/action/remove_libvirt_image.rb
|
145
|
+
- lib/vagrant-libvirt/action/remove_stale_volume.rb
|
145
146
|
- lib/vagrant-libvirt/action/resume_domain.rb
|
146
147
|
- lib/vagrant-libvirt/action/set_name_of_domain.rb
|
147
148
|
- lib/vagrant-libvirt/action/share_folders.rb
|
@@ -186,12 +187,12 @@ require_paths:
|
|
186
187
|
- lib
|
187
188
|
required_ruby_version: !ruby/object:Gem::Requirement
|
188
189
|
requirements:
|
189
|
-
- -
|
190
|
+
- - ">="
|
190
191
|
- !ruby/object:Gem::Version
|
191
192
|
version: '0'
|
192
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
194
|
requirements:
|
194
|
-
- -
|
195
|
+
- - ">="
|
195
196
|
- !ruby/object:Gem::Version
|
196
197
|
version: '0'
|
197
198
|
requirements: []
|