Sha256: 763d9dd1d9df2a68947ec7840fef5c68170f52fc4a42557a5fd2686c4427fee6

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

require 'linecook/commands/vbox_command'

module Linecook
  module Commands
    
    # :startdoc::desc start a vm
    #
    # Starts one or more VirtualBox virtual machines, and resets to a snapshot
    # if provided. By default all virtual machines configured in config/ssh
    # will be reset and started in this way.
    class Start < VboxCommand
      config :type, 'headless'             # vm type (headless|gui)
      config :snapshot, '', :short => :s   # start snapshot
      config :socket, false, &c.flag
      
      def process(*hosts)
        vm_names = resolve_vm_names(hosts)
        each_vm_name(vm_names) do |vm_name|
          if running?(vm_name)
            stop(vm_name)
            sleep 0.5
          end
          
          unless snapshot.empty?
            restore(vm_name, snapshot)
          end
          
          start(vm_name, type)
          start_ssh_socket(vm_name) if socket
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
linecook-1.2.1 lib/linecook/commands/start.rb
linecook-1.2.0 lib/linecook/commands/start.rb
linecook-1.1.0 lib/linecook/commands/start.rb
linecook-1.0.0 lib/linecook/commands/start.rb