Skip to content

Commit

Permalink
Drop eth0 from MiqServer.get_network_information
Browse files Browse the repository at this point in the history
Don't depend on having an interface named eth0 for the
get_network_information method.

MiqEnvironment already has logic for finding a non-loopback interface
with an ipv4 or ipv6 address.  This doesn't work great with multiple
interfaces but it does work on our default appliances with a single
non lo iface.
  • Loading branch information
agrare committed Jul 30, 2024
1 parent 80ff67c commit 28f15d7
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions app/models/miq_server/environment_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ module MiqServer::EnvironmentManagement
module ClassMethods
def get_network_information
ipaddr = hostname = mac_address = nil

begin
if MiqEnvironment::Command.is_appliance?
eth0 = LinuxAdmin::NetworkInterface.new("eth0")

ipaddr = eth0.address || eth0.address6
hostname = LinuxAdmin::Hosts.new.hostname
mac_address = eth0.mac_address
else
ipaddr = MiqEnvironment.local_ip_address
hostname = MiqEnvironment.fully_qualified_domain_name
mac_address = UUIDTools::UUID.mac_address.dup
end
rescue
ipaddr = MiqEnvironment.local_ip_address
hostname = MiqEnvironment.fully_qualified_domain_name
mac_address = UUIDTools::UUID.mac_address.dup
rescue => err
_log.warn("Failed to get network information: #{err}")
_log.log_backtrace(err)
end

[ipaddr, hostname, mac_address]
Expand Down

0 comments on commit 28f15d7

Please sign in to comment.