Class: Hosts

Inherits:
Object
  • Object
show all
Defined in:
lib/floatyhelper/hosts.rb

Class Method Summary collapse

Class Method Details

.get_hosts_from_id(id) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/floatyhelper/hosts.rb', line 23

def self.get_hosts_from_id(id)
  data = Config.load_data
  if id == 'all'
    hosts = []
    data['vms'].each do |_tag, hostlist|
      hostlist.each do |host|
        hosts << host unless hosts.include?(host)
      end
    end
  elsif Groups.tag?(id)
    hosts = data['vms'][id]
  else
    hosts = [id].flatten
  end
  hosts
end

.get_hosts_from_sut_log(file) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/floatyhelper/hosts.rb', line 7

def self.get_hosts_from_sut_log(file)
  hosts = []
  File.open(file).each do |line|
    items = line.split("\t")
    hostname, tag = items[4].split # rubocop:disable Lint/UselessAssignment
    short_host = hostname.split('.')[0]
    hosts << short_host
  end
  hosts
end

.get_options_hosts(hosts) ⇒ Object



18
19
20
21
# File 'lib/floatyhelper/hosts.rb', line 18

def self.get_options_hosts(hosts)
  hosts = hosts.split(',')
  hosts.map { |h| h.split('.')[0] }
end