Class: Sahara::Command::On

Inherits:
Object
  • Object
show all
Defined in:
lib/sahara/command/on.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sahara/command/on.rb', line 4

def execute

  options = {}

  opts = OptionParser.new do |opts|
    opts.banner = "Enters sandbox state"
    opts.separator ""
    opts.separator "Usage: vagrant sandbox on <vmname>"

  end

  # Parse the options
  argv = parse_options(opts)
  return if !argv

  with_target_vms(argv, :reverse => true) do |machine|

    ses = Sahara::Session::Factory.create(machine)
    if !ses.is_vm_created? then
      puts "[#{machine.name}] VM is not created"
      next
    end
    if !ses.is_snapshot_mode_on? then
      puts "[#{machine.name}] Starting sandbox mode..."
      ses.on
    else
      puts "[#{machine.name}] Already sandbox mode"
    end

  end
end