Module: LXC
- Extended by:
- Shell
- Defined in:
- lib/lxc.rb,
lib/lxc/shell.rb,
lib/lxc/status.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, Status
Constant Summary collapse
- VERSION =
"0.3.1"
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 a single container instance.
-
.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 currently installeded 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
22 23 24 25 |
# File 'lib/lxc.rb', line 22 def self.binary_installed?(name) path = File.join(LXC::Shell::BIN_PREFIX, name) File.exists?(path) end |
.config ⇒ Hash
Get LXC configuration info
35 36 37 38 39 40 41 42 43 |
# File 'lib/lxc.rb', line 35 def self.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 a single container instance
48 49 50 |
# File 'lib/lxc.rb', line 48 def self.container(name) LXC::Container.new(name) end |
.containers(filter = nil) ⇒ Array
Get a list of all available containers
55 56 57 58 59 60 |
# File 'lib/lxc.rb', line 55 def self.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| LXC::Container.new(name) } end |