Class: Vagrant::LXC::Config
- Inherits:
-
Object
- Object
- Vagrant::LXC::Config
- Defined in:
- lib/vagrant-lxc/config.rb
Instance Attribute Summary collapse
-
#backingstore ⇒ Object
A string that contains the backing store type used with lxc-create -B.
-
#backingstore_options ⇒ Array
Optional arguments for the backing store, such as –fssize, –fstype, …
-
#container_name ⇒ Object
A string to explicitly set the container name.
-
#customizations ⇒ Array
readonly
An array of container’s configuration overrides to be provided to ‘lxc-start`.
-
#fetch_ip_tries ⇒ Object
Returns the value of attribute fetch_ip_tries.
-
#privileged ⇒ Object
Whether the container needs to be privileged.
-
#tmpfs_mount_size ⇒ Object
Size (as a string like ‘400M’) of the tmpfs to mount at /tmp on boot.
Instance Method Summary collapse
-
#backingstore_option(key, value) ⇒ Object
Stores options for backingstores like lvm, btrfs, etc.
-
#customize(key, value) ⇒ Object
Customize the container by calling ‘lxc-start` with the given configuration overrides.
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
33 34 35 36 37 38 39 40 41 |
# File 'lib/vagrant-lxc/config.rb', line 33 def initialize @customizations = [] @backingstore = UNSET_VALUE @backingstore_options = [] @container_name = UNSET_VALUE @tmpfs_mount_size = UNSET_VALUE @fetch_ip_tries = UNSET_VALUE @privileged = UNSET_VALUE end |
Instance Attribute Details
#backingstore ⇒ Object
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_options ⇒ Array
Optional arguments for the backing store, such as –fssize, –fstype, …
15 16 17 |
# File 'lib/vagrant-lxc/config.rb', line 15 def @backingstore_options end |
#container_name ⇒ Object
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 |
#customizations ⇒ Array (readonly)
An array of container’s configuration overrides to be provided to ‘lxc-start`.
7 8 9 |
# File 'lib/vagrant-lxc/config.rb', line 7 def customizations @customizations end |
#fetch_ip_tries ⇒ Object
Returns the value of attribute fetch_ip_tries.
25 26 27 |
# File 'lib/vagrant-lxc/config.rb', line 25 def fetch_ip_tries @fetch_ip_tries end |
#privileged ⇒ Object
Whether the container needs to be privileged. Defaults to true (unprivileged containers is a very new feature in vagrant-lxc). If false, will try creating an unprivileged container. If it can’t, will revert to the old “sudo wrapper” method to create a privileged container.
31 32 33 |
# File 'lib/vagrant-lxc/config.rb', line 31 def privileged @privileged end |
#tmpfs_mount_size ⇒ Object
Size (as a string like ‘400M’) of the tmpfs to mount at /tmp on boot. Set to false or nil to disable the tmpfs mount altogether. Defaults to ‘2G’.
23 24 25 |
# File 'lib/vagrant-lxc/config.rb', line 23 def tmpfs_mount_size @tmpfs_mount_size end |
Instance Method Details
#backingstore_option(key, value) ⇒ Object
Stores options for backingstores like lvm, btrfs, etc
59 60 61 |
# File 'lib/vagrant-lxc/config.rb', line 59 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.
54 55 56 |
# File 'lib/vagrant-lxc/config.rb', line 54 def customize(key, value) @customizations << [key, value] end |
#finalize! ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/vagrant-lxc/config.rb', line 63 def finalize! @container_name = nil if @container_name == UNSET_VALUE @backingstore = nil if @backingstore == UNSET_VALUE @existing_container_name = nil if @existing_container_name == UNSET_VALUE @tmpfs_mount_size = '2G' if @tmpfs_mount_size == UNSET_VALUE @fetch_ip_tries = 10 if @fetch_ip_tries == UNSET_VALUE @privileged = true if @privileged == UNSET_VALUE end |