Sha256: 330a95bef25a8c4c30c0f575906b7147353b08880c51aa09a65bba0dd4750cd9

Contents?: true

Size: 1.37 KB

Versions: 47

Compression:

Stored size: 1.37 KB

Contents

module ForemanDiscovery
  class FactParser < ::PuppetFactParser
    def suggested_primary_interface(host)
      raise(::Foreman::Exception.new(N_("Discovery fact parser does not work with non-discovery host '%{host}'") %
        {:host => host})) if host.type != "Host::Discovered"
      raise(::Foreman::Exception.new(N_("Discovered host '%{host}' has all NICs filtered out, filter: %{filter}") %
        {:host => host, :filter => Setting[:ignored_interface_identifiers]})) if interfaces.size == 0
      bootif_mac = FacterUtils::bootif_mac(facts).try(:downcase)
      detected = interfaces.detect { |_, values| values[:macaddress].try(:downcase) == bootif_mac && (values[:ipaddress].present? || values[:ipaddress6].present?) }
      Rails.logger.debug "Discovery fact parser detected primary interface: #{detected}"
      # return the detected interface as array [name, facts]
      detected || raise(::Foreman::Exception.new(N_("Unable to find primary NIC with %{mac} specified via '%{fact}', NIC filter: %{filter}") %
        {:mac => bootif_mac, :fact => FacterUtils::bootif_name, :filter => Setting[:ignored_interface_identifiers]}))
    end

    # ignores 'ignore_puppet_facts_for_provisioning' setting
    def parse_interfaces?
      true
    end

    # ignores 'update_subnets_from_facts' setting
    def get_facts_for_interface(interface)
      super.merge(keep_subnet: true)
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
foreman_discovery-25.1.0 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-25.0.1 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-25.0.0 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-24.0.2 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-23.0.2 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-24.0.1 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-24.0.0 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-23.0.1 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-23.0.0 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-22.0.4 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-21.0.5 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-22.0.2 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-21.0.4 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-21.0.3 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-21.0.2 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-19.0.5 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-19.0.4 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-21.0.1 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-19.0.3 app/services/foreman_discovery/fact_parser.rb
foreman_discovery-21.0.0 app/services/foreman_discovery/fact_parser.rb