diff --git a/app/controllers/discovered_hosts_controller.rb b/app/controllers/discovered_hosts_controller.rb index dc6bec1a..eb9cba53 100644 --- a/app/controllers/discovered_hosts_controller.rb +++ b/app/controllers/discovered_hosts_controller.rb @@ -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 diff --git a/app/services/foreman_discovery/fact_to_category_resolver.rb b/app/services/foreman_discovery/fact_to_category_resolver.rb index 1b57cc95..6c06e1af 100644 --- a/app/services/foreman_discovery/fact_to_category_resolver.rb +++ b/app/services/foreman_discovery/fact_to_category_resolver.rb @@ -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) @@ -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