Class: LxcSsh::Manager
- Inherits:
-
Object
- Object
- LxcSsh::Manager
- Defined in:
- lib/lxc_ssh/manager.rb
Instance Method Summary collapse
-
#container(name) ⇒ LxcSsh::Container
Returns an LxcSsh::Container object for the given container name.
-
#container_config(name) ⇒ LxcSsh::ContainerConfig
Returns a LxcSsh::ContainerConfig object for the container name.
-
#container_names ⇒ Array
Returns an array of lxc containers.
-
#containers ⇒ Array
Returns an array containing objects with container metadata.
-
#create_container(name, template, template_options = nil) ⇒ String
Creates a container with the default configuration and additional template options and returns the output as a string.
-
#destroy_container(name) ⇒ Boolean
Destroys a container with the given name.
-
#initialize(session, lxc_version, lxc_path) ⇒ Manager
constructor
Initializes the lxc manager by creating an instance of the version-specific lxc manager for the detected version.
-
#start_container(name) ⇒ Boolean
Starts a container with the given name.
-
#stop_container(name) ⇒ Boolean
Stops a container.
-
#template_help(name) ⇒ String
Returns the template help text for a given template name.
-
#template_names ⇒ Array
Returns an array containing all templates.
-
#write_config(name, config) ⇒ Object
Writes the config file contents back to the container config.
Constructor Details
#initialize(session, lxc_version, lxc_path) ⇒ Manager
Initializes the lxc manager by creating an instance of the version-specific lxc manager for the detected version
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lxc_ssh/manager.rb', line 10 def initialize(session, lxc_version, lxc_path) @lxc_path = lxc_path @specific_manager = nil # LXC APIs mac change in the future, therefore a version specific adapter # must be used if Gem::Version.new(lxc_version) >= Gem::Version.new('1.0') @specific_manager = LxcSsh::SpecificManager10.new(session, lxc_path) # other version checks go here else raise 'lxc versions < 1.0 are not supported' end end |
Instance Method Details
#container(name) ⇒ LxcSsh::Container
Returns an LxcSsh::Container object for the given container name
48 49 50 |
# File 'lib/lxc_ssh/manager.rb', line 48 def container(name) @specific_manager.get_container_obj name end |
#container_config(name) ⇒ LxcSsh::ContainerConfig
Returns a LxcSsh::ContainerConfig object for the container name
41 42 43 |
# File 'lib/lxc_ssh/manager.rb', line 41 def container_config(name) @specific_manager.container_config name end |
#container_names ⇒ Array
Returns an array of lxc containers
27 28 29 |
# File 'lib/lxc_ssh/manager.rb', line 27 def container_names @specific_manager.container_names end |
#containers ⇒ Array
Returns an array containing objects with container metadata
34 35 36 |
# File 'lib/lxc_ssh/manager.rb', line 34 def containers @specific_manager.containers end |
#create_container(name, template, template_options = nil) ⇒ String
Creates a container with the default configuration and additional template options and returns the output as a string
85 86 87 |
# File 'lib/lxc_ssh/manager.rb', line 85 def create_container(name, template, = nil) @specific_manager.create_container name, template, end |
#destroy_container(name) ⇒ Boolean
Destroys a container with the given name
109 110 111 |
# File 'lib/lxc_ssh/manager.rb', line 109 def destroy_container(name) @specific_manager.destroy_container name end |
#start_container(name) ⇒ Boolean
Starts a container with the given name
93 94 95 |
# File 'lib/lxc_ssh/manager.rb', line 93 def start_container(name) @specific_manager.start_container name end |
#stop_container(name) ⇒ Boolean
Stops a container
101 102 103 |
# File 'lib/lxc_ssh/manager.rb', line 101 def stop_container(name) @specific_manager.stop_container name end |
#template_help(name) ⇒ String
Returns the template help text for a given template name
73 74 75 |
# File 'lib/lxc_ssh/manager.rb', line 73 def template_help(name) @specific_manager.template_help name end |
#template_names ⇒ Array
check path
Returns an array containing all templates
65 66 67 |
# File 'lib/lxc_ssh/manager.rb', line 65 def template_names @specific_manager.template_names end |
#write_config(name, config) ⇒ Object
Writes the config file contents back to the container config
56 57 58 |
# File 'lib/lxc_ssh/manager.rb', line 56 def write_config(name, config) @specific_manager.write_config name, config end |