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
@@ -17,16 +17,9 @@ require_relative '../lib/cisco_node_utils/tacacs_server_group'
17
17
  require_relative '../lib/cisco_node_utils/tacacs_server_host'
18
18
 
19
19
  # Test class for Tacacs Server Group
20
- class TestTacacsServerGroup < CiscoTestCase
20
+ class TestTacacsSvrGrp < CiscoTestCase
21
21
  @skip_unless_supported = 'tacacs_server_group'
22
22
 
23
- def setup
24
- super
25
- # TBD: Remove once CSCuz44696 is resolved.
26
- skip('This test is not currently supported on 7.0(3)I3 images') if
27
- node.os_version[/7.0\(3\)I3\(/]
28
- end
29
-
30
23
  def clean_tacacs_config
31
24
  config('no feature tacacs',
32
25
  'feature tacacs')
@@ -141,7 +134,7 @@ class TestTacacsServerGroup < CiscoTestCase
141
134
  destroy_aaa_group(group_name3, 'tacacs+')
142
135
  end
143
136
 
144
- def test_servers_tacacs
137
+ def test_servers
145
138
  clean_tacacs_config
146
139
  server_name1 = '1.1.1.1'
147
140
  server_name2 = '2.2.2.2'
@@ -170,25 +163,6 @@ class TestTacacsServerGroup < CiscoTestCase
170
163
  detach_tacacsserverhost(server_name2)
171
164
  end
172
165
 
173
- def test_add_server_tacacs
174
- server_name1 = '1.1.1.1'
175
- server_name2 = '2.2.2.2'
176
- create_tacacsserverhost(server_name1)
177
- create_tacacsserverhost(server_name2)
178
-
179
- aaa_group = TacacsServerGroup.new('Group1')
180
- aaa_group.servers = [server_name1, server_name2]
181
-
182
- assert_show_match(command: config_command,
183
- pattern: /server #{server_name1}/)
184
- assert_show_match(command: config_command,
185
- pattern: /server #{server_name2}/)
186
-
187
- detach_aaaservergroup(aaa_group)
188
- detach_tacacsserverhost(server_name1)
189
- detach_tacacsserverhost(server_name2)
190
- end
191
-
192
166
  def test_remove_server_tacacs
193
167
  clean_tacacs_config
194
168
  server_name1 = '1.1.1.1'
@@ -389,7 +363,7 @@ class TestTacacsServerGroup < CiscoTestCase
389
363
  detach_aaaservergroup(aaa_group)
390
364
  end
391
365
 
392
- def test_get_default_source_interface_tacacs
366
+ def test_source_interface
393
367
  # TODO
394
368
  return if validate_property_excluded?('tacacs_server_group',
395
369
  'source_interface')
@@ -22,7 +22,7 @@ DEFAULT_TACACS_SERVER_HOST_TIMEOUT = 0
22
22
  DEFAULT_TACACS_SERVER_HOST_ENCRYPTION_PASSWORD = ''
23
23
 
24
24
  # TestTacacsServerHost - Minitest for TacacsServerHost node utility
25
- class TestTacacsServerHost < CiscoTestCase
25
+ class TestTacacsSvrHost < CiscoTestCase
26
26
  @skip_unless_supported = 'tacacs_server_host'
27
27
 
28
28
  def setup
@@ -44,7 +44,7 @@ class TestTacacsServerHost < CiscoTestCase
44
44
  'no aaa group server tacacs blue')
45
45
  end
46
46
 
47
- def test_tacacsserverhost_collection_empty
47
+ def test_collection_empty
48
48
  hosts = TacacsServerHost.hosts
49
49
  hosts.each_value(&:destroy)
50
50
  hosts = TacacsServerHost.hosts
@@ -52,7 +52,7 @@ class TestTacacsServerHost < CiscoTestCase
52
52
  assert_empty(hosts, 'Error: Tacacs Host collection is not empty')
53
53
  end
54
54
 
55
- def test_tacacsserverhost_collection
55
+ def test_collection
56
56
  hosts_hash = {}
57
57
  hosts_hash['4.4.4.4'] = 1138
58
58
  hosts_hash['5.5.5.5'] = DEFAULT_TACACS_SERVER_HOST_PORT
@@ -80,21 +80,18 @@ class TestTacacsServerHost < CiscoTestCase
80
80
  hosts_hash.each_key { |name| hosts[name].destroy }
81
81
  end
82
82
 
83
- def test_tacacsserverhost_create_server_nil
83
+ def test_negative
84
84
  assert_raises(TypeError) { TacacsServerHost.new(nil) }
85
- end
86
-
87
- def test_tacacsserverhost_create_name_zero_length
88
85
  assert_raises(ArgumentError) { TacacsServerHost.new('') }
89
86
  end
90
87
 
91
- def test_tacacsserverhost_create_valid
88
+ def test_create
92
89
  host = TacacsServerHost.new(@host_name)
93
90
  assert_show_match(msg: 'Error: Tacacs Host not created')
94
91
  host.destroy
95
92
  end
96
93
 
97
- def test_tacacsserverhost_destroy
94
+ def test_destroy
98
95
  host = TacacsServerHost.new(@host_name)
99
96
  assert_show_match(msg: 'Error: Tacacs Host not created')
100
97
  host.destroy
@@ -102,7 +99,7 @@ class TestTacacsServerHost < CiscoTestCase
102
99
  refute_show_match(msg: 'Error: Tacacs Host still present')
103
100
  end
104
101
 
105
- def test_tacacsserverhost_get_name
102
+ def test_name
106
103
  host = TacacsServerHost.new(@host_name)
107
104
  line = assert_show_match(msg: 'Error: Tacacs Host not found')
108
105
  assert_equal(@host_name, line.captures[0],
@@ -112,7 +109,7 @@ class TestTacacsServerHost < CiscoTestCase
112
109
  host.destroy
113
110
  end
114
111
 
115
- def test_tacacsserverhost_get_name_preconfigured
112
+ def test_name_preconfigured
116
113
  config("tacacs-server host #{@host_name}")
117
114
 
118
115
  line = assert_show_match(msg: 'Error: Tacacs Host not found')
@@ -127,7 +124,7 @@ class TestTacacsServerHost < CiscoTestCase
127
124
  hosts.each_value(&:destroy)
128
125
  end
129
126
 
130
- def test_tacacsserverhost_get_name_formats
127
+ def test_name_formats
131
128
  host_name = 'testhost.example.com'
132
129
  host_ip = '192.168.1.1'
133
130
 
@@ -159,7 +156,7 @@ class TestTacacsServerHost < CiscoTestCase
159
156
  hosts.each_value(&:destroy)
160
157
  end
161
158
 
162
- def test_tacacsserverhost_get_port
159
+ def test_port_get
163
160
  host = TacacsServerHost.new(@host_name)
164
161
 
165
162
  # not previously configured
@@ -177,7 +174,7 @@ class TestTacacsServerHost < CiscoTestCase
177
174
  host.destroy
178
175
  end
179
176
 
180
- def test_tacacsserverhost_get_default_port
177
+ def test_port_default
181
178
  host = TacacsServerHost.new(@host_name)
182
179
 
183
180
  port = DEFAULT_TACACS_SERVER_HOST_PORT
@@ -186,7 +183,7 @@ class TestTacacsServerHost < CiscoTestCase
186
183
  host.destroy
187
184
  end
188
185
 
189
- def test_tacacsserverhost_set_port
186
+ def test_port_set
190
187
  return if platform == :ios_xr
191
188
 
192
189
  host = TacacsServerHost.new(@host_name)
@@ -202,7 +199,7 @@ class TestTacacsServerHost < CiscoTestCase
202
199
  host.destroy
203
200
  end
204
201
 
205
- def test_tacacsserverhost_get_timeout
202
+ def test_timeout_get
206
203
  # Cleanup first
207
204
  s = @device.cmd("show run | i 'tacacs.*timeout'")[/^tacacs.*timeout.*$/]
208
205
  config("no #{s}") if s
@@ -221,7 +218,7 @@ class TestTacacsServerHost < CiscoTestCase
221
218
  host.destroy
222
219
  end
223
220
 
224
- def test_tacacsserverhost_get_default_timeout
221
+ def test_timeout_default
225
222
  host = TacacsServerHost.new(@host_name)
226
223
 
227
224
  timeout = DEFAULT_TACACS_SERVER_HOST_TIMEOUT
@@ -230,7 +227,7 @@ class TestTacacsServerHost < CiscoTestCase
230
227
  host.destroy
231
228
  end
232
229
 
233
- def test_tacacsserverhost_set_timeout
230
+ def test_timeout_set
234
231
  host = TacacsServerHost.new(@host_name)
235
232
 
236
233
  timeout = 30
@@ -249,7 +246,7 @@ class TestTacacsServerHost < CiscoTestCase
249
246
  host.destroy
250
247
  end
251
248
 
252
- def test_tacacsserverhost_unset_timeout
249
+ def test_timeout_unset
253
250
  host = TacacsServerHost.new(@host_name)
254
251
 
255
252
  timeout = DEFAULT_TACACS_SERVER_HOST_TIMEOUT
@@ -261,7 +258,7 @@ class TestTacacsServerHost < CiscoTestCase
261
258
  host.destroy
262
259
  end
263
260
 
264
- def test_tacacsserverhost_get_encryption_type
261
+ def test_encryption_type
265
262
  host = TacacsServerHost.new(@host_name)
266
263
 
267
264
  # when not configured
@@ -279,7 +276,7 @@ class TestTacacsServerHost < CiscoTestCase
279
276
  host.destroy
280
277
  end
281
278
 
282
- def test_tacacsserverhost_get_default_encryption_type
279
+ def test_encryption_type_default
283
280
  host = TacacsServerHost.new(@host_name)
284
281
 
285
282
  assert_equal(TACACS_SERVER_ENC_NONE,
@@ -288,7 +285,7 @@ class TestTacacsServerHost < CiscoTestCase
288
285
  host.destroy
289
286
  end
290
287
 
291
- def test_tacacsserverhost_get_encryption_password
288
+ def test_encryption_password
292
289
  host = TacacsServerHost.new(@host_name)
293
290
 
294
291
  # when not configured
@@ -312,7 +309,7 @@ class TestTacacsServerHost < CiscoTestCase
312
309
  host.destroy
313
310
  end
314
311
 
315
- def test_tacacsserverhost_get_default_encryption_password
312
+ def test_encryption_password_default
316
313
  host = TacacsServerHost.new(@host_name)
317
314
 
318
315
  assert_equal('', TacacsServerHost.default_encryption_password,
@@ -320,7 +317,7 @@ class TestTacacsServerHost < CiscoTestCase
320
317
  host.destroy
321
318
  end
322
319
 
323
- def test_tacacsserverhost_set_key
320
+ def test_key
324
321
  host = TacacsServerHost.new(@host_name)
325
322
 
326
323
  enctype = TACACS_SERVER_ENC_NONE
@@ -352,7 +349,7 @@ class TestTacacsServerHost < CiscoTestCase
352
349
  host.destroy
353
350
  end
354
351
 
355
- def test_tacacsserverhost_unset_key
352
+ def test_key_unset
356
353
  # Cleanup first
357
354
  s = @device.cmd("show run | i 'tacacs.*host'")[/^tacacs.*host.*$/]
358
355
  config("no #{s}") if s
@@ -360,7 +357,7 @@ class TestTacacsServerHost < CiscoTestCase
360
357
  host = TacacsServerHost.new(@host_name)
361
358
 
362
359
  # First configure key value. Whether that can be passed
363
- # will be decided by test_tacacsserverhost_set_key
360
+ # will be decided by test_key
364
361
  enctype = TACACS_SERVER_ENC_NONE
365
362
  pass = 'TEST'
366
363
  host.encryption_key_set(enctype, pass)
@@ -393,7 +390,7 @@ class TestTacacsServerHost < CiscoTestCase
393
390
  'no tacacs-server host 8.8.8.8 port 33')
394
391
  end
395
392
 
396
- def test_create_destroy_single_with_duplicates
393
+ def test_duplicates
397
394
  return if platform != :ios_xr
398
395
  setup_duplicates
399
396
 
data/tests/test_vlan.rb CHANGED
@@ -21,18 +21,7 @@ include Cisco
21
21
  # TestVlan - Minitest for Vlan node utility
22
22
  class TestVlan < CiscoTestCase
23
23
  @skip_unless_supported = 'vlan'
24
-
25
24
  @@cleaned = false # rubocop:disable Style/ClassVars
26
- def cleanup
27
- Vlan.vlans.each do |vlan, obj|
28
- # skip reserved vlans
29
- next if vlan == '1'
30
- next if node.product_id[/N5K|N6K|N7K/] && (1002..1005).include?(vlan.to_i)
31
- obj.destroy
32
- end
33
- interface_ethernet_default(interfaces[0])
34
- config_no_warn('no feature vtp')
35
- end
36
25
 
37
26
  def setup
38
27
  super
@@ -44,6 +33,17 @@ class TestVlan < CiscoTestCase
44
33
  cleanup
45
34
  end
46
35
 
36
+ def cleanup
37
+ remove_all_vlans
38
+ interface_ethernet_default(interfaces[0])
39
+ config_no_warn('no feature vtp')
40
+ end
41
+
42
+ def overlay_cleanup
43
+ config_no_warn('no feature vn-segment-vlan-based')
44
+ config_no_warn('no nv overlay evpn ; no feature nv overlay')
45
+ end
46
+
47
47
  def interface_ethernet_default(intf)
48
48
  config("default interface #{intf}")
49
49
  end
@@ -70,7 +70,7 @@ class TestVlan < CiscoTestCase
70
70
  assert_match(/Invalid value.non-numeric/, e.message)
71
71
  end
72
72
 
73
- def test_create_and_destroy
73
+ def test_create_destroy
74
74
  v = Vlan.new(1000)
75
75
  vlans = Vlan.vlans
76
76
  assert(vlans.key?('1000'), 'Error: failed to create vlan 1000')
@@ -149,34 +149,6 @@ class TestVlan < CiscoTestCase
149
149
  v.destroy
150
150
  end
151
151
 
152
- def test_name_too_long
153
- v = Vlan.new(1000)
154
- name = 'a' * VLAN_NAME_SIZE
155
- assert_raises(RuntimeError, 'vlan misconfig did not raise RuntimeError') do
156
- v.vlan_name = name
157
- end
158
- ref = cmd_ref.lookup('vlan', 'name')
159
- assert(ref, 'Error, reference not found for vlan name')
160
- v.destroy
161
- end
162
-
163
- def test_name_duplicate
164
- # Testbed cleanup
165
- v = Vlan.new(1000)
166
- v.destroy
167
- v = Vlan.new(1001)
168
- v.destroy
169
- # start test
170
- v1 = Vlan.new(1000)
171
- v1.vlan_name = 'test'
172
- v2 = Vlan.new(1001)
173
- assert_raises(RuntimeError, 'vlan misconfig did not raise RuntimeError') do
174
- v2.vlan_name = 'test'
175
- end
176
- v1.destroy
177
- v2.destroy
178
- end
179
-
180
152
  def test_state_invalid
181
153
  v = Vlan.new(1000)
182
154
  assert_raises(CliError) do
@@ -234,32 +206,26 @@ class TestVlan < CiscoTestCase
234
206
  'present on any interfaces')
235
207
 
236
208
  # Add test vlan to 3 ethernet interfaces
237
- vlan_intf_max = 3
238
- vlan_intf_list = []
239
- Interface.interfaces.each do |name, i|
240
- next unless i.name[/ethernet/]
241
- interface_ethernet_default(name)
209
+ vlan_intf_list = interfaces.first(3)
210
+ vlan_intf_list.each do |intf, i|
211
+ interface_ethernet_default(intf)
212
+ i = Interface.new(intf)
242
213
  i.switchport_mode = :access
243
214
  assert_equal(i.default_access_vlan, i.access_vlan,
244
- "access vlan is not default on #{name}")
215
+ "access vlan is not default on #{intf}")
245
216
 
246
217
  v.add_interface(i)
247
218
  assert_equal(vlan_id, i.access_vlan,
248
- "access vlan #{vlan_id} not present on #{name}")
249
- vlan_intf_list << name
250
- break if vlan_intf_list.count == vlan_intf_max
219
+ "access vlan #{vlan_id} not present on #{intf}")
251
220
  end
252
- count = v.interfaces.count
253
- assert_equal(vlan_intf_max, count,
254
- "vlan #{vlan_id} found on #{count} interfaces, "\
255
- "expected #{vlan_intf_max} total")
221
+ assert_equal(vlan_intf_list.count, v.interfaces.count)
256
222
 
257
223
  # Remove test vlan from interfaces
258
- vlan_intf_list.each do |name|
259
- i = Interface.new(name)
224
+ vlan_intf_list.each do |intf|
225
+ i = Interface.new(intf)
260
226
  v.remove_interface(i)
261
227
  assert_equal(i.default_access_vlan, i.access_vlan,
262
- "access vlan #{vlan_id} should not be present on #{name}")
228
+ "access vlan #{vlan_id} should not be present on #{intf}")
263
229
  end
264
230
  assert_empty(v.interfaces, "access vlan #{vlan_id} should not be "\
265
231
  'present on any interfaces')
@@ -290,6 +256,12 @@ class TestVlan < CiscoTestCase
290
256
  end
291
257
 
292
258
  def test_mapped_vnis
259
+ if validate_property_excluded?('vlan', 'mapped_vni')
260
+ assert_raises(Cisco::UnsupportedError) do
261
+ Vlan.new(100).mapped_vni = 10_000
262
+ end
263
+ return
264
+ end
293
265
  # Map
294
266
  v1 = Vlan.new(100)
295
267
  vni1 = 10_000
@@ -343,13 +315,39 @@ class TestVlan < CiscoTestCase
343
315
 
344
316
  def test_mode_with_pvlan
345
317
  v = Vlan.new(1000)
346
- if validate_property_excluded?('vlan', 'private_vlan_type') ||
318
+ if validate_property_excluded?('vlan', 'pvlan_type') ||
347
319
  validate_property_excluded?('vlan', 'mode')
348
- features = 'private_vlan_type and/or vlan mode'
320
+ features = 'pvlan_type and/or vlan mode'
349
321
  skip("Skip test: Features #{features} are not supported on this device")
350
322
  end
351
323
  result = 'CE'
352
- v.private_vlan_type = 'primary'
324
+ v.pvlan_type = 'primary'
353
325
  assert_equal(result, v.mode)
354
326
  end
327
+
328
+ def test_vlan_mode_fabricpath
329
+ if validate_property_excluded?('vlan', 'mode')
330
+ assert_raises(Cisco::UnsupportedError) { Vlan.new(2000).mode = 'foo' }
331
+ return
332
+ end
333
+ config_no_warn('no feature vn-segment-vlan-based')
334
+ config_no_warn('no nv overlay evpn ; no feature nv overlay')
335
+ # Test for valid mode
336
+ v = Vlan.new(2000)
337
+ default = v.default_mode
338
+ assert_equal(default, v.mode,
339
+ 'Mode should have been default value: #{default}')
340
+ v.mode = 'fabricpath'
341
+ assert_equal(:enabled, v.fabricpath_feature,
342
+ 'Fabricpath feature should have been enabled')
343
+ assert_equal('fabricpath', v.mode,
344
+ 'Mode should have been set to fabricpath')
345
+
346
+ # Test for invalid mode
347
+ v = Vlan.new(100)
348
+ assert_equal(default, v.mode,
349
+ 'Mode should have been default value: #{default}')
350
+
351
+ assert_raises(CliError) { v.mode = 'junk' }
352
+ end
355
353
  end
@@ -20,17 +20,12 @@ require_relative '../lib/cisco_node_utils/vlan'
20
20
  include Cisco
21
21
 
22
22
  # TestVlan - Minitest for Vlan node utility
23
- class TestVlan < CiscoTestCase
23
+ class TestVlanPVlan < CiscoTestCase
24
24
  @skip_unless_supported = 'vlan'
25
25
 
26
26
  @@cleaned = false # rubocop:disable Style/ClassVars
27
27
  def cleanup
28
- Vlan.vlans.each do |vlan, obj|
29
- # skip reserved vlans
30
- next if vlan == '1'
31
- next if node.product_id[/N5K|N6K|N7K/] && (1002..1005).include?(vlan.to_i)
32
- obj.destroy
33
- end
28
+ remove_all_vlans
34
29
  config_no_warn('no feature vtp')
35
30
  config_no_warn('no feature private-vlan')
36
31
  end
@@ -45,357 +40,357 @@ class TestVlan < CiscoTestCase
45
40
  cleanup
46
41
  end
47
42
 
48
- def test_private_type_default
43
+ def test_type_default
49
44
  config_no_warn('no feature vtp')
50
45
  config_no_warn('feature private-vlan')
51
46
  v1 = Vlan.new(100)
52
47
  pv_type = ''
53
- if validate_property_excluded?('vlan', 'private_vlan_type')
54
- assert_nil(v1.private_vlan_type)
48
+ if validate_property_excluded?('vlan', 'pvlan_type')
49
+ assert_nil(v1.pvlan_type)
55
50
  else
56
- assert_equal(pv_type, v1.private_vlan_type)
51
+ assert_equal(pv_type, v1.pvlan_type)
57
52
  end
58
53
  end
59
54
 
60
- def test_private_association_default
55
+ def test_association_default
61
56
  config_no_warn('no feature vtp')
62
57
  config_no_warn('feature private-vlan')
63
58
  v1 = Vlan.new(100)
64
- if validate_property_excluded?('vlan', 'private_vlan_type')
65
- assert_nil(v1.private_vlan_type)
59
+ if validate_property_excluded?('vlan', 'pvlan_type')
60
+ assert_nil(v1.pvlan_type)
66
61
  return
67
62
  else
68
63
  result = []
69
- assert_equal(result, v1.private_vlan_association)
64
+ assert_equal(result, v1.pvlan_association)
70
65
  end
71
66
  end
72
67
 
73
- def test_private_vlan_type_primary
68
+ def test_type_primary
74
69
  v1 = Vlan.new(100)
75
70
  pv_type = 'primary'
76
- if validate_property_excluded?('vlan', 'private_vlan_type')
77
- assert_nil(v1.private_vlan_type)
71
+ if validate_property_excluded?('vlan', 'pvlan_type')
72
+ assert_nil(v1.pvlan_type)
78
73
  assert_raises(Cisco::UnsupportedError) do
79
- v1.private_vlan_type = pv_type
74
+ v1.pvlan_type = pv_type
80
75
  end
81
76
  else
82
- v1.private_vlan_type = pv_type
83
- assert_equal(pv_type, v1.private_vlan_type)
77
+ v1.pvlan_type = pv_type
78
+ assert_equal(pv_type, v1.pvlan_type)
84
79
  end
85
80
  end
86
81
 
87
- def test_no_private_vlan_type_primary
82
+ def test_no_pvlan_type_primary
88
83
  v1 = Vlan.new(200)
89
84
  pv_type = 'primary'
90
- if validate_property_excluded?('vlan', 'private_vlan_type')
91
- assert_nil(v1.private_vlan_type)
85
+ if validate_property_excluded?('vlan', 'pvlan_type')
86
+ assert_nil(v1.pvlan_type)
92
87
  assert_raises(Cisco::UnsupportedError) do
93
- v1.private_vlan_type = pv_type
88
+ v1.pvlan_type = pv_type
94
89
  end
95
90
  return
96
91
  else
97
- v1.private_vlan_type = pv_type
98
- assert_equal(pv_type, v1.private_vlan_type)
92
+ v1.pvlan_type = pv_type
93
+ assert_equal(pv_type, v1.pvlan_type)
99
94
  pv_type = ''
100
- v1.private_vlan_type = pv_type
101
- assert_equal(pv_type, v1.private_vlan_type)
95
+ v1.pvlan_type = pv_type
96
+ assert_equal(pv_type, v1.pvlan_type)
102
97
  end
103
98
  end
104
99
 
105
- def test_multi_private_vlan_type_primary
100
+ def test_multi_pvlan_type_primary
106
101
  v1 = Vlan.new(100)
107
102
  v2 = Vlan.new(101)
108
103
  v3 = Vlan.new(200)
109
104
  v4 = Vlan.new(201)
110
105
  v5 = Vlan.new(203)
111
106
  pv_type = 'primary'
112
- if validate_property_excluded?('vlan', 'private_vlan_type')
113
- assert_nil(v1.private_vlan_type)
107
+ if validate_property_excluded?('vlan', 'pvlan_type')
108
+ assert_nil(v1.pvlan_type)
114
109
  assert_raises(Cisco::UnsupportedError) do
115
- v1.private_vlan_type = pv_type
110
+ v1.pvlan_type = pv_type
116
111
  end
117
112
  return
118
113
  else
119
- v1.private_vlan_type = pv_type
120
- v2.private_vlan_type = pv_type
121
- v3.private_vlan_type = pv_type
122
- v4.private_vlan_type = pv_type
123
- v5.private_vlan_type = pv_type
124
-
125
- assert_equal(pv_type, v1.private_vlan_type)
126
- assert_equal(pv_type, v2.private_vlan_type)
127
- assert_equal(pv_type, v3.private_vlan_type)
128
- assert_equal(pv_type, v4.private_vlan_type)
129
- assert_equal(pv_type, v5.private_vlan_type)
114
+ v1.pvlan_type = pv_type
115
+ v2.pvlan_type = pv_type
116
+ v3.pvlan_type = pv_type
117
+ v4.pvlan_type = pv_type
118
+ v5.pvlan_type = pv_type
119
+
120
+ assert_equal(pv_type, v1.pvlan_type)
121
+ assert_equal(pv_type, v2.pvlan_type)
122
+ assert_equal(pv_type, v3.pvlan_type)
123
+ assert_equal(pv_type, v4.pvlan_type)
124
+ assert_equal(pv_type, v5.pvlan_type)
130
125
  end
131
126
  end
132
127
 
133
- def test_private_vlan_type_isolated
128
+ def test_type_isolated
134
129
  v1 = Vlan.new(100)
135
130
  pv_type = 'isolated'
136
- if validate_property_excluded?('vlan', 'private_vlan_type')
137
- assert_nil(v1.private_vlan_type)
131
+ if validate_property_excluded?('vlan', 'pvlan_type')
132
+ assert_nil(v1.pvlan_type)
138
133
  assert_raises(Cisco::UnsupportedError) do
139
- v1.private_vlan_type = pv_type
134
+ v1.pvlan_type = pv_type
140
135
  end
141
136
  else
142
- v1.private_vlan_type = pv_type
143
- assert_equal(pv_type, v1.private_vlan_type)
137
+ v1.pvlan_type = pv_type
138
+ assert_equal(pv_type, v1.pvlan_type)
144
139
  end
145
140
  end
146
141
 
147
- def test_private_vlan_type_community
142
+ def test_type_community
148
143
  v1 = Vlan.new(100)
149
144
  pv_type = 'community'
150
- if validate_property_excluded?('vlan', 'private_vlan_type')
151
- assert_nil(v1.private_vlan_type)
145
+ if validate_property_excluded?('vlan', 'pvlan_type')
146
+ assert_nil(v1.pvlan_type)
152
147
  assert_raises(Cisco::UnsupportedError) do
153
- v1.private_vlan_type = pv_type
148
+ v1.pvlan_type = pv_type
154
149
  end
155
150
  else
156
- v1.private_vlan_type = pv_type
157
- assert_equal(pv_type, v1.private_vlan_type)
151
+ v1.pvlan_type = pv_type
152
+ assert_equal(pv_type, v1.pvlan_type)
158
153
  end
159
154
  end
160
155
 
161
- def test_private_vlan_type_isolated_primary
156
+ def test_type_isolated_primary
162
157
  v1 = Vlan.new(100)
163
158
  pv_type = 'isolated'
164
- if validate_property_excluded?('vlan', 'private_vlan_type')
165
- assert_nil(v1.private_vlan_type)
159
+ if validate_property_excluded?('vlan', 'pvlan_type')
160
+ assert_nil(v1.pvlan_type)
166
161
  assert_raises(Cisco::UnsupportedError) do
167
- v1.private_vlan_type = pv_type
162
+ v1.pvlan_type = pv_type
168
163
  end
169
164
  return
170
165
  else
171
- v1.private_vlan_type = pv_type
172
- assert_equal(pv_type, v1.private_vlan_type)
166
+ v1.pvlan_type = pv_type
167
+ assert_equal(pv_type, v1.pvlan_type)
173
168
  v2 = Vlan.new(200)
174
169
  pv_type = 'primary'
175
- v2.private_vlan_type = pv_type
176
- assert_equal(pv_type, v2.private_vlan_type)
170
+ v2.pvlan_type = pv_type
171
+ assert_equal(pv_type, v2.pvlan_type)
177
172
  end
178
173
  end
179
174
 
180
- def test_private_vlan_type_isolated_community_primary
175
+ def test_type_isolated_community_primary
181
176
  v1 = Vlan.new(100)
182
177
  pv_type = 'isolated'
183
- if validate_property_excluded?('vlan', 'private_vlan_type')
184
- assert_nil(v1.private_vlan_type)
178
+ if validate_property_excluded?('vlan', 'pvlan_type')
179
+ assert_nil(v1.pvlan_type)
185
180
  assert_raises(Cisco::UnsupportedError) do
186
- v1.private_vlan_type = pv_type
181
+ v1.pvlan_type = pv_type
187
182
  end
188
183
  return
189
184
  else
190
- v1.private_vlan_type = pv_type
191
- assert_equal(pv_type, v1.private_vlan_type)
185
+ v1.pvlan_type = pv_type
186
+ assert_equal(pv_type, v1.pvlan_type)
192
187
  v2 = Vlan.new(200)
193
188
  pv_type = 'primary'
194
- v2.private_vlan_type = pv_type
195
- assert_equal(pv_type, v2.private_vlan_type)
189
+ v2.pvlan_type = pv_type
190
+ assert_equal(pv_type, v2.pvlan_type)
196
191
  v3 = Vlan.new(300)
197
192
  pv_type = 'community'
198
- v3.private_vlan_type = pv_type
199
- assert_equal(pv_type, v3.private_vlan_type)
193
+ v3.pvlan_type = pv_type
194
+ assert_equal(pv_type, v3.pvlan_type)
200
195
  end
201
196
  end
202
197
 
203
- def test_private_vlan_type_change_isolated_to_primary
198
+ def test_type_change_isolated_to_primary
204
199
  v1 = Vlan.new(100)
205
200
  pv_type = 'isolated'
206
- if validate_property_excluded?('vlan', 'private_vlan_type')
207
- assert_nil(v1.private_vlan_type)
201
+ if validate_property_excluded?('vlan', 'pvlan_type')
202
+ assert_nil(v1.pvlan_type)
208
203
  assert_raises(Cisco::UnsupportedError) do
209
- v1.private_vlan_type = pv_type
204
+ v1.pvlan_type = pv_type
210
205
  end
211
206
  return
212
207
  else
213
- v1.private_vlan_type = pv_type
214
- assert_equal(pv_type, v1.private_vlan_type)
208
+ v1.pvlan_type = pv_type
209
+ assert_equal(pv_type, v1.pvlan_type)
215
210
  pv_type = 'primary'
216
- v1.private_vlan_type = pv_type
217
- assert_equal(pv_type, v1.private_vlan_type)
211
+ v1.pvlan_type = pv_type
212
+ assert_equal(pv_type, v1.pvlan_type)
218
213
  end
219
214
  end
220
215
 
221
- def test_private_vlan_type_change_isolated_to_community
216
+ def test_type_change_isolated_to_community
222
217
  v1 = Vlan.new(100)
223
218
  pv_type = 'isolated'
224
- if validate_property_excluded?('vlan', 'private_vlan_type')
225
- assert_nil(v1.private_vlan_type)
219
+ if validate_property_excluded?('vlan', 'pvlan_type')
220
+ assert_nil(v1.pvlan_type)
226
221
  assert_raises(Cisco::UnsupportedError) do
227
- v1.private_vlan_type = pv_type
222
+ v1.pvlan_type = pv_type
228
223
  end
229
224
  return
230
225
  else
231
- v1.private_vlan_type = pv_type
232
- assert_equal(pv_type, v1.private_vlan_type)
226
+ v1.pvlan_type = pv_type
227
+ assert_equal(pv_type, v1.pvlan_type)
233
228
  pv_type = 'community'
234
- v1.private_vlan_type = pv_type
235
- assert_equal(pv_type, v1.private_vlan_type)
229
+ v1.pvlan_type = pv_type
230
+ assert_equal(pv_type, v1.pvlan_type)
236
231
  end
237
232
  end
238
233
 
239
- def test_private_vlan_type_change_community_to_isolated
234
+ def test_type_change_community_to_isolated
240
235
  v1 = Vlan.new(100)
241
236
  pv_type = 'community'
242
- if validate_property_excluded?('vlan', 'private_vlan_type')
243
- assert_nil(v1.private_vlan_type)
237
+ if validate_property_excluded?('vlan', 'pvlan_type')
238
+ assert_nil(v1.pvlan_type)
244
239
  assert_raises(Cisco::UnsupportedError) do
245
- v1.private_vlan_type = pv_type
240
+ v1.pvlan_type = pv_type
246
241
  end
247
242
  return
248
243
  else
249
- v1.private_vlan_type = pv_type
250
- assert_equal(pv_type, v1.private_vlan_type)
244
+ v1.pvlan_type = pv_type
245
+ assert_equal(pv_type, v1.pvlan_type)
251
246
  pv_type = 'isolated'
252
- v1.private_vlan_type = pv_type
253
- assert_equal(pv_type, v1.private_vlan_type)
247
+ v1.pvlan_type = pv_type
248
+ assert_equal(pv_type, v1.pvlan_type)
254
249
  end
255
250
  end
256
251
 
257
- def test_private_vlan_type_change_community_to_primary
252
+ def test_type_change_community_to_primary
258
253
  v1 = Vlan.new(100)
259
254
  pv_type = 'community'
260
- if validate_property_excluded?('vlan', 'private_vlan_type')
261
- assert_nil(v1.private_vlan_type)
255
+ if validate_property_excluded?('vlan', 'pvlan_type')
256
+ assert_nil(v1.pvlan_type)
262
257
  assert_raises(Cisco::UnsupportedError) do
263
- v1.private_vlan_type = pv_type
258
+ v1.pvlan_type = pv_type
264
259
  end
265
260
  return
266
261
  else
267
- v1.private_vlan_type = pv_type
268
- assert_equal(pv_type, v1.private_vlan_type)
262
+ v1.pvlan_type = pv_type
263
+ assert_equal(pv_type, v1.pvlan_type)
269
264
  pv_type = 'primary'
270
- v1.private_vlan_type = pv_type
271
- assert_equal(pv_type, v1.private_vlan_type)
265
+ v1.pvlan_type = pv_type
266
+ assert_equal(pv_type, v1.pvlan_type)
272
267
  end
273
268
  end
274
269
 
275
- def test_private_vlan_type_change_primary_to_isolated
270
+ def test_type_change_primary_to_isolated
276
271
  v1 = Vlan.new(100)
277
272
  pv_type = 'primary'
278
- if validate_property_excluded?('vlan', 'private_vlan_type')
279
- assert_nil(v1.private_vlan_type)
273
+ if validate_property_excluded?('vlan', 'pvlan_type')
274
+ assert_nil(v1.pvlan_type)
280
275
  assert_raises(Cisco::UnsupportedError) do
281
- v1.private_vlan_type = pv_type
276
+ v1.pvlan_type = pv_type
282
277
  end
283
278
  return
284
279
  else
285
- v1.private_vlan_type = pv_type
286
- assert_equal(pv_type, v1.private_vlan_type)
280
+ v1.pvlan_type = pv_type
281
+ assert_equal(pv_type, v1.pvlan_type)
287
282
  pv_type = 'isolated'
288
- v1.private_vlan_type = pv_type
289
- assert_equal(pv_type, v1.private_vlan_type)
283
+ v1.pvlan_type = pv_type
284
+ assert_equal(pv_type, v1.pvlan_type)
290
285
  end
291
286
  end
292
287
 
293
- def test_private_vlan_type_change_primary_to_community
288
+ def test_type_change_primary_to_community
294
289
  v1 = Vlan.new(100)
295
290
  pv_type = 'primary'
296
- if validate_property_excluded?('vlan', 'private_vlan_type')
297
- assert_nil(v1.private_vlan_type)
291
+ if validate_property_excluded?('vlan', 'pvlan_type')
292
+ assert_nil(v1.pvlan_type)
298
293
  assert_raises(Cisco::UnsupportedError) do
299
- v1.private_vlan_type = pv_type
294
+ v1.pvlan_type = pv_type
300
295
  end
301
296
  return
302
297
  else
303
- v1.private_vlan_type = pv_type
304
- assert_equal(pv_type, v1.private_vlan_type)
298
+ v1.pvlan_type = pv_type
299
+ assert_equal(pv_type, v1.pvlan_type)
305
300
  pv_type = 'community'
306
- v1.private_vlan_type = pv_type
307
- assert_equal(pv_type, v1.private_vlan_type)
301
+ v1.pvlan_type = pv_type
302
+ assert_equal(pv_type, v1.pvlan_type)
308
303
  end
309
304
  end
310
305
 
311
- def test_private_vlan_isolate_association
306
+ def test_isolate_association
312
307
  vlan_list = %w(100 101)
313
308
  result = ['101']
314
309
  v1 = Vlan.new(vlan_list[0])
315
310
  v2 = Vlan.new(vlan_list[1])
316
311
  pv_type = 'primary'
317
- if validate_property_excluded?('vlan', 'private_vlan_type')
318
- assert_nil(v1.private_vlan_type)
312
+ if validate_property_excluded?('vlan', 'pvlan_type')
313
+ assert_nil(v1.pvlan_type)
319
314
  assert_raises(Cisco::UnsupportedError) do
320
- v1.private_vlan_type = pv_type
315
+ v1.pvlan_type = pv_type
321
316
  end
322
317
  return
323
318
  else
324
- v1.private_vlan_type = pv_type
325
- assert_equal(pv_type, v1.private_vlan_type)
319
+ v1.pvlan_type = pv_type
320
+ assert_equal(pv_type, v1.pvlan_type)
326
321
  pv_type = 'isolated'
327
- v2.private_vlan_type = pv_type
328
- assert_equal(pv_type, v2.private_vlan_type)
322
+ v2.pvlan_type = pv_type
323
+ assert_equal(pv_type, v2.pvlan_type)
329
324
 
330
- v1.private_vlan_association = ['101']
325
+ v1.pvlan_association = ['101']
331
326
 
332
- assert_equal(result, v1.private_vlan_association)
327
+ assert_equal(result, v1.pvlan_association)
333
328
  end
334
329
  end
335
330
 
336
- def test_private_vlan_community_association
331
+ def test_community_association
337
332
  vlan_list = %w(100 101)
338
333
  result = ['101']
339
334
  v1 = Vlan.new(vlan_list[0])
340
335
  v2 = Vlan.new(vlan_list[1])
341
336
  pv_type = 'primary'
342
- if validate_property_excluded?('vlan', 'private_vlan_type')
343
- assert_nil(v1.private_vlan_type)
337
+ if validate_property_excluded?('vlan', 'pvlan_type')
338
+ assert_nil(v1.pvlan_type)
344
339
  assert_raises(Cisco::UnsupportedError) do
345
- v1.private_vlan_type = pv_type
340
+ v1.pvlan_type = pv_type
346
341
  end
347
342
  return
348
343
  else
349
- v1.private_vlan_type = pv_type
350
- assert_equal(pv_type, v1.private_vlan_type)
344
+ v1.pvlan_type = pv_type
345
+ assert_equal(pv_type, v1.pvlan_type)
351
346
  pv_type = 'community'
352
- v2.private_vlan_type = pv_type
353
- assert_equal(pv_type, v2.private_vlan_type)
347
+ v2.pvlan_type = pv_type
348
+ assert_equal(pv_type, v2.pvlan_type)
354
349
 
355
- v1.private_vlan_association = ['101']
350
+ v1.pvlan_association = ['101']
356
351
 
357
- assert_equal(result, v1.private_vlan_association)
352
+ assert_equal(result, v1.pvlan_association)
358
353
  end
359
354
  end
360
355
 
361
- def test_private_vlan_association_failure
356
+ def test_association_failure
362
357
  vlan_list = %w(100 101 200)
363
358
  result = %w(101 200)
364
359
  v1 = Vlan.new(vlan_list[0])
365
360
  v2 = Vlan.new(vlan_list[1])
366
361
  v3 = Vlan.new(vlan_list[2])
367
362
  pv_type = 'primary'
368
- if validate_property_excluded?('vlan', 'private_vlan_type')
369
- assert_nil(v1.private_vlan_type)
363
+ if validate_property_excluded?('vlan', 'pvlan_type')
364
+ assert_nil(v1.pvlan_type)
370
365
  assert_raises(Cisco::UnsupportedError) do
371
- v1.private_vlan_type = pv_type
366
+ v1.pvlan_type = pv_type
372
367
  end
373
368
  return
374
369
  else
375
- v1.private_vlan_type = pv_type
376
- assert_equal(pv_type, v1.private_vlan_type)
370
+ v1.pvlan_type = pv_type
371
+ assert_equal(pv_type, v1.pvlan_type)
377
372
  pv_type = 'isolated'
378
- v2.private_vlan_type = pv_type
379
- assert_equal(pv_type, v2.private_vlan_type)
373
+ v2.pvlan_type = pv_type
374
+ assert_equal(pv_type, v2.pvlan_type)
380
375
  pv_type = 'community'
381
- v3.private_vlan_type = pv_type
382
- assert_equal(pv_type, v3.private_vlan_type)
376
+ v3.pvlan_type = pv_type
377
+ assert_equal(pv_type, v3.pvlan_type)
383
378
 
384
- v1.private_vlan_association = %w(101 200)
379
+ v1.pvlan_association = %w(101 200)
385
380
 
386
- assert_equal(result, v1.private_vlan_association)
381
+ assert_equal(result, v1.pvlan_association)
387
382
 
388
383
  pv_type = 'isolated'
389
384
  assert_raises(RuntimeError, 'vlan misconf did not raise RuntimeError') do
390
- v3.private_vlan_type = pv_type
385
+ v3.pvlan_type = pv_type
391
386
  end
392
387
 
393
- assert_equal(result, v1.private_vlan_association)
388
+ assert_equal(result, v1.pvlan_association)
394
389
 
395
390
  end
396
391
  end
397
392
 
398
- def test_private_vlan_association_operational_and_not_operational
393
+ def test_association_ops
399
394
  vlan_list = %w(100 101 200)
400
395
  result = %w(101 200)
401
396
 
@@ -403,109 +398,109 @@ class TestVlan < CiscoTestCase
403
398
  v2 = Vlan.new(vlan_list[1])
404
399
 
405
400
  pv_type = 'primary'
406
- if validate_property_excluded?('vlan', 'private_vlan_type')
407
- assert_nil(v1.private_vlan_type)
401
+ if validate_property_excluded?('vlan', 'pvlan_type')
402
+ assert_nil(v1.pvlan_type)
408
403
  assert_raises(Cisco::UnsupportedError) do
409
- v1.private_vlan_type = pv_type
404
+ v1.pvlan_type = pv_type
410
405
  end
411
406
  return
412
407
  else
413
- v1.private_vlan_type = pv_type
414
- assert_equal(pv_type, v1.private_vlan_type)
408
+ v1.pvlan_type = pv_type
409
+ assert_equal(pv_type, v1.pvlan_type)
415
410
 
416
411
  pv_type = 'isolated'
417
- v2.private_vlan_type = pv_type
418
- assert_equal(pv_type, v2.private_vlan_type)
412
+ v2.pvlan_type = pv_type
413
+ assert_equal(pv_type, v2.pvlan_type)
419
414
 
420
- v1.private_vlan_association = %w(101 200)
415
+ v1.pvlan_association = %w(101 200)
421
416
 
422
- assert_equal(result, v1.private_vlan_association)
417
+ assert_equal(result, v1.pvlan_association)
423
418
  end
424
419
  end
425
420
 
426
- def test_private_vlan_association_vlan_not_configured
421
+ def test_association_vlan_not_configured
427
422
  vlan_list = %w(100 101 200)
428
423
  result = %w(101 200)
429
424
  v1 = Vlan.new(vlan_list[0])
430
425
  v2 = Vlan.new(vlan_list[1])
431
426
  pv_type = 'primary'
432
- if validate_property_excluded?('vlan', 'private_vlan_type')
433
- assert_nil(v1.private_vlan_type)
427
+ if validate_property_excluded?('vlan', 'pvlan_type')
428
+ assert_nil(v1.pvlan_type)
434
429
  assert_raises(Cisco::UnsupportedError) do
435
- v1.private_vlan_type = pv_type
430
+ v1.pvlan_type = pv_type
436
431
  end
437
432
  return
438
433
  else
439
- v1.private_vlan_type = pv_type
440
- assert_equal(pv_type, v1.private_vlan_type)
434
+ v1.pvlan_type = pv_type
435
+ assert_equal(pv_type, v1.pvlan_type)
441
436
  pv_type = 'isolated'
442
- v2.private_vlan_type = pv_type
443
- assert_equal(pv_type, v2.private_vlan_type)
437
+ v2.pvlan_type = pv_type
438
+ assert_equal(pv_type, v2.pvlan_type)
444
439
 
445
- v1.private_vlan_association = %w(101 200)
446
- assert_equal(result, v1.private_vlan_association)
440
+ v1.pvlan_association = %w(101 200)
441
+ assert_equal(result, v1.pvlan_association)
447
442
  end
448
443
  end
449
444
 
450
- def test_private_vlan_association_add_vlan
445
+ def test_association_add_vlan
451
446
  vlan_list = %w(100 101)
452
447
  result = ['101']
453
448
  v1 = Vlan.new(vlan_list[0])
454
449
  v2 = Vlan.new(vlan_list[1])
455
450
  pv_type = 'primary'
456
- if validate_property_excluded?('vlan', 'private_vlan_type')
457
- assert_nil(v1.private_vlan_type)
451
+ if validate_property_excluded?('vlan', 'pvlan_type')
452
+ assert_nil(v1.pvlan_type)
458
453
  assert_raises(Cisco::UnsupportedError) do
459
- v1.private_vlan_type = pv_type
454
+ v1.pvlan_type = pv_type
460
455
  end
461
456
  return
462
457
  else
463
- v1.private_vlan_type = pv_type
464
- assert_equal(pv_type, v1.private_vlan_type)
458
+ v1.pvlan_type = pv_type
459
+ assert_equal(pv_type, v1.pvlan_type)
465
460
  pv_type = 'isolated'
466
- v2.private_vlan_type = pv_type
467
- assert_equal(pv_type, v2.private_vlan_type)
461
+ v2.pvlan_type = pv_type
462
+ assert_equal(pv_type, v2.pvlan_type)
468
463
 
469
- v1.private_vlan_association = ['101']
470
- assert_equal(result, v1.private_vlan_association)
464
+ v1.pvlan_association = ['101']
465
+ assert_equal(result, v1.pvlan_association)
471
466
  end
472
467
  end
473
468
 
474
- def test_private_vlan_association_remove_vlan
469
+ def test_association_remove_vlan
475
470
  vlan_list = %w(100 101 200)
476
471
  result = %w(101 200)
477
472
  v1 = Vlan.new(vlan_list[0])
478
473
  v2 = Vlan.new(vlan_list[1])
479
474
  v3 = Vlan.new(vlan_list[2])
480
475
  pv_type = 'primary'
481
- if validate_property_excluded?('vlan', 'private_vlan_type')
482
- assert_nil(v1.private_vlan_type)
476
+ if validate_property_excluded?('vlan', 'pvlan_type')
477
+ assert_nil(v1.pvlan_type)
483
478
  assert_raises(Cisco::UnsupportedError) do
484
- v1.private_vlan_type = pv_type
479
+ v1.pvlan_type = pv_type
485
480
  end
486
481
  return
487
482
  else
488
- v1.private_vlan_type = pv_type
489
- assert_equal(pv_type, v1.private_vlan_type)
483
+ v1.pvlan_type = pv_type
484
+ assert_equal(pv_type, v1.pvlan_type)
490
485
  pv_type = 'isolated'
491
- v2.private_vlan_type = pv_type
492
- assert_equal(pv_type, v2.private_vlan_type)
486
+ v2.pvlan_type = pv_type
487
+ assert_equal(pv_type, v2.pvlan_type)
493
488
 
494
489
  pv_type = 'community'
495
- v3.private_vlan_type = pv_type
496
- assert_equal(pv_type, v3.private_vlan_type)
490
+ v3.pvlan_type = pv_type
491
+ assert_equal(pv_type, v3.pvlan_type)
497
492
 
498
- v1.private_vlan_association = %w(101 200)
499
- assert_equal(result, v1.private_vlan_association)
493
+ v1.pvlan_association = %w(101 200)
494
+ assert_equal(result, v1.pvlan_association)
500
495
 
501
- # v1.private_vlan_association_remove_vlans = '101'
496
+ # v1.pvlan_association_remove_vlans = '101'
502
497
  # result = '200'
503
498
  # assert_equal(result, vlan_list(v1))
504
499
 
505
500
  end
506
501
  end
507
502
 
508
- def test_no_private_vlan_association
503
+ def test_no_pvlan_association
509
504
  vlan_list = %w(100 101 200)
510
505
  result = %w(101 200)
511
506
  v1 = Vlan.new(vlan_list[0])
@@ -513,35 +508,35 @@ class TestVlan < CiscoTestCase
513
508
  v3 = Vlan.new(vlan_list[2])
514
509
 
515
510
  pv_type = 'primary'
516
- if validate_property_excluded?('vlan', 'private_vlan_type')
517
- assert_nil(v1.private_vlan_type)
511
+ if validate_property_excluded?('vlan', 'pvlan_type')
512
+ assert_nil(v1.pvlan_type)
518
513
  assert_raises(Cisco::UnsupportedError) do
519
- v1.private_vlan_type = pv_type
514
+ v1.pvlan_type = pv_type
520
515
  end
521
516
  return
522
517
  else
523
- v1.private_vlan_type = pv_type
524
- assert_equal(pv_type, v1.private_vlan_type)
518
+ v1.pvlan_type = pv_type
519
+ assert_equal(pv_type, v1.pvlan_type)
525
520
 
526
521
  pv_type = 'isolated'
527
- v2.private_vlan_type = pv_type
528
- assert_equal(pv_type, v2.private_vlan_type)
522
+ v2.pvlan_type = pv_type
523
+ assert_equal(pv_type, v2.pvlan_type)
529
524
 
530
525
  pv_type = 'community'
531
- v3.private_vlan_type = pv_type
532
- assert_equal(pv_type, v3.private_vlan_type)
526
+ v3.pvlan_type = pv_type
527
+ assert_equal(pv_type, v3.pvlan_type)
533
528
 
534
- v1.private_vlan_association = %w(101 200)
535
- assert_equal(result, v1.private_vlan_association)
529
+ v1.pvlan_association = %w(101 200)
530
+ assert_equal(result, v1.pvlan_association)
536
531
 
537
- v1.private_vlan_association = ['200']
532
+ v1.pvlan_association = ['200']
538
533
  result = ['200']
539
- assert_equal(result, v1.private_vlan_association)
534
+ assert_equal(result, v1.pvlan_association)
540
535
 
541
536
  end
542
537
  end
543
538
 
544
- def test_no_private_vlan_association_all
539
+ def test_no_pvlan_association_all
545
540
  vlan_list = %w(100 101 200)
546
541
  result = %w(101 200)
547
542
  v1 = Vlan.new(vlan_list[0])
@@ -549,121 +544,113 @@ class TestVlan < CiscoTestCase
549
544
  v3 = Vlan.new(vlan_list[2])
550
545
 
551
546
  pv_type = 'primary'
552
- if validate_property_excluded?('vlan', 'private_vlan_type')
553
- assert_nil(v1.private_vlan_type)
547
+ if validate_property_excluded?('vlan', 'pvlan_type')
548
+ assert_nil(v1.pvlan_type)
554
549
  assert_raises(Cisco::UnsupportedError) do
555
- v1.private_vlan_type = pv_type
550
+ v1.pvlan_type = pv_type
556
551
  end
557
552
  return
558
553
  else
559
- v1.private_vlan_type = pv_type
560
- assert_equal(pv_type, v1.private_vlan_type)
554
+ v1.pvlan_type = pv_type
555
+ assert_equal(pv_type, v1.pvlan_type)
561
556
 
562
557
  pv_type = 'isolated'
563
- v2.private_vlan_type = pv_type
564
- assert_equal(pv_type, v2.private_vlan_type)
558
+ v2.pvlan_type = pv_type
559
+ assert_equal(pv_type, v2.pvlan_type)
565
560
 
566
561
  pv_type = 'community'
567
- v3.private_vlan_type = pv_type
568
- assert_equal(pv_type, v3.private_vlan_type)
562
+ v3.pvlan_type = pv_type
563
+ assert_equal(pv_type, v3.pvlan_type)
569
564
 
570
- v1.private_vlan_association = %w(101 200)
571
- assert_equal(result, v1.private_vlan_association)
572
- v1.private_vlan_association = []
565
+ v1.pvlan_association = %w(101 200)
566
+ assert_equal(result, v1.pvlan_association)
567
+ v1.pvlan_association = []
573
568
  result = []
574
- assert_equal(result, v1.private_vlan_association)
569
+ assert_equal(result, v1.pvlan_association)
575
570
 
576
571
  end
577
572
  end
578
573
 
579
- def test_private_vlan_isolate_community_association
574
+ def test_isolate_community_association
580
575
  vlan_list = %w(100 101 200)
581
576
  result = %w(101 200)
582
577
  v1 = Vlan.new(vlan_list[0])
583
578
  v2 = Vlan.new(vlan_list[1])
584
579
  v3 = Vlan.new(vlan_list[2])
585
580
  pv_type = 'primary'
586
- if validate_property_excluded?('vlan', 'private_vlan_type')
587
- assert_nil(v1.private_vlan_type)
581
+ if validate_property_excluded?('vlan', 'pvlan_type')
582
+ assert_nil(v1.pvlan_type)
588
583
  assert_raises(Cisco::UnsupportedError) do
589
- v1.private_vlan_type = pv_type
584
+ v1.pvlan_type = pv_type
590
585
  end
591
586
  return
592
587
  else
593
- v1.private_vlan_type = pv_type
594
- assert_equal(pv_type, v1.private_vlan_type)
588
+ v1.pvlan_type = pv_type
589
+ assert_equal(pv_type, v1.pvlan_type)
595
590
  pv_type = 'isolated'
596
- v2.private_vlan_type = pv_type
597
- assert_equal(pv_type, v2.private_vlan_type)
591
+ v2.pvlan_type = pv_type
592
+ assert_equal(pv_type, v2.pvlan_type)
598
593
  pv_type = 'community'
599
- v3.private_vlan_type = pv_type
600
- assert_equal(pv_type, v3.private_vlan_type)
594
+ v3.pvlan_type = pv_type
595
+ assert_equal(pv_type, v3.pvlan_type)
601
596
 
602
- v1.private_vlan_association = %w(101 200)
597
+ v1.pvlan_association = %w(101 200)
603
598
 
604
- assert_equal(result, v1.private_vlan_association)
599
+ assert_equal(result, v1.pvlan_association)
605
600
  end
606
601
  end
607
602
 
608
- def test_private_vlan_multi_isolate_community_association
603
+ def test_multi_isolate_community_association
609
604
  vlan_list = %w(100 101 102 104 105 200 201 202)
610
- result = %w(101 104 105 200 202)
611
605
  v1 = Vlan.new(vlan_list[0])
612
606
 
613
607
  pv_type = 'primary'
614
- if validate_property_excluded?('vlan', 'private_vlan_type')
615
- assert_nil(v1.private_vlan_type)
616
- assert_raises(Cisco::UnsupportedError) do
617
- v1.private_vlan_type = pv_type
618
- end
608
+ if validate_property_excluded?('vlan', 'pvlan_type')
609
+ assert_nil(v1.pvlan_type)
610
+ assert_raises(Cisco::UnsupportedError) { v1.pvlan_type = pv_type }
619
611
  return
620
- else
621
- v2 = Vlan.new(vlan_list[1])
622
- v3 = Vlan.new(vlan_list[2])
623
- v4 = Vlan.new(vlan_list[3])
624
- v5 = Vlan.new(vlan_list[4])
625
- v6 = Vlan.new(vlan_list[5])
626
- v7 = Vlan.new(vlan_list[6])
627
-
628
- v1.private_vlan_type = pv_type
629
- assert_equal(pv_type, v1.private_vlan_type)
630
-
631
- pv_type = 'isolated'
632
- v2.private_vlan_type = pv_type
633
- assert_equal(pv_type, v2.private_vlan_type)
612
+ end
634
613
 
635
- pv_type = 'isolated'
636
- v3.private_vlan_type = pv_type
637
- assert_equal(pv_type, v3.private_vlan_type)
614
+ v2 = Vlan.new(vlan_list[1])
615
+ v3 = Vlan.new(vlan_list[2])
616
+ v4 = Vlan.new(vlan_list[3])
617
+ v5 = Vlan.new(vlan_list[4])
618
+ v6 = Vlan.new(vlan_list[5])
619
+ v7 = Vlan.new(vlan_list[6])
638
620
 
639
- pv_type = 'community'
640
- v4.private_vlan_type = pv_type
641
- assert_equal(pv_type, v4.private_vlan_type)
621
+ v1.pvlan_type = pv_type
622
+ assert_equal(pv_type, v1.pvlan_type)
642
623
 
643
- pv_type = 'community'
644
- v5.private_vlan_type = pv_type
645
- assert_equal(pv_type, v5.private_vlan_type)
624
+ pv_type = 'isolated'
625
+ v2.pvlan_type = pv_type
626
+ assert_equal(pv_type, v2.pvlan_type)
646
627
 
647
- pv_type = 'community'
648
- v6.private_vlan_type = pv_type
649
- assert_equal(pv_type, v6.private_vlan_type)
628
+ pv_type = 'isolated'
629
+ v3.pvlan_type = pv_type
630
+ assert_equal(pv_type, v3.pvlan_type)
650
631
 
651
- pv_type = 'primary'
652
- v7.private_vlan_type = pv_type
653
- assert_equal(pv_type, v7.private_vlan_type)
632
+ pv_type = 'community'
633
+ v4.pvlan_type = pv_type
634
+ assert_equal(pv_type, v4.pvlan_type)
654
635
 
655
- v1.private_vlan_association = ['101', '104-105', '200', '202']
636
+ pv_type = 'community'
637
+ v5.pvlan_type = pv_type
638
+ assert_equal(pv_type, v5.pvlan_type)
656
639
 
657
- assert_equal(result, v1.private_vlan_association)
640
+ pv_type = 'community'
641
+ v6.pvlan_type = pv_type
642
+ assert_equal(pv_type, v6.pvlan_type)
658
643
 
659
- v1.private_vlan_association = ['101', '103-105', '108']
644
+ pv_type = 'primary'
645
+ v7.pvlan_type = pv_type
646
+ assert_equal(pv_type, v7.pvlan_type)
660
647
 
661
- result = %w(101 103 104 105 108)
662
- assert_equal(result, v1.private_vlan_association)
648
+ v1.pvlan_association = %w(101 104 105 200 202)
649
+ result = %w(101 104-105 200 202)
650
+ assert_equal(result, v1.pvlan_association)
663
651
 
664
- v1.private_vlan_association = ['101', '103-105', '108']
665
- result = %w(101 103 104 105 108)
666
- assert_equal(result, v1.private_vlan_association)
667
- end
652
+ v1.pvlan_association = %w(101 103 104-105 108)
653
+ result = %w(101 103-105 108)
654
+ assert_equal(result, v1.pvlan_association)
668
655
  end
669
656
  end