vagrant-libvirt 0.0.42 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +393 -147
- data/lib/vagrant-libvirt/action.rb +3 -2
- data/lib/vagrant-libvirt/action/create_domain.rb +87 -37
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +19 -14
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +9 -5
- data/lib/vagrant-libvirt/action/create_networks.rb +7 -2
- data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/destroy_networks.rb +5 -0
- data/lib/vagrant-libvirt/action/forward_ports.rb +10 -8
- data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/handle_box_image.rb +26 -15
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +9 -4
- data/lib/vagrant-libvirt/action/package_domain.rb +58 -12
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +3 -9
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +19 -9
- data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +2 -2
- data/lib/vagrant-libvirt/action/remove_stale_volume.rb +17 -11
- data/lib/vagrant-libvirt/action/set_boot_order.rb +2 -2
- data/lib/vagrant-libvirt/action/set_name_of_domain.rb +6 -9
- data/lib/vagrant-libvirt/action/start_domain.rb +2 -2
- data/lib/vagrant-libvirt/action/wait_till_up.rb +31 -16
- data/lib/vagrant-libvirt/cap/public_address.rb +16 -0
- data/lib/vagrant-libvirt/cap/synced_folder.rb +3 -3
- data/lib/vagrant-libvirt/config.rb +177 -29
- data/lib/vagrant-libvirt/driver.rb +31 -2
- data/lib/vagrant-libvirt/errors.rb +5 -1
- data/lib/vagrant-libvirt/plugin.rb +7 -2
- data/lib/vagrant-libvirt/templates/default_storage_pool.xml.erb +3 -3
- data/lib/vagrant-libvirt/templates/domain.xml.erb +48 -8
- data/lib/vagrant-libvirt/util.rb +1 -0
- data/lib/vagrant-libvirt/util/erb_template.rb +6 -7
- data/lib/vagrant-libvirt/util/network_util.rb +33 -13
- data/lib/vagrant-libvirt/util/nfs.rb +17 -0
- data/lib/vagrant-libvirt/util/storage_util.rb +27 -0
- data/lib/vagrant-libvirt/version.rb +1 -1
- data/locales/en.yml +8 -4
- data/spec/support/environment_helper.rb +1 -1
- data/spec/support/libvirt_context.rb +1 -1
- data/spec/support/sharedcontext.rb +2 -2
- data/spec/unit/action/destroy_domain_spec.rb +2 -2
- data/spec/unit/action/set_name_of_domain_spec.rb +3 -3
- data/spec/unit/config_spec.rb +173 -0
- data/spec/unit/templates/domain_all_settings.xml +20 -4
- data/spec/unit/templates/domain_custom_cpu_model.xml +48 -0
- data/spec/unit/templates/domain_defaults.xml +2 -0
- data/spec/unit/templates/domain_spec.rb +26 -2
- metadata +24 -32
- data/.coveralls.yml +0 -1
- data/.github/issue_template.md +0 -37
- data/.gitignore +0 -21
- data/.travis.yml +0 -24
- data/Gemfile +0 -26
- data/Rakefile +0 -8
- data/example_box/README.md +0 -29
- data/example_box/Vagrantfile +0 -60
- data/example_box/metadata.json +0 -5
- data/tools/create_box.sh +0 -130
- data/tools/prepare_redhat_for_box.sh +0 -119
- data/vagrant-libvirt.gemspec +0 -54
@@ -4,6 +4,9 @@ module VagrantPlugins
|
|
4
4
|
module ProviderLibvirt
|
5
5
|
module Action
|
6
6
|
class HandleBoxImage
|
7
|
+
include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
|
8
|
+
|
9
|
+
|
7
10
|
@@lock = Mutex.new
|
8
11
|
|
9
12
|
def initialize(app, _env)
|
@@ -31,11 +34,12 @@ module VagrantPlugins
|
|
31
34
|
config = env[:machine].provider_config
|
32
35
|
box_image_file = env[:machine].box.directory.join('box.img').to_s
|
33
36
|
env[:box_volume_name] = env[:machine].box.name.to_s.dup.gsub('/', '-VAGRANTSLASH-')
|
34
|
-
env[:box_volume_name] << "_vagrant_box_image_#{
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
env[:box_volume_name] << "_vagrant_box_image_#{
|
38
|
+
begin
|
39
|
+
env[:machine].box.version.to_s
|
40
|
+
rescue
|
41
|
+
''
|
42
|
+
end}.img"
|
39
43
|
|
40
44
|
# Override box_virtual_size
|
41
45
|
if config.machine_virtual_size
|
@@ -44,7 +48,7 @@ module VagrantPlugins
|
|
44
48
|
# is not supported and will be ignored
|
45
49
|
env[:ui].warn I18n.t(
|
46
50
|
'vagrant_libvirt.warnings.ignoring_virtual_size_too_small',
|
47
|
-
|
51
|
+
requested: config.machine_virtual_size, minimum: box_virtual_size
|
48
52
|
)
|
49
53
|
else
|
50
54
|
env[:ui].info I18n.t('vagrant_libvirt.manual_resize_required')
|
@@ -59,9 +63,10 @@ module VagrantPlugins
|
|
59
63
|
# locking all subsequent actions as well.
|
60
64
|
@@lock.synchronize do
|
61
65
|
# Don't continue if image already exists in storage pool.
|
62
|
-
|
63
|
-
|
64
|
-
)
|
66
|
+
box_volume = env[:machine].provider.driver.connection.volumes.all(
|
67
|
+
name: env[:box_volume_name]
|
68
|
+
).first
|
69
|
+
break if box_volume && box_volume.id
|
65
70
|
|
66
71
|
# Box is not available as a storage pool volume. Create and upload
|
67
72
|
# it as a copy of local box image.
|
@@ -75,13 +80,19 @@ module VagrantPlugins
|
|
75
80
|
message = "Creating volume #{env[:box_volume_name]}"
|
76
81
|
message << " in storage pool #{config.storage_pool_name}."
|
77
82
|
@logger.info(message)
|
83
|
+
|
84
|
+
@storage_volume_uid = storage_uid env
|
85
|
+
@storage_volume_gid = storage_gid env
|
86
|
+
|
78
87
|
begin
|
79
88
|
fog_volume = env[:machine].provider.driver.connection.volumes.create(
|
80
|
-
name:
|
81
|
-
allocation:
|
82
|
-
capacity:
|
83
|
-
format_type:
|
84
|
-
|
89
|
+
name: env[:box_volume_name],
|
90
|
+
allocation: "#{box_image_size / 1024 / 1024}M",
|
91
|
+
capacity: "#{box_virtual_size}G",
|
92
|
+
format_type: box_format,
|
93
|
+
owner: @storage_volume_uid,
|
94
|
+
group: @storage_volume_gid,
|
95
|
+
pool_name: config.storage_pool_name
|
85
96
|
)
|
86
97
|
rescue Fog::Errors::Error => e
|
87
98
|
raise Errors::FogCreateVolumeError,
|
@@ -115,7 +126,7 @@ module VagrantPlugins
|
|
115
126
|
|
116
127
|
protected
|
117
128
|
|
118
|
-
# Fog
|
129
|
+
# Fog Libvirt currently doesn't support uploading images to storage
|
119
130
|
# pool volumes. Use ruby-libvirt client instead.
|
120
131
|
def upload_image(image_file, pool_name, volume_name, env)
|
121
132
|
image_size = File.size(image_file) # B
|
@@ -5,6 +5,8 @@ module VagrantPlugins
|
|
5
5
|
module Action
|
6
6
|
class HandleStoragePool
|
7
7
|
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
8
|
+
include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
|
9
|
+
|
8
10
|
|
9
11
|
@@lock = Mutex.new
|
10
12
|
|
@@ -22,9 +24,9 @@ module VagrantPlugins
|
|
22
24
|
# locking all subsequent actions as well.
|
23
25
|
@@lock.synchronize do
|
24
26
|
# Check for storage pool, where box image should be created
|
25
|
-
break
|
26
|
-
|
27
|
-
)
|
27
|
+
break unless env[:machine].provider.driver.connection.pools.all(
|
28
|
+
name: config.storage_pool_name
|
29
|
+
).empty?
|
28
30
|
|
29
31
|
@logger.info("No storage pool '#{config.storage_pool_name}' is available.")
|
30
32
|
|
@@ -34,9 +36,12 @@ module VagrantPlugins
|
|
34
36
|
|
35
37
|
@logger.info("Creating storage pool 'default'")
|
36
38
|
|
37
|
-
# Fog
|
39
|
+
# Fog Libvirt currently doesn't support creating pools. Use
|
38
40
|
# ruby-libvirt client directly.
|
39
41
|
begin
|
42
|
+
@storage_pool_path = storage_pool_path(env)
|
43
|
+
@storage_pool_uid = storage_uid(env)
|
44
|
+
@storage_pool_gid = storage_gid(env)
|
40
45
|
libvirt_pool = env[:machine].provider.driver.connection.client.define_storage_pool_xml(
|
41
46
|
to_xml('default_storage_pool')
|
42
47
|
)
|
@@ -1,9 +1,10 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'log4r'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
4
5
|
module ProviderLibvirt
|
5
6
|
module Action
|
6
|
-
# Action for create new box for
|
7
|
+
# Action for create new box for Libvirt provider
|
7
8
|
class PackageDomain
|
8
9
|
def initialize(app, env)
|
9
10
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::package_domain')
|
@@ -21,24 +22,31 @@ module VagrantPlugins
|
|
21
22
|
root_disk = domain.volumes.select do |x|
|
22
23
|
x.name == libvirt_domain.name + '.img'
|
23
24
|
end.first
|
25
|
+
raise Errors::NoDomainVolume if root_disk.nil?
|
24
26
|
boxname = env['package.output']
|
25
27
|
raise "#{boxname}: Already exists" if File.exist?(boxname)
|
26
28
|
@tmp_dir = Dir.pwd + '/_tmp_package'
|
27
29
|
@tmp_img = @tmp_dir + '/box.img'
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
env[:ui].
|
33
|
-
|
34
|
-
|
30
|
+
FileUtils.mkdir_p(@tmp_dir)
|
31
|
+
env[:ui].info("Downloading #{root_disk.name} to #{@tmp_img}")
|
32
|
+
ret = download_image(@tmp_img, env[:machine].provider_config.storage_pool_name,
|
33
|
+
root_disk.name, env) do |progress,image_size|
|
34
|
+
env[:ui].clear_line
|
35
|
+
env[:ui].report_progress(progress, image_size, false)
|
36
|
+
end
|
37
|
+
# Clear the line one last time since the progress meter doesn't
|
38
|
+
# disappear immediately.
|
39
|
+
env[:ui].clear_line
|
40
|
+
backing = `qemu-img info "#{@tmp_img}" | grep 'backing file:' | cut -d ':' -f2`.chomp
|
41
|
+
if backing
|
42
|
+
env[:ui].info('Image has backing image, copying image and rebasing ...')
|
43
|
+
`qemu-img rebase -p -b "" #{@tmp_img}`
|
35
44
|
end
|
36
|
-
env[:ui].info('Image has backing image, copying image and rebasing ...')
|
37
|
-
FileUtils.cp(root_disk.path, @tmp_img)
|
38
|
-
`qemu-img rebase -p -b "" #{@tmp_img}`
|
39
45
|
# remove hw association with interface
|
40
46
|
# working for centos with lvs default disks
|
41
|
-
|
47
|
+
options = ENV.fetch('VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS', '')
|
48
|
+
operations = ENV.fetch('VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS', 'defaults,-ssh-userdir')
|
49
|
+
`virt-sysprep --no-logfile --operations #{operations} -a #{@tmp_img} #{options}`
|
42
50
|
# add any user provided file
|
43
51
|
extra = ''
|
44
52
|
@tmp_include = @tmp_dir + '/_include'
|
@@ -99,6 +107,44 @@ module VagrantPlugins
|
|
99
107
|
}
|
100
108
|
EOF
|
101
109
|
end
|
110
|
+
|
111
|
+
protected
|
112
|
+
|
113
|
+
# Fog libvirt currently doesn't support downloading images from storage
|
114
|
+
# pool volumes. Use ruby-libvirt client instead.
|
115
|
+
def download_image(image_file, pool_name, volume_name, env)
|
116
|
+
begin
|
117
|
+
pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(
|
118
|
+
pool_name
|
119
|
+
)
|
120
|
+
volume = pool.lookup_volume_by_name(volume_name)
|
121
|
+
image_size = volume.info.allocation # B
|
122
|
+
|
123
|
+
stream = env[:machine].provider.driver.connection.client.stream
|
124
|
+
|
125
|
+
# Use length of 0 to download remaining contents after offset
|
126
|
+
volume.download(stream, offset = 0, length = 0)
|
127
|
+
|
128
|
+
buf_size = 1024 * 250 # 250K, copied from upload_image in handle_box_image.rb
|
129
|
+
progress = 0
|
130
|
+
retval = stream.recv(buf_size)
|
131
|
+
open(image_file, 'wb') do |io|
|
132
|
+
while (retval.at(0) > 0)
|
133
|
+
recvd = io.write(retval.at(1))
|
134
|
+
progress += recvd
|
135
|
+
yield [progress, image_size]
|
136
|
+
retval = stream.recv(buf_size)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
rescue => e
|
140
|
+
raise Errors::ImageDownloadError,
|
141
|
+
volume_name: volume_name,
|
142
|
+
pool_name: pool_name,
|
143
|
+
error_message: e.message
|
144
|
+
end
|
145
|
+
|
146
|
+
progress == image_size
|
147
|
+
end
|
102
148
|
end
|
103
149
|
end
|
104
150
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'socket'
|
3
3
|
require 'timeout'
|
4
|
+
require 'vagrant-libvirt/util/nfs'
|
4
5
|
|
5
6
|
module VagrantPlugins
|
6
7
|
module ProviderLibvirt
|
7
8
|
module Action
|
8
9
|
class PrepareNFSSettings
|
9
|
-
include
|
10
|
+
include VagrantPlugins::ProviderLibvirt::Util::Nfs
|
10
11
|
|
11
12
|
def initialize(app, _env)
|
12
13
|
@app = app
|
@@ -28,13 +29,6 @@ module VagrantPlugins
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
# We're using NFS if we have any synced folder with NFS configured. If
|
32
|
-
# we are not using NFS we don't need to do the extra work to
|
33
|
-
# populate these fields in the environment.
|
34
|
-
def using_nfs?
|
35
|
-
!!synced_folders(@machine)[:nfs]
|
36
|
-
end
|
37
|
-
|
38
32
|
# Returns the IP address of the host
|
39
33
|
#
|
40
34
|
# @param [Machine] machine
|
@@ -79,7 +73,7 @@ module VagrantPlugins
|
|
79
73
|
# Check if we can open a connection to the host
|
80
74
|
def ping(host, timeout = 3)
|
81
75
|
::Timeout.timeout(timeout) do
|
82
|
-
s = TCPSocket.new(host, '
|
76
|
+
s = TCPSocket.new(host, 'ssh')
|
83
77
|
s.close
|
84
78
|
end
|
85
79
|
true
|
@@ -1,22 +1,32 @@
|
|
1
|
+
require 'vagrant-libvirt/util/nfs'
|
1
2
|
require 'yaml'
|
3
|
+
|
2
4
|
module VagrantPlugins
|
3
5
|
module ProviderLibvirt
|
4
6
|
module Action
|
5
7
|
class PruneNFSExports
|
8
|
+
include VagrantPlugins::ProviderLibvirt::Util::Nfs
|
9
|
+
|
6
10
|
def initialize(app, _env)
|
11
|
+
@logger = Log4r::Logger.new('vagrant_libvirt::action::prune_nfs_exports')
|
7
12
|
@app = app
|
8
13
|
end
|
9
14
|
|
10
15
|
def call(env)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
@machine = env[:machine]
|
17
|
+
|
18
|
+
if using_nfs?
|
19
|
+
@logger.info('Using NFS, prunning NFS settings from host')
|
20
|
+
if env[:host]
|
21
|
+
uuid = env[:machine].id
|
22
|
+
# get all uuids
|
23
|
+
uuids = env[:machine].provider.driver.connection.servers.all.map(&:id)
|
24
|
+
# not exiisted in array will removed from nfs
|
25
|
+
uuids.delete(uuid)
|
26
|
+
env[:host].capability(
|
27
|
+
:nfs_prune, env[:machine].ui, uuids
|
28
|
+
)
|
29
|
+
end
|
20
30
|
end
|
21
31
|
|
22
32
|
@app.call(env)
|
@@ -10,8 +10,8 @@ module VagrantPlugins
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(env)
|
13
|
-
env[:ui].info('Vagrant-libvirt plugin removed box only from
|
14
|
-
env[:ui].info('From
|
13
|
+
env[:ui].info('Vagrant-libvirt plugin removed box only from your LOCAL ~/.vagrant/boxes directory')
|
14
|
+
env[:ui].info('From Libvirt storage pool you have to delete image manually(virsh, virt-manager or by any other tool)')
|
15
15
|
@app.call(env)
|
16
16
|
end
|
17
17
|
end
|
@@ -16,13 +16,19 @@ module VagrantPlugins
|
|
16
16
|
|
17
17
|
def call(env)
|
18
18
|
# Remove stale server volume
|
19
|
-
env[:ui].info(I18n.t('vagrant_libvirt.remove_stale_volume'))
|
20
|
-
|
21
19
|
config = env[:machine].provider_config
|
22
20
|
# Check for storage pool, where box image should be created
|
23
|
-
fog_pool =
|
24
|
-
|
25
|
-
)
|
21
|
+
fog_pool = env[:machine].provider.driver.connection.pools.all(
|
22
|
+
name: config.storage_pool_name
|
23
|
+
).first
|
24
|
+
|
25
|
+
env[:result] = nil
|
26
|
+
|
27
|
+
if not fog_pool
|
28
|
+
@logger.debug("**** Pool #{config.storage_pool_name} not found")
|
29
|
+
return @app.call(env)
|
30
|
+
end
|
31
|
+
|
26
32
|
@logger.debug("**** Pool #{fog_pool.name}")
|
27
33
|
|
28
34
|
# This is name of newly created image for vm.
|
@@ -30,17 +36,17 @@ module VagrantPlugins
|
|
30
36
|
@logger.debug("**** Volume name #{name}")
|
31
37
|
|
32
38
|
# remove root storage
|
33
|
-
box_volume =
|
34
|
-
|
35
|
-
)
|
36
|
-
if box_volume && box_volume.
|
39
|
+
box_volume = env[:machine].provider.driver.connection.volumes.all(
|
40
|
+
name: name
|
41
|
+
).find { |x| x.pool_name == fog_pool.name }
|
42
|
+
if box_volume && box_volume.id
|
43
|
+
env[:ui].info(I18n.t('vagrant_libvirt.remove_stale_volume'))
|
37
44
|
@logger.info("Deleting volume #{box_volume.key}")
|
38
45
|
box_volume.destroy
|
39
46
|
env[:result] = box_volume
|
40
47
|
else
|
41
|
-
|
48
|
+
@logger.debug("**** Volume #{name} not found in pool #{fog_pool.name}")
|
42
49
|
end
|
43
|
-
|
44
50
|
# Continue the middleware chain.
|
45
51
|
@app.call(env)
|
46
52
|
end
|
@@ -33,7 +33,7 @@ module VagrantPlugins
|
|
33
33
|
if @boot_order.count >= 1
|
34
34
|
|
35
35
|
# If a domain is initially defined with no box or disk or
|
36
|
-
# with an explicit boot order,
|
36
|
+
# with an explicit boot order, Libvirt adds <boot dev="foo">
|
37
37
|
# This conflicts with an explicit boot_order configuration,
|
38
38
|
# so we need to remove it from the domain xml and feed it back.
|
39
39
|
# Also see https://bugzilla.redhat.com/show_bug.cgi?id=1248514
|
@@ -66,7 +66,7 @@ module VagrantPlugins
|
|
66
66
|
logger_msg(node, index)
|
67
67
|
end
|
68
68
|
|
69
|
-
# Finally redefine the domain XML through
|
69
|
+
# Finally redefine the domain XML through Libvirt
|
70
70
|
# to apply the boot ordering
|
71
71
|
env[:machine].provider
|
72
72
|
.driver
|
@@ -13,20 +13,17 @@ module VagrantPlugins
|
|
13
13
|
env[:domain_name] = build_domain_name(env)
|
14
14
|
|
15
15
|
begin
|
16
|
-
@logger.info("Looking for domain #{env[:domain_name]}
|
17
|
-
"#{env[:machine].provider.driver.connection.servers.all}")
|
16
|
+
@logger.info("Looking for domain #{env[:domain_name]}")
|
18
17
|
# Check if the domain name is not already taken
|
19
18
|
|
20
|
-
domain =
|
21
|
-
|
19
|
+
domain = env[:machine].provider.driver.connection.servers.all(
|
20
|
+
name: env[:domain_name]
|
22
21
|
)
|
23
|
-
rescue
|
22
|
+
rescue Libvirt::RetrieveError => e
|
24
23
|
@logger.info(e.to_s)
|
25
24
|
domain = nil
|
26
25
|
end
|
27
26
|
|
28
|
-
@logger.info("Looking for domain #{env[:domain_name]}")
|
29
|
-
|
30
27
|
unless domain.nil?
|
31
28
|
raise ProviderLibvirt::Errors::DomainNameExists,
|
32
29
|
domain_name: env[:domain_name]
|
@@ -41,7 +38,7 @@ module VagrantPlugins
|
|
41
38
|
# parsable and sortable by epoch time
|
42
39
|
# @example
|
43
40
|
# development-centos-6-chef-11_1404488971_3b7a569e2fd7c554b852
|
44
|
-
# @return [String]
|
41
|
+
# @return [String] Libvirt domain name
|
45
42
|
def build_domain_name(env)
|
46
43
|
config = env[:machine].provider_config
|
47
44
|
domain_name =
|
@@ -51,7 +48,7 @@ module VagrantPlugins
|
|
51
48
|
# don't have any prefix, not even "_"
|
52
49
|
''
|
53
50
|
else
|
54
|
-
config.default_prefix.to_s.dup
|
51
|
+
config.default_prefix.to_s.dup
|
55
52
|
end
|
56
53
|
domain_name << env[:machine].name.to_s
|
57
54
|
domain_name.gsub!(/[^-a-z0-9_\.]/i, '')
|
@@ -23,7 +23,7 @@ module VagrantPlugins
|
|
23
23
|
|
24
24
|
libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
|
25
25
|
|
26
|
-
#
|
26
|
+
# Libvirt API doesn't support modifying memory on NUMA enabled CPUs
|
27
27
|
# http://libvirt.org/git/?p=libvirt.git;a=commit;h=d174394105cf00ed266bf729ddf461c21637c736
|
28
28
|
if config.numa_nodes == nil
|
29
29
|
if config.memory.to_i * 1024 != libvirt_domain.max_memory
|
@@ -68,7 +68,7 @@ module VagrantPlugins
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# vCpu count
|
71
|
-
if config.cpus.to_i != libvirt_domain.
|
71
|
+
if config.cpus.to_i != libvirt_domain.num_vcpus(0)
|
72
72
|
descr_changed = true
|
73
73
|
REXML::XPath.first(xml_descr, '/domain/vcpu').text = config.cpus
|
74
74
|
end
|
@@ -28,25 +28,42 @@ module VagrantPlugins
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Wait for domain to obtain an ip address. Ip address is searched
|
31
|
-
# from arp table, either
|
31
|
+
# from arp table, either locally or remotely via ssh, if Libvirt
|
32
32
|
# connection was done via ssh.
|
33
33
|
env[:ip_address] = nil
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
@logger.debug("Searching for IP for MAC address: #{domain.mac}")
|
35
|
+
env[:ui].info(I18n.t('vagrant_libvirt.waiting_for_ip'))
|
36
|
+
|
37
|
+
if env[:machine].provider_config.qemu_use_session
|
38
|
+
env[:metrics]['instance_ip_time'] = Util::Timer.time do
|
39
|
+
retryable(on: Fog::Errors::TimeoutError, tries: 300) do
|
40
|
+
# just return if interrupted and let the warden call recover
|
41
|
+
return if env[:interrupted]
|
42
|
+
|
43
|
+
# Wait for domain to obtain an ip address
|
44
|
+
domain.wait_for(2) do
|
45
|
+
env[:ip_address] = env[:machine].provider.driver.get_ipaddress_system(domain.mac)
|
46
|
+
!env[:ip_address].nil?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
else
|
51
|
+
env[:metrics]['instance_ip_time'] = Util::Timer.time do
|
52
|
+
retryable(on: Fog::Errors::TimeoutError, tries: 300) do
|
53
|
+
# just return if interrupted and let the warden call recover
|
54
|
+
return if env[:interrupted]
|
40
55
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
56
|
+
# Wait for domain to obtain an ip address
|
57
|
+
domain.wait_for(2) do
|
58
|
+
addresses.each_pair do |_type, ip|
|
59
|
+
env[:ip_address] = ip[0] unless ip[0].nil?
|
60
|
+
end
|
61
|
+
!env[:ip_address].nil?
|
45
62
|
end
|
46
|
-
!env[:ip_address].nil?
|
47
63
|
end
|
48
64
|
end
|
49
65
|
end
|
66
|
+
|
50
67
|
@logger.info("Got IP address #{env[:ip_address]}")
|
51
68
|
@logger.info("Time for getting IP: #{env[:metrics]['instance_ip_time']}")
|
52
69
|
|
@@ -67,8 +84,8 @@ module VagrantPlugins
|
|
67
84
|
end
|
68
85
|
end
|
69
86
|
end
|
70
|
-
# if interrupted
|
71
|
-
return
|
87
|
+
# just return if interrupted and let the warden call recover
|
88
|
+
return if env[:interrupted]
|
72
89
|
@logger.info("Time for SSH ready: #{env[:metrics]['instance_ssh_time']}")
|
73
90
|
|
74
91
|
# Booted and ready for use.
|
@@ -78,8 +95,6 @@ module VagrantPlugins
|
|
78
95
|
end
|
79
96
|
|
80
97
|
def recover(env)
|
81
|
-
return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
|
82
|
-
|
83
98
|
# Undo the import
|
84
99
|
terminate(env)
|
85
100
|
end
|