Class: TestLab::Container
- Inherits:
-
ZTK::DSL::Base
- Object
- ZTK::DSL::Base
- TestLab::Container
- Extended by:
- ClassMethods
- Includes:
- Actions, Clone, Configuration, IO, Interface, LXC, Provision, SSH, Status, Support, User, Support::Execution, Support::Lifecycle, Utility::Misc
- Defined in:
- lib/testlab/container.rb,
lib/testlab/container/io.rb,
lib/testlab/container/lxc.rb,
lib/testlab/container/ssh.rb,
lib/testlab/container/user.rb,
lib/testlab/container/clone.rb,
lib/testlab/container/status.rb,
lib/testlab/container/actions.rb,
lib/testlab/container/support.rb,
lib/testlab/container/interface.rb,
lib/testlab/container/provision.rb,
lib/testlab/container/class_methods.rb,
lib/testlab/container/configuration.rb
Overview
Container Class
This class represents the TestLab Container DSL object.
The operating system is determined by the distro and release attributes. The hostname (container ID) is passed as a parameter to the container call. A domain may additionally be specified (overriding the global domain, if set). If the domain attributes is omited, then the global domain is use, again only if it is set. The hostname (container ID) and the domain will be joined together to form the FQDN of the container.
Defined Under Namespace
Modules: Actions, ClassMethods, Clone, Configuration, IO, Interface, LXC, Provision, SSH, Status, Support, User
Constant Summary collapse
- STATUS_KEYS =
An array of symbols of the various keys in our status hash.
%w(id node_id priority cpu_time memory_usage disk_usage mode fqdn state distro release interfaces provisioners inherited).map(&:to_sym)
Constants included from IO
IO::PBZIP2_MEMORY, IO::READ_SIZE, IO::TRANSFER_MESSAGE
Class Method Summary collapse
Instance Method Summary collapse
- #config_dir ⇒ Object
-
#initialize(*args) ⇒ Container
constructor
A new instance of Container.
- #repo_dir ⇒ Object
Methods included from ClassMethods
Methods included from Utility::Misc
#do_provisioner_callbacks, #format_message, #format_object_action, #please_wait, #sudo, #sudo_prompt
Methods included from Support::Lifecycle
#bounce, #build, #demolish, #recycle
Methods included from Support::Execution
#bootstrap, #download, #exec, #file, #upload
Methods included from User
Methods included from Support
#clone_args, #create_args, #detect_arch, #start_args
Methods included from Status
#alive?, #cidr, #cpu_usage, #disk_usage, #fqdn, #importable?, #ip, #memory_usage, #mode, #ptr, #state, #status
Methods included from SSH
Methods included from Provision
Methods included from LXC
#console, #exists?, #fs_root, #lxc
Methods included from IO
#copy, #export, #import, #progress_callback, #sc_download, #transfer_message
Methods included from Interface
Methods included from Configuration
#build_lxc_config, #build_lxc_network_conf, #configure
Methods included from Clone
#ephemeral, #is_ephemeral?, #is_persistent?, #lxc_clone, #persistent, #persistent_operation_check, #to_ephemeral, #to_persistent
Methods included from Actions
Constructor Details
#initialize(*args) ⇒ Container
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/testlab/container.rb', line 154 def initialize(*args) @ui = TestLab.ui @ui.logger.debug { "Loading Container" } super(*args) @ui.logger.debug { "Container '#{self.id}' Loaded" } if self.priority.nil? && (self.template == false) $priority_counter ||= 0 self.priority = (1000 - $priority_counter) $priority_counter += 1 end self. ||= [ self.id ] if !self.inherit.nil? @ui.logger.debug { "INHERIT: #{self.inherit}" } parent = TestLab::Container.first(self.inherit) if parent.nil? raise ContainerError, "Could not find the container you specified to inherit attributes from! (#{self.inherit.inspect})" end # Inherit the containers attributes parent.attributes.reject{ |k,v| [:id, :node_id, :inherit, :template, :priority].include?(k) }.each do |key, value| self.send("#{key}=", (value.dup rescue value)) end # Inherit the containers users parent.users.each do |user| inherited_user = TestLab::User.new inherited_user.container_id = self.id user.attributes.reject{ |k,v| [:id, :container_id].include?(k) }.each do |key, value| inherited_user.send("#{key}=", (value.dup rescue value)) end end end end |
Class Method Details
.by_priority(priority) ⇒ Object
209 210 211 |
# File 'lib/testlab/container.rb', line 209 def by_priority(priority) self.all.delete_if{|c| (c.template == true) }.select{ |c| c.priority == priority } end |
.priority_groups ⇒ Object
205 206 207 |
# File 'lib/testlab/container.rb', line 205 def priority_groups self.all.delete_if{|c| (c.template == true) }.map(&:priority).sort.uniq.reverse end |
Instance Method Details
#config_dir ⇒ Object
195 196 197 |
# File 'lib/testlab/container.rb', line 195 def config_dir self.node.config_dir end |
#repo_dir ⇒ Object
199 200 201 |
# File 'lib/testlab/container.rb', line 199 def repo_dir self.node.repo_dir end |