Class: VagrantFreeMemory::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-free-memory/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
23
24
# File 'lib/vagrant-free-memory/command.rb', line 3

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

  argv = parse_options(opts)

  command = "grep MemFree /proc/meminfo | awk '{print $2}'"

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

    machine.communicate.execute(command) do |type, data|
      @env.ui.info(data)
    end
  end

  return 0
end