Class: VagrantPeach::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-peach/command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-peach/command.rb', line 3

def execute
  opts = OptionParser.new do |o|
    o.banner = "Usage: vagrant free-memory [--help]"
  end

  argv = parse_options(opts)

  with_target_vms(argv) do |machine|
    if machine.state.id != :running
      @env.ui.info("#{machine.name} is not running.")
      next
    end

    command = "grep MemFree /proc/meminfo | awk '{print $2}'"
    machine.communicate.execute(command) do |type, data|
      @env.ui.info(data)
    end
  end
  return 0
end