Fix LXC 3.0 compatibility with old boxes
Creating a new vagrant machine with a box created with an old LXC config format would fail with LXC 3.0. We now update the LXC config of the box itself before calling `lxc-create`.
This commit is contained in:
parent
dd24cdc3d6
commit
8cfe577b17
3 changed files with 10 additions and 3 deletions
|
@ -25,7 +25,11 @@ module Vagrant
|
||||||
end
|
end
|
||||||
driver = env[:machine].provider.driver
|
driver = env[:machine].provider.driver
|
||||||
template_options = env[:lxc_template_opts]
|
template_options = env[:lxc_template_opts]
|
||||||
if ! driver.supports_new_config_format
|
if driver.supports_new_config_format
|
||||||
|
if env[:lxc_box_config]
|
||||||
|
driver.update_config_keys(env[:lxc_box_config])
|
||||||
|
end
|
||||||
|
else
|
||||||
template_options['--oldconfig'] = ''
|
template_options['--oldconfig'] = ''
|
||||||
end
|
end
|
||||||
driver.create(
|
driver.create(
|
||||||
|
|
|
@ -33,8 +33,10 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
if template_config_file.exist?
|
if template_config_file.exist?
|
||||||
|
@env[:lxc_box_config] = template_config_file.to_s
|
||||||
@env[:lxc_template_opts].merge!('--config' => template_config_file.to_s)
|
@env[:lxc_template_opts].merge!('--config' => template_config_file.to_s)
|
||||||
elsif old_template_config_file.exist?
|
elsif old_template_config_file.exist?
|
||||||
|
@env[:lxc_box_config] = old_template_config_file.to_s
|
||||||
@env[:lxc_template_config] = old_template_config_file.to_s
|
@env[:lxc_template_config] = old_template_config_file.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -249,8 +249,9 @@ module Vagrant
|
||||||
write_config(contents)
|
write_config(contents)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_config_keys
|
def update_config_keys(path = nil)
|
||||||
@cli.update_config(config_path)
|
path = path || config_path
|
||||||
|
@cli.update_config(path)
|
||||||
rescue Errors::ExecuteError
|
rescue Errors::ExecuteError
|
||||||
# not on LXC 2.1+. Doesn't matter, ignore.
|
# not on LXC 2.1+. Doesn't matter, ignore.
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue