Class: OsCtld::Container::LxcConfig
- Inherits:
-
Object
- Object
- OsCtld::Container::LxcConfig
- Includes:
- OsCtl::Lib::Utils::Log, Lockable
- Defined in:
- lib/osctld/container/lxc_config.rb
Overview
LXC configuration generator
Instance Attribute Summary collapse
-
#ct ⇒ Object
readonly
protected
Returns the value of attribute ct.
Instance Method Summary collapse
- #assets(add) ⇒ Object
- #config_path ⇒ Object
- #configure ⇒ Object (also: #configure_base, #configure_cgparams, #configure_prlimits, #configure_network, #configure_mounts)
- #dup(new_ct) ⇒ Object
-
#initialize(ct) ⇒ LxcConfig
constructor
A new instance of LxcConfig.
Methods included from Lockable
#exclusively, included, #inclusively, #init_lock, #lock, #unlock
Constructor Details
#initialize(ct) ⇒ LxcConfig
Returns a new instance of LxcConfig.
10 11 12 13 |
# File 'lib/osctld/container/lxc_config.rb', line 10 def initialize(ct) init_lock @ct = ct end |
Instance Attribute Details
#ct ⇒ Object (readonly, protected)
Returns the value of attribute ct.
74 75 76 |
# File 'lib/osctld/container/lxc_config.rb', line 74 def ct @ct end |
Instance Method Details
#assets(add) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/osctld/container/lxc_config.rb', line 15 def assets(add) add.file( config_path, desc: 'LXC config', user: 0, group: 0, mode: 0o644 ) end |
#config_path ⇒ Object
61 62 63 |
# File 'lib/osctld/container/lxc_config.rb', line 61 def config_path File.join(ct.lxc_dir, 'config') end |
#configure ⇒ Object Also known as: configure_base, configure_cgparams, configure_prlimits, configure_network, configure_mounts
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/osctld/container/lxc_config.rb', line 25 def configure exclusively do run_conf = ct.get_run_conf rootfs = run_conf.rootfs unless rootfs if ct.state == :staged log(:warn, ct, 'Skipping LXC config generation: rootfs path is not available') else ct.state = :error log(:warn, ct, 'Unable to generate LXC config: rootfs path is not available') end next false end ErbTemplate.render_to('ct/config', { distribution: run_conf.distribution, version: run_conf.version, ct:, rootfs:, cgparams: ct.cgparams, prlimits: ct.prlimits, netifs: ct.netifs, mounts: ct.mounts.all_entries, raw: ct.raw_configs.lxc }, config_path) end end |
#dup(new_ct) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/osctld/container/lxc_config.rb', line 65 def dup(new_ct) ret = super() ret.init_lock ret.instance_variable_set('@ct', new_ct) ret end |