Skip to content

Commit

Permalink
(FACT-2736) Add missing require and log messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanIrimie committed Aug 4, 2020
1 parent fe1fb4e commit 155f93f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/facter/resolvers/networking_linux_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class << self
private

def post_resolve(fact_name)
log.debug('in networking_linux_resolver')
@fact_list.fetch(fact_name) { retrieve_network_info(fact_name) }

@fact_list[fact_name]
Expand All @@ -36,12 +37,17 @@ def retrieve_interfaces_mac_and_mtu
end

def retrieve_interface_info
log.debug('retrieve_interface_info')
output = Facter::Core::Execution.execute('ip -o address', logger: log)
log.debug("ip -o address result is:\n#{output}")

interfaces = {}

output.each_line do |ip_line|
ip_tokens = ip_line.split(' ')

log.debug("ip_tokens = #{ip_tokens}")
log.debug("interfaces = #{interfaces}")
fill_ip_v4_info!(ip_tokens, interfaces)
fill_io_v6_info!(ip_tokens, interfaces)
find_dhcp!(ip_tokens, interfaces)
Expand Down Expand Up @@ -93,10 +99,15 @@ def search_internal_leases(interface_name)
end

def fill_ip_v4_info!(ip_tokens, network_info)
log.debug('fill_ip_v4_info!')
return unless ip_tokens[2].casecmp('inet').zero?

interface_name, ip4_address, ip4_mask_length = retrieve_name_and_ip_info(ip_tokens)

log.debug("interface_name = #{interface_name}\n" \
"ip4_address = #{ip4_address}\n" \
"ip4_mask_length = #{ip4_mask_length}")

binding = ::Resolvers::Utils::Networking.build_binding(ip4_address, ip4_mask_length)
build_network_info_structure!(network_info, interface_name, :bindings)

Expand Down
2 changes: 2 additions & 0 deletions lib/facter/resolvers/utils/networking.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'ipaddr'

module Resolvers
module Utils
module Networking
Expand Down
2 changes: 0 additions & 2 deletions lib/facter/resolvers/windows/networking_resolver.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'ipaddr'

module Facter
module Resolvers
class Networking < BaseResolver
Expand Down

0 comments on commit 155f93f

Please sign in to comment.