lib/testlab/container/actions.rb in testlab-0.9.0 vs lib/testlab/container/actions.rb in testlab-0.9.1

- old
+ new

@@ -8,11 +8,11 @@ # Builds the configuration for the container and sends a request to the # LXC sub-system to create the container. # # @return [Boolean] True if successful. def create - @ui.logger.debug { "Container Create: #{self.id} " } + @ui.logger.debug { "Container Create: #{self.id}" } (self.node.state != :running) and return false (self.lxc.state != :not_created) and return false please_wait(:ui => @ui, :message => format_object_action(self, 'Create', :green)) do @@ -28,11 +28,11 @@ # # Sends a request to the LXC sub-system to destroy the container. # # @return [Boolean] True if successful. def destroy - @ui.logger.debug { "Container Destroy: #{self.id} " } + @ui.logger.debug { "Container Destroy: #{self.id}" } (self.node.state != :running) and return false (self.lxc.state == :not_created) and return false please_wait(:ui => @ui, :message => format_object_action(self, 'Destroy', :red)) do @@ -47,11 +47,11 @@ # # Sends a request to the LXC sub-system to bring the container online. # # @return [Boolean] True if successful. def up - @ui.logger.debug { "Container Up: #{self.id} " } + @ui.logger.debug { "Container Up: #{self.id}" } (self.node.state != :running) and return false (self.lxc.state == :running) and return false please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do @@ -66,10 +66,11 @@ self.users.each do |user| user.setup end + self.ssh.exec(%(sudo hostname #{self.fqdn})) end true end @@ -77,18 +78,17 @@ # # Sends a request to the LXC sub-system to take the container offline. # # @return [Boolean] True if successful. def down - @ui.logger.debug { "Container Down: #{self.id} " } + @ui.logger.debug { "Container Down: #{self.id}" } (self.node.state != :running) and return false (self.lxc.state != :running) and return false please_wait(:ui => @ui, :message => format_object_action(self, 'Down', :red)) do self.lxc.stop - self.lxc.wait(:stopped) (self.lxc.state == :running) and raise ContainerError, "The container failed to offline!" end true @@ -110,18 +110,22 @@ self.node.ssh.exec(%(sudo arp --verbose --delete #{self.ip}), :ignore_exit_status => true) ephemeral_arguments = Array.new ephemeral_arguments << %W(-o #{self.lxc_clone.name} -n #{self.lxc.name} -d) ephemeral_arguments << %W(--keep-data) if self.persist - ephemeral_arguments = ephemeral_arguments.flatten.compact + ephemeral_arguments.flatten!.compact! self.lxc_clone.start_ephemeral(ephemeral_arguments) end true end # Configure the container + # + # Configures the LXC subsystem for the container. + # + # @return [Boolean] True if successful. def configure self.domain ||= self.node.domain self.arch ||= detect_arch build_lxc_config(self.lxc.config)