Class: ForemanDiscovery::FactToCategoryResolver

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::NumberHelper
Defined in:
app/services/foreman_discovery/fact_to_category_resolver.rb

Constant Summary collapse

CATEGORIES_NAMES =
[N_("Highlights"),
N_("Storage"),
N_("Hardware"),
N_("Network"),
N_("Software"),
N_("IPMI"),
N_("Miscellaneous")].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ FactToCategoryResolver



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/services/foreman_discovery/fact_to_category_resolver.rb', line 15

def initialize(host)
  categories = i[highlights storage hardware network software ipmi]

  @regex_array = categories.map do |category|
    settings_category = settings_discovery_fact_prefix(category)
    if settings_category.empty?
      send(category)
    else
      Regexp.new(settings_category)
    end
  end

  @regex_array << false

  @categories = []

  @interfaces = host.interfaces.map do |interface|
    {
      identifier: interface["identifier"],
      type: interface["type"],
      mac: interface["mac"],
      ip: interface["ip"],
      ip6: interface["ip6"],
      primary: interface["primary"],
      provision: interface["provision"],
    }
  end

  assign_facts(host)
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



5
6
7
# File 'app/services/foreman_discovery/fact_to_category_resolver.rb', line 5

def categories
  @categories
end

#interfacesObject (readonly)

Returns the value of attribute interfaces.



5
6
7
# File 'app/services/foreman_discovery/fact_to_category_resolver.rb', line 5

def interfaces
  @interfaces
end