Skip to content

Commit

Permalink
Support subnet6 facts in FactToCategoryResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
stejskalleos committed Jan 21, 2025
1 parent fd64b8a commit 74f3ca6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
7 changes: 0 additions & 7 deletions app/controllers/discovered_hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,6 @@ def skip_bullet
Bullet.enable = true if defined? Bullet
end

def add_custom_facts
unless @host.primary_interface.subnet.nil?
discovery_subnet = "#{@host.primary_interface.subnet.name} (#{@host.primary_interface.subnet.network})"
assign_fact_to_category("discovery_subnet", discovery_subnet)
end
end

def process_warning(hash = {})
warning hash[:warning_msg]
end
Expand Down
13 changes: 9 additions & 4 deletions app/services/foreman_discovery/fact_to_category_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ def assign_facts(host)
assign_fact_to_category(key, value)
end

return if host.primary_interface.subnet.nil?

discovery_subnet = "#{host.primary_interface.subnet.name} (#{host.primary_interface.subnet.network})"
assign_fact_to_category("discovery_subnet", discovery_subnet)
subnets_facts(host.primary_interface)
end

def assign_fact_to_category(key, value)
Expand All @@ -75,6 +72,14 @@ def assign_fact_to_category(key, value)
end
end

def subnets_facts(iface)
subnet4 = iface.subnet
subnet6 = iface.subnet6

assign_fact_to_category("discovery_subnet", "#{subnet4.name} (#{subnet4.network})") if subnet4
assign_fact_to_category("discovery_subnet6", "#{subnet6.name} (#{subnet6.network})") if subnet6
end

def highlights
/^(productname|memorysize|manufacturer|architecture|macaddress$|processorcount|physicalprocessorcount|discovery_subnet|discovery_boot|ipaddress$)/
end
Expand Down

0 comments on commit 74f3ca6

Please sign in to comment.