Module: LXC
- Extended by:
- Shell
- Defined in:
- lib/lxc.rb,
lib/lxc/shell.rb,
lib/lxc/errors.rb,
lib/lxc/version.rb,
lib/lxc/container.rb,
lib/lxc/configuration.rb,
lib/lxc/configuration_options.rb
Defined Under Namespace
Modules: ConfigurationOptions, Shell Classes: Configuration, ConfigurationError, Container, ContainerError, Error
Constant Summary collapse
- VERSION =
'0.2.3'
Constants included from Shell
Shell::BIN_FILES, Shell::BIN_PREFIX, Shell::CONTAINER_STATES, Shell::REMOVE_COLORS
Class Method Summary collapse
-
.binary_installed?(name) ⇒ Boolean
Check if binary file is installed.
-
.config ⇒ Hash
Get LXC configuration info.
-
.container(name) ⇒ LXC::Container
Get container information record.
-
.containers(filter = nil) ⇒ Array
Get a list of all available containers.
-
.installed? ⇒ Boolean
Check if all binaries are present in the system.
-
.version ⇒ String
Get current LXC version.
Methods included from Shell
run, use_sudo, use_sudo=, valid_state?
Class Method Details
.binary_installed?(name) ⇒ Boolean
Check if binary file is installed
15 16 17 18 |
# File 'lib/lxc.rb', line 15 def binary_installed?(name) path = File.join(LXC::Shell::BIN_PREFIX, name) File.exists?(path) end |
.config ⇒ Hash
Get LXC configuration info
28 29 30 31 32 33 34 |
# File 'lib/lxc.rb', line 28 def config str = LXC.run('checkconfig') { LXC::Shell::REMOVE_COLORS } data = str.scan(/^([\w\s]+): (enabled|disabled)$/).map { |r| [r.first.downcase.gsub(' ', '_'), r.last == 'enabled'] } Hash[data] end |
.container(name) ⇒ LXC::Container
Get container information record
39 40 41 |
# File 'lib/lxc.rb', line 39 def container(name) LXC::Container.new(name) end |
.containers(filter = nil) ⇒ Array
Get a list of all available containers
46 47 48 49 50 |
# File 'lib/lxc.rb', line 46 def containers(filter=nil) names = LXC.run('ls').split("\n").uniq names.delete_if { |v| !v.include?(filter) } if filter.kind_of?(String) names.map { |name| Container.new(name) } end |
.installed? ⇒ Boolean
Check if all binaries are present in the system
22 23 24 |
# File 'lib/lxc.rb', line 22 def installed? !BIN_FILES.map { |f| binary_installed?(f) }.uniq.include?(false) end |
.version ⇒ String
Get current LXC version
54 55 56 |
# File 'lib/lxc.rb', line 54 def version LXC.run('version').strip.split(' ').last end |