vagrant-libvirt 0.0.43 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +434 -150
- data/lib/vagrant-libvirt/action.rb +2 -2
- data/lib/vagrant-libvirt/action/create_domain.rb +103 -38
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +19 -14
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +10 -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 +9 -7
- data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/handle_box_image.rb +32 -18
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +9 -4
- data/lib/vagrant-libvirt/action/package_domain.rb +63 -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 +3 -3
- 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 +178 -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/templates/public_interface.xml.erb +5 -1
- data/lib/vagrant-libvirt/util.rb +2 -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/util/ui.rb +23 -0
- data/lib/vagrant-libvirt/version +1 -0
- data/lib/vagrant-libvirt/version.rb +24 -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 +3 -3
- data/spec/unit/action/create_domain_spec.rb +85 -0
- data/spec/unit/action/create_domain_spec/default_storage_pool.xml +17 -0
- 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/action/start_domain_spec.rb +49 -0
- data/spec/unit/action/start_domain_spec/default.xml +48 -0
- 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 +34 -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,10 @@ module VagrantPlugins
|
|
4
4
|
module ProviderLibvirt
|
5
5
|
module Action
|
6
6
|
class HandleBoxImage
|
7
|
+
include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
|
8
|
+
include VagrantPlugins::ProviderLibvirt::Util::Ui
|
9
|
+
|
10
|
+
|
7
11
|
@@lock = Mutex.new
|
8
12
|
|
9
13
|
def initialize(app, _env)
|
@@ -31,11 +35,12 @@ module VagrantPlugins
|
|
31
35
|
config = env[:machine].provider_config
|
32
36
|
box_image_file = env[:machine].box.directory.join('box.img').to_s
|
33
37
|
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
|
-
|
38
|
+
env[:box_volume_name] << "_vagrant_box_image_#{
|
39
|
+
begin
|
40
|
+
env[:machine].box.version.to_s
|
41
|
+
rescue
|
42
|
+
''
|
43
|
+
end}.img"
|
39
44
|
|
40
45
|
# Override box_virtual_size
|
41
46
|
if config.machine_virtual_size
|
@@ -44,7 +49,7 @@ module VagrantPlugins
|
|
44
49
|
# is not supported and will be ignored
|
45
50
|
env[:ui].warn I18n.t(
|
46
51
|
'vagrant_libvirt.warnings.ignoring_virtual_size_too_small',
|
47
|
-
|
52
|
+
requested: config.machine_virtual_size, minimum: box_virtual_size
|
48
53
|
)
|
49
54
|
else
|
50
55
|
env[:ui].info I18n.t('vagrant_libvirt.manual_resize_required')
|
@@ -59,9 +64,10 @@ module VagrantPlugins
|
|
59
64
|
# locking all subsequent actions as well.
|
60
65
|
@@lock.synchronize do
|
61
66
|
# Don't continue if image already exists in storage pool.
|
62
|
-
|
63
|
-
|
64
|
-
)
|
67
|
+
box_volume = env[:machine].provider.driver.connection.volumes.all(
|
68
|
+
name: env[:box_volume_name]
|
69
|
+
).first
|
70
|
+
break if box_volume && box_volume.id
|
65
71
|
|
66
72
|
# Box is not available as a storage pool volume. Create and upload
|
67
73
|
# it as a copy of local box image.
|
@@ -75,13 +81,19 @@ module VagrantPlugins
|
|
75
81
|
message = "Creating volume #{env[:box_volume_name]}"
|
76
82
|
message << " in storage pool #{config.storage_pool_name}."
|
77
83
|
@logger.info(message)
|
84
|
+
|
85
|
+
@storage_volume_uid = storage_uid env
|
86
|
+
@storage_volume_gid = storage_gid env
|
87
|
+
|
78
88
|
begin
|
79
89
|
fog_volume = env[:machine].provider.driver.connection.volumes.create(
|
80
|
-
name:
|
81
|
-
allocation:
|
82
|
-
capacity:
|
83
|
-
format_type:
|
84
|
-
|
90
|
+
name: env[:box_volume_name],
|
91
|
+
allocation: "#{box_image_size / 1024 / 1024}M",
|
92
|
+
capacity: "#{box_virtual_size}G",
|
93
|
+
format_type: box_format,
|
94
|
+
owner: @storage_volume_uid,
|
95
|
+
group: @storage_volume_gid,
|
96
|
+
pool_name: config.storage_pool_name
|
85
97
|
)
|
86
98
|
rescue Fog::Errors::Error => e
|
87
99
|
raise Errors::FogCreateVolumeError,
|
@@ -91,13 +103,15 @@ module VagrantPlugins
|
|
91
103
|
# Upload box image to storage pool
|
92
104
|
ret = upload_image(box_image_file, config.storage_pool_name,
|
93
105
|
env[:box_volume_name], env) do |progress|
|
94
|
-
env[:ui]
|
95
|
-
|
106
|
+
rewriting(env[:ui]) do |ui|
|
107
|
+
ui.clear_line
|
108
|
+
ui.report_progress(progress, box_image_size, false)
|
109
|
+
end
|
96
110
|
end
|
97
111
|
|
98
112
|
# Clear the line one last time since the progress meter doesn't
|
99
113
|
# disappear immediately.
|
100
|
-
env[:ui].clear_line
|
114
|
+
rewriting(env[:ui]) {|ui| ui.clear_line}
|
101
115
|
|
102
116
|
# If upload failed or was interrupted, remove created volume from
|
103
117
|
# storage pool.
|
@@ -115,7 +129,7 @@ module VagrantPlugins
|
|
115
129
|
|
116
130
|
protected
|
117
131
|
|
118
|
-
# Fog
|
132
|
+
# Fog Libvirt currently doesn't support uploading images to storage
|
119
133
|
# pool volumes. Use ruby-libvirt client instead.
|
120
134
|
def upload_image(image_file, pool_name, volume_name, env)
|
121
135
|
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,10 +1,14 @@
|
|
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
|
9
|
+
include VagrantPlugins::ProviderLibvirt::Util::Ui
|
10
|
+
|
11
|
+
|
8
12
|
def initialize(app, env)
|
9
13
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::package_domain')
|
10
14
|
@app = app
|
@@ -21,24 +25,33 @@ module VagrantPlugins
|
|
21
25
|
root_disk = domain.volumes.select do |x|
|
22
26
|
x.name == libvirt_domain.name + '.img'
|
23
27
|
end.first
|
28
|
+
raise Errors::NoDomainVolume if root_disk.nil?
|
24
29
|
boxname = env['package.output']
|
25
30
|
raise "#{boxname}: Already exists" if File.exist?(boxname)
|
26
31
|
@tmp_dir = Dir.pwd + '/_tmp_package'
|
27
32
|
@tmp_img = @tmp_dir + '/box.img'
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
env[:ui]
|
33
|
-
|
34
|
-
|
33
|
+
FileUtils.mkdir_p(@tmp_dir)
|
34
|
+
env[:ui].info("Downloading #{root_disk.name} to #{@tmp_img}")
|
35
|
+
ret = download_image(@tmp_img, env[:machine].provider_config.storage_pool_name,
|
36
|
+
root_disk.name, env) do |progress,image_size|
|
37
|
+
rewriting(env[:ui]) do |ui|
|
38
|
+
ui.clear_line
|
39
|
+
ui.report_progress(progress, image_size, false)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
# Clear the line one last time since the progress meter doesn't
|
43
|
+
# disappear immediately.
|
44
|
+
rewriting(env[:ui]) {|ui| ui.clear_line}
|
45
|
+
backing = `qemu-img info "#{@tmp_img}" | grep 'backing file:' | cut -d ':' -f2`.chomp
|
46
|
+
if backing
|
47
|
+
env[:ui].info('Image has backing image, copying image and rebasing ...')
|
48
|
+
`qemu-img rebase -p -b "" #{@tmp_img}`
|
35
49
|
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
50
|
# remove hw association with interface
|
40
51
|
# working for centos with lvs default disks
|
41
|
-
|
52
|
+
options = ENV.fetch('VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS', '')
|
53
|
+
operations = ENV.fetch('VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS', 'defaults,-ssh-userdir')
|
54
|
+
`virt-sysprep --no-logfile --operations #{operations} -a #{@tmp_img} #{options}`
|
42
55
|
# add any user provided file
|
43
56
|
extra = ''
|
44
57
|
@tmp_include = @tmp_dir + '/_include'
|
@@ -99,6 +112,44 @@ module VagrantPlugins
|
|
99
112
|
}
|
100
113
|
EOF
|
101
114
|
end
|
115
|
+
|
116
|
+
protected
|
117
|
+
|
118
|
+
# Fog libvirt currently doesn't support downloading images from storage
|
119
|
+
# pool volumes. Use ruby-libvirt client instead.
|
120
|
+
def download_image(image_file, pool_name, volume_name, env)
|
121
|
+
begin
|
122
|
+
pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(
|
123
|
+
pool_name
|
124
|
+
)
|
125
|
+
volume = pool.lookup_volume_by_name(volume_name)
|
126
|
+
image_size = volume.info.allocation # B
|
127
|
+
|
128
|
+
stream = env[:machine].provider.driver.connection.client.stream
|
129
|
+
|
130
|
+
# Use length of 0 to download remaining contents after offset
|
131
|
+
volume.download(stream, offset = 0, length = 0)
|
132
|
+
|
133
|
+
buf_size = 1024 * 250 # 250K, copied from upload_image in handle_box_image.rb
|
134
|
+
progress = 0
|
135
|
+
retval = stream.recv(buf_size)
|
136
|
+
open(image_file, 'wb') do |io|
|
137
|
+
while (retval.at(0) > 0)
|
138
|
+
recvd = io.write(retval.at(1))
|
139
|
+
progress += recvd
|
140
|
+
yield [progress, image_size]
|
141
|
+
retval = stream.recv(buf_size)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
rescue => e
|
145
|
+
raise Errors::ImageDownloadError,
|
146
|
+
volume_name: volume_name,
|
147
|
+
pool_name: pool_name,
|
148
|
+
error_message: e.message
|
149
|
+
end
|
150
|
+
|
151
|
+
progress == image_size
|
152
|
+
end
|
102
153
|
end
|
103
154
|
end
|
104
155
|
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, '')
|