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



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

def hosts_with_name(hosts, name = nil)
  hosts.select do |host|
    name.nil? or host.name =~ /\A#{name}/ or host[:vmhostname] =~ /\A#{name}/ or host[:ip] =~ /\A#{name}/
  end
end