Class: Vagrant::LXC::Config
- Inherits:
-
Object
- Object
- Vagrant::LXC::Config
- Defined in:
- lib/vagrant-lxc/config.rb
Instance Attribute Summary collapse
-
#customizations ⇒ Array
readonly
An array of container’s configuration overrides to be provided to ‘lxc-start`.
-
#sudo_wrapper ⇒ Object
A String that points to a file that acts as a wrapper for sudo commands.
Instance Method Summary collapse
-
#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.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
15 16 17 18 |
# File 'lib/vagrant-lxc/config.rb', line 15 def initialize @customizations = [] @sudo_wrapper = UNSET_VALUE end |
Instance Attribute Details
#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 |
#sudo_wrapper ⇒ Object
A String that points to a file that acts as a wrapper for sudo commands.
This allows us to have a single entry when whitelisting NOPASSWD commands on /etc/sudoers
13 14 15 |
# File 'lib/vagrant-lxc/config.rb', line 13 def sudo_wrapper @sudo_wrapper end |
Instance Method Details
#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.
31 32 33 |
# File 'lib/vagrant-lxc/config.rb', line 31 def customize(key, value) @customizations << [key, value] end |
#finalize! ⇒ Object
35 36 37 |
# File 'lib/vagrant-lxc/config.rb', line 35 def finalize! @sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE end |
#validate(machine) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vagrant-lxc/config.rb', line 39 def validate(machine) errors = [] if @sudo_wrapper hostpath = Pathname.new(@sudo_wrapper).(machine.env.root_path) if ! hostpath.file? errors << I18n.t('vagrant_lxc.sudo_wrapper_not_found', path: hostpath.to_s) elsif ! hostpath.executable? errors << I18n.t('vagrant_lxc.sudo_wrapper_not_executable', path: hostpath.to_s) end end { "lxc provider" => errors } end |