Skip to content

Commit

Permalink
(FACT-2656) Added dhcp for primary interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-miclea committed Jul 9, 2020
1 parent 68264e7 commit aa767ff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
17 changes: 17 additions & 0 deletions lib/facts/solaris/networking/dhcp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Facts
module Solaris
module Networking
class Dhcp
FACT_NAME = 'networking.dhcp'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Networking.resolve(:dhcp)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/facts/solaris/networking/interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Interfaces
FACT_NAME = 'networking.interfaces'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::NetworkingInterfaces.resolve(:interfaces)
fact_value = Facter::Resolvers::Solaris::Networking.resolve(:interfaces)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
Expand Down
8 changes: 8 additions & 0 deletions lib/resolvers/solaris/networking_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def read_facts(fact_name)
end

@fact_list = { interfaces: @fact_list }
primary_interface
extract_dhcp(@fact_list[:primary_interface])
@fact_list[fact_name]
end

Expand Down Expand Up @@ -132,6 +134,12 @@ def primary_interface

@fact_list[:primary_interface] = result.match(/interface: (.+)/)&.captures&.first
end

def extract_dhcp(interface_name)
result = Facter::Core::Execution.execute("dhcpinfo -i #{interface_name} ServerID", logger: log)

@fact_list[:dhcp] = result.chomp
end
end
end
end
Expand Down

0 comments on commit aa767ff

Please sign in to comment.