Sha256: c3f4f678cd21115dca0b4e160f9a5a106317bc3a925ea14562529b11a6a0d56a

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

module Vagrant
  class VM < Actions::Runner
    include Vagrant::Util

    attr_accessor :env
    attr_accessor :vm
    attr_accessor :from

    class << self
      # Finds a virtual machine by a given UUID and either returns
      # a Vagrant::VM object or returns nil.
      def find(uuid)
        vm = VirtualBox::VM.find(uuid)
        return nil if vm.nil?
        new(vm)
      end
    end

    def initialize(vm=nil)
      @vm = vm
    end

    def uuid
      vm ? vm.uuid : nil
    end

    def reload!
      @vm = VirtualBox::VM.find(@vm.uuid)
    end

    def package(out_path, include_files=[])
      add_action(Actions::VM::Export)
      add_action(Actions::VM::Package, out_path, include_files)
      execute!
    end

    def start
      return if @vm.running?

      execute!(Actions::VM::Start)
    end

    def destroy
      execute!(Actions::VM::Down)
    end

    def suspend
      execute!(Actions::VM::Suspend)
    end

    def resume
      execute!(Actions::VM::Resume)
    end

    def saved?
      @vm.saved?
    end

    def powered_off?; @vm.powered_off? end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
vagrantup-0.3.4 lib/vagrant/vm.rb
vagrantup-0.3.3 lib/vagrant/vm.rb
vagrantup-0.3.2 lib/vagrant/vm.rb
vagrantup-0.3.1 lib/vagrant/vm.rb
vagrantup-0.3.0 lib/vagrant/vm.rb
vagrant-0.3.4 lib/vagrant/vm.rb
vagrant-0.3.3 lib/vagrant/vm.rb
vagrant-0.3.2 lib/vagrant/vm.rb
vagrant-0.3.1 lib/vagrant/vm.rb
vagrant-0.3.0 lib/vagrant/vm.rb
bmabey-vagrant-0.2.0 lib/vagrant/vm.rb