Merge branch 'backingstore_options' of https://github.com/tailhook/vagrant-lxc
Conflicts: lib/vagrant-lxc/config.rb
This commit is contained in:
commit
4c3143aa34
4 changed files with 24 additions and 4 deletions
|
@ -7,7 +7,8 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
container_name = env[:machine].provider_config.container_name
|
||||
config = env[:machine].provider_config
|
||||
container_name = config.container_name
|
||||
|
||||
case container_name
|
||||
when :machine
|
||||
|
@ -24,6 +25,8 @@ module Vagrant
|
|||
|
||||
env[:machine].provider.driver.create(
|
||||
container_name,
|
||||
config.backingstore,
|
||||
config.backingstore_options,
|
||||
env[:lxc_template_src],
|
||||
env[:lxc_template_config],
|
||||
env[:lxc_template_opts]
|
||||
|
|
|
@ -6,12 +6,20 @@ module Vagrant
|
|||
# @return [Array]
|
||||
attr_reader :customizations
|
||||
|
||||
# A string that contains the backing store type used with lxc-create -B
|
||||
attr_accessor :backingstore
|
||||
|
||||
# Optional arguments for the backing store, such as --fssize, --fstype, ...
|
||||
attr_accessor :backingstore_options
|
||||
|
||||
# A string to explicitly set the container name. To use the vagrant
|
||||
# machine name, set this to :machine
|
||||
attr_accessor :container_name
|
||||
|
||||
def initialize
|
||||
@customizations = []
|
||||
@backingstore = UNSET_VALUE
|
||||
@backingstore_options = []
|
||||
@sudo_wrapper = UNSET_VALUE
|
||||
@container_name = UNSET_VALUE
|
||||
end
|
||||
|
@ -31,9 +39,16 @@ module Vagrant
|
|||
@customizations << [key, value]
|
||||
end
|
||||
|
||||
# Stores options for backingstores like lvm, btrfs, etc
|
||||
def backingstore_option(key, value)
|
||||
@backingstore_options << [key, value]
|
||||
end
|
||||
|
||||
def finalize!
|
||||
@sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE
|
||||
@container_name = nil if @container_name == UNSET_VALUE
|
||||
@backingstore = "none" if @backingstore == UNSET_VALUE
|
||||
@existing_container_name = nil if @existing_container_name == UNSET_VALUE
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,12 +51,12 @@ module Vagrant
|
|||
@sudo_wrapper.run('cat', base_path.join('config').to_s)
|
||||
end
|
||||
|
||||
def create(name, template_path, config_file, template_options = {})
|
||||
def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {})
|
||||
@cli.name = @container_name = name
|
||||
|
||||
import_template(template_path) do |template_name|
|
||||
@logger.debug "Creating container..."
|
||||
@cli.create template_name, config_file, template_options
|
||||
@cli.create template_name, backingstore, backingstore_options, config_file, template_options
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
def create(template, config_file, template_opts = {})
|
||||
def create(template, backingstore, backingstore_options, config_file, template_opts = {})
|
||||
if config_file
|
||||
config_opts = ['-f', config_file]
|
||||
end
|
||||
|
@ -54,6 +54,8 @@ module Vagrant
|
|||
extra.unshift '--' unless extra.empty?
|
||||
|
||||
run :create,
|
||||
'-B', backingstore,
|
||||
*(backingstore_options.to_a.flatten),
|
||||
'--template', template,
|
||||
'--name', @name,
|
||||
*(config_opts),
|
||||
|
|
Loading…
Reference in a new issue