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
|
||||
driver = env[:machine].provider.driver
|
||||
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'] = ''
|
||||
end
|
||||
driver.create(
|
||||
|
|
|
@ -33,8 +33,10 @@ module Vagrant
|
|||
end
|
||||
|
||||
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)
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -249,8 +249,9 @@ module Vagrant
|
|||
write_config(contents)
|
||||
end
|
||||
|
||||
def update_config_keys
|
||||
@cli.update_config(config_path)
|
||||
def update_config_keys(path = nil)
|
||||
path = path || config_path
|
||||
@cli.update_config(path)
|
||||
rescue Errors::ExecuteError
|
||||
# not on LXC 2.1+. Doesn't matter, ignore.
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue