cisco_node_utils 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/README.md +8 -7
  4. data/docs/README-maintainers.md +0 -1
  5. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +2 -2
  6. data/lib/cisco_node_utils/bgp.rb +2 -2
  7. data/lib/cisco_node_utils/cisco_cmn_utils.rb +16 -0
  8. data/lib/cisco_node_utils/client/utils.rb +7 -1
  9. data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +12 -12
  10. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +35 -7
  11. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +1 -1
  12. data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +4 -4
  13. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +1 -1
  14. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +1 -1
  15. data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +1 -1
  16. data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +1 -1
  17. data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +5 -5
  18. data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +1 -1
  19. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +5 -5
  20. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +1 -1
  21. data/lib/cisco_node_utils/cmd_ref/feature.yaml +8 -3
  22. data/lib/cisco_node_utils/cmd_ref/hsrp_global.yaml +25 -0
  23. data/lib/cisco_node_utils/cmd_ref/interface.yaml +65 -14
  24. data/lib/cisco_node_utils/cmd_ref/interface_hsrp_group.yaml +117 -0
  25. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +1 -1
  26. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +1 -1
  27. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +4 -8
  28. data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +1 -1
  29. data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +1 -1
  30. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +1 -1
  31. data/lib/cisco_node_utils/cmd_ref/pim.yaml +6 -0
  32. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +9 -9
  33. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +1 -1
  34. data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +8 -8
  35. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +1 -1
  36. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +16 -8
  37. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +11 -11
  38. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +2 -1
  39. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +1 -1
  40. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +1 -1
  41. data/lib/cisco_node_utils/command_reference.rb +8 -1
  42. data/lib/cisco_node_utils/domain_name.rb +17 -2
  43. data/lib/cisco_node_utils/feature.rb +14 -0
  44. data/lib/cisco_node_utils/hsrp_global.rb +97 -0
  45. data/lib/cisco_node_utils/interface.rb +146 -0
  46. data/lib/cisco_node_utils/interface_hsrp_group.rb +544 -0
  47. data/lib/cisco_node_utils/node.rb +93 -4
  48. data/lib/cisco_node_utils/pim.rb +17 -0
  49. data/lib/cisco_node_utils/portchannel_global.rb +2 -2
  50. data/lib/cisco_node_utils/version.rb +1 -1
  51. data/lib/cisco_node_utils/vlan.rb +2 -5
  52. data/lib/cisco_node_utils/yum.rb +11 -6
  53. data/spec/schema.yaml +3 -3
  54. data/tests/ciscotest.rb +25 -4
  55. data/tests/cmd_config.yaml +0 -2
  56. data/tests/test_bgp_af.rb +13 -2
  57. data/tests/test_feature.rb +5 -0
  58. data/tests/test_hsrp_global.rb +79 -0
  59. data/tests/test_interface.rb +23 -0
  60. data/tests/test_interface_hsrp.rb +134 -0
  61. data/tests/test_interface_hsrp_group.rb +582 -0
  62. data/tests/test_node_ext.rb +7 -1
  63. data/tests/test_pim.rb +27 -3
  64. data/tests/test_platform.rb +1 -1
  65. data/tests/test_radius_global.rb +4 -5
  66. data/tests/test_radius_server.rb +16 -11
  67. data/tests/test_router_bgp.rb +11 -6
  68. data/tests/test_router_ospf_area.rb +6 -6
  69. data/tests/test_tacacs_server.rb +2 -2
  70. data/tests/test_tacacs_server_host.rb +2 -2
  71. data/tests/test_vlan.rb +14 -0
  72. data/tests/test_yum.rb +2 -2
  73. data/tests/yum_package.yaml +4 -0
  74. metadata +10 -3
@@ -579,6 +579,11 @@ class TestInterface < CiscoTestCase
579
579
  Interface.new(inf_name).destroy
580
580
 
581
581
  interface = Interface.new(inf_name)
582
+
583
+ # The newly created port-channel interface
584
+ # will default to switchport in some cases
585
+ # so we need to disable it.
586
+ interface.switchport_mode = :disabled
582
587
  assert_equal(interface.default_bfd_echo,
583
588
  interface.bfd_echo)
584
589
  interface.bfd_echo = false
@@ -1717,4 +1722,22 @@ class TestInterface < CiscoTestCase
1717
1722
  assert_equal(interface.default_ipv6_dhcp_relay_src_intf,
1718
1723
  interface.ipv6_dhcp_relay_src_intf)
1719
1724
  end
1725
+
1726
+ def test_pim_bfd
1727
+ inf_name = interfaces[0]
1728
+ interface = Interface.new(inf_name)
1729
+ interface.switchport_enable(false)
1730
+ if validate_property_excluded?('interface', 'pim_bfd')
1731
+ assert_nil(interface.pim_bfd)
1732
+ assert_raises(Cisco::UnsupportedError) do
1733
+ interface.pim_bfd = true
1734
+ end
1735
+ return
1736
+ end
1737
+ assert_equal(interface.default_pim_bfd, interface.pim_bfd)
1738
+ interface.pim_bfd = true
1739
+ assert_equal(true, interface.pim_bfd)
1740
+ interface.pim_bfd = interface.default_pim_bfd
1741
+ assert_equal(interface.default_pim_bfd, interface.pim_bfd)
1742
+ end
1720
1743
  end
@@ -0,0 +1,134 @@
1
+ # Copyright (c) 2016 Cisco and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/interface'
17
+
18
+ # TestX__CLASS_NAME__X - Minitest for X__CLASS_NAME__X node utility class
19
+ class TestInterfaceHsrp < CiscoTestCase
20
+ @skip_unless_supported = 'interface'
21
+ # TESTS
22
+
23
+ def setup
24
+ super
25
+ config_no_warn('no feature hsrp')
26
+ end
27
+
28
+ def teardown
29
+ config_no_warn('no feature hsrp') if first_or_last_teardown
30
+ super
31
+ end
32
+
33
+ def create_intf
34
+ interface = Interface.new(interfaces[0])
35
+ interface.switchport_mode = :disabled
36
+ interface
37
+ end
38
+
39
+ def test_hsrp_bfd
40
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
41
+ ih = create_intf
42
+ if validate_property_excluded?('interface', 'hsrp_bfd')
43
+ assert_nil(ih.hsrp_bfd)
44
+ assert_raises(Cisco::UnsupportedError) do
45
+ ih.hsrp_bfd = true
46
+ end
47
+ return
48
+ end
49
+ assert_equal(ih.default_hsrp_bfd, ih.hsrp_bfd)
50
+ ih.hsrp_bfd = true
51
+ assert_equal(true, ih.hsrp_bfd)
52
+ ih.hsrp_bfd = ih.default_hsrp_bfd
53
+ assert_equal(ih.default_hsrp_bfd, ih.hsrp_bfd)
54
+ end
55
+
56
+ def test_hsrp_delay
57
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
58
+ ih = create_intf
59
+ if validate_property_excluded?('interface', 'hsrp_delay')
60
+ assert_nil(ih.hsrp_delay_minimum)
61
+ assert_nil(ih.hsrp_delay_reload)
62
+ assert_raises(Cisco::UnsupportedError) do
63
+ ih.hsrp_delay_minimum = 100
64
+ ih.hsrp_delay_reload = 555
65
+ end
66
+ return
67
+ end
68
+ assert_equal(ih.default_hsrp_delay_minimum, ih.hsrp_delay_minimum)
69
+ assert_equal(ih.default_hsrp_delay_reload, ih.hsrp_delay_reload)
70
+ ih.hsrp_delay_minimum = 100
71
+ ih.hsrp_delay_reload = 555
72
+ assert_equal(100, ih.hsrp_delay_minimum)
73
+ assert_equal(555, ih.hsrp_delay_reload)
74
+ ih.hsrp_delay_minimum = ih.default_hsrp_delay_minimum
75
+ ih.hsrp_delay_reload = ih.default_hsrp_delay_reload
76
+ assert_equal(ih.default_hsrp_delay_minimum, ih.hsrp_delay_minimum)
77
+ assert_equal(ih.default_hsrp_delay_reload, ih.hsrp_delay_reload)
78
+ end
79
+
80
+ def test_hsrp_mac_refresh
81
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
82
+ ih = create_intf
83
+ if validate_property_excluded?('interface', 'hsrp_mac_refresh')
84
+ assert_nil(ih.hsrp_mac_refresh)
85
+ assert_raises(Cisco::UnsupportedError) do
86
+ ih.hsrp_mac_refresh = 60
87
+ end
88
+ return
89
+ end
90
+ assert_equal(ih.default_hsrp_mac_refresh, ih.hsrp_mac_refresh)
91
+ ih.hsrp_mac_refresh = 60
92
+ assert_equal(60, ih.hsrp_mac_refresh)
93
+ ih.hsrp_mac_refresh = ih.default_hsrp_mac_refresh
94
+ assert_equal(ih.default_hsrp_mac_refresh, ih.hsrp_mac_refresh)
95
+ end
96
+
97
+ def test_hsrp_use_bia
98
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
99
+ ih = create_intf
100
+ if validate_property_excluded?('interface', 'hsrp_use_bia')
101
+ assert_nil(ih.hsrp_use_bia)
102
+ assert_raises(Cisco::UnsupportedError) do
103
+ ih.hsrp_use_bia = :use_bia
104
+ end
105
+ return
106
+ end
107
+ assert_equal(ih.default_hsrp_use_bia, ih.hsrp_use_bia)
108
+ ih.hsrp_use_bia = :use_bia
109
+ assert_equal(:use_bia, ih.hsrp_use_bia)
110
+ ih.hsrp_use_bia = :use_bia_intf
111
+ assert_equal(:use_bia_intf, ih.hsrp_use_bia)
112
+ ih.hsrp_use_bia = :use_bia
113
+ assert_equal(:use_bia, ih.hsrp_use_bia)
114
+ ih.hsrp_use_bia = ih.default_hsrp_use_bia
115
+ assert_equal(ih.default_hsrp_use_bia, ih.hsrp_use_bia)
116
+ end
117
+
118
+ def test_hsrp_version
119
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
120
+ ih = create_intf
121
+ if validate_property_excluded?('interface', 'hsrp_version')
122
+ assert_nil(ih.hsrp_version)
123
+ assert_raises(Cisco::UnsupportedError) do
124
+ ih.hsrp_version = 2
125
+ end
126
+ return
127
+ end
128
+ assert_equal(ih.default_hsrp_version, ih.hsrp_version)
129
+ ih.hsrp_version = 2
130
+ assert_equal(2, ih.hsrp_version)
131
+ ih.hsrp_version = ih.default_hsrp_version
132
+ assert_equal(ih.default_hsrp_version, ih.hsrp_version)
133
+ end
134
+ end
@@ -0,0 +1,582 @@
1
+ # Copyright (c) 2016 Cisco and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/interface'
17
+ require_relative '../lib/cisco_node_utils/interface_hsrp_group'
18
+
19
+ # TestInterfaceHsrpGroup - Minitest for InterfaceHsrpGroup
20
+ # node utility class
21
+ class TestInterfaceHsrpGroup < CiscoTestCase
22
+ @skip_unless_supported = 'interface_hsrp_group'
23
+
24
+ def setup
25
+ super
26
+ config_no_warn('no feature hsrp')
27
+ config_no_warn('no interface Po100')
28
+ end
29
+
30
+ def teardown
31
+ if first_or_last_teardown
32
+ config_no_warn('no interface Po100')
33
+ config_no_warn('no feature hsrp')
34
+ end
35
+ super
36
+ end
37
+
38
+ def create_interface_hsrp_group_ipv4(name='port-channel100',
39
+ group=1,
40
+ iptype='ipv4')
41
+ intf = Interface.new(name)
42
+ intf.switchport_mode = :disabled
43
+ InterfaceHsrpGroup.new(name, group, iptype)
44
+ end
45
+
46
+ def create_interface_hsrp_group_ipv6(name='port-channel100',
47
+ group=3,
48
+ iptype='ipv6')
49
+ intf = Interface.new(name)
50
+ intf.switchport_mode = :disabled
51
+ intf.hsrp_version = 2
52
+ InterfaceHsrpGroup.new(name, group, iptype)
53
+ end
54
+
55
+ def test_collection_size
56
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
57
+ ihg1 = create_interface_hsrp_group_ipv4
58
+ ihg2 = create_interface_hsrp_group_ipv4('port-channel100', 2, 'ipv4')
59
+ ihg3 = create_interface_hsrp_group_ipv4('port-channel100', 3, 'ipv4')
60
+ ihg4 = create_interface_hsrp_group_ipv6
61
+ ihg5 = create_interface_hsrp_group_ipv6('port-channel10', 3, 'ipv6')
62
+ ihg6 = create_interface_hsrp_group_ipv4('port-channel10', 100, 'ipv4')
63
+ assert_equal(1, InterfaceHsrpGroup.groups['port-channel100']['1'].size)
64
+ assert_equal(1, InterfaceHsrpGroup.groups['port-channel100']['2'].size)
65
+ assert_equal(2, InterfaceHsrpGroup.groups['port-channel100']['3'].size)
66
+ assert_equal(1, InterfaceHsrpGroup.groups['port-channel10']['3'].size)
67
+ assert_equal(1, InterfaceHsrpGroup.groups['port-channel10']['100'].size)
68
+ ihg1.destroy
69
+ ihg2.destroy
70
+ ihg3.destroy
71
+ ihg4.destroy
72
+ ihg5.destroy
73
+ ihg6.destroy
74
+ assert_empty(InterfaceHsrpGroup.groups)
75
+ end
76
+
77
+ def test_group_name
78
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
79
+ ihg = create_interface_hsrp_group_ipv4
80
+ assert_equal(ihg.default_group_name, ihg.group_name)
81
+ ihg.group_name = 'hsrp_group_name'
82
+ assert_equal('hsrp_group_name', ihg.group_name)
83
+ ihg.group_name = ihg.default_group_name
84
+ assert_equal(ihg.default_group_name, ihg.group_name)
85
+ ihg = create_interface_hsrp_group_ipv6
86
+ assert_equal(ihg.default_group_name, ihg.group_name)
87
+ ihg.group_name = 'hsrp_group_name'
88
+ assert_equal('hsrp_group_name', ihg.group_name)
89
+ ihg.group_name = ihg.default_group_name
90
+ assert_equal(ihg.default_group_name, ihg.group_name)
91
+ end
92
+
93
+ def test_mac_addr
94
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
95
+ ihg = create_interface_hsrp_group_ipv4
96
+ assert_equal(ihg.default_mac_addr, ihg.mac_addr)
97
+ ihg.mac_addr = '00:00:11:11:22:22'
98
+ assert_equal('00:00:11:11:22:22', ihg.mac_addr)
99
+ ihg.mac_addr = ihg.default_mac_addr
100
+ assert_equal(ihg.default_mac_addr, ihg.mac_addr)
101
+ ihg = create_interface_hsrp_group_ipv6
102
+ assert_equal(ihg.default_mac_addr, ihg.mac_addr)
103
+ ihg.mac_addr = '00:22:33:44:55:66'
104
+ assert_equal('00:22:33:44:55:66', ihg.mac_addr)
105
+ ihg.mac_addr = ihg.default_mac_addr
106
+ assert_equal(ihg.default_mac_addr, ihg.mac_addr)
107
+ end
108
+
109
+ def test_auth_type_clear
110
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
111
+ ihg = create_interface_hsrp_group_ipv4
112
+ assert_equal(ihg.default_authentication_string,
113
+ ihg.authentication_string)
114
+ attrs = {}
115
+ attrs[:authentication_auth_type] = 'cleartext'
116
+ attrs[:authentication_string] = 'Test'
117
+ ihg.authentication_set(attrs)
118
+ assert_equal('cleartext', ihg.authentication_auth_type)
119
+ assert_equal('Test', ihg.authentication_string)
120
+ attrs[:authentication_string] = ihg.default_authentication_string
121
+ ihg.authentication_set(attrs)
122
+ assert_equal(ihg.default_authentication_string,
123
+ ihg.authentication_string)
124
+
125
+ ihg = create_interface_hsrp_group_ipv6
126
+ attrs[:authentication_auth_type] = 'cleartext'
127
+ attrs[:authentication_string] = 'Test'
128
+ ihg.authentication_set(attrs)
129
+ assert_equal('cleartext', ihg.authentication_auth_type)
130
+ assert_equal('Test', ihg.authentication_string)
131
+ attrs[:authentication_string] = ihg.default_authentication_string
132
+ ihg.authentication_set(attrs)
133
+ assert_equal(ihg.default_authentication_string,
134
+ ihg.authentication_string)
135
+ end
136
+
137
+ def test_auth_type_md5
138
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
139
+ attrs = {}
140
+ ihg = create_interface_hsrp_group_ipv4
141
+ attrs[:authentication_auth_type] = 'md5'
142
+ attrs[:authentication_key_type] = 'key-chain'
143
+ attrs[:authentication_string] = 'MyMD5Password'
144
+ ihg.authentication_set(attrs)
145
+ assert_equal('md5', ihg.authentication_auth_type)
146
+ assert_equal('key-chain', ihg.authentication_key_type)
147
+ assert_equal('MyMD5Password', ihg.authentication_string)
148
+ attrs[:authentication_string] = ihg.default_authentication_string
149
+ ihg.authentication_set(attrs)
150
+ assert_equal(ihg.default_authentication_string,
151
+ ihg.authentication_string)
152
+ ihg = create_interface_hsrp_group_ipv6
153
+ attrs[:authentication_string] = 'MyMD5Password'
154
+ ihg.authentication_set(attrs)
155
+ assert_equal('md5', ihg.authentication_auth_type)
156
+ assert_equal('key-chain', ihg.authentication_key_type)
157
+ assert_equal('MyMD5Password', ihg.authentication_string)
158
+ attrs[:authentication_string] = ihg.default_authentication_string
159
+ ihg.authentication_set(attrs)
160
+ assert_equal(ihg.default_authentication_string,
161
+ ihg.authentication_string)
162
+ end
163
+
164
+ def test_auth_key_string_enc_0
165
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
166
+ attrs = {}
167
+ ihg = create_interface_hsrp_group_ipv4
168
+ attrs[:authentication_auth_type] = 'md5'
169
+ attrs[:authentication_key_type] = 'key-string'
170
+ attrs[:authentication_enc_type] = '0'
171
+ attrs[:authentication_string] = '7'
172
+ attrs[:authentication_compatibility] = ihg.default_authentication_compatibility
173
+ attrs[:authentication_timeout] = ihg.default_authentication_timeout
174
+ ihg.authentication_set(attrs)
175
+ assert_equal('md5', ihg.authentication_auth_type)
176
+ assert_equal('key-string', ihg.authentication_key_type)
177
+ assert_equal('0', ihg.authentication_enc_type)
178
+ assert_equal('7', ihg.authentication_string)
179
+ attrs[:authentication_string] = ihg.default_authentication_string
180
+ ihg.authentication_set(attrs)
181
+ assert_equal(ihg.default_authentication_string,
182
+ ihg.authentication_string)
183
+ ihg = create_interface_hsrp_group_ipv6
184
+ attrs[:authentication_string] = '7'
185
+ ihg.authentication_set(attrs)
186
+ assert_equal('md5', ihg.authentication_auth_type)
187
+ assert_equal('key-string', ihg.authentication_key_type)
188
+ assert_equal('0', ihg.authentication_enc_type)
189
+ assert_equal('7', ihg.authentication_string)
190
+ attrs[:authentication_string] = ihg.default_authentication_string
191
+ ihg.authentication_set(attrs)
192
+ assert_equal(ihg.default_authentication_string,
193
+ ihg.authentication_string)
194
+ end
195
+
196
+ def test_auth_key_string_enc_7
197
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
198
+ attrs = {}
199
+ ihg = create_interface_hsrp_group_ipv4
200
+ attrs[:authentication_auth_type] = 'md5'
201
+ attrs[:authentication_key_type] = 'key-string'
202
+ attrs[:authentication_enc_type] = '7'
203
+ attrs[:authentication_string] = '12345678901234567890'
204
+ attrs[:authentication_compatibility] = ihg.default_authentication_compatibility
205
+ attrs[:authentication_timeout] = ihg.default_authentication_timeout
206
+ ihg.authentication_set(attrs)
207
+ assert_equal('md5', ihg.authentication_auth_type)
208
+ assert_equal('key-string', ihg.authentication_key_type)
209
+ assert_equal('7', ihg.authentication_enc_type)
210
+ assert_equal('12345678901234567890', ihg.authentication_string)
211
+ ihg = create_interface_hsrp_group_ipv6
212
+ attrs[:authentication_string] = '12345678901234567890'
213
+ ihg.authentication_set(attrs)
214
+ assert_equal('md5', ihg.authentication_auth_type)
215
+ assert_equal('key-string', ihg.authentication_key_type)
216
+ assert_equal('7', ihg.authentication_enc_type)
217
+ assert_equal('12345678901234567890', ihg.authentication_string)
218
+ attrs[:authentication_string] = ihg.default_authentication_string
219
+ ihg.authentication_set(attrs)
220
+ assert_equal(ihg.default_authentication_string,
221
+ ihg.authentication_string)
222
+ end
223
+
224
+ def test_auth_key_string_enc_7_compat_timeout_ipv4
225
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
226
+ attrs = {}
227
+ ihg = create_interface_hsrp_group_ipv4
228
+ attrs[:authentication_auth_type] = 'md5'
229
+ attrs[:authentication_key_type] = 'key-string'
230
+ attrs[:authentication_enc_type] = '7'
231
+ attrs[:authentication_string] = '12345678901234567890'
232
+ attrs[:authentication_compatibility] = ihg.default_authentication_compatibility
233
+ attrs[:authentication_timeout] = ihg.default_authentication_timeout
234
+ ihg.authentication_set(attrs)
235
+ assert_equal('md5', ihg.authentication_auth_type)
236
+ assert_equal('key-string', ihg.authentication_key_type)
237
+ assert_equal('7', ihg.authentication_enc_type)
238
+ assert_equal('12345678901234567890', ihg.authentication_string)
239
+ attrs[:authentication_compatibility] = true
240
+ attrs[:authentication_timeout] = 6666
241
+ ihg.authentication_set(attrs)
242
+ assert_equal('md5', ihg.authentication_auth_type)
243
+ assert_equal('key-string', ihg.authentication_key_type)
244
+ assert_equal('7', ihg.authentication_enc_type)
245
+ assert_equal('12345678901234567890', ihg.authentication_string)
246
+ assert_equal(true, ihg.authentication_compatibility)
247
+ assert_equal(6666, ihg.authentication_timeout)
248
+ attrs[:authentication_compatibility] = false
249
+ ihg.authentication_set(attrs)
250
+ assert_equal(false, ihg.authentication_compatibility)
251
+ attrs[:authentication_string] = ihg.default_authentication_string
252
+ ihg.authentication_set(attrs)
253
+ assert_equal(ihg.default_authentication_string,
254
+ ihg.authentication_string)
255
+ end
256
+
257
+ def test_auth_key_string_enc_7_compat_timeout_ipv6
258
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
259
+ attrs = {}
260
+ ihg = create_interface_hsrp_group_ipv6
261
+ attrs[:authentication_auth_type] = 'md5'
262
+ attrs[:authentication_key_type] = 'key-string'
263
+ attrs[:authentication_enc_type] = '7'
264
+ attrs[:authentication_string] = '12345678901234567890'
265
+ attrs[:authentication_compatibility] = ihg.default_authentication_compatibility
266
+ attrs[:authentication_timeout] = ihg.default_authentication_timeout
267
+ ihg.authentication_set(attrs)
268
+ assert_equal('md5', ihg.authentication_auth_type)
269
+ assert_equal('key-string', ihg.authentication_key_type)
270
+ assert_equal('7', ihg.authentication_enc_type)
271
+ assert_equal('12345678901234567890', ihg.authentication_string)
272
+ attrs[:authentication_compatibility] = true
273
+ attrs[:authentication_timeout] = 6666
274
+ ihg.authentication_set(attrs)
275
+ assert_equal('md5', ihg.authentication_auth_type)
276
+ assert_equal('key-string', ihg.authentication_key_type)
277
+ assert_equal('7', ihg.authentication_enc_type)
278
+ assert_equal('12345678901234567890', ihg.authentication_string)
279
+ assert_equal(true, ihg.authentication_compatibility)
280
+ assert_equal(6666, ihg.authentication_timeout)
281
+ attrs[:authentication_compatibility] = false
282
+ ihg.authentication_set(attrs)
283
+ assert_equal(false, ihg.authentication_compatibility)
284
+ attrs[:authentication_string] = ihg.default_authentication_string
285
+ ihg.authentication_set(attrs)
286
+ assert_equal(ihg.default_authentication_string,
287
+ ihg.authentication_string)
288
+ end
289
+
290
+ def test_auth_key_string_enc_0_compat_timeout_ipv4
291
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
292
+ attrs = {}
293
+ ihg = create_interface_hsrp_group_ipv4
294
+ attrs[:authentication_auth_type] = 'md5'
295
+ attrs[:authentication_key_type] = 'key-string'
296
+ attrs[:authentication_enc_type] = '0'
297
+ attrs[:authentication_string] = 'MyUnEncr'
298
+ attrs[:authentication_compatibility] = true
299
+ attrs[:authentication_timeout] = 6666
300
+ ihg.authentication_set(attrs)
301
+ assert_equal('md5', ihg.authentication_auth_type)
302
+ assert_equal('key-string', ihg.authentication_key_type)
303
+ assert_equal('0', ihg.authentication_enc_type)
304
+ assert_equal('MyUnEncr', ihg.authentication_string)
305
+ assert_equal(true, ihg.authentication_compatibility)
306
+ assert_equal(6666, ihg.authentication_timeout)
307
+ attrs[:authentication_compatibility] = false
308
+ attrs[:authentication_timeout] = 3333
309
+ ihg.authentication_set(attrs)
310
+ assert_equal('md5', ihg.authentication_auth_type)
311
+ assert_equal('key-string', ihg.authentication_key_type)
312
+ assert_equal('0', ihg.authentication_enc_type)
313
+ assert_equal('MyUnEncr', ihg.authentication_string)
314
+ assert_equal(false, ihg.authentication_compatibility)
315
+ assert_equal(3333, ihg.authentication_timeout)
316
+ attrs[:authentication_string] = ihg.default_authentication_string
317
+ ihg.authentication_set(attrs)
318
+ assert_equal(ihg.default_authentication_string,
319
+ ihg.authentication_string)
320
+ end
321
+
322
+ def test_auth_key_string_enc_0_compat_timeout_ipv6
323
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
324
+ attrs = {}
325
+ ihg = create_interface_hsrp_group_ipv6
326
+ attrs[:authentication_auth_type] = 'md5'
327
+ attrs[:authentication_key_type] = 'key-string'
328
+ attrs[:authentication_enc_type] = '0'
329
+ attrs[:authentication_string] = 'MyUnEncr'
330
+ attrs[:authentication_compatibility] = true
331
+ attrs[:authentication_timeout] = 6666
332
+ ihg.authentication_set(attrs)
333
+ assert_equal('md5', ihg.authentication_auth_type)
334
+ assert_equal('key-string', ihg.authentication_key_type)
335
+ assert_equal('0', ihg.authentication_enc_type)
336
+ assert_equal('MyUnEncr', ihg.authentication_string)
337
+ assert_equal(true, ihg.authentication_compatibility)
338
+ assert_equal(6666, ihg.authentication_timeout)
339
+ attrs[:authentication_compatibility] = false
340
+ attrs[:authentication_timeout] = 3333
341
+ ihg.authentication_set(attrs)
342
+ assert_equal('md5', ihg.authentication_auth_type)
343
+ assert_equal('key-string', ihg.authentication_key_type)
344
+ assert_equal('0', ihg.authentication_enc_type)
345
+ assert_equal('MyUnEncr', ihg.authentication_string)
346
+ assert_equal(false, ihg.authentication_compatibility)
347
+ assert_equal(3333, ihg.authentication_timeout)
348
+ attrs[:authentication_string] = ihg.default_authentication_string
349
+ ihg.authentication_set(attrs)
350
+ assert_equal(ihg.default_authentication_string,
351
+ ihg.authentication_string)
352
+ end
353
+
354
+ def test_preempt_ipv4
355
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
356
+ ihg = create_interface_hsrp_group_ipv4
357
+ assert_equal(ihg.default_preempt, ihg.preempt)
358
+ assert_equal(ihg.default_preempt_delay_minimum, ihg.preempt_delay_minimum)
359
+ assert_equal(ihg.default_preempt_delay_reload, ihg.preempt_delay_reload)
360
+ assert_equal(ihg.default_preempt_delay_sync, ihg.preempt_delay_sync)
361
+ delay = 100
362
+ reload = 200
363
+ sync = 300
364
+ ihg.preempt_set(true, delay, reload, sync)
365
+ assert_equal(true, ihg.preempt)
366
+ assert_equal(100, ihg.preempt_delay_minimum)
367
+ assert_equal(200, ihg.preempt_delay_reload)
368
+ assert_equal(300, ihg.preempt_delay_sync)
369
+ delay = 0
370
+ reload = 0
371
+ sync = 0
372
+ ihg.preempt_set(true, delay, reload, sync)
373
+ assert_equal(0, ihg.preempt_delay_minimum)
374
+ assert_equal(0, ihg.preempt_delay_reload)
375
+ assert_equal(0, ihg.preempt_delay_sync)
376
+ ihg.preempt_set(ihg.default_preempt,
377
+ ihg.default_preempt_delay_minimum,
378
+ ihg.default_preempt_delay_reload,
379
+ ihg.default_preempt_delay_sync)
380
+ assert_equal(ihg.default_preempt, ihg.preempt)
381
+ assert_equal(ihg.default_preempt_delay_minimum, ihg.preempt_delay_minimum)
382
+ assert_equal(ihg.default_preempt_delay_reload, ihg.preempt_delay_reload)
383
+ assert_equal(ihg.default_preempt_delay_sync, ihg.preempt_delay_sync)
384
+ end
385
+
386
+ def test_preempt_ipv6
387
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
388
+ ihg = create_interface_hsrp_group_ipv6
389
+ assert_equal(ihg.default_preempt, ihg.preempt)
390
+ assert_equal(ihg.default_preempt_delay_minimum, ihg.preempt_delay_minimum)
391
+ assert_equal(ihg.default_preempt_delay_reload, ihg.preempt_delay_reload)
392
+ assert_equal(ihg.default_preempt_delay_sync, ihg.preempt_delay_sync)
393
+ delay = 222
394
+ reload = 444
395
+ sync = 666
396
+ ihg.preempt_set(true, delay, reload, sync)
397
+ assert_equal(true, ihg.preempt)
398
+ assert_equal(222, ihg.preempt_delay_minimum)
399
+ assert_equal(444, ihg.preempt_delay_reload)
400
+ assert_equal(666, ihg.preempt_delay_sync)
401
+ delay = 0
402
+ reload = 0
403
+ sync = 0
404
+ ihg.preempt_set(true, delay, reload, sync)
405
+ assert_equal(0, ihg.preempt_delay_minimum)
406
+ assert_equal(0, ihg.preempt_delay_reload)
407
+ assert_equal(0, ihg.preempt_delay_sync)
408
+ ihg.preempt_set(ihg.default_preempt,
409
+ ihg.default_preempt_delay_minimum,
410
+ ihg.default_preempt_delay_reload,
411
+ ihg.default_preempt_delay_sync)
412
+ assert_equal(ihg.default_preempt, ihg.preempt)
413
+ assert_equal(ihg.default_preempt_delay_minimum, ihg.preempt_delay_minimum)
414
+ assert_equal(ihg.default_preempt_delay_reload, ihg.preempt_delay_reload)
415
+ assert_equal(ihg.default_preempt_delay_sync, ihg.preempt_delay_sync)
416
+ end
417
+
418
+ def test_priority_ipv4
419
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
420
+ ihg = create_interface_hsrp_group_ipv4
421
+ assert_equal(ihg.default_priority, ihg.priority)
422
+ assert_equal(ihg.default_priority_forward_thresh_lower,
423
+ ihg.priority_forward_thresh_lower)
424
+ assert_equal(ihg.default_priority_forward_thresh_upper,
425
+ ihg.priority_forward_thresh_upper)
426
+ ihg.priority_level_set(50, 10, 20)
427
+ assert_equal(50, ihg.priority)
428
+ assert_equal(10, ihg.priority_forward_thresh_lower)
429
+ assert_equal(20, ihg.priority_forward_thresh_upper)
430
+ ihg.priority_level_set(99,
431
+ ihg.default_priority_forward_thresh_lower,
432
+ ihg.default_priority_forward_thresh_upper)
433
+ assert_equal(99, ihg.priority)
434
+ assert_equal(ihg.default_priority_forward_thresh_lower,
435
+ ihg.priority_forward_thresh_lower)
436
+ assert_equal(ihg.default_priority_forward_thresh_upper,
437
+ ihg.priority_forward_thresh_upper)
438
+ ihg.priority_level_set(ihg.default_priority,
439
+ ihg.default_priority_forward_thresh_lower,
440
+ ihg.default_priority_forward_thresh_upper)
441
+ assert_equal(ihg.default_priority, ihg.priority)
442
+ assert_equal(ihg.default_priority_forward_thresh_lower,
443
+ ihg.priority_forward_thresh_lower)
444
+ assert_equal(ihg.default_priority_forward_thresh_upper,
445
+ ihg.priority_forward_thresh_upper)
446
+ end
447
+
448
+ def test_priority_ipv6
449
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
450
+ ihg = create_interface_hsrp_group_ipv6
451
+ assert_equal(ihg.default_priority, ihg.priority)
452
+ assert_equal(ihg.default_priority_forward_thresh_lower,
453
+ ihg.priority_forward_thresh_lower)
454
+ assert_equal(ihg.default_priority_forward_thresh_upper,
455
+ ihg.priority_forward_thresh_upper)
456
+ ihg.priority_level_set(44, 22, 33)
457
+ assert_equal(44, ihg.priority)
458
+ assert_equal(22, ihg.priority_forward_thresh_lower)
459
+ assert_equal(33, ihg.priority_forward_thresh_upper)
460
+ ihg.priority_level_set(155,
461
+ ihg.default_priority_forward_thresh_lower,
462
+ ihg.default_priority_forward_thresh_upper)
463
+ assert_equal(155, ihg.priority)
464
+ assert_equal(ihg.default_priority_forward_thresh_lower,
465
+ ihg.priority_forward_thresh_lower)
466
+ assert_equal(ihg.default_priority_forward_thresh_upper,
467
+ ihg.priority_forward_thresh_upper)
468
+ ihg.priority_level_set(ihg.default_priority,
469
+ ihg.default_priority_forward_thresh_lower,
470
+ ihg.default_priority_forward_thresh_upper)
471
+ assert_equal(ihg.default_priority, ihg.priority)
472
+ assert_equal(ihg.default_priority_forward_thresh_lower,
473
+ ihg.priority_forward_thresh_lower)
474
+ assert_equal(ihg.default_priority_forward_thresh_upper,
475
+ ihg.priority_forward_thresh_upper)
476
+ end
477
+
478
+ def test_timers_ipv4
479
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
480
+ ihg = create_interface_hsrp_group_ipv4
481
+ assert_equal(ihg.default_timers_hello, ihg.timers_hello)
482
+ assert_equal(ihg.default_timers_hello_msec, ihg.timers_hello_msec)
483
+ assert_equal(ihg.default_timers_hold, ihg.timers_hold)
484
+ assert_equal(ihg.default_timers_hold_msec, ihg.timers_hold_msec)
485
+ ihg.timers_set(ihg.default_timers_hello_msec,
486
+ 10, ihg.default_timers_hold_msec, 50)
487
+ assert_equal(10, ihg.timers_hello)
488
+ assert_equal(ihg.default_timers_hello_msec, ihg.timers_hello_msec)
489
+ assert_equal(50, ihg.timers_hold)
490
+ assert_equal(ihg.default_timers_hold_msec, ihg.timers_hold_msec)
491
+ ihg.timers_set(true, 500, true, 1500)
492
+ assert_equal(500, ihg.timers_hello)
493
+ assert_equal(true, ihg.timers_hello_msec)
494
+ assert_equal(1500, ihg.timers_hold)
495
+ assert_equal(true, ihg.timers_hold_msec)
496
+ ihg.timers_set(true, 500, false, 5)
497
+ assert_equal(500, ihg.timers_hello)
498
+ assert_equal(true, ihg.timers_hello_msec)
499
+ assert_equal(5, ihg.timers_hold)
500
+ assert_equal(false, ihg.timers_hold_msec)
501
+ ihg.timers_set(ihg.default_timers_hello_msec,
502
+ ihg.default_timers_hello,
503
+ ihg.default_timers_hold_msec,
504
+ ihg.default_timers_hold)
505
+ assert_equal(ihg.default_timers_hello, ihg.timers_hello)
506
+ assert_equal(ihg.default_timers_hello_msec, ihg.timers_hello_msec)
507
+ assert_equal(ihg.default_timers_hold, ihg.timers_hold)
508
+ assert_equal(ihg.default_timers_hold_msec, ihg.timers_hold_msec)
509
+ end
510
+
511
+ def test_timers_ipv6
512
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
513
+ ihg = create_interface_hsrp_group_ipv6
514
+ assert_equal(ihg.default_timers_hello, ihg.timers_hello)
515
+ assert_equal(ihg.default_timers_hello_msec, ihg.timers_hello_msec)
516
+ assert_equal(ihg.default_timers_hold, ihg.timers_hold)
517
+ assert_equal(ihg.default_timers_hold_msec, ihg.timers_hold_msec)
518
+ ihg.timers_set(ihg.default_timers_hello_msec,
519
+ 20, ihg.default_timers_hold_msec, 100)
520
+ assert_equal(20, ihg.timers_hello)
521
+ assert_equal(ihg.default_timers_hello_msec, ihg.timers_hello_msec)
522
+ assert_equal(100, ihg.timers_hold)
523
+ assert_equal(ihg.default_timers_hold_msec, ihg.timers_hold_msec)
524
+ ihg.timers_set(true, 300, true, 2000)
525
+ assert_equal(300, ihg.timers_hello)
526
+ assert_equal(true, ihg.timers_hello_msec)
527
+ assert_equal(2000, ihg.timers_hold)
528
+ assert_equal(true, ihg.timers_hold_msec)
529
+ ihg.timers_set(true, 300, false, 10)
530
+ assert_equal(300, ihg.timers_hello)
531
+ assert_equal(true, ihg.timers_hello_msec)
532
+ assert_equal(10, ihg.timers_hold)
533
+ assert_equal(false, ihg.timers_hold_msec)
534
+ ihg.timers_set(ihg.default_timers_hello_msec,
535
+ ihg.default_timers_hello,
536
+ ihg.default_timers_hold_msec,
537
+ ihg.default_timers_hold)
538
+ assert_equal(ihg.default_timers_hello, ihg.timers_hello)
539
+ assert_equal(ihg.default_timers_hello_msec, ihg.timers_hello_msec)
540
+ assert_equal(ihg.default_timers_hold, ihg.timers_hold)
541
+ assert_equal(ihg.default_timers_hold_msec, ihg.timers_hold_msec)
542
+ end
543
+
544
+ def test_ipv4_vip
545
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
546
+ ihg = create_interface_hsrp_group_ipv4
547
+ assert_equal(ihg.default_ipv4_enable, ihg.ipv4_enable)
548
+ assert_equal(ihg.default_ipv4_vip, ihg.ipv4_vip)
549
+ ihg.ipv4_vip_set(true, ihg.default_ipv4_vip)
550
+ assert_equal(true, ihg.ipv4_enable)
551
+ assert_equal(ihg.default_ipv4_vip, ihg.ipv4_vip)
552
+ ihg.ipv4_vip_set(true, '1.1.1.1')
553
+ assert_equal(true, ihg.ipv4_enable)
554
+ assert_equal('1.1.1.1', ihg.ipv4_vip)
555
+ ihg.ipv4_vip_set(true, ihg.default_ipv4_vip)
556
+ assert_equal(true, ihg.ipv4_enable)
557
+ assert_equal(ihg.default_ipv4_vip, ihg.ipv4_vip)
558
+ ihg.ipv4_vip_set(ihg.default_ipv4_enable, ihg.default_ipv4_vip)
559
+ assert_equal(ihg.default_ipv4_enable, ihg.ipv4_enable)
560
+ assert_equal(ihg.default_ipv4_vip, ihg.ipv4_vip)
561
+ ihg.ipv4_vip_set(true, '1.1.1.1')
562
+ ihg.ipv4_vip_set(ihg.default_ipv4_enable, ihg.default_ipv4_vip)
563
+ assert_equal(ihg.default_ipv4_enable, ihg.ipv4_enable)
564
+ assert_equal(ihg.default_ipv4_vip, ihg.ipv4_vip)
565
+ end
566
+
567
+ def test_ipv6_vip
568
+ skip_legacy_defect?('7.3.0.D1.1', 'CSCuh90262: hsrp indentation')
569
+ config_no_warn('interface Po100 ; ipv6 address 2000::01/64')
570
+ ihg = create_interface_hsrp_group_ipv6
571
+ assert_equal(ihg.default_ipv6_vip, ihg.ipv6_vip)
572
+ ihg.ipv6_vip = ['2000::11', '2000::55']
573
+ assert_equal(['2000::11', '2000::55'], ihg.ipv6_vip)
574
+ ihg.ipv6_vip = ihg.default_ipv6_vip
575
+ assert_equal(ihg.default_ipv6_vip, ihg.ipv6_vip)
576
+ assert_equal(ihg.default_ipv6_autoconfig, ihg.ipv6_autoconfig)
577
+ ihg.ipv6_autoconfig = true
578
+ assert_equal(true, ihg.ipv6_autoconfig)
579
+ ihg.ipv6_autoconfig = ihg.default_ipv6_autoconfig
580
+ assert_equal(ihg.default_ipv6_autoconfig, ihg.ipv6_autoconfig)
581
+ end
582
+ end