diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b48c3db..4591feef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Changelog * `level` * Extend syslog_server with attribute: * `facility` +* Extend interface with attributes: + * `ipv6_redirects` ### Changed diff --git a/lib/cisco_node_utils/cmd_ref/interface.yaml b/lib/cisco_node_utils/cmd_ref/interface.yaml index 3d7c9698..aacab245 100644 --- a/lib/cisco_node_utils/cmd_ref/interface.yaml +++ b/lib/cisco_node_utils/cmd_ref/interface.yaml @@ -306,6 +306,13 @@ ipv6_dhcp_relay_src_intf: set_value: " ipv6 dhcp relay source-interface " default_value: false +ipv6_redirects: + _exclude: [ios_xr] + kind: boolean + get_value: '/^((?:no )?ipv6 redirects)$/' + set_value: " ipv6 redirects" + default_value: true + load_interval_counter_1_delay: _exclude: [ios_xr] kind: int diff --git a/lib/cisco_node_utils/interface.rb b/lib/cisco_node_utils/interface.rb index a25d8e1a..f4fb7719 100644 --- a/lib/cisco_node_utils/interface.rb +++ b/lib/cisco_node_utils/interface.rb @@ -1,6 +1,6 @@ # November 2015, Chris Van Heuveln # -# Copyright (c) 2015-2017 Cisco and/or its affiliates. +# Copyright (c) 2015-2018 Cisco and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -834,6 +834,21 @@ def default_ipv6_dhcp_relay_src_intf config_get_default('interface', 'ipv6_dhcp_relay_src_intf') end + def ipv6_redirects + config_get('interface', 'ipv6_redirects', name: @name) + end + + def ipv6_redirects=(redirects) + check_switchport(:disabled) + no_cmd = (redirects ? '' : 'no') + config_set('interface', 'ipv6_redirects', + name: @name, state: no_cmd) + end + + def default_ipv6_redirects + config_get_default('interface', 'ipv6_redirects') + end + def feature_lacp? config_get('interface', 'feature_lacp') end diff --git a/tests/test_interface.rb b/tests/test_interface.rb index 73457173..8966b449 100755 --- a/tests/test_interface.rb +++ b/tests/test_interface.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2017 Cisco and/or its affiliates. +# Copyright (c) 2013-2018 Cisco and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1250,6 +1250,27 @@ def test_ipv4_redirects 'Error: ip redirects default get value mismatch') end + def test_ipv6_redirects + interface = create_interface + interface.switchport_mode = :disabled if platform == :nexus + + # check default value + assert_equal(interface.default_ipv6_redirects, interface.ipv6_redirects, + 'Error: ipv6 redirects default get value mismatch') + + # set with value false + interface.ipv6_redirects = false + assert_equal(interface.ipv6_redirects, false) + + # set with value true + interface.ipv6_redirects = true + assert_equal(interface.ipv6_redirects, true) + + # get default and set + interface.ipv6_redirects = interface.default_ipv6_redirects + assert_equal(interface.ipv6_redirects, interface.default_ipv6_redirects) + end + def config_from_hash(inttype_h) inttype_h.each do |k, v| config('feature interface-vlan') if (/^Vlan\d./).match(k.to_s)