Class: ForemanProbing::FactParser
- Inherits:
-
FactParser
- Object
- FactParser
- ForemanProbing::FactParser
- Defined in:
- app/services/foreman_probing/fact_parser.rb
Instance Attribute Summary collapse
-
#facts ⇒ Object
readonly
Returns the value of attribute facts.
Instance Method Summary collapse
-
#architecture ⇒ Object
We don’t know anything about those.
- #domain ⇒ Object
- #environment ⇒ Object
- #get_facts_for_interface(interface) ⇒ Object
-
#get_interfaces ⇒ Object
rubocop:disable Style/AccessorMethodName.
-
#initialize(facts) ⇒ FactParser
constructor
A new instance of FactParser.
- #ipmi_interface ⇒ Object
- #model ⇒ Object
- #operatingsystem ⇒ Object
- #support_interfaces_parsing? ⇒ Boolean
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
#facts ⇒ Object (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
#architecture ⇒ Object
We don’t know anything about those
11 |
# File 'app/services/foreman_probing/fact_parser.rb', line 11 def architecture; end |
#domain ⇒ Object
12 |
# File 'app/services/foreman_probing/fact_parser.rb', line 12 def domain; end |
#environment ⇒ Object
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_interfaces ⇒ Object
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_interface ⇒ Object
21 |
# File 'app/services/foreman_probing/fact_parser.rb', line 21 def ipmi_interface; end |
#model ⇒ Object
14 |
# File 'app/services/foreman_probing/fact_parser.rb', line 14 def model; end |
#operatingsystem ⇒ Object
15 |
# File 'app/services/foreman_probing/fact_parser.rb', line 15 def ; end |
#support_interfaces_parsing? ⇒ Boolean
17 18 19 |
# File 'app/services/foreman_probing/fact_parser.rb', line 17 def support_interfaces_parsing? true end |