Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/fact_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class FactParser
delegate :logger, :to => :Rails
VIRTUAL = /\A([a-z0-9]+)[_|.|:]([a-z0-9]+)\Z/
BRIDGES = /\A(vir|lxc)?br(\d+|-[a-z0-9]+)(_nic)?\Z/
BONDS = /\A(bond[\d-].*)\Z|\A(lagg\d)\Z/
BONDS = /\A(bond\d+|bond-[a-z0-9-]+|lagg\d+)\Z/
ALIASES = /(\A[a-z0-9.]+):([a-z0-9]+)\Z/
VLANS = /\A([a-zA-Z0-9]+)\.([0-9]+)\Z/
VIRTUAL_NAMES = /#{ALIASES}|#{VLANS}|#{VIRTUAL}|#{BRIDGES}|#{BONDS}/
Expand Down
9 changes: 9 additions & 0 deletions test/models/host_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ class HostTest < ActiveSupport::TestCase
refute host.primary_interface.managed?
end

test "should identify a VLAN on a bond as a managed primary interface" do
host = FactoryBot.build(:host)
parser = mock('parser')
parser.expects(:parse_interfaces?).returns(true)
parser.expects(:suggested_primary_interface).with(host).returns(['bond0.601', {}])

assert_equal 'Nic::Managed', host.primary_interface_type(parser)
end

test "should ignore link-local ipv6 addresses when importing from facts" do
host = FactoryBot.create(:host, :mac => '00:00:11:22:11:22')

Expand Down
5 changes: 5 additions & 0 deletions test/unit/fact_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ class FactParserTest < ActiveSupport::TestCase
assert_match FactParser::BONDS, 'bond-foo'
assert_match FactParser::BONDS, 'bond-foo-bar'
assert_match FactParser::BONDS, 'lagg0'
assert_match FactParser::BONDS, 'lagg10'
refute_match FactParser::BONDS, 'bond'
refute_match FactParser::BONDS, 'bonding'
refute_match FactParser::BONDS, 'bond0.0'
refute_match FactParser::BONDS, 'bond0:0'
refute_match FactParser::BONDS, 'bond0.0:0'
refute_match FactParser::BONDS, 'bond0_0'
end

test "bridge regexp matches bridges" do
Expand Down
Loading