Module: VagrantPlugins::Parallels::Cap

Defined in:
lib/vagrant-parallels/cap.rb

Class Method Summary collapse

Class Method Details

.forwarded_ports(machine) ⇒ Hash<Integer, Integer>

Reads the forwarded ports that currently exist on the machine itself.

This also may not match up with configured forwarded ports, because Vagrant auto port collision fixing may have taken place.

Returns:

  • (Hash<Integer, Integer>)

    Host => Guest port mappings.



11
12
13
14
15
16
17
18
19
# File 'lib/vagrant-parallels/cap.rb', line 11

def self.forwarded_ports(machine)
  return nil if machine.state.id != :running

  {}.tap do |result|
    machine.provider.driver.read_forwarded_ports.each do |fp|
      result[fp[:hostport]] = fp[:guestport]
    end
  end
end

.host_address(machine) ⇒ String

Returns host’s IP address that can be used to access the host machine from the VM.

Returns:

  • (String)

    Host’s IP address



25
26
27
28
29
30
# File 'lib/vagrant-parallels/cap.rb', line 25

def self.host_address(machine)
  shared_iface = machine.provider.driver.read_shared_interface
  return shared_iface[:ip] if shared_iface

  nil
end

.nic_mac_addresses(machine) ⇒ Hash<Integer, String>

Reads the network interface card MAC addresses and returns them.

Returns:

  • (Hash<Integer, String>)

    Adapter => MAC address



35
36
37
38
39
40
# File 'lib/vagrant-parallels/cap.rb', line 35

def self.nic_mac_addresses(machine)
  nic_macs = machine.provider.driver.read_mac_addresses

  # Make numeration starting from 1, as it is expected in Vagrant.
  Hash[nic_macs.map.with_index{ |mac, index| [index+1, mac] }]
end

.public_address(machine) ⇒ String

Returns guest’s IP address that can be used to access the VM from the host machine.

Returns:

  • (String)

    Guest’s IP address



46
47
48
49
50
51
52
# File 'lib/vagrant-parallels/cap.rb', line 46

def self.public_address(machine)
  return nil if machine.state.id != :running

  ssh_info = machine.ssh_info
  return nil if !ssh_info
  ssh_info[:host]
end

.snapshot_list(machine) ⇒ Array<String>

Returns a list of the snapshots that are taken on this machine.

Returns:

  • (Array<String>)

    Snapshot Name



57
58
59
# File 'lib/vagrant-parallels/cap.rb', line 57

def self.snapshot_list(machine)
  machine.provider.driver.list_snapshots(machine.id).keys
end