Class: Vagrant::LXC::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lxc/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



21
22
23
24
25
26
27
# File 'lib/vagrant-lxc/config.rb', line 21

def initialize
  @customizations = []
  @backingstore = UNSET_VALUE
  @backingstore_options = []
  @sudo_wrapper   = UNSET_VALUE
  @container_name = UNSET_VALUE
end

Instance Attribute Details

#backingstoreObject

A string that contains the backing store type used with lxc-create -B



10
11
12
# File 'lib/vagrant-lxc/config.rb', line 10

def backingstore
  @backingstore
end

#backingstore_optionsArray

Optional arguments for the backing store, such as –fssize, –fstype, …

Returns:

  • (Array)


15
16
17
# File 'lib/vagrant-lxc/config.rb', line 15

def backingstore_options
  @backingstore_options
end

#container_nameObject

A string to explicitly set the container name. To use the vagrant machine name, set this to :machine



19
20
21
# File 'lib/vagrant-lxc/config.rb', line 19

def container_name
  @container_name
end

#customizationsArray (readonly)

An array of container’s configuration overrides to be provided to ‘lxc-start`.

Returns:

  • (Array)


7
8
9
# File 'lib/vagrant-lxc/config.rb', line 7

def customizations
  @customizations
end

Instance Method Details

#backingstore_option(key, value) ⇒ Object

Stores options for backingstores like lvm, btrfs, etc



45
46
47
# File 'lib/vagrant-lxc/config.rb', line 45

def backingstore_option(key, value)
  @backingstore_options << [key, value]
end

#customize(key, value) ⇒ Object

Customize the container by calling ‘lxc-start` with the given configuration overrides.

For example, if you want to set the memory limit, you can use it like: config.customize ‘cgroup.memory.limit_in_bytes’, ‘400M’

When ‘lxc-start`ing the container, vagrant-lxc will pass in “-s lxc.cgroup.memory.limit_in_bytes=400M” to it.

Parameters:

  • key (String)

    Configuration key to override

  • value (String)

    Configuration value to override



40
41
42
# File 'lib/vagrant-lxc/config.rb', line 40

def customize(key, value)
  @customizations << [key, value]
end

#finalize!Object



49
50
51
52
53
54
# File 'lib/vagrant-lxc/config.rb', line 49

def finalize!
  @sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE
  @container_name = nil if @container_name == UNSET_VALUE
  @backingstore = "best" if @backingstore == UNSET_VALUE
  @existing_container_name = nil if @existing_container_name == UNSET_VALUE
end