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
6 changes: 3 additions & 3 deletions lib/cisco_node_utils/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ def storm_control_multicast
end

def storm_control_multicast=(val)
return if val == storm_control_broadcast
return if val == storm_control_multicast
state = val == default_storm_control_multicast ? 'no' : ''
level = val == default_storm_control_multicast ? '' : val
config_set('interface', 'storm_control_multicast',
Expand All @@ -1102,7 +1102,7 @@ def storm_control_unicast
end

def storm_control_unicast=(val)
return if val == storm_control_broadcast
return if val == storm_control_unicast
state = val == default_storm_control_unicast ? 'no' : ''
level = val == default_storm_control_unicast ? '' : val
config_set('interface', 'storm_control_unicast',
Expand Down Expand Up @@ -2025,7 +2025,7 @@ def vpc_peer_link
end

def vpc_peer_link=(state)
return if vpc_peerlink == state
return if vpc_peer_link == state
no_cmd = (state ? '' : 'no')
config_set('interface', 'vpc_peer_link', name: @name, state: no_cmd)
end
Expand Down
12 changes: 5 additions & 7 deletions tests/test_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,16 @@ def validate_get_access_vlan(inttype_h)
# Validate the collection
inttype_h.each_value do |v|
interface = v[:interface]
next if interface.name[/vlan|loopback/]
interface.switchport_mode = :access

assert_equal(v[:access_vlan], interface.access_vlan,
'Error: Access vlan value not correct')

# get_default check
assert_equal(v[:default_access_vlan], interface.default_access_vlan,
'Error: Access vlan, default, value not correct')
interface.switchport_mode = :disabled
end
end

Expand Down Expand Up @@ -856,8 +859,7 @@ def test_negotiate_auto_loopback
config("interface #{int}")
interface = Interface.new(int)

assert_equal(interface.negotiate_auto, ref.default_value,
"Error: #{int} negotiate auto value mismatch")
assert_nil(interface.negotiate_auto)

assert_raises(Cisco::UnsupportedError) do
interface.negotiate_auto = true
Expand Down Expand Up @@ -1328,8 +1330,6 @@ def interface_test_data
default_shutdown: true,
switchport: :disabled,
default_switchport: :disabled,
access_vlan: DEFAULT_IF_ACCESS_VLAN,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For loopback and vlan interfaces, access_vlan is not an option. For ethernet and port-channel it is available if the switchport mode is turned on.

default_access_vlan: DEFAULT_IF_ACCESS_VLAN,
vrf_new: 'test2',
default_vrf: DEFAULT_IF_VRF,
}
Expand Down Expand Up @@ -1362,8 +1362,6 @@ def interface_test_data
default_shutdown: false,
switchport: platform == :ios_xr ? nil : :disabled,
default_switchport: platform == :ios_xr ? nil : :disabled,
access_vlan: DEFAULT_IF_ACCESS_VLAN,
default_access_vlan: DEFAULT_IF_ACCESS_VLAN,
vrf_new: 'test2',
default_vrf: DEFAULT_IF_VRF,
}
Expand Down Expand Up @@ -1411,12 +1409,12 @@ def test_ipv4_all_interfaces
validate_interfaces_not_empty
validate_get_switchport(inttype_h)
validate_description(inttype_h)
validate_get_access_vlan(inttype_h) unless platform == :ios_xr
validate_ipv4_address(inttype_h)
validate_ipv4_proxy_arp(inttype_h)
validate_ipv4_redirects(inttype_h)
validate_interface_shutdown(inttype_h)
validate_vrf(inttype_h)
validate_get_access_vlan(inttype_h) unless platform == :ios_xr
config(*cfg)
interface_ethernet_default(interfaces[1])
rescue Minitest::Assertion
Expand Down
12 changes: 12 additions & 0 deletions tests/test_interface_private_vlan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_switchport_pvlan_host
return
end

i.switchport_mode = :access
assert_equal(i.default_switchport_pvlan_host,
i.switchport_pvlan_host)

Expand All @@ -96,6 +97,7 @@ def test_switchport_pvlan_host

i.switchport_pvlan_host = false
refute(i.switchport_pvlan_host)
i.switchport_mode = :disabled
end

def test_sw_pvlan_promiscuous
Expand All @@ -107,6 +109,7 @@ def test_sw_pvlan_promiscuous
return
end

i.switchport_mode = :access
assert_equal(i.default_switchport_pvlan_promiscuous,
i.switchport_pvlan_promiscuous)

Expand All @@ -115,6 +118,7 @@ def test_sw_pvlan_promiscuous

i.switchport_pvlan_promiscuous = false
refute(i.switchport_pvlan_promiscuous)
i.switchport_mode = :disabled
end

def test_sw_pvlan_trunk_promiscuous
Expand All @@ -126,6 +130,7 @@ def test_sw_pvlan_trunk_promiscuous
return
end

i.switchport_mode = :access
assert_equal(i.default_switchport_pvlan_trunk_promiscuous,
i.switchport_pvlan_trunk_promiscuous)

Expand All @@ -134,6 +139,7 @@ def test_sw_pvlan_trunk_promiscuous

i.switchport_pvlan_trunk_promiscuous = false
refute(i.switchport_pvlan_trunk_promiscuous)
i.switchport_mode = :disabled
end

def test_sw_pvlan_trunk_secondary
Expand All @@ -145,6 +151,7 @@ def test_sw_pvlan_trunk_secondary
return
end

i.switchport_mode = :access
assert_equal(i.default_switchport_pvlan_trunk_secondary,
i.switchport_pvlan_trunk_secondary)

Expand All @@ -153,6 +160,7 @@ def test_sw_pvlan_trunk_secondary

i.switchport_pvlan_trunk_secondary = false
refute(i.switchport_pvlan_trunk_secondary)
i.switchport_mode = :disabled
end

# Helper to setup vlan associations
Expand Down Expand Up @@ -309,6 +317,7 @@ def test_sw_pvlan_trunk_allowed_vlan
return
end

i.switchport_mode = :access
default = i.default_switchport_pvlan_trunk_allowed_vlan
assert_equal(default, i.switchport_pvlan_trunk_allowed_vlan)

Expand All @@ -325,6 +334,7 @@ def test_sw_pvlan_trunk_allowed_vlan
vlans = '500-528,530,532,534,587,590-593,597-598,600,602,604'
i.switchport_pvlan_trunk_allowed_vlan = vlans
assert_equal(vlans, i.switchport_pvlan_trunk_allowed_vlan)
i.switchport_mode = :disabled
end

def test_sw_pvlan_trunk_native_vlan
Expand All @@ -336,6 +346,7 @@ def test_sw_pvlan_trunk_native_vlan
return
end

i.switchport_mode = :access
default = i.default_switchport_pvlan_trunk_native_vlan
assert_equal(default, i.switchport_pvlan_trunk_native_vlan)

Expand All @@ -344,5 +355,6 @@ def test_sw_pvlan_trunk_native_vlan

i.switchport_pvlan_trunk_native_vlan = default
assert_equal(default, i.switchport_pvlan_trunk_native_vlan)
i.switchport_mode = :disabled
end
end
6 changes: 1 addition & 5 deletions tests/test_interface_switchport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ def test_access_vlan

def test_access_vlan_sw_disabled
interface.switchport_mode = :disabled
if platform == :ios_xr
assert_nil(interface.access_vlan)
else
assert_equal(DEFAULT_IF_ACCESS_VLAN, interface.access_vlan)
end
assert_nil(interface.access_vlan)
end

def test_access_vlan_sw_trunk
Expand Down