cisco_node_utils 1.3.0 → 1.4.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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +66 -0
  4. data/Gemfile +1 -0
  5. data/README.md +44 -43
  6. data/bin/.rubocop.yml +18 -0
  7. data/bin/show_running_yang.rb +233 -0
  8. data/cisco_node_utils.gemspec +1 -1
  9. data/docs/README-maintainers.md +1 -0
  10. data/docs/README-utilities.md +14 -0
  11. data/lib/.rubocop.yml +1 -1
  12. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +8 -3
  13. data/lib/cisco_node_utils/aaa_authorization_service.rb +6 -0
  14. data/lib/cisco_node_utils/bfd_global.rb +300 -0
  15. data/lib/cisco_node_utils/bgp.rb +6 -4
  16. data/lib/cisco_node_utils/bgp_af.rb +2 -0
  17. data/lib/cisco_node_utils/bgp_neighbor.rb +14 -0
  18. data/lib/cisco_node_utils/bgp_neighbor_af.rb +4 -1
  19. data/lib/cisco_node_utils/cisco_cmn_utils.rb +126 -0
  20. data/lib/cisco_node_utils/client/client.rb +6 -2
  21. data/lib/cisco_node_utils/client/grpc/client.rb +120 -36
  22. data/lib/cisco_node_utils/client/nxapi/client.rb +6 -2
  23. data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +118 -0
  24. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +14 -0
  25. data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
  26. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +7 -7
  27. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +7 -0
  28. data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +125 -0
  29. data/lib/cisco_node_utils/cmd_ref/feature.yaml +10 -0
  30. data/lib/cisco_node_utils/cmd_ref/interface.yaml +141 -49
  31. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +44 -0
  32. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +6 -0
  33. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +6 -0
  34. data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
  35. data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
  36. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +0 -3
  37. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +3 -3
  38. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +39 -15
  39. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +43 -21
  40. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +48 -19
  41. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +0 -0
  42. data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +30 -0
  43. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +18 -6
  44. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +4 -0
  45. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +1 -0
  46. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +23 -10
  47. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +8 -2
  48. data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
  49. data/lib/cisco_node_utils/cmd_ref/yum.yaml +10 -1
  50. data/lib/cisco_node_utils/constants.rb +8 -1
  51. data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
  52. data/lib/cisco_node_utils/exceptions.rb +29 -0
  53. data/lib/cisco_node_utils/feature.rb +28 -0
  54. data/lib/cisco_node_utils/interface.rb +493 -402
  55. data/lib/cisco_node_utils/interface_DEPRECATED.rb +513 -0
  56. data/lib/cisco_node_utils/interface_ospf.rb +126 -0
  57. data/lib/cisco_node_utils/interface_portchannel.rb +16 -0
  58. data/lib/cisco_node_utils/logger.rb +3 -0
  59. data/lib/cisco_node_utils/node.rb +29 -1
  60. data/lib/cisco_node_utils/overlay_global.rb +1 -12
  61. data/lib/cisco_node_utils/pim.rb +1 -0
  62. data/lib/cisco_node_utils/pim_group_list.rb +1 -0
  63. data/lib/cisco_node_utils/pim_rp_address.rb +1 -0
  64. data/lib/cisco_node_utils/platform.rb +9 -2
  65. data/lib/cisco_node_utils/router_ospf.rb +1 -1
  66. data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
  67. data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
  68. data/lib/cisco_node_utils/router_ospf_vrf.rb +17 -0
  69. data/lib/cisco_node_utils/snmp_notification_receiver.rb +27 -9
  70. data/lib/cisco_node_utils/snmpcommunity.rb +34 -8
  71. data/lib/cisco_node_utils/snmpserver.rb +4 -4
  72. data/lib/cisco_node_utils/snmpuser.rb +0 -0
  73. data/lib/cisco_node_utils/tacacs_global.rb +102 -0
  74. data/lib/cisco_node_utils/tacacs_server.rb +8 -7
  75. data/lib/cisco_node_utils/vdc.rb +25 -7
  76. data/lib/cisco_node_utils/version.rb +1 -1
  77. data/lib/cisco_node_utils/vlan.rb +30 -56
  78. data/lib/cisco_node_utils/vlan_DEPRECATED.rb +108 -0
  79. data/lib/cisco_node_utils/yang.rb +160 -0
  80. data/lib/cisco_node_utils/yum.rb +25 -32
  81. data/tests/.rubocop.yml +3 -0
  82. data/tests/ciscotest.rb +136 -19
  83. data/tests/cmd_config_invalid.yaml +1 -1
  84. data/tests/noop.rb +7 -0
  85. data/tests/tacacs_server.yaml.example +6 -0
  86. data/tests/test_aaa_authentication_login.rb +24 -1
  87. data/tests/test_aaa_authentication_login_service.rb +9 -16
  88. data/tests/test_aaa_authorization_service.rb +111 -84
  89. data/tests/test_bfd_global.rb +278 -0
  90. data/tests/test_bgp_neighbor.rb +20 -0
  91. data/tests/test_bridge_domain_vni.rb +2 -9
  92. data/tests/test_cmn_utils.rb +76 -0
  93. data/tests/test_dhcp_relay_global.rb +284 -0
  94. data/tests/test_dns_domain.rb +4 -4
  95. data/tests/test_domain_name.rb +2 -2
  96. data/tests/test_encapsulation.rb +2 -4
  97. data/tests/test_evpn_vni.rb +14 -7
  98. data/tests/test_fabricpath_global.rb +12 -13
  99. data/tests/test_feature.rb +35 -17
  100. data/tests/test_interface.rb +352 -127
  101. data/tests/test_interface_bdi.rb +2 -2
  102. data/tests/test_interface_channel_group.rb +1 -1
  103. data/tests/test_interface_ospf.rb +153 -23
  104. data/tests/test_interface_portchannel.rb +15 -6
  105. data/tests/test_interface_private_vlan.rb +200 -576
  106. data/tests/test_interface_svi.rb +5 -52
  107. data/tests/test_interface_switchport.rb +80 -240
  108. data/tests/test_itd_device_group.rb +2 -2
  109. data/tests/test_itd_device_group_node.rb +2 -2
  110. data/tests/test_itd_service.rb +1 -1
  111. data/tests/test_name_server.rb +3 -3
  112. data/tests/test_node_ext.rb +15 -17
  113. data/tests/test_ntp_config.rb +1 -1
  114. data/tests/test_ntp_server.rb +3 -3
  115. data/tests/test_nxapi.rb +1 -0
  116. data/tests/test_overlay_global.rb +15 -19
  117. data/tests/test_pim.rb +5 -5
  118. data/tests/test_pim_group_list.rb +1 -37
  119. data/tests/test_pim_rp_address.rb +1 -1
  120. data/tests/test_platform.rb +9 -11
  121. data/tests/test_portchannel_global.rb +43 -3
  122. data/tests/test_radius_server.rb +1 -1
  123. data/tests/test_radius_server_group.rb +1 -1
  124. data/tests/test_router_bgp.rb +17 -30
  125. data/tests/test_router_ospf_area.rb +433 -0
  126. data/tests/test_router_ospf_area_vlink.rb +298 -0
  127. data/tests/test_router_ospf_vrf.rb +17 -0
  128. data/tests/test_snmp_notification_receiver.rb +11 -11
  129. data/tests/test_snmpcommunity.rb +177 -69
  130. data/tests/test_snmpgroup.rb +7 -7
  131. data/tests/test_snmpserver.rb +164 -253
  132. data/tests/test_snmpuser.rb +73 -69
  133. data/tests/test_stp_global.rb +15 -15
  134. data/tests/test_syslog_settings.rb +1 -1
  135. data/tests/test_tacacs_global.rb +80 -0
  136. data/tests/test_tacacs_server.rb +129 -51
  137. data/tests/test_tacacs_server_group.rb +3 -29
  138. data/tests/test_tacacs_server_host.rb +24 -27
  139. data/tests/test_vlan.rb +57 -59
  140. data/tests/test_vlan_private.rb +271 -284
  141. data/tests/test_vpc.rb +10 -4
  142. data/tests/test_vrf.rb +2 -0
  143. data/tests/test_vrf_af.rb +2 -5
  144. data/tests/test_vtp.rb +5 -2
  145. data/tests/test_vxlan_vtep.rb +20 -44
  146. data/tests/test_vxlan_vtep_vni.rb +23 -16
  147. data/tests/test_yang.rb +369 -0
  148. data/tests/test_yum.rb +34 -42
  149. data/tests/yum_package.yaml +35 -0
  150. metadata +31 -4
  151. data/tests/test_vlan_mt_full.rb +0 -85
@@ -51,7 +51,7 @@ class TestDnsDomain < CiscoTestCase
51
51
 
52
52
  # TESTS
53
53
 
54
- def test_dnsdomain_create_destroy_single
54
+ def test_create_destroy_single
55
55
  id = 'aoeu.com'
56
56
  refute_includes(Cisco::DnsDomain.dnsdomains, id)
57
57
 
@@ -63,7 +63,7 @@ class TestDnsDomain < CiscoTestCase
63
63
  refute_includes(Cisco::DnsDomain.dnsdomains, id)
64
64
  end
65
65
 
66
- def test_dnsdomain_create_destroy_multiple
66
+ def test_create_destroy_multiple
67
67
  id1 = 'aoeu.com'
68
68
  id2 = 'asdf.com'
69
69
  refute_includes(Cisco::DnsDomain.dnsdomains, id1)
@@ -83,7 +83,7 @@ class TestDnsDomain < CiscoTestCase
83
83
  refute_includes(Cisco::DnsDomain.dnsdomains, id2)
84
84
  end
85
85
 
86
- def test_dnsdomain_create_destroy_single_vrf
86
+ def test_create_destroy_single_vrf
87
87
  id = 'aoeu.com'
88
88
  vrf = 'test'
89
89
  non_vrf = Cisco::DnsDomain.new(id)
@@ -100,7 +100,7 @@ class TestDnsDomain < CiscoTestCase
100
100
  non_vrf.destroy
101
101
  end
102
102
 
103
- def test_dnsdomain_create_destroy_multiple_vrf
103
+ def test_create_destroy_multiple_vrf
104
104
  id1 = 'aoeu.com'
105
105
  id2 = 'asdf.com'
106
106
  vrf = 'test'
@@ -51,7 +51,7 @@ class TestDomainName < CiscoTestCase
51
51
 
52
52
  # TESTS
53
53
 
54
- def test_domainname_create_replace_destroy
54
+ def test_create_replace_destroy
55
55
  name1 = 'test.abc'
56
56
  name2 = 'test.xyz'
57
57
  refute_includes(Cisco::DomainName.domainnames, name1)
@@ -72,7 +72,7 @@ class TestDomainName < CiscoTestCase
72
72
  refute_includes(Cisco::DomainName.domainnames, name2)
73
73
  end
74
74
 
75
- def test_domainname_create_replace_destroy_vrf
75
+ def test_create_replace_destroy_vrf
76
76
  name1 = 'test.abc'
77
77
  name2 = 'test.xyz'
78
78
  vrf = 'test'
@@ -23,16 +23,14 @@ class TestEncapsulation < CiscoTestCase
23
23
 
24
24
  def setup
25
25
  super
26
+ vdc_limit_f3_no_intf_needed(:set)
26
27
  return unless @@pre_clean_needed
27
-
28
- # This provider requires MT-Full and a compatible linecard
29
- mt_full_interface?
30
- Vdc.new('default').limit_resource_module_type = 'f3'
31
28
  cleanup
32
29
  @@pre_clean_needed = false # rubocop:disable Style/ClassVars
33
30
  end
34
31
 
35
32
  def teardown
33
+ vdc_limit_f3_no_intf_needed(:clear) if first_or_last_teardown
36
34
  cleanup
37
35
  super
38
36
  end
@@ -73,13 +73,20 @@ class TestEvpnVni < CiscoTestCase
73
73
  # test route_target
74
74
  def test_route_target
75
75
  vni = EvpnVni.new(4096)
76
-
77
- # test route target both auto and route target both auto evpn
78
- if Utils.nexus_i2_image
79
- opts = [:import, :export]
80
- else
81
- opts = [:both, :import, :export]
82
- end
76
+ opts = [:both, :import, :export]
77
+
78
+ # 'route_target_both' has limited support with I3 and later images.
79
+ # The Puppet README states:
80
+ # Caveat: The route_target_both property is discouraged due to the
81
+ # inconsistent behavior of the property across Nexus platforms and image
82
+ # versions. The 'both' keyword has a transformative behavior on some
83
+ # platforms/versions in which it creates two cli configurations: one for
84
+ # import targets, a second for export targets, while the 'both' command
85
+ # itself may not appear at all. When the 'both' keyword does not appear
86
+ # in the configuration it causes an idempotency problem for puppet. For
87
+ # this reason it is recommended to use explicit 'route_target_export' and
88
+ # 'route_target_import' properties instead of route_target_both.
89
+ opts.delete(:both) unless Utils.nexus_i2_image
83
90
 
84
91
  # Master list of communities to test against
85
92
  master = ['1.2.3.4:55', '2:2', '55:33', 'auto']
@@ -23,32 +23,31 @@ include Cisco
23
23
  # TestFabricpathGlobal - Minitest for Fabricpath Global node utils
24
24
  class TestFabricpathGlobal < CiscoTestCase
25
25
  @skip_unless_supported = 'fabricpath'
26
+ @@pre_clean_needed = true # rubocop:disable Style/ClassVars
26
27
 
27
28
  def setup
28
- # setup runs at the beginning of each test
29
29
  super
30
- fabricpath_testenv_setup
31
- no_feature_fabricpath
30
+ vdc_limit_f3_no_intf_needed(:set)
31
+ return unless @@pre_clean_needed
32
+ config_no_warn('no nv overlay evpn ; no feature nv overlay')
33
+ remove_fabricpath_globals
34
+ @@pre_clean_needed = false # rubocop:disable Style/ClassVars
32
35
  end
33
36
 
34
37
  def teardown
35
- # teardown runs at the end of each test
36
- no_feature_fabricpath
38
+ remove_fabricpath_globals
39
+ if first_or_last_teardown
40
+ vdc_limit_f3_no_intf_needed(:clear)
41
+ config_no_warn('no feature-set fabricpath')
42
+ end
37
43
  super
38
44
  end
39
45
 
40
- def no_feature_fabricpath
46
+ def remove_fabricpath_globals
41
47
  fg = FabricpathGlobal.globals
42
48
  fg.each { |_key, elem| elem.destroy } unless fg.empty?
43
49
  end
44
50
 
45
- # def no_feature_fabricpath
46
- # # Turn the feature off for a clean test.
47
- # config('no feature-set fabricpath')
48
- # end
49
-
50
- # TESTS
51
-
52
51
  def test_create_destroy
53
52
  assert_empty(FabricpathGlobal.globals)
54
53
 
@@ -22,6 +22,27 @@ include Cisco
22
22
  class TestFeature < CiscoTestCase
23
23
  @skip_unless_supported = 'feature'
24
24
 
25
+ def teardown
26
+ # f3 cleanup for non-f3 N7k's
27
+ vdc_limit_f3_no_intf_needed(:clear) if first_or_last_teardown
28
+
29
+ ['no nv overlay evpn',
30
+ 'no feature bfd',
31
+ 'no feature bgp',
32
+ 'no feature dhcp',
33
+ 'no feature fabric forwarding',
34
+ 'no feature-set fex',
35
+ 'no feature itd',
36
+ 'no feature nv overlay',
37
+ 'no feature ospf',
38
+ 'no feature pim',
39
+ 'no feature private-vlan',
40
+ 'no feature tacacs',
41
+ 'no feature vn-segment-vlan-based',
42
+ 'no feature vni',
43
+ 'no feature vtp'].each { |f| config_no_warn(f) }
44
+ end
45
+
25
46
  ###########
26
47
  # Helpers #
27
48
  ###########
@@ -33,6 +54,7 @@ class TestFeature < CiscoTestCase
33
54
 
34
55
  if ref
35
56
  feat_str = Regexp.last_match[1]
57
+ refute_nil(feat_str)
36
58
  else
37
59
  skip("'feature','#{feat}' is unsupported on this node")
38
60
  end
@@ -62,10 +84,19 @@ class TestFeature < CiscoTestCase
62
84
  ###################
63
85
  # Feature tests #
64
86
  ###################
87
+
88
+ def test_bfd
89
+ feature('bfd')
90
+ end
91
+
65
92
  def test_bgp
66
93
  feature('bgp')
67
94
  end
68
95
 
96
+ def test_dhcp
97
+ feature('dhcp')
98
+ end
99
+
69
100
  def test_fabric_forwarding
70
101
  if node.product_id[/N(3)/]
71
102
  assert_nil(Feature.fabric_forwarding_enabled?)
@@ -85,12 +116,7 @@ class TestFeature < CiscoTestCase
85
116
  assert_raises(Cisco::UnsupportedError) { Feature.nv_overlay_enable }
86
117
  return
87
118
  end
88
-
89
- # Dependency setup
90
- vxlan_linecard?
91
- vdc_lc_state('f3')
92
- config_no_warn('no feature-set fabricpath')
93
-
119
+ vdc_limit_f3_no_intf_needed(:set)
94
120
  feature('nv_overlay')
95
121
  end
96
122
 
@@ -100,9 +126,8 @@ class TestFeature < CiscoTestCase
100
126
  assert_raises(Cisco::UnsupportedError) { Feature.nv_overlay_evpn_enable }
101
127
  return
102
128
  end
103
- vxlan_linecard?
104
- vdc_lc_state('f3')
105
129
 
130
+ vdc_limit_f3_no_intf_needed(:set)
106
131
  # nv_overlay_evpn can't use the 'feature' helper so test it explicitly here
107
132
  # Get current state of feature, then disable it
108
133
  pre_clean_enabled = Feature.nv_overlay_evpn_enabled?
@@ -144,15 +169,12 @@ class TestFeature < CiscoTestCase
144
169
  end
145
170
 
146
171
  def test_vni
147
- # Dependency setup
148
- vxlan_linecard?
149
- vdc_lc_state('f3')
150
-
151
172
  if node.product_id[/N(5|6)/]
152
173
  Feature.nv_overlay_enable
153
174
  else
154
175
  # vni can't be removed if nv overlay is present
155
176
  config_no_warn('no feature nv overlay')
177
+ vdc_limit_f3_no_intf_needed(:set)
156
178
  end
157
179
  feature('vni')
158
180
  rescue RuntimeError => e
@@ -173,10 +195,10 @@ class TestFeature < CiscoTestCase
173
195
  assert_raises(Cisco::UnsupportedError) { Feature.fabric_enable }
174
196
  return
175
197
  end
198
+ vdc_limit_f3_no_intf_needed(:set)
176
199
  fs = 'feature-set fabric'
177
200
  # Get current state of the feature-set
178
201
  feature_set_installed = Feature.fabric_installed?
179
- feature_enabled = Feature.fabric_enabled?
180
202
 
181
203
  config("no #{fs} ; no install #{fs}") if feature_set_installed
182
204
  refute_show_match(
@@ -187,10 +209,6 @@ class TestFeature < CiscoTestCase
187
209
 
188
210
  Feature.fabric_enable
189
211
  assert(Feature.fabric_enabled?, "(#{fs}) is not enabled")
190
-
191
- # Return testbed to pre-clean state
192
- config("no #{fs}") unless feature_enabled
193
- config("no install #{fs}") unless feature_set_installed
194
212
  end
195
213
 
196
214
  def test_feature_set_fex
@@ -64,6 +64,14 @@ class TestInterface < CiscoTestCase
64
64
 
65
65
  def teardown
66
66
  interface_ethernet_default(interfaces[0])
67
+ if first_or_last_teardown
68
+ config_no_warn('no feature pim')
69
+ config_no_warn('no feature dhcp')
70
+ config_no_warn('no feature bfd')
71
+ config_no_warn('no feature interface-vlan')
72
+ config_no_warn('no feature-set fabric')
73
+ config_no_warn('no install feature-set fabric')
74
+ end
67
75
  super
68
76
  end
69
77
 
@@ -184,12 +192,10 @@ class TestInterface < CiscoTestCase
184
192
  flunk(message)
185
193
  end
186
194
 
187
- # Helper to find first valid speed that isn't "auto"
188
- def valid_speed_set(interface)
189
- valid_speed = nil
190
- speeds = capable_speed_values(interface)
191
- speeds.each do |value|
192
- next if value == 'auto'
195
+ # Helper to find all configurable speeds for an interface
196
+ def valid_speeds(interface)
197
+ speeds = []
198
+ capable_speed_values(interface).each do |value|
193
199
  begin
194
200
  interface.speed = value
195
201
  assert_equal(value, interface.speed)
@@ -197,11 +203,9 @@ class TestInterface < CiscoTestCase
197
203
  next if speed_change_disallowed?(e.message)
198
204
  raise
199
205
  end
200
- # Exit loop once proper speed is found
201
- valid_speed = value
202
- break
206
+ speeds << value
203
207
  end
204
- valid_speed
208
+ speeds
205
209
  end
206
210
 
207
211
  # Helper to check for misc speed change disallowed error messages.
@@ -211,7 +215,8 @@ class TestInterface < CiscoTestCase
211
215
  'requested config change not allowed',
212
216
  /does not match the (transceiver speed|port capability)/,
213
217
  'but the transceiver doesn t support this speed',
214
- '% Ambiguous parameter']
218
+ '% Ambiguous parameter',
219
+ '% Invalid parameter']
215
220
  message[Regexp.union(patterns)]
216
221
  end
217
222
 
@@ -254,8 +259,21 @@ class TestInterface < CiscoTestCase
254
259
  "Error: #{interface.name} shutdown is not false")
255
260
 
256
261
  interface.shutdown = true
257
- assert(interface.shutdown,
258
- "Error: #{interface.name} shutdown is not true")
262
+ # On some platforms, a small delay is needed after setting the
263
+ # shutdown property before the new state can be retrieved by
264
+ # the getter.
265
+ # TBD: Likely a bug in nxapi, but it's not reproducible using
266
+ # the nxapi sandbox.
267
+ begin
268
+ assert(interface.shutdown,
269
+ "Error: #{interface.name} shutdown is not true")
270
+ rescue Minitest::Assertion
271
+ sleep 1
272
+ node.cache_flush
273
+ tries ||= 1
274
+ retry unless (tries += 1) > 5
275
+ raise
276
+ end
259
277
 
260
278
  # Test default shutdown state
261
279
  if k.downcase.include?('ethernet') # Ethernet interfaces
@@ -486,43 +504,43 @@ class TestInterface < CiscoTestCase
486
504
  end
487
505
  end
488
506
 
489
- def test_interface_create_name_nil
507
+ def test_create_name_nil
490
508
  assert_raises(TypeError) do
491
509
  Interface.new(nil)
492
510
  end
493
511
  end
494
512
 
495
- def test_interface_create_name_invalid
513
+ def test_create_name_invalid
496
514
  assert_raises(TypeError) do
497
515
  Interface.new(node)
498
516
  end
499
517
  end
500
518
 
501
- def test_interface_create_does_not_exist
519
+ def test_create_does_not_exist
502
520
  assert_raises(CliError) do
503
521
  Interface.new('bogus')
504
522
  end
505
523
  end
506
524
 
507
- def test_interface_create_valid
525
+ def test_create_valid
508
526
  interface = Interface.new(interfaces[0])
509
527
  assert_equal(interfaces[0].downcase, interface.name)
510
528
  end
511
529
 
512
- def test_interface_description_nil
530
+ def test_description_nil
513
531
  interface = Interface.new(interfaces[0])
514
532
  assert_raises(TypeError) do
515
533
  interface.description = nil
516
534
  end
517
535
  end
518
536
 
519
- def test_interface_description_zero_length
537
+ def test_description_zero_length
520
538
  interface = Interface.new(interfaces[0])
521
539
  interface.description = ''
522
540
  assert_equal('', interface.description)
523
541
  end
524
542
 
525
- def test_interface_description_valid
543
+ def test_description_valid
526
544
  interface = Interface.new(interfaces[0])
527
545
  description = 'This is a test description ! '
528
546
  interface.description = description
@@ -541,7 +559,35 @@ class TestInterface < CiscoTestCase
541
559
  subif.destroy
542
560
  end
543
561
 
544
- def test_interface_mtu_change
562
+ def test_bfd_echo
563
+ interface = Interface.new(interfaces[0])
564
+ if validate_property_excluded?('interface', 'bfd_echo')
565
+ assert_nil(interface.bfd_echo)
566
+ assert_raises(Cisco::UnsupportedError) { interface.bfd_echo = false }
567
+ return
568
+ end
569
+ assert_equal(interface.default_bfd_echo,
570
+ interface.bfd_echo)
571
+ interface.bfd_echo = false
572
+ assert_equal(false, interface.bfd_echo)
573
+ interface.bfd_echo = interface.default_bfd_echo
574
+ assert_equal(interface.default_bfd_echo,
575
+ interface.bfd_echo)
576
+ # Clean up any stale config first
577
+ inf_name = "#{@port_channel}10"
578
+ Interface.new(inf_name).destroy
579
+
580
+ interface = Interface.new(inf_name)
581
+ assert_equal(interface.default_bfd_echo,
582
+ interface.bfd_echo)
583
+ interface.bfd_echo = false
584
+ assert_equal(false, interface.bfd_echo)
585
+ interface.bfd_echo = interface.default_bfd_echo
586
+ assert_equal(interface.default_bfd_echo,
587
+ interface.bfd_echo)
588
+ end
589
+
590
+ def test_mtu_change
545
591
  interface = Interface.new(interfaces[0])
546
592
  interface.switchport_mode = :disabled
547
593
  interface.mtu = 1520
@@ -552,13 +598,13 @@ class TestInterface < CiscoTestCase
552
598
  assert_equal(interface.default_mtu, interface.mtu)
553
599
  end
554
600
 
555
- def test_interface_mtu_invalid
601
+ def test_mtu_invalid
556
602
  interface = Interface.new(interfaces[0])
557
603
  interface.switchport_mode = :disabled
558
604
  assert_raises(Cisco::CliError) { interface.mtu = 'hello' }
559
605
  end
560
606
 
561
- def test_interface_mtu_valid
607
+ def test_mtu_valid
562
608
  interface = Interface.new(interfaces[0])
563
609
  interface.switchport_mode = :disabled
564
610
  interface.mtu = 1550
@@ -625,8 +671,9 @@ class TestInterface < CiscoTestCase
625
671
 
626
672
  # Ensure speed is non-auto value
627
673
  if interface.default_speed == 'auto'
628
- valid_speed = valid_speed_set(interface)
674
+ valid_speed = valid_speeds(interface).select { |v| v != 'auto' }.shift
629
675
  skip('Cannot configure non-auto speed') if valid_speed.nil?
676
+ interface.speed = valid_speed
630
677
  end
631
678
 
632
679
  # Test non-default values
@@ -642,7 +689,7 @@ class TestInterface < CiscoTestCase
642
689
  assert_equal(interface.duplex, interface.default_duplex)
643
690
  end
644
691
 
645
- def test_interface_shutdown_valid
692
+ def test_shutdown_valid
646
693
  interface = Interface.new(interfaces[0])
647
694
  interface.shutdown = true
648
695
  assert(interface.shutdown, 'Error: shutdown state is not true')
@@ -659,14 +706,14 @@ class TestInterface < CiscoTestCase
659
706
  'Error: svi_management should be nil when interface is ethernet')
660
707
  end
661
708
 
662
- # def test_interface_get_prefix_list_when_switchport
709
+ # def test_prefix_list_when_switchport
663
710
  # interface = Interface.new(interfaces[0])
664
711
  # interface.switchport_mode = :access
665
712
  # addresses = interface.prefixes
666
713
  # assert_empty(addresses)
667
714
  # end
668
715
  #
669
- # def test_interface_get_prefix_list_with_ipv4_address_assignment
716
+ # def test_prefix_list_with_ipv4
670
717
  # interface = Interface.new(interfaces[0])
671
718
  # interface.switchport_mode = :access
672
719
  # interface.switchport_mode = :disabled if platform == :nexus
@@ -679,7 +726,7 @@ class TestInterface < CiscoTestCase
679
726
  # prefixes = nil
680
727
  # end
681
728
  #
682
- # def test_interface_get_prefix_list_with_ipv6_address_assignment
729
+ # def test_prefix_list_with_ipv6
683
730
  # interface = Interface.new(interfaces[0] )
684
731
  # interface.switchport_mode = :access
685
732
  # interface.switchport_mode = :disabled if platform == :nexus
@@ -692,7 +739,7 @@ class TestInterface < CiscoTestCase
692
739
  # prefixes = nil
693
740
  # end
694
741
  #
695
- # def test_interface_prefix_list_with_both_ip4_and_ipv6_address_assignments
742
+ # def test_prefix_list_with_ipv4_ipv6
696
743
  # interface = Interface.new(interfaces[0])
697
744
  # interface.switchport_mode = :access
698
745
  # interface.switchport_mode = :disabled if platform == :nexus
@@ -707,68 +754,35 @@ class TestInterface < CiscoTestCase
707
754
  # prefixes = nil
708
755
  # end
709
756
 
710
- def negotiate_auto_helper(interface, default, speed)
757
+ def negotiate_auto_helper(interface, speed)
711
758
  if validate_property_excluded?('interface',
712
759
  interface.negotiate_auto_lookup_string)
713
760
  assert_raises(Cisco::UnsupportedError) { interface.negotiate_auto = true }
714
761
  return
715
762
  end
716
- # Check current default state before any other changes
717
- inf_name = interface.name
718
- assert_equal(default, interface.default_negotiate_auto,
719
- "Error: #{inf_name} negotiate auto default value mismatch")
720
-
721
- # Test non-defaults: Note that 'speed' and 'negotiate' are tightly coupled
722
- # on some platforms. Some platforms need the speed command to be toggled
723
- # before negotiate will work without raising an error; while others just
724
- # need a non-'auto' speed value or may not support 'auto' at all; therefore
725
- # just set a static speed value before setting any negotiate settings.
726
- if default == true
727
- negotiate_false(interface, speed)
728
- negotiate_true(interface, speed)
729
- else
730
- negotiate_true(interface, speed)
731
- negotiate_false(interface, speed)
732
- end
733
- end
734
763
 
735
- def negotiate_true(interface, speed)
736
- # puts " true: 'speed #{speed}', 'negotiate auto'"
737
- intf = interface.name
764
+ # Note that 'speed' and 'negotiate auto' are tightly coupled
765
+ # When speed is 'auto', set negotiate auto to 'true'
766
+ # When speed is static value, turn off negotiate auto
738
767
  interface.speed = speed
739
- interface.negotiate_auto = true
740
- assert(interface.negotiate_auto,
741
- "#{intf} negotiate auto value should be true")
742
- assert_show_match(pattern: /^\s+negotiate auto/)
743
- rescue Cisco::CliError => e
744
- # 10G+ interfaces do not support negotiation
745
- interface_supports_property?(intf, e.message)
746
- end
747
-
748
- # Yes, this method is nearly identical to negotiate_true.
749
- # The negotiate property is evil to troubleshoot. Keep them separate.
750
- def negotiate_false(interface, speed)
751
- # puts "false: 'speed #{speed}', 'no negotiate auto'"
752
- intf = interface.name
753
- interface.speed = speed
754
- interface.negotiate_auto = false
755
- refute(interface.negotiate_auto,
756
- "#{intf} negotiate auto value should be false")
757
- assert_show_match(pattern: /^\s+no negotiate auto/)
758
- rescue Cisco::CliError => e
759
- # 10G+ interfaces do not support negotiation
760
- interface_supports_property?(intf, e.message)
768
+ if speed == 'auto'
769
+ interface.negotiate_auto = true
770
+ assert(interface.negotiate_auto,
771
+ "#{interface.name} negotiate auto value should be true")
772
+ else
773
+ interface.negotiate_auto = false
774
+ refute(interface.negotiate_auto,
775
+ "#{interface.name} negotiate auto value should be false")
776
+ end
761
777
  end
762
778
 
763
779
  def test_negotiate_auto_portchannel
764
- # Create interface member of this group (required for XR)
765
- member = InterfaceChannelGroup.new(interfaces[0])
766
- begin
767
- member.channel_group = 10
768
- rescue Cisco::UnsupportedError
769
- # Some XR platform/version combinations don't support port-channel intfs
770
- skip('bundle id config not supported on this node') if platform == :ios_xr
771
- raise
780
+ if validate_property_excluded?('interface_channel_group', 'channel_group')
781
+ member = InterfaceChannelGroup.new(interfaces[0])
782
+ assert_raises(Cisco::UnsupportedError) do
783
+ member.channel_group = 10
784
+ end
785
+ return
772
786
  end
773
787
 
774
788
  # Clean up any stale config first
@@ -783,20 +797,14 @@ class TestInterface < CiscoTestCase
783
797
  interface.negotiate_auto = false
784
798
  end
785
799
  else
786
- default = interface.default_negotiate_auto
787
800
  @default_show_command = show_cmd(inf_name)
788
801
 
789
- # Port-channels will raise an error on some platforms unless they
790
- # have a static speed value set first.
791
- speed = '100'
792
-
793
- # Test with switchport
794
- interface.switchport_mode = :access
795
- negotiate_auto_helper(interface, default, speed)
802
+ # Platforms raise error unless speed is properly configured first
803
+ speeds = valid_speeds(interface)
804
+ negotiate_auto_helper(interface, 'auto') if speeds.delete('auto')
796
805
 
797
- # Test with no switchport
798
- interface.switchport_mode = :disabled
799
- negotiate_auto_helper(interface, default, speed)
806
+ non_auto = speeds.shift
807
+ negotiate_auto_helper(interface, non_auto) unless non_auto.nil?
800
808
  end
801
809
 
802
810
  # Cleanup
@@ -816,20 +824,14 @@ class TestInterface < CiscoTestCase
816
824
  return
817
825
  end
818
826
 
819
- # Find a static speed. Some platforms will raise an error unless
820
- # speed is configured before setting negotiate auto.
821
- speed = valid_speed_set(interface)
822
-
823
- default = interface.default_negotiate_auto
824
827
  @default_show_command = show_cmd(inf_name)
825
828
 
826
- # Test with switchport
827
- interface.switchport_mode = :access
828
- negotiate_auto_helper(interface, default, speed)
829
+ # Platforms raise error unless speed is properly configured first
830
+ speeds = valid_speeds(interface)
831
+ negotiate_auto_helper(interface, 'auto') if speeds.delete('auto')
829
832
 
830
- # Test with no switchport
831
- interface.switchport_mode = :disabled
832
- negotiate_auto_helper(interface, default, speed)
833
+ non_auto = speeds.shift
834
+ negotiate_auto_helper(interface, non_auto) unless non_auto.nil?
833
835
  end
834
836
 
835
837
  def test_negotiate_auto_loopback
@@ -859,7 +861,7 @@ class TestInterface < CiscoTestCase
859
861
  refute_empty(Interface.interfaces, 'Error: interfaces collection empty')
860
862
  end
861
863
 
862
- def test_interface_ipv4_addr_mask_set_address_invalid
864
+ def test_ipv4_addr_mask_set_inv
863
865
  interface = create_interface
864
866
  interface.switchport_mode = :disabled if platform == :nexus
865
867
  assert_raises(Cisco::CliError) do
@@ -867,7 +869,7 @@ class TestInterface < CiscoTestCase
867
869
  end
868
870
  end
869
871
 
870
- def test_interface_ipv4_addr_mask_set_netmask_invalid
872
+ def test_ipv4_addr_mask_set_inv_mask
871
873
  interface = create_interface
872
874
  interface.switchport_mode = :disabled if platform == :nexus
873
875
  assert_raises(Cisco::CliError) do
@@ -955,7 +957,7 @@ class TestInterface < CiscoTestCase
955
957
  end
956
958
  end
957
959
 
958
- def test_interface_ipv4_address
960
+ def test_ipv4_address
959
961
  interface = create_interface
960
962
  interface.switchport_mode = :disabled if platform == :nexus
961
963
  address = '8.7.1.1'
@@ -1010,7 +1012,7 @@ class TestInterface < CiscoTestCase
1010
1012
  'Error: ipv4 netmask length default get value mismatch')
1011
1013
  end
1012
1014
 
1013
- def test_interface_ipv4_address_getter_with_preconfig
1015
+ def test_ipv4_addr_preconfig
1014
1016
  address = '8.7.1.1'
1015
1017
  length = 15
1016
1018
  ifname = interfaces[0]
@@ -1027,7 +1029,7 @@ class TestInterface < CiscoTestCase
1027
1029
  interface_ipv4_config(ifname, address, length, false)
1028
1030
  end
1029
1031
 
1030
- def test_interface_ipv4_address_getter_with_preconfig_secondary
1032
+ def test_ipv4_addr_preconfig_sec
1031
1033
  address = '8.7.1.1'
1032
1034
  length = 15
1033
1035
  sec_address = '1.1.2.5'
@@ -1048,27 +1050,27 @@ class TestInterface < CiscoTestCase
1048
1050
  interface_ipv4_config(ifname, address, length, false, false)
1049
1051
  end
1050
1052
 
1051
- def test_interface_ipv4_arp_timeout
1053
+ def test_ipv4_arp_timeout
1052
1054
  unless platform == :ios_xr
1053
1055
  # Setup
1054
1056
  config_no_warn('no interface vlan11')
1055
- int = Interface.new('vlan11')
1057
+ svi = Interface.new('vlan11')
1056
1058
 
1057
1059
  # Test default
1058
- assert_equal(int.default_ipv4_arp_timeout, int.ipv4_arp_timeout)
1060
+ assert_equal(svi.default_ipv4_arp_timeout, svi.ipv4_arp_timeout)
1059
1061
  # Test non-default
1060
- int.ipv4_arp_timeout = 300
1061
- assert_equal(300, int.ipv4_arp_timeout)
1062
+ svi.ipv4_arp_timeout = 300
1063
+ assert_equal(300, svi.ipv4_arp_timeout)
1062
1064
  # Set back to default
1063
- int.ipv4_arp_timeout = int.default_ipv4_arp_timeout
1064
- assert_equal(int.default_ipv4_arp_timeout, int.ipv4_arp_timeout)
1065
+ svi.ipv4_arp_timeout = svi.default_ipv4_arp_timeout
1066
+ assert_equal(svi.default_ipv4_arp_timeout, svi.ipv4_arp_timeout)
1065
1067
  end
1066
1068
  # Attempt to configure on a non-vlan interface
1067
- nonvlanint = create_interface
1068
- assert_raises(RuntimeError) { nonvlanint.ipv4_arp_timeout = 300 }
1069
+ nonsvi = create_interface
1070
+ assert_raises(RuntimeError) { nonsvi.ipv4_arp_timeout = 300 }
1069
1071
  end
1070
1072
 
1071
- def test_interface_ipv4_forwarding
1073
+ def test_ipv4_forwarding
1072
1074
  intf = interfaces[0]
1073
1075
  i = Interface.new(intf)
1074
1076
 
@@ -1099,7 +1101,7 @@ class TestInterface < CiscoTestCase
1099
1101
  assert_equal(i.default_ipv4_forwarding, i.ipv4_forwarding)
1100
1102
  end
1101
1103
 
1102
- def test_interface_fabric_forwarding_anycast_gateway
1104
+ def test_ff_anycast_gateway_mac
1103
1105
  # Ensure N7k has compatible interface
1104
1106
  mt_full_interface? if node.product_id[/N7/]
1105
1107
 
@@ -1154,7 +1156,7 @@ class TestInterface < CiscoTestCase
1154
1156
  end
1155
1157
  end
1156
1158
 
1157
- def test_interface_ipv4_proxy_arp
1159
+ def test_ipv4_proxy_arp
1158
1160
  interface = create_interface
1159
1161
  interface.switchport_mode = :disabled if platform == :nexus
1160
1162
 
@@ -1191,7 +1193,7 @@ class TestInterface < CiscoTestCase
1191
1193
  'Error: ip proxy-arp default get value mismatch')
1192
1194
  end
1193
1195
 
1194
- def test_interface_ipv4_redirects
1196
+ def test_ipv4_redirects
1195
1197
  interface = create_interface
1196
1198
  interface.switchport_mode = :disabled if platform == :nexus
1197
1199
 
@@ -1338,7 +1340,7 @@ class TestInterface < CiscoTestCase
1338
1340
 
1339
1341
  # NOTE - Changes to this method may require new validation methods
1340
1342
  # to be created or existing ones to be modified.
1341
- def test_interface_ipv4_all_interfaces
1343
+ def test_ipv4_all_interfaces
1342
1344
  inttype_h = interface_test_data
1343
1345
 
1344
1346
  # Set system defaults to "factory" values prior to initial test.
@@ -1391,7 +1393,7 @@ class TestInterface < CiscoTestCase
1391
1393
  end
1392
1394
  end
1393
1395
 
1394
- def test_interface_vrf_default
1396
+ def test_vrf_default
1395
1397
  interface = Interface.new('loopback1')
1396
1398
  assert_empty(interface.vrf)
1397
1399
  interface.vrf = 'foo'
@@ -1400,18 +1402,18 @@ class TestInterface < CiscoTestCase
1400
1402
  assert_equal(interface.vrf, interface.default_vrf)
1401
1403
  end
1402
1404
 
1403
- def test_interface_vrf_invalid_type
1405
+ def test_vrf_invalid_type
1404
1406
  interface = Interface.new('loopback1')
1405
1407
  assert_raises(TypeError) { interface.vrf = 1 }
1406
1408
  end
1407
1409
 
1408
- def test_interface_vrf_exceeds_max_length
1410
+ def test_vrf_exceeds_max_length
1409
1411
  interface = Interface.new('loopback1')
1410
1412
  long_string = 'a' * (IF_VRF_MAX_LENGTH + 1)
1411
1413
  assert_raises(Cisco::CliError) { interface.vrf = long_string }
1412
1414
  end
1413
1415
 
1414
- def test_interface_vrf_override
1416
+ def test_vrf_override
1415
1417
  interface = Interface.new('loopback1')
1416
1418
  vrf1 = 'test1'
1417
1419
  vrf2 = 'test2'
@@ -1421,7 +1423,7 @@ class TestInterface < CiscoTestCase
1421
1423
  interface.destroy
1422
1424
  end
1423
1425
 
1424
- def test_interface_vrf_valid
1426
+ def test_vrf_valid
1425
1427
  interface = Interface.new('loopback1')
1426
1428
  vrf = 'test'
1427
1429
  interface.vrf = vrf
@@ -1491,4 +1493,227 @@ class TestInterface < CiscoTestCase
1491
1493
  i.ipv4_pim_sparse_mode = i.default_ipv4_pim_sparse_mode
1492
1494
  assert_equal(i.default_ipv4_pim_sparse_mode, i.ipv4_pim_sparse_mode)
1493
1495
  end
1496
+
1497
+ def test_storm_control_broadcast
1498
+ interface = Interface.new(interfaces[0])
1499
+ interface.switchport_enable(true)
1500
+ if validate_property_excluded?('interface', 'storm_control_broadcast')
1501
+ assert_nil(interface.storm_control_broadcast)
1502
+ assert_raises(Cisco::UnsupportedError) do
1503
+ interface.storm_control_broadcast = '20.12'
1504
+ end
1505
+ return
1506
+ end
1507
+ assert_equal(interface.default_storm_control_broadcast,
1508
+ interface.storm_control_broadcast)
1509
+ interface.storm_control_broadcast = '20.12'
1510
+ assert_equal('20.12', interface.storm_control_broadcast)
1511
+ interface.storm_control_broadcast =
1512
+ interface.default_storm_control_broadcast
1513
+ assert_equal(interface.default_storm_control_broadcast,
1514
+ interface.storm_control_broadcast)
1515
+ end
1516
+
1517
+ def test_storm_control_multicast
1518
+ interface = Interface.new(interfaces[0])
1519
+ interface.switchport_enable(true)
1520
+ if validate_property_excluded?('interface', 'storm_control_multicast')
1521
+ assert_nil(interface.storm_control_multicast)
1522
+ assert_raises(Cisco::UnsupportedError) do
1523
+ interface.storm_control_multicast = '33.33'
1524
+ end
1525
+ return
1526
+ end
1527
+ assert_equal(interface.default_storm_control_multicast,
1528
+ interface.storm_control_multicast)
1529
+ interface.storm_control_multicast = '33.33'
1530
+ assert_equal('33.33', interface.storm_control_multicast)
1531
+ interface.storm_control_multicast =
1532
+ interface.default_storm_control_multicast
1533
+ assert_equal(interface.default_storm_control_multicast,
1534
+ interface.storm_control_multicast)
1535
+ end
1536
+
1537
+ def test_storm_control_unicast
1538
+ interface = Interface.new(interfaces[0])
1539
+ interface.switchport_enable(true)
1540
+ if validate_property_excluded?('interface', 'storm_control_unicast')
1541
+ assert_nil(interface.storm_control_unicast)
1542
+ assert_raises(Cisco::UnsupportedError) do
1543
+ interface.storm_control_unicast = '44.44'
1544
+ end
1545
+ return
1546
+ end
1547
+ assert_equal(interface.default_storm_control_unicast,
1548
+ interface.storm_control_unicast)
1549
+ interface.storm_control_unicast = '44.44'
1550
+ assert_equal('44.44', interface.storm_control_unicast)
1551
+ interface.storm_control_unicast =
1552
+ interface.default_storm_control_unicast
1553
+ assert_equal(interface.default_storm_control_unicast,
1554
+ interface.storm_control_unicast)
1555
+ end
1556
+
1557
+ def test_ipv4_dhcp_relay_addr
1558
+ interface = Interface.new(interfaces[0])
1559
+ interface.switchport_enable(false)
1560
+ list = ['1.1.1.1', '2.2.2.2']
1561
+ if validate_property_excluded?('interface', 'ipv4_dhcp_relay_addr')
1562
+ assert_nil(interface.ipv4_dhcp_relay_addr)
1563
+ assert_raises(Cisco::UnsupportedError) do
1564
+ interface.ipv4_dhcp_relay_addr = list
1565
+ end
1566
+ return
1567
+ end
1568
+ assert_equal(interface.default_ipv4_dhcp_relay_addr,
1569
+ interface.ipv4_dhcp_relay_addr)
1570
+ interface.ipv4_dhcp_relay_addr = list
1571
+ assert_equal(list, interface.ipv4_dhcp_relay_addr)
1572
+ interface.ipv4_dhcp_relay_addr =
1573
+ interface.default_ipv4_dhcp_relay_addr
1574
+ assert_equal(interface.default_ipv4_dhcp_relay_addr,
1575
+ interface.ipv4_dhcp_relay_addr)
1576
+ end
1577
+
1578
+ def test_ipv4_dhcp_relay_info_trust
1579
+ interface = Interface.new(interfaces[0])
1580
+ interface.switchport_enable(false)
1581
+ if validate_property_excluded?('interface', 'ipv4_dhcp_relay_info_trust')
1582
+ assert_nil(interface.ipv4_dhcp_relay_info_trust)
1583
+ assert_raises(Cisco::UnsupportedError) do
1584
+ interface.ipv4_dhcp_relay_info_trust = true
1585
+ end
1586
+ return
1587
+ end
1588
+ assert_equal(interface.default_ipv4_dhcp_relay_info_trust,
1589
+ interface.ipv4_dhcp_relay_info_trust)
1590
+ interface.ipv4_dhcp_relay_info_trust = true
1591
+ assert_equal(true, interface.ipv4_dhcp_relay_info_trust)
1592
+ interface.ipv4_dhcp_relay_info_trust =
1593
+ interface.default_ipv4_dhcp_relay_info_trust
1594
+ assert_equal(interface.default_ipv4_dhcp_relay_info_trust,
1595
+ interface.ipv4_dhcp_relay_info_trust)
1596
+ end
1597
+
1598
+ def test_ipv4_dhcp_relay_src_addr_hsrp
1599
+ interface = Interface.new(interfaces[0])
1600
+ interface.switchport_enable(false)
1601
+ if validate_property_excluded?('interface', 'ipv4_dhcp_relay_src_addr_hsrp')
1602
+ assert_nil(interface.ipv4_dhcp_relay_src_addr_hsrp)
1603
+ assert_raises(Cisco::UnsupportedError) do
1604
+ interface.ipv4_dhcp_relay_src_addr_hsrp = true
1605
+ end
1606
+ return
1607
+ end
1608
+ assert_equal(interface.default_ipv4_dhcp_relay_src_addr_hsrp,
1609
+ interface.ipv4_dhcp_relay_src_addr_hsrp)
1610
+ interface.ipv4_dhcp_relay_src_addr_hsrp = true
1611
+ assert_equal(true, interface.ipv4_dhcp_relay_src_addr_hsrp)
1612
+ interface.ipv4_dhcp_relay_src_addr_hsrp =
1613
+ interface.default_ipv4_dhcp_relay_src_addr_hsrp
1614
+ assert_equal(interface.default_ipv4_dhcp_relay_src_addr_hsrp,
1615
+ interface.ipv4_dhcp_relay_src_addr_hsrp)
1616
+ end
1617
+
1618
+ def test_ipv4_dhcp_relay_src_intf
1619
+ interface = Interface.new(interfaces[0])
1620
+ interface.switchport_enable(false)
1621
+ if validate_property_excluded?('interface', 'ipv4_dhcp_relay_src_intf')
1622
+ assert_nil(interface.ipv4_dhcp_relay_src_intf)
1623
+ assert_raises(Cisco::UnsupportedError) do
1624
+ interface.ipv4_dhcp_relay_src_intf = 'port-channel200'
1625
+ end
1626
+ return
1627
+ end
1628
+ assert_equal(interface.default_ipv4_dhcp_relay_src_intf,
1629
+ interface.ipv4_dhcp_relay_src_intf)
1630
+ interface.ipv4_dhcp_relay_src_intf = 'port-channel200'
1631
+ assert_equal('port-channel200', interface.ipv4_dhcp_relay_src_intf)
1632
+ interface.ipv4_dhcp_relay_src_intf =
1633
+ interface.default_ipv4_dhcp_relay_src_intf
1634
+ assert_equal(interface.default_ipv4_dhcp_relay_src_intf,
1635
+ interface.ipv4_dhcp_relay_src_intf)
1636
+ end
1637
+
1638
+ def test_ipv4_dhcp_relay_subnet_broadcast
1639
+ interface = Interface.new(interfaces[0])
1640
+ interface.switchport_enable(false)
1641
+ if validate_property_excluded?('interface', 'ipv4_dhcp_relay_subnet_broadcast')
1642
+ assert_nil(interface.ipv4_dhcp_relay_subnet_broadcast)
1643
+ assert_raises(Cisco::UnsupportedError) do
1644
+ interface.ipv4_dhcp_relay_subnet_broadcast = true
1645
+ end
1646
+ return
1647
+ end
1648
+ assert_equal(interface.default_ipv4_dhcp_relay_subnet_broadcast,
1649
+ interface.ipv4_dhcp_relay_subnet_broadcast)
1650
+ interface.ipv4_dhcp_relay_subnet_broadcast = true
1651
+ assert_equal(true, interface.ipv4_dhcp_relay_subnet_broadcast)
1652
+ interface.ipv4_dhcp_relay_subnet_broadcast =
1653
+ interface.default_ipv4_dhcp_relay_subnet_broadcast
1654
+ assert_equal(interface.default_ipv4_dhcp_relay_subnet_broadcast,
1655
+ interface.ipv4_dhcp_relay_subnet_broadcast)
1656
+ end
1657
+
1658
+ def test_ipv4_dhcp_smart_relay
1659
+ interface = Interface.new(interfaces[0])
1660
+ interface.switchport_enable(false)
1661
+ if validate_property_excluded?('interface', 'ipv4_dhcp_smart_relay')
1662
+ assert_nil(interface.ipv4_dhcp_smart_relay)
1663
+ assert_raises(Cisco::UnsupportedError) do
1664
+ interface.ipv4_dhcp_smart_relay = true
1665
+ end
1666
+ return
1667
+ end
1668
+ assert_equal(interface.default_ipv4_dhcp_smart_relay,
1669
+ interface.ipv4_dhcp_smart_relay)
1670
+ interface.ipv4_dhcp_smart_relay = true
1671
+ assert_equal(true, interface.ipv4_dhcp_smart_relay)
1672
+ interface.ipv4_dhcp_smart_relay =
1673
+ interface.default_ipv4_dhcp_smart_relay
1674
+ assert_equal(interface.default_ipv4_dhcp_smart_relay,
1675
+ interface.ipv4_dhcp_smart_relay)
1676
+ end
1677
+
1678
+ def test_ipv6_dhcp_relay_addr
1679
+ interface = Interface.new(interfaces[0])
1680
+ interface.switchport_enable(false)
1681
+ list = ['2000::11', '2000::12']
1682
+ if validate_property_excluded?('interface', 'ipv6_dhcp_relay_addr')
1683
+ assert_nil(interface.ipv6_dhcp_relay_addr)
1684
+ assert_raises(Cisco::UnsupportedError) do
1685
+ interface.ipv6_dhcp_relay_addr = list
1686
+ end
1687
+ return
1688
+ end
1689
+ assert_equal(interface.default_ipv6_dhcp_relay_addr,
1690
+ interface.ipv6_dhcp_relay_addr)
1691
+ interface.ipv6_dhcp_relay_addr = list
1692
+ assert_equal(list, interface.ipv6_dhcp_relay_addr)
1693
+ interface.ipv6_dhcp_relay_addr =
1694
+ interface.default_ipv6_dhcp_relay_addr
1695
+ assert_equal(interface.default_ipv6_dhcp_relay_addr,
1696
+ interface.ipv6_dhcp_relay_addr)
1697
+ end
1698
+
1699
+ def test_ipv6_dhcp_relay_src_intf
1700
+ inf_name = interfaces[0]
1701
+ interface = Interface.new(inf_name)
1702
+ interface.switchport_enable(false)
1703
+ if validate_property_excluded?('interface', 'ipv6_dhcp_relay_src_intf')
1704
+ assert_nil(interface.ipv6_dhcp_relay_src_intf)
1705
+ assert_raises(Cisco::UnsupportedError) do
1706
+ interface.ipv6_dhcp_relay_src_intf = inf_name
1707
+ end
1708
+ return
1709
+ end
1710
+ assert_equal(interface.default_ipv6_dhcp_relay_src_intf,
1711
+ interface.ipv6_dhcp_relay_src_intf)
1712
+ interface.ipv6_dhcp_relay_src_intf = inf_name
1713
+ assert_equal(inf_name, interface.ipv6_dhcp_relay_src_intf)
1714
+ interface.ipv6_dhcp_relay_src_intf =
1715
+ interface.default_ipv6_dhcp_relay_src_intf
1716
+ assert_equal(interface.default_ipv6_dhcp_relay_src_intf,
1717
+ interface.ipv6_dhcp_relay_src_intf)
1718
+ end
1494
1719
  end