Skip to content
Merged
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
20 changes: 10 additions & 10 deletions lib/cisco_node_utils/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ def self.fabric_supported?
def self.fabric_forwarding_enable
return if fabric_forwarding_enabled?
Feature.fabric_enable if Feature.fabric_supported?
config_set('feature', 'fabric_forwarding')
# The feature fabric-forwarding cli is required in some older nxos images
# but is not present in newer images because nv_overlay_evpn handles
# both features; therefore feature fabric-forwarding is best-effort
# and ignored on cli failure.
begin
config_set('feature', 'fabric_forwarding')
rescue Cisco::CliError
CiscoLogger.debug '"feature fabric forwarding" CLI was rejected'
end
end

def self.fabric_forwarding_enabled?
Expand All @@ -80,15 +88,7 @@ def self.nv_overlay_enabled?

# ---------------------------
def self.nv_overlay_evpn_enable
# The feature fabric-forwarding cli is required in some older nxos images
# but is not present in newer images because nv_overlay_evpn handles
# both features; therefore feature fabric-forwarding is best-effort
# and ignored on cli failure.
begin
config_set('feature', 'fabric_forwarding')
rescue Cisco::CliError
CiscoLogger.debug '"feature fabric forwarding" CLI was rejected'
end
return if nv_overlay_evpn_enabled?
config_set('feature', 'nv_overlay_evpn')
end

Expand Down
9 changes: 6 additions & 3 deletions lib/cisco_node_utils/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,15 @@ def fabric_forwarding_anycast_gateway=(state)
'fabric_forwarding_anycast_gateway', @name, no_cmd)
fail if fabric_forwarding_anycast_gateway.to_s != state.to_s
rescue Cisco::CliError => e
info = "[#{@name}] '#{e.command}' : #{e.clierror}"
raise "#{info} 'fabric_forwarding_anycast_gateway' can only be " \
'configured on a vlan interface' unless /vlan/.match(@name)
anycast_gateway_mac = OverlayGlobal.new.anycast_gateway_mac
if anycast_gateway_mac.nil? || anycast_gateway_mac.empty?
raise "[#{@name}] '#{e.command}' : #{e.clierror}
Anycast gateway mac needs to be configured
before configuring forwarding mode under interface"
raise "#{info} Anycast gateway mac must be configured " \
'before configuring forwarding mode under interface'
end
raise info
end

def default_fabric_forwarding_anycast_gateway
Expand Down
3 changes: 2 additions & 1 deletion lib/cisco_node_utils/overlay_global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def dup_host_ip_addr_detection_timeout
end

def dup_host_ip_addr_detection_set(host_moves, timeout)
Feature.nv_overlay_evpn_enable unless Feature.nv_overlay_evpn_enabled?
Feature.nv_overlay_evpn_enable
if host_moves == default_dup_host_ip_addr_detection_host_moves &&
timeout == default_dup_host_ip_addr_detection_timeout
state = 'no'
Expand Down Expand Up @@ -132,6 +132,7 @@ def anycast_gateway_mac=(mac_addr)
fail TypeError unless mac_addr.is_a?(String)

Feature.nv_overlay_evpn_enable
Feature.fabric_forwarding_enable
if mac_addr == default_anycast_gateway_mac
state = 'no'
mac_addr = ''
Expand Down
19 changes: 7 additions & 12 deletions tests/test_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,7 @@ def test_interface_fabric_forwarding_anycast_gateway
foo = OverlayGlobal.new
foo.anycast_gateway_mac = '1223.3445.5668'

# 1. Testing default
int.fabric_forwarding_anycast_gateway =
int.default_fabric_forwarding_anycast_gateway
# 1. Testing default for newly created vlan
assert_equal(int.default_fabric_forwarding_anycast_gateway,
int.fabric_forwarding_anycast_gateway)

Expand All @@ -980,19 +978,16 @@ def test_interface_fabric_forwarding_anycast_gateway
int.fabric_forwarding_anycast_gateway = false
refute(int.fabric_forwarding_anycast_gateway)

# 4. Removing fabric forwarding anycast gateway mac
foo.anycast_gateway_mac = foo.default_anycast_gateway_mac
assert_raises(RuntimeError) { int.fabric_forwarding_anycast_gateway = true }

# 5. Removing feature fabric forwarding
config('no feature fabric forwarding')
assert_raises(RuntimeError) { int.fabric_forwarding_anycast_gateway = true }

# 6. Attempting to configure on a non-vlan interface
# 4. Attempt to configure on a non-vlan interface
nonvlanint = create_interface
assert_raises(RuntimeError) do
nonvlanint.fabric_forwarding_anycast_gateway = true
end

# 5. Attempt to set 'fabric forwarding anycast gateway' while the
# overlay gateway mac is not set.
foo.anycast_gateway_mac = foo.default_anycast_gateway_mac
assert_raises(RuntimeError) { int.fabric_forwarding_anycast_gateway = true }
end

def test_interface_ipv4_proxy_arp
Expand Down