Method: Beaker::Shared::HostManager#hosts_with_name

Defined in:
lib/beaker/shared/host_manager.rb

#hosts_with_name(hosts, name = nil) ⇒ Array<Host>

Find hosts from a given array of hosts that all have the desired name, match against host name, vmhostname and ip (the three valid ways to identify an individual host)

Parameters:

  • hosts (Array<Host>)

    The hosts to examine

  • name (String) (defaults to: nil)

    The hosts returned will have this name/vmhostname/ip

Returns:

  • (Array<Host>)

    The hosts that have the desired name/vmhostname/ip



24
25
26
27
28
# File 'lib/beaker/shared/host_manager.rb', line 24

def hosts_with_name(hosts, name = nil)
  hosts.select do |host|
    name.nil? or host.name&.start_with?(name) or host[:vmhostname]&.start_with?(name) or host[:ip]&.start_with?(name)
  end
end