Class: VagrantPlugins::ESXi::CapAddress

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



24
25
26
# File 'lib/vagrant-vmware-esxi/command.rb', line 24

def self.synopsis
    "outputs the IP address of a guest."
end

Instance Method Details

#executeObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vagrant-vmware-esxi/command.rb', line 27

def execute
  opts = OptionParser.new do |o|
    o.banner = "Usage: vagrant address [name]"
  end

  argv = parse_options(opts)

  # Count total number of vms to print the IP
  totalvms = 0
  with_target_vms(argv) do
    totalvms += 1
  end

  if argv.length == 1 or totalvms == 1
    with_target_vms(argv, {:single_target=>true}) do |machine|
      machine.action(:address)
    end
  else
    with_target_vms(argv) do |machine|
      machine.action(:address_multi)
    end
  end
end