Class: ForemanProbing::FactParser

Inherits:
FactParser
  • Object
show all
Defined in:
app/services/foreman_probing/fact_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facts) ⇒ FactParser

Returns a new instance of FactParser.



6
7
8
# File 'app/services/foreman_probing/fact_parser.rb', line 6

def initialize(facts)
  @facts = HashWithIndifferentAccess.new(facts)
end

Instance Attribute Details

#factsObject (readonly)

Returns the value of attribute facts.



4
5
6
# File 'app/services/foreman_probing/fact_parser.rb', line 4

def facts
  @facts
end

Instance Method Details

#architectureObject

We don’t know anything about those



11
# File 'app/services/foreman_probing/fact_parser.rb', line 11

def architecture; end

#domainObject



12
# File 'app/services/foreman_probing/fact_parser.rb', line 12

def domain; end

#environmentObject



13
# File 'app/services/foreman_probing/fact_parser.rb', line 13

def environment; end

#get_facts_for_interface(interface) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'app/services/foreman_probing/fact_parser.rb', line 31

def get_facts_for_interface(interface)
  addresses = facts['addresses']
  result = { :ipaddress => 'ipv4',
           :ip6address => 'ipv6',
           :macaddress => 'hwaddr' }.reduce({}) do |acc, (key, kind)|
    acc.merge(key => address_by_identifier(addresses, kind, interface))
  end
  HashWithIndifferentAccess.new(result)
end

#get_interfacesObject

rubocop:disable Style/AccessorMethodName



23
24
25
26
27
28
29
# File 'app/services/foreman_probing/fact_parser.rb', line 23

def get_interfaces # rubocop:disable Style/AccessorMethodName
  identifiers = facts['addresses'].values_at(*%w(ipv4 ipv6 hwaddr))
    .compact.map do |hash|
      hash.values.map { |value| value['identifier'] }
    end
  identifiers.flatten.compact.uniq
end

#ipmi_interfaceObject



21
# File 'app/services/foreman_probing/fact_parser.rb', line 21

def ipmi_interface; end

#modelObject



14
# File 'app/services/foreman_probing/fact_parser.rb', line 14

def model; end

#operatingsystemObject



15
# File 'app/services/foreman_probing/fact_parser.rb', line 15

def operatingsystem; end

#support_interfaces_parsing?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/services/foreman_probing/fact_parser.rb', line 17

def support_interfaces_parsing?
  true
end