Skip to content

Add networking report#990

Merged
ehelms merged 6 commits intotheforeman:masterfrom
adamruzicka:report-net
May 6, 2025
Merged

Add networking report#990
ehelms merged 6 commits intotheforeman:masterfrom
adamruzicka:report-net

Conversation

@adamruzicka
Copy link
Copy Markdown
Contributor

@adamruzicka adamruzicka commented Mar 7, 2025

Rather than trying to answer the loosely defined "are we running ipv4-only, ipv6-only or dualstack?" question directly, the aim here is to collect enough data to be able to answer the question later, depending on how exactly we define it.

# foreman-maintain report generate | grep -e ipv -e dualstack
subnet_ipv4_count: 0
subnet_ipv6_count: 0
hosts_with_ipv4only_interface_count: 5
hosts_with_ipv6only_interface_count: 0
hosts_with_dualstack_interface_count: 0
foreman_interfaces_ipv4only_count: 1
foreman_interfaces_ipv6only_count: 0
foreman_interfaces_dualstack_count: 0
setting_remote_execution_connect_by_ip_prefer_ipv6: false
setting_discovery_prefer_ipv6: true

I was also thinking about further scoping the hosts_with_{ipv4-only,ipv6-only,dualstack}_interace_count by the flag of the interface (primary, provision and so on), but that would probably be too granular.

I also though about including the ipv4 vs ipv6 preference settings (remote_execution_connect_by_ip_prefer_ipv6, discovery_prefer_ipv6), but we can already infer that from the list of modified settings.

@adamruzicka
Copy link
Copy Markdown
Contributor Author

@ShimShtein @ares any thoughts on this?

@ShimShtein
Copy link
Copy Markdown
Member

but we can already infer that from the list of modified settings

It's quite painful to look back for changed settings, so I think it would be OK to duplicate the current setting value here.

hosts_with_ipv6-only_interface_count

Having mixed - and _ feels weird, even though I understand where it comes from.

by the flag of the interface (primary, provision and so on)

Agreed, at least theoretically it should add cardinality, which is not desired.

@adamruzicka
Copy link
Copy Markdown
Contributor Author

@ShimShtein ready for another round

@adamruzicka adamruzicka mentioned this pull request Apr 11, 2025
5 tasks
def subnet_counts_by_type
%w[ipv4 ipv6].each do |type|
data_field("subnet_#{type}_count") do
sql_count("subnets where type = 'Subnet::Ipv#{type}'")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will generate Subnet::Ipvipv6

INNER JOIN nics on nics.host_id = hosts.id
WHERE #{condition}
SQL
data_field("hosts_with_#{kind}_interface_count") { sql_count(query) }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, for host with two nics, you will get 2 records in the joined table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right, fixed

@ehelms ehelms merged commit e929c46 into theforeman:master May 6, 2025
8 checks passed
@adamruzicka adamruzicka deleted the report-net branch May 6, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants