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



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

def self.get_hosts_from_id(id)
  data = Conf.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.is_tag?(id)
    hosts = data['vms'][id]
  else
    hosts = [id].flatten
  end
  hosts
end

.get_hosts_from_sut_log(file) ⇒ Object



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

def self.get_hosts_from_sut_log(file)
  hosts = []
  File.open(file).each do |line|
    items = line.split("\t")
    hostname, tag = items[4].split(" ")
    short_host = hostname.split(".")[0]
    hosts << short_host
  end
  hosts
end

.get_options_hosts(hosts) ⇒ Object



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

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