Sha256: 73fee8dc4fd804be9f050a52d23d7678ad1ac586f018ef98ac26232bd416285b

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

class TestLab
  class Container

    module Actions

      # Create the container
      def create
        @ui.logger.debug { "Container Create: #{self.id} " }

        please_wait(:ui => @ui, :message => format_object_action(self, 'Create', :green)) do
          self.domain  ||= self.node.labfile.config[:domain]
          self.distro  ||= "ubuntu"
          self.release ||= "precise"

          self.arch    ||= detect_arch

          self.lxc.config.clear
          self.lxc.config['lxc.utsname'] = self.id
          self.lxc.config['lxc.arch'] = self.arch
          self.lxc.config.networks = build_lxc_network_conf(self.interfaces)
          self.lxc.config.save

          self.lxc.create(*create_args)
        end
      end

      # Destroy the container
      def destroy
        @ui.logger.debug { "Container Destroy: #{self.id} " }

        please_wait(:ui => @ui, :message => format_object_action(self, 'Destroy', :red)) do
          self.lxc.destroy
        end
      end

      # Start the container
      def up
        @ui.logger.debug { "Container Up: #{self.id} " }

        please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do
          self.lxc.start
        end
      end

      # Stop the container
      def down
        @ui.logger.debug { "Container Down: #{self.id} " }

        please_wait(:ui => @ui, :message => format_object_action(self, 'Down', :red)) do
          self.lxc.stop
        end
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
testlab-0.2.1 lib/testlab/container/actions.rb
testlab-0.2.0 lib/testlab/container/actions.rb