cisco_node_utils 1.5.0 → 1.6.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +2 -1
  4. data/docs/cisco_node_utils.yaml.example +6 -0
  5. data/lib/cisco_node_utils/cisco_cmn_utils.rb +6 -15
  6. data/lib/cisco_node_utils/client/nxapi/client.rb +19 -1
  7. data/lib/cisco_node_utils/client/utils.rb +1 -1
  8. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +1 -1
  9. data/lib/cisco_node_utils/cmd_ref/interface.yaml +25 -0
  10. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +1 -1
  11. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +1 -1
  12. data/lib/cisco_node_utils/cmd_ref/route_map.yaml +592 -0
  13. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +40 -12
  14. data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +1 -1
  15. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +1 -1
  16. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +1 -1
  17. data/lib/cisco_node_utils/cmd_ref/upgrade.yaml +38 -0
  18. data/lib/cisco_node_utils/dhcp_relay_global.rb +6 -2
  19. data/lib/cisco_node_utils/dns_domain.rb +2 -2
  20. data/lib/cisco_node_utils/environment.rb +1 -0
  21. data/lib/cisco_node_utils/interface.rb +58 -0
  22. data/lib/cisco_node_utils/itd_service.rb +5 -2
  23. data/lib/cisco_node_utils/node.rb +26 -13
  24. data/lib/cisco_node_utils/radius_global.rb +6 -1
  25. data/lib/cisco_node_utils/radius_server.rb +7 -1
  26. data/lib/cisco_node_utils/route_map.rb +2558 -0
  27. data/lib/cisco_node_utils/tacacs_global.rb +5 -2
  28. data/lib/cisco_node_utils/tacacs_server.rb +5 -2
  29. data/lib/cisco_node_utils/tacacs_server_host.rb +10 -4
  30. data/lib/cisco_node_utils/upgrade.rb +118 -0
  31. data/lib/cisco_node_utils/version.rb +1 -1
  32. data/spec/environment_spec.rb +16 -2
  33. data/tests/test_bgp_af.rb +8 -1
  34. data/tests/test_dhcp_relay_global.rb +3 -2
  35. data/tests/test_evpn_vni.rb +2 -2
  36. data/tests/test_feature.rb +4 -1
  37. data/tests/test_interface.rb +93 -0
  38. data/tests/test_interface_svi.rb +1 -0
  39. data/tests/test_itd_service.rb +4 -0
  40. data/tests/test_radius_global.rb +2 -2
  41. data/tests/test_radius_server.rb +6 -6
  42. data/tests/test_route_map.rb +1489 -0
  43. data/tests/test_router_bgp.rb +2 -0
  44. data/tests/test_snmpcommunity.rb +12 -0
  45. data/tests/test_snmpserver.rb +1 -1
  46. data/tests/test_snmpuser.rb +6 -9
  47. data/tests/test_tacacs_server.rb +2 -2
  48. data/tests/test_tacacs_server_host.rb +2 -2
  49. data/tests/test_upgrade.rb +106 -0
  50. data/tests/test_vlan.rb +2 -4
  51. data/tests/upgrade_info.yaml.example +3 -0
  52. data/tests/yum_package.yaml +13 -3
  53. metadata +9 -2
@@ -195,6 +195,7 @@ class TestSvi < CiscoTestCase
195
195
 
196
196
  def test_sys_def_svi_autostate
197
197
  skip_autostate_test?
198
+ skip_legacy_defect?('8.0.1', 'CSC: Atherton behavior change')
198
199
  interface = Interface.new(interfaces[0])
199
200
 
200
201
  system_default_svi_autostate('no ')
@@ -103,6 +103,10 @@ class TestItdSvc < CiscoTestCase
103
103
  ['port-channel 100', '3.3.3.3']]
104
104
  itd.ingress_interface = ii
105
105
  assert_equal(itd.ingress_interface, ii)
106
+ ii = [['vlan 2', ''],
107
+ ['port-channel 100', '']]
108
+ itd.ingress_interface = ii
109
+ assert_equal(itd.ingress_interface, ii)
106
110
  itd.ingress_interface = itd.default_ingress_interface
107
111
  assert_equal(itd.ingress_interface, itd.default_ingress_interface)
108
112
  config 'no interface port-channel 100'
@@ -68,8 +68,8 @@ class TestRadiusGlobal < CiscoTestCase
68
68
  if platform == :nexus
69
69
  key = '44444444'
70
70
  global.key_set(key, nil)
71
- assert_equal(Utils.add_quotes(key), global.key)
72
- assert_equal(Utils.add_quotes(key), Cisco::RadiusGlobal.radius_global[id].key)
71
+ assert_match(/#{key}/, global.key)
72
+ assert_match(/#{key}/, Cisco::RadiusGlobal.radius_global[id].key)
73
73
  elsif platform == :ios_xr
74
74
  global.key_set('QsEfThUkO', nil)
75
75
  assert(!global.key.nil?)
@@ -98,7 +98,7 @@ class TestRadiusSvr < CiscoTestCase
98
98
 
99
99
  key = '44444444'
100
100
  server.key_set(key, nil)
101
- assert_equal(Utils.add_quotes(key), Cisco::RadiusServer.radiusservers[id].key)
101
+ assert_match(/#{key}/, Cisco::RadiusServer.radiusservers[id].key)
102
102
  else
103
103
  assert_nil(server.accounting)
104
104
  assert_raises(Cisco::UnsupportedError) do
@@ -162,7 +162,7 @@ class TestRadiusSvr < CiscoTestCase
162
162
 
163
163
  key = '44444444'
164
164
  server.key_set(key, nil)
165
- assert_equal(Utils.add_quotes(key), Cisco::RadiusServer.radiusservers[id].key)
165
+ assert_match(/#{key}/, Cisco::RadiusServer.radiusservers[id].key)
166
166
  else
167
167
  assert_nil(server.accounting)
168
168
  assert_raises(Cisco::UnsupportedError) do
@@ -227,7 +227,7 @@ class TestRadiusSvr < CiscoTestCase
227
227
 
228
228
  key = '44444444'
229
229
  server.key_set(key, nil)
230
- assert_equal(Utils.add_quotes(key), Cisco::RadiusServer.radiusservers[id].key)
230
+ assert_match(/#{key}/, Cisco::RadiusServer.radiusservers[id].key)
231
231
  else
232
232
  assert_nil(server.accounting)
233
233
  assert_raises(Cisco::UnsupportedError) do
@@ -298,8 +298,8 @@ class TestRadiusSvr < CiscoTestCase
298
298
 
299
299
  key = '44444444'
300
300
  server.key_set(key, nil)
301
- assert_equal(Utils.add_quotes(key), Cisco::RadiusServer.radiusservers[id].key)
302
- assert_equal(Utils.add_quotes(key), server.key)
301
+ assert_match(/#{key}/, Cisco::RadiusServer.radiusservers[id].key)
302
+ assert_match(/#{key}/, server.key)
303
303
  else
304
304
  assert_nil(server.accounting)
305
305
  assert_raises(Cisco::UnsupportedError) do
@@ -333,7 +333,7 @@ class TestRadiusSvr < CiscoTestCase
333
333
 
334
334
  key = '44444444'
335
335
  server2.key_set(key, nil)
336
- assert_equal(Utils.add_quotes(key), Cisco::RadiusServer.radiusservers[id2].key)
336
+ assert_match(/#{key}/, Cisco::RadiusServer.radiusservers[id2].key)
337
337
  else
338
338
  assert_nil(server.accounting)
339
339
  assert_raises(Cisco::UnsupportedError) do
@@ -0,0 +1,1489 @@
1
+ # Copyright (c) 2017 Cisco and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/route_map'
17
+
18
+ def evergreen_or_later?
19
+ return false if Utils.image_version?(/7.0.3.I2|I3|I4/)
20
+ true
21
+ end
22
+
23
+ def older_n9k?
24
+ return true if Utils.image_version?(/7.0.3.I2|I3|I4/) &&
25
+ node.product_id[/N9K/]
26
+ false
27
+ end
28
+
29
+ def dplus_n9k?
30
+ return true if Utils.image_version?(/7.0.3.I4/) &&
31
+ node.product_id[/N9K/]
32
+ false
33
+ end
34
+
35
+ # TestRouteMap - Minitest for RouteMap
36
+ # node utility class
37
+ class TestRouteMap < CiscoTestCase
38
+ @skip_unless_supported = 'route_map'
39
+
40
+ def setup
41
+ super
42
+ end
43
+
44
+ def teardown
45
+ RouteMap.maps.each do |_rmname, sequences|
46
+ sequences.each do |_sequence, actions|
47
+ actions.each do |_action, obj|
48
+ obj.destroy
49
+ end
50
+ end
51
+ end
52
+ super
53
+ end
54
+
55
+ def create_route_map(name='MyRouteMap', seq='100', action='permit')
56
+ RouteMap.new(name, seq, action)
57
+ end
58
+
59
+ def test_description
60
+ rm = create_route_map
61
+ assert_equal(rm.default_description, rm.description)
62
+ rm.description = 'TestRouteMap'
63
+ assert_equal('TestRouteMap', rm.description)
64
+ rm.description = rm.default_description
65
+ assert_equal(rm.default_description, rm.description)
66
+ end
67
+
68
+ def test_collection_size
69
+ create_route_map('my1', '100', 'permit')
70
+ create_route_map('my1', '101', 'permit')
71
+ create_route_map('my1', '102', 'deny')
72
+ create_route_map('my2', '102', 'permit')
73
+ create_route_map('my2', '104', 'deny')
74
+ create_route_map('my3', '105', 'deny')
75
+ assert_equal(1, RouteMap.maps['my1']['100'].size)
76
+ assert_equal(1, RouteMap.maps['my1']['101'].size)
77
+ assert_equal(1, RouteMap.maps['my1']['102'].size)
78
+ assert_equal(3, RouteMap.maps['my1'].size)
79
+ assert_equal(1, RouteMap.maps['my2']['102'].size)
80
+ assert_equal(1, RouteMap.maps['my2']['104'].size)
81
+ assert_equal(2, RouteMap.maps['my2'].size)
82
+ assert_equal(1, RouteMap.maps['my3']['105'].size)
83
+ assert_equal(1, RouteMap.maps['my3'].size)
84
+ end
85
+
86
+ def test_match_as_number
87
+ rm = create_route_map
88
+ assert_equal(rm.default_match_as_number, rm.match_as_number)
89
+ array = ['3', '22-34', '35', '100', '101-220']
90
+ rm.match_as_number = array
91
+ assert_equal(array, rm.match_as_number)
92
+ rm.match_as_number = rm.default_match_as_number
93
+ assert_equal(rm.default_match_as_number, rm.match_as_number)
94
+ end
95
+
96
+ def test_match_as_number_as_path_list
97
+ rm = create_route_map
98
+ assert_equal(rm.default_match_as_number_as_path_list, rm.match_as_number_as_path_list)
99
+ array = %w(cbc xyz pwd)
100
+ rm.match_as_number_as_path_list = array
101
+ assert_equal(array, rm.match_as_number_as_path_list)
102
+ rm.match_as_number_as_path_list = rm.default_match_as_number_as_path_list
103
+ assert_equal(rm.default_match_as_number_as_path_list, rm.match_as_number_as_path_list)
104
+ end
105
+
106
+ def test_community
107
+ rm = create_route_map
108
+ assert_equal(rm.default_match_community, rm.match_community)
109
+ assert_equal(rm.default_match_community_exact_match, rm.match_community_exact_match)
110
+ array = %w(public private)
111
+ rm.match_community_set(array, false)
112
+ assert_equal(array, rm.match_community)
113
+ refute(rm.match_community_exact_match)
114
+ rm.match_community_set(array, true)
115
+ assert_equal(array, rm.match_community)
116
+ assert(rm.match_community_exact_match)
117
+ rm.match_community_set(rm.default_match_community, rm.default_match_community_exact_match)
118
+ assert_equal(rm.default_match_community, rm.match_community)
119
+ assert_equal(rm.default_match_community_exact_match, rm.match_community_exact_match)
120
+ end
121
+
122
+ def test_match_ext_community
123
+ rm = create_route_map
124
+ assert_equal(rm.default_match_ext_community, rm.match_ext_community)
125
+ assert_equal(rm.default_match_ext_community_exact_match, rm.match_ext_community_exact_match)
126
+ array = %w(public private)
127
+ rm.match_ext_community_set(array, false)
128
+ assert_equal(array, rm.match_ext_community)
129
+ refute(rm.match_ext_community_exact_match)
130
+ rm.match_ext_community_set(array, true)
131
+ assert_equal(array, rm.match_ext_community)
132
+ assert(rm.match_ext_community_exact_match)
133
+ rm.match_ext_community_set(rm.default_match_ext_community, rm.default_match_ext_community_exact_match)
134
+ assert_equal(rm.default_match_ext_community, rm.match_ext_community)
135
+ assert_equal(rm.default_match_ext_community_exact_match, rm.match_ext_community_exact_match)
136
+ end
137
+
138
+ def test_match_interface
139
+ rm = create_route_map
140
+ assert_equal(rm.default_match_interface, rm.match_interface)
141
+ array = %w(ethernet1/1 loopback2 mgmt0 null0 port-channel10)
142
+ rm.match_interface = array
143
+ assert_equal(array, rm.match_interface)
144
+ rm.match_interface = rm.default_match_interface
145
+ assert_equal(rm.default_match_interface, rm.match_interface)
146
+ end
147
+
148
+ def test_match_tag
149
+ rm = create_route_map
150
+ assert_equal(rm.default_match_tag, rm.match_tag)
151
+ array = %w(5 342 28 3221)
152
+ rm.match_tag = array
153
+ assert_equal(array, rm.match_tag)
154
+ rm.match_tag = rm.default_match_tag
155
+ assert_equal(rm.default_match_tag, rm.match_tag)
156
+ end
157
+
158
+ def test_match_src_proto
159
+ rm = create_route_map
160
+ assert_equal(rm.default_match_src_proto, rm.match_src_proto)
161
+ array = %w(tcp udp igmp)
162
+ rm.match_src_proto = array
163
+ assert_equal(array, rm.match_src_proto)
164
+ rm.match_src_proto = rm.default_match_src_proto
165
+ assert_equal(rm.default_match_src_proto, rm.match_src_proto)
166
+ end
167
+
168
+ def test_match_ip_addr_access_list
169
+ rm = create_route_map
170
+ assert_equal(rm.default_match_ipv4_addr_access_list, rm.match_ipv4_addr_access_list)
171
+ assert_equal(rm.default_match_ipv6_addr_access_list, rm.match_ipv6_addr_access_list)
172
+ rm.match_ip_addr_access_list('MyAccessList',
173
+ rm.default_match_ipv6_addr_access_list)
174
+ assert_equal('MyAccessList', rm.match_ipv4_addr_access_list)
175
+ assert_equal(rm.default_match_ipv6_addr_access_list, rm.match_ipv6_addr_access_list)
176
+ rm.match_ip_addr_access_list(rm.default_match_ipv4_addr_access_list,
177
+ 'MyV6AccessList')
178
+ assert_equal(rm.default_match_ipv4_addr_access_list, rm.match_ipv4_addr_access_list)
179
+ assert_equal('MyV6AccessList', rm.match_ipv6_addr_access_list)
180
+ rm.match_ip_addr_access_list(rm.default_match_ipv4_addr_access_list,
181
+ rm.default_match_ipv6_addr_access_list)
182
+ assert_equal(rm.default_match_ipv4_addr_access_list, rm.match_ipv4_addr_access_list)
183
+ assert_equal(rm.default_match_ipv6_addr_access_list, rm.match_ipv6_addr_access_list)
184
+ end
185
+
186
+ def test_match_ip_addr_prefix_list
187
+ rm = create_route_map
188
+ assert_equal(rm.default_match_ipv4_addr_prefix_list, rm.match_ipv4_addr_prefix_list)
189
+ assert_equal(rm.default_match_ipv6_addr_prefix_list, rm.match_ipv6_addr_prefix_list)
190
+ array1 = %w(pre1 pre7 pre5)
191
+ array2 = rm.default_match_ipv6_addr_prefix_list
192
+ rm.match_ip_addr_prefix_list(array1, array2)
193
+ assert_equal(array1, rm.match_ipv4_addr_prefix_list)
194
+ assert_equal(rm.default_match_ipv6_addr_prefix_list, rm.match_ipv6_addr_prefix_list)
195
+ array1 = rm.default_match_ipv4_addr_prefix_list
196
+ array2 = %w(pre1 pre7 pre5)
197
+ rm.match_ip_addr_prefix_list(array1, array2)
198
+ assert_equal(rm.default_match_ipv4_addr_prefix_list, rm.match_ipv4_addr_prefix_list)
199
+ assert_equal(array2, rm.match_ipv6_addr_prefix_list)
200
+ array2 = rm.default_match_ipv6_addr_prefix_list
201
+ rm.match_ip_addr_prefix_list(array1, array2)
202
+ assert_equal(rm.default_match_ipv4_addr_prefix_list, rm.match_ipv4_addr_prefix_list)
203
+ assert_equal(rm.default_match_ipv6_addr_prefix_list, rm.match_ipv6_addr_prefix_list)
204
+ end
205
+
206
+ def test_match_ipv4_next_hop_prefix_list
207
+ rm = create_route_map
208
+ assert_equal(rm.default_match_ipv4_next_hop_prefix_list, rm.match_ipv4_next_hop_prefix_list)
209
+ array = %w(nh5 nh1 nh42)
210
+ rm.match_ipv4_next_hop_prefix_list = array
211
+ assert_equal(array, rm.match_ipv4_next_hop_prefix_list)
212
+ rm.match_ipv4_next_hop_prefix_list = rm.default_match_ipv4_next_hop_prefix_list
213
+ assert_equal(rm.default_match_ipv4_next_hop_prefix_list, rm.match_ipv4_next_hop_prefix_list)
214
+ end
215
+
216
+ def test_match_ipv4_route_src_prefix_list
217
+ rm = create_route_map
218
+ assert_equal(rm.default_match_ipv4_route_src_prefix_list, rm.match_ipv4_route_src_prefix_list)
219
+ array = %w(rs1 rs22 pre15)
220
+ rm.match_ipv4_route_src_prefix_list = array
221
+ assert_equal(array, rm.match_ipv4_route_src_prefix_list)
222
+ rm.match_ipv4_route_src_prefix_list = rm.default_match_ipv4_route_src_prefix_list
223
+ assert_equal(rm.default_match_ipv4_route_src_prefix_list, rm.match_ipv4_route_src_prefix_list)
224
+ end
225
+
226
+ def match_ipv4_multicast_helper(props)
227
+ rm = create_route_map
228
+ test_hash = {
229
+ match_ipv4_multicast_enable: true,
230
+ match_ipv4_multicast_src_addr: rm.default_match_ipv4_multicast_src_addr,
231
+ match_ipv4_multicast_group_addr: rm.default_match_ipv4_multicast_group_addr,
232
+ match_ipv4_multicast_group_range_begin_addr: rm.default_match_ipv4_multicast_group_range_begin_addr,
233
+ match_ipv4_multicast_group_range_end_addr: rm.default_match_ipv4_multicast_group_range_end_addr,
234
+ match_ipv4_multicast_rp_addr: rm.default_match_ipv4_multicast_rp_addr,
235
+ match_ipv4_multicast_rp_type: rm.default_match_ipv4_multicast_rp_type,
236
+ }.merge!(props)
237
+ rm.match_ipv4_multicast_set(test_hash)
238
+ rm
239
+ end
240
+
241
+ def test_match_ipv4_multicast
242
+ rm = match_ipv4_multicast_helper(match_ipv4_multicast_src_addr: '242.1.1.1/32',
243
+ match_ipv4_multicast_group_addr: '239.2.2.2/32',
244
+ match_ipv4_multicast_rp_addr: '242.1.1.1/32',
245
+ match_ipv4_multicast_rp_type: 'ASM')
246
+ assert(rm.match_ipv4_multicast_enable)
247
+ assert_equal('242.1.1.1/32', rm.match_ipv4_multicast_src_addr)
248
+ assert_equal('239.2.2.2/32', rm.match_ipv4_multicast_group_addr)
249
+ assert_equal('242.1.1.1/32', rm.match_ipv4_multicast_rp_addr)
250
+ assert_equal('ASM', rm.match_ipv4_multicast_rp_type)
251
+
252
+ rm = match_ipv4_multicast_helper(match_ipv4_multicast_src_addr: '242.1.1.1/32',
253
+ match_ipv4_multicast_group_range_begin_addr: '239.1.1.1',
254
+ match_ipv4_multicast_group_range_end_addr: '239.2.2.2',
255
+ match_ipv4_multicast_rp_addr: '242.1.1.1/32',
256
+ match_ipv4_multicast_rp_type: 'Bidir')
257
+ assert(rm.match_ipv4_multicast_enable)
258
+ assert_equal('242.1.1.1/32', rm.match_ipv4_multicast_src_addr)
259
+ assert_equal('239.1.1.1', rm.match_ipv4_multicast_group_range_begin_addr)
260
+ assert_equal('239.2.2.2', rm.match_ipv4_multicast_group_range_end_addr)
261
+ assert_equal('242.1.1.1/32', rm.match_ipv4_multicast_rp_addr)
262
+ assert_equal('Bidir', rm.match_ipv4_multicast_rp_type)
263
+
264
+ rm = match_ipv4_multicast_helper(match_ipv4_multicast_enable: false)
265
+ assert_equal(rm.default_match_ipv4_multicast_enable, rm.match_ipv4_multicast_enable)
266
+ assert_equal(rm.default_match_ipv4_multicast_src_addr, rm.match_ipv4_multicast_src_addr)
267
+ assert_equal(rm.default_match_ipv4_multicast_group_addr, rm.match_ipv4_multicast_group_addr)
268
+ assert_equal(rm.default_match_ipv4_multicast_group_range_begin_addr, rm.match_ipv4_multicast_group_range_begin_addr)
269
+ assert_equal(rm.default_match_ipv4_multicast_group_range_end_addr, rm.match_ipv4_multicast_group_range_end_addr)
270
+ assert_equal(rm.default_match_ipv4_multicast_rp_addr, rm.match_ipv4_multicast_rp_addr)
271
+ assert_equal(rm.default_match_ipv4_multicast_rp_type, rm.match_ipv4_multicast_rp_type)
272
+ end
273
+
274
+ def test_match_ipv6_next_hop_prefix_list
275
+ rm = create_route_map
276
+ assert_equal(rm.default_match_ipv6_next_hop_prefix_list, rm.match_ipv6_next_hop_prefix_list)
277
+ array = %w(nh5 nh1 nh42)
278
+ rm.match_ipv6_next_hop_prefix_list = array
279
+ assert_equal(array, rm.match_ipv6_next_hop_prefix_list)
280
+ rm.match_ipv6_next_hop_prefix_list = rm.default_match_ipv6_next_hop_prefix_list
281
+ assert_equal(rm.default_match_ipv6_next_hop_prefix_list, rm.match_ipv6_next_hop_prefix_list)
282
+ end
283
+
284
+ def test_match_ipv6_route_src_prefix_list
285
+ rm = create_route_map
286
+ assert_equal(rm.default_match_ipv6_route_src_prefix_list, rm.match_ipv6_route_src_prefix_list)
287
+ array = %w(rs1 rs22 pre15)
288
+ rm.match_ipv6_route_src_prefix_list = array
289
+ assert_equal(array, rm.match_ipv6_route_src_prefix_list)
290
+ rm.match_ipv6_route_src_prefix_list = rm.default_match_ipv6_route_src_prefix_list
291
+ assert_equal(rm.default_match_ipv6_route_src_prefix_list, rm.match_ipv6_route_src_prefix_list)
292
+ end
293
+
294
+ def match_ipv6_multicast_helper(props)
295
+ rm = create_route_map
296
+ test_hash = {
297
+ match_ipv6_multicast_enable: true,
298
+ match_ipv6_multicast_src_addr: rm.default_match_ipv6_multicast_src_addr,
299
+ match_ipv6_multicast_group_addr: rm.default_match_ipv6_multicast_group_addr,
300
+ match_ipv6_multicast_group_range_begin_addr: rm.default_match_ipv6_multicast_group_range_begin_addr,
301
+ match_ipv6_multicast_group_range_end_addr: rm.default_match_ipv6_multicast_group_range_end_addr,
302
+ match_ipv6_multicast_rp_addr: rm.default_match_ipv6_multicast_rp_addr,
303
+ match_ipv6_multicast_rp_type: rm.default_match_ipv6_multicast_rp_type,
304
+ }.merge!(props)
305
+ rm.match_ipv6_multicast_set(test_hash)
306
+ rm
307
+ end
308
+
309
+ def test_match_ipv6_multicast
310
+ rm = match_ipv6_multicast_helper(match_ipv6_multicast_src_addr: '2001::348:0:0/96',
311
+ match_ipv6_multicast_group_addr: 'ff0e::2:101:0:0/96',
312
+ match_ipv6_multicast_rp_addr: '2001::348:0:0/96',
313
+ match_ipv6_multicast_rp_type: 'ASM')
314
+ assert(rm.match_ipv6_multicast_enable)
315
+ assert_equal('2001::348:0:0/96', rm.match_ipv6_multicast_src_addr)
316
+ assert_equal('ff0e::2:101:0:0/96', rm.match_ipv6_multicast_group_addr)
317
+ assert_equal('2001::348:0:0/96', rm.match_ipv6_multicast_rp_addr)
318
+ assert_equal('ASM', rm.match_ipv6_multicast_rp_type)
319
+
320
+ rm = match_ipv6_multicast_helper(match_ipv6_multicast_src_addr: '2001::348:0:0/96',
321
+ match_ipv6_multicast_group_range_begin_addr: 'ff01::',
322
+ match_ipv6_multicast_group_range_end_addr: 'ff02::',
323
+ match_ipv6_multicast_rp_addr: '2001::348:0:0/96',
324
+ match_ipv6_multicast_rp_type: 'Bidir')
325
+ assert(rm.match_ipv6_multicast_enable)
326
+ assert_equal('2001::348:0:0/96', rm.match_ipv6_multicast_src_addr)
327
+ assert_equal('ff01::', rm.match_ipv6_multicast_group_range_begin_addr)
328
+ assert_equal('ff02::', rm.match_ipv6_multicast_group_range_end_addr)
329
+ assert_equal('2001::348:0:0/96', rm.match_ipv6_multicast_rp_addr)
330
+ assert_equal('Bidir', rm.match_ipv6_multicast_rp_type)
331
+
332
+ rm = match_ipv6_multicast_helper(match_ipv6_multicast_enable: false)
333
+ assert_equal(rm.default_match_ipv6_multicast_enable, rm.match_ipv6_multicast_enable)
334
+ assert_equal(rm.default_match_ipv6_multicast_src_addr, rm.match_ipv6_multicast_src_addr)
335
+ assert_equal(rm.default_match_ipv6_multicast_group_addr, rm.match_ipv6_multicast_group_addr)
336
+ assert_equal(rm.default_match_ipv6_multicast_group_range_begin_addr, rm.match_ipv6_multicast_group_range_begin_addr)
337
+ assert_equal(rm.default_match_ipv6_multicast_group_range_end_addr, rm.match_ipv6_multicast_group_range_end_addr)
338
+ assert_equal(rm.default_match_ipv6_multicast_rp_addr, rm.match_ipv6_multicast_rp_addr)
339
+ assert_equal(rm.default_match_ipv6_multicast_rp_type, rm.match_ipv6_multicast_rp_type)
340
+ end
341
+
342
+ def test_match_metric
343
+ # bug CSCvc82934 on fretta and n9k running dplus
344
+ skip('platform not supported for this test') if node.product_id[/N9.*-F/] ||
345
+ dplus_n9k?
346
+ rm = create_route_map
347
+ assert_equal(rm.default_match_metric, rm.match_metric)
348
+ metric = [%w(1 0), %w(8 0), %w(224 9), %w(23 0), %w(5 8), %w(6 0)]
349
+ rm.match_metric = metric
350
+ assert_equal(metric, rm.match_metric)
351
+ metric = [%w(22 5), %w(5 0), %w(24 9), %w(238 255)]
352
+ rm.match_metric = metric
353
+ assert_equal(metric, rm.match_metric)
354
+ rm.match_metric = rm.default_match_metric
355
+ assert_equal(rm.default_match_metric, rm.match_metric)
356
+ end
357
+
358
+ def match_route_type_helper(props)
359
+ rm = create_route_map
360
+ test_hash = {
361
+ match_route_type_external: rm.default_match_route_type_external,
362
+ match_route_type_inter_area: rm.default_match_route_type_inter_area,
363
+ match_route_type_internal: rm.default_match_route_type_internal,
364
+ match_route_type_intra_area: rm.default_match_route_type_intra_area,
365
+ match_route_type_level_1: rm.default_match_route_type_level_1,
366
+ match_route_type_level_2: rm.default_match_route_type_level_2,
367
+ match_route_type_local: rm.default_match_route_type_local,
368
+ match_route_type_nssa_external: rm.default_match_route_type_nssa_external,
369
+ match_route_type_type_1: rm.default_match_route_type_type_1,
370
+ match_route_type_type_2: rm.default_match_route_type_type_2,
371
+ }.merge!(props)
372
+ rm.match_route_type_set(test_hash)
373
+ rm
374
+ end
375
+
376
+ def test_match_route_type
377
+ rm = match_route_type_helper(
378
+ match_route_type_external: true,
379
+ match_route_type_internal: true,
380
+ match_route_type_level_1: true,
381
+ match_route_type_local: true,
382
+ match_route_type_type_2: true)
383
+ assert(rm.match_route_type_external)
384
+ assert(rm.match_route_type_internal)
385
+ assert(rm.match_route_type_level_1)
386
+ assert(rm.match_route_type_local)
387
+ assert(rm.match_route_type_type_2)
388
+ refute(rm.match_route_type_type_1)
389
+ refute(rm.match_route_type_inter_area)
390
+ refute(rm.match_route_type_level_2)
391
+ refute(rm.match_route_type_nssa_external)
392
+ refute(rm.match_route_type_type_1)
393
+
394
+ rm = match_route_type_helper(
395
+ match_route_type_external: true,
396
+ match_route_type_inter_area: true,
397
+ match_route_type_internal: true,
398
+ match_route_type_intra_area: true,
399
+ match_route_type_level_1: true,
400
+ match_route_type_level_2: true,
401
+ match_route_type_local: true,
402
+ match_route_type_nssa_external: true,
403
+ match_route_type_type_1: true,
404
+ match_route_type_type_2: true)
405
+
406
+ assert(rm.match_route_type_external)
407
+ assert(rm.match_route_type_internal)
408
+ assert(rm.match_route_type_level_1)
409
+ assert(rm.match_route_type_local)
410
+ assert(rm.match_route_type_type_2)
411
+ assert(rm.match_route_type_type_1)
412
+ assert(rm.match_route_type_inter_area)
413
+ assert(rm.match_route_type_level_2)
414
+ assert(rm.match_route_type_nssa_external)
415
+ assert(rm.match_route_type_type_1)
416
+ rm = match_route_type_helper(
417
+ match_route_type_level_1: true)
418
+ assert(rm.match_route_type_level_1)
419
+ rm = match_route_type_helper({})
420
+ refute(rm.match_route_type_external)
421
+ refute(rm.match_route_type_internal)
422
+ refute(rm.match_route_type_level_1)
423
+ refute(rm.match_route_type_local)
424
+ refute(rm.match_route_type_type_2)
425
+ refute(rm.match_route_type_type_1)
426
+ refute(rm.match_route_type_inter_area)
427
+ refute(rm.match_route_type_level_2)
428
+ refute(rm.match_route_type_nssa_external)
429
+ refute(rm.match_route_type_type_1)
430
+ end
431
+
432
+ def test_match_ospf_area
433
+ skip('platform not supported for this test') unless evergreen_or_later?
434
+ rm = create_route_map
435
+ if validate_property_excluded?('route_map', 'match_ospf_area')
436
+ assert_nil(rm.match_ospf_area)
437
+ assert_raises(Cisco::UnsupportedError) do
438
+ rm.match_ospf_area = %w(10 7 222)
439
+ end
440
+ return
441
+ end
442
+ assert_equal(rm.default_match_ospf_area, rm.match_ospf_area)
443
+ array = %w(10 7 222)
444
+ rm.match_ospf_area = array
445
+ assert_equal(array, rm.match_ospf_area)
446
+ rm.match_ospf_area = rm.default_match_ospf_area
447
+ assert_equal(rm.default_match_ospf_area, rm.match_ospf_area)
448
+ end
449
+
450
+ def test_match_mac_list
451
+ rm = create_route_map
452
+ if validate_property_excluded?('route_map', 'match_mac_list')
453
+ assert_nil(rm.match_mac_list)
454
+ assert_raises(Cisco::UnsupportedError) do
455
+ rm.match_mac_list = %w(mac1 listmac some)
456
+ end
457
+ return
458
+ end
459
+ assert_equal(rm.default_match_mac_list, rm.match_mac_list)
460
+ array = %w(mac1 listmac some)
461
+ rm.match_mac_list = array
462
+ assert_equal(array, rm.match_mac_list)
463
+ rm.match_mac_list = rm.default_match_mac_list
464
+ assert_equal(rm.default_match_mac_list, rm.match_mac_list)
465
+ end
466
+
467
+ def test_match_length
468
+ rm = create_route_map
469
+ if validate_property_excluded?('route_map', 'match_length')
470
+ assert_nil(rm.match_length)
471
+ assert_raises(Cisco::UnsupportedError) do
472
+ rm.match_length = %w(45 500)
473
+ end
474
+ return
475
+ end
476
+ assert_equal(rm.default_match_length, rm.match_length)
477
+ array = %w(45 500)
478
+ rm.match_length = array
479
+ assert_equal(array, rm.match_length)
480
+ rm.match_length = rm.default_match_length
481
+ assert_equal(rm.default_match_length, rm.match_length)
482
+ end
483
+
484
+ def test_match_vlan
485
+ rm = create_route_map
486
+ if validate_property_excluded?('route_map', 'match_vlan')
487
+ assert_nil(rm.match_vlan)
488
+ assert_raises(Cisco::UnsupportedError) do
489
+ rm.match_vlan = '32, 45-200, 300-399, 402'
490
+ end
491
+ return
492
+ end
493
+ assert_equal(rm.default_match_vlan, rm.match_vlan)
494
+ rm.match_vlan = '32, 45-200, 300-399, 402'
495
+ assert_equal('32, 45-200, 300-399, 402', rm.match_vlan)
496
+ rm.match_vlan = rm.default_match_vlan
497
+ assert_equal(rm.default_match_vlan, rm.match_vlan)
498
+ end
499
+
500
+ def test_match_evpn_route_type1
501
+ rm = create_route_map
502
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_1')
503
+ assert_nil(rm.match_evpn_route_type_1)
504
+ assert_raises(Cisco::UnsupportedError) do
505
+ rm.match_evpn_route_type_1 = true
506
+ end
507
+ return
508
+ end
509
+ assert_equal(rm.default_match_evpn_route_type_1, rm.match_evpn_route_type_1)
510
+ rm.match_evpn_route_type_1 = true
511
+ assert(rm.match_evpn_route_type_1)
512
+ rm.match_evpn_route_type_1 = rm.default_match_evpn_route_type_1
513
+ assert_equal(rm.default_match_evpn_route_type_1, rm.match_evpn_route_type_1)
514
+ end
515
+
516
+ def test_match_evpn_route_type3
517
+ rm = create_route_map
518
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_3')
519
+ assert_nil(rm.match_evpn_route_type_3)
520
+ assert_raises(Cisco::UnsupportedError) do
521
+ rm.match_evpn_route_type_3 = true
522
+ end
523
+ return
524
+ end
525
+ assert_equal(rm.default_match_evpn_route_type_3, rm.match_evpn_route_type_3)
526
+ rm.match_evpn_route_type_3 = true
527
+ assert(rm.match_evpn_route_type_3)
528
+ rm.match_evpn_route_type_3 = rm.default_match_evpn_route_type_3
529
+ assert_equal(rm.default_match_evpn_route_type_3, rm.match_evpn_route_type_3)
530
+ end
531
+
532
+ def test_match_evpn_route_type4
533
+ rm = create_route_map
534
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_4')
535
+ assert_nil(rm.match_evpn_route_type_4)
536
+ assert_raises(Cisco::UnsupportedError) do
537
+ rm.match_evpn_route_type_4 = true
538
+ end
539
+ return
540
+ end
541
+ assert_equal(rm.default_match_evpn_route_type_4, rm.match_evpn_route_type_4)
542
+ rm.match_evpn_route_type_4 = true
543
+ assert(rm.match_evpn_route_type_4)
544
+ rm.match_evpn_route_type_4 = rm.default_match_evpn_route_type_4
545
+ assert_equal(rm.default_match_evpn_route_type_4, rm.match_evpn_route_type_4)
546
+ end
547
+
548
+ def test_match_evpn_route_type5
549
+ rm = create_route_map
550
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_5')
551
+ assert_nil(rm.match_evpn_route_type_5)
552
+ assert_raises(Cisco::UnsupportedError) do
553
+ rm.match_evpn_route_type_5 = true
554
+ end
555
+ return
556
+ end
557
+ assert_equal(rm.default_match_evpn_route_type_5, rm.match_evpn_route_type_5)
558
+ rm.match_evpn_route_type_5 = true
559
+ assert(rm.match_evpn_route_type_5)
560
+ rm.match_evpn_route_type_5 = rm.default_match_evpn_route_type_5
561
+ assert_equal(rm.default_match_evpn_route_type_5, rm.match_evpn_route_type_5)
562
+ end
563
+
564
+ def test_match_evpn_route_type6
565
+ rm = create_route_map
566
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_6')
567
+ assert_nil(rm.match_evpn_route_type_6)
568
+ assert_raises(Cisco::UnsupportedError) do
569
+ rm.match_evpn_route_type_6 = true
570
+ end
571
+ return
572
+ end
573
+ assert_equal(rm.default_match_evpn_route_type_6, rm.match_evpn_route_type_6)
574
+ rm.match_evpn_route_type_6 = true
575
+ assert(rm.match_evpn_route_type_6)
576
+ rm.match_evpn_route_type_6 = rm.default_match_evpn_route_type_6
577
+ assert_equal(rm.default_match_evpn_route_type_6, rm.match_evpn_route_type_6)
578
+ end
579
+
580
+ def test_match_evpn_route_type_all
581
+ rm = create_route_map
582
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_all')
583
+ assert_nil(rm.match_evpn_route_type_all)
584
+ assert_raises(Cisco::UnsupportedError) do
585
+ rm.match_evpn_route_type_all = true
586
+ end
587
+ return
588
+ end
589
+ assert_equal(rm.default_match_evpn_route_type_all, rm.match_evpn_route_type_all)
590
+ rm.match_evpn_route_type_all = true
591
+ assert(rm.match_evpn_route_type_all)
592
+ rm.match_evpn_route_type_all = rm.default_match_evpn_route_type_all
593
+ assert_equal(rm.default_match_evpn_route_type_all, rm.match_evpn_route_type_all)
594
+ end
595
+
596
+ def test_match_evpn_route_type_2_all
597
+ rm = create_route_map
598
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_2_all')
599
+ assert_nil(rm.match_evpn_route_type_2_all)
600
+ assert_raises(Cisco::UnsupportedError) do
601
+ rm.match_evpn_route_type_2_all = true
602
+ end
603
+ return
604
+ end
605
+ assert_equal(rm.default_match_evpn_route_type_2_all, rm.match_evpn_route_type_2_all)
606
+ rm.match_evpn_route_type_2_all = true
607
+ assert(rm.match_evpn_route_type_2_all)
608
+ rm.match_evpn_route_type_2_all = rm.default_match_evpn_route_type_2_all
609
+ assert_equal(rm.default_match_evpn_route_type_2_all, rm.match_evpn_route_type_2_all)
610
+ end
611
+
612
+ def test_match_evpn_route_type_2_mac_ip
613
+ rm = create_route_map
614
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_2_mac_ip')
615
+ assert_nil(rm.match_evpn_route_type_2_mac_ip)
616
+ assert_raises(Cisco::UnsupportedError) do
617
+ rm.match_evpn_route_type_2_mac_ip = true
618
+ end
619
+ return
620
+ end
621
+ assert_equal(rm.default_match_evpn_route_type_2_mac_ip, rm.match_evpn_route_type_2_mac_ip)
622
+ rm.match_evpn_route_type_2_mac_ip = true
623
+ assert(rm.match_evpn_route_type_2_mac_ip)
624
+ rm.match_evpn_route_type_2_mac_ip = rm.default_match_evpn_route_type_2_mac_ip
625
+ assert_equal(rm.default_match_evpn_route_type_2_mac_ip, rm.match_evpn_route_type_2_mac_ip)
626
+ end
627
+
628
+ def test_match_evpn_route_type_2_mac_only
629
+ rm = create_route_map
630
+ if validate_property_excluded?('route_map', 'match_evpn_route_type_2_mac_only')
631
+ assert_nil(rm.match_evpn_route_type_2_mac_only)
632
+ assert_raises(Cisco::UnsupportedError) do
633
+ rm.match_evpn_route_type_2_mac_only = true
634
+ end
635
+ return
636
+ end
637
+ assert_equal(rm.default_match_evpn_route_type_2_mac_only, rm.match_evpn_route_type_2_mac_only)
638
+ rm.match_evpn_route_type_2_mac_only = true
639
+ assert(rm.match_evpn_route_type_2_mac_only)
640
+ rm.match_evpn_route_type_2_mac_only = rm.default_match_evpn_route_type_2_mac_only
641
+ assert_equal(rm.default_match_evpn_route_type_2_mac_only, rm.match_evpn_route_type_2_mac_only)
642
+ end
643
+
644
+ def test_set_comm_list
645
+ rm = create_route_map
646
+ assert_equal(rm.default_set_comm_list, rm.set_comm_list)
647
+ rm.set_comm_list = 'abc'
648
+ assert_equal('abc', rm.set_comm_list)
649
+ rm.set_comm_list = rm.default_set_comm_list
650
+ assert_equal(rm.default_set_comm_list, rm.set_comm_list)
651
+ end
652
+
653
+ def test_set_extcomm_list
654
+ rm = create_route_map
655
+ assert_equal(rm.default_set_extcomm_list, rm.set_extcomm_list)
656
+ rm.set_extcomm_list = 'xyz'
657
+ assert_equal('xyz', rm.set_extcomm_list)
658
+ rm.set_extcomm_list = rm.default_set_extcomm_list
659
+ assert_equal(rm.default_set_extcomm_list, rm.set_extcomm_list)
660
+ end
661
+
662
+ def test_set_forwarding_addr
663
+ rm = create_route_map
664
+ assert_equal(rm.default_set_forwarding_addr, rm.set_forwarding_addr)
665
+ rm.set_forwarding_addr = true
666
+ assert(rm.set_forwarding_addr)
667
+ rm.set_forwarding_addr = rm.default_set_forwarding_addr
668
+ assert_equal(rm.default_set_forwarding_addr, rm.set_forwarding_addr)
669
+ end
670
+
671
+ def test_set_ipv4_next_hop_peer_addr
672
+ rm = lset_ip_next_hop_helper(v4peer: true)
673
+ assert(rm.set_ipv4_next_hop_peer_addr)
674
+ hash = {}
675
+ rm = lset_ip_next_hop_helper(hash)
676
+ assert_equal(rm.default_set_ipv4_next_hop_peer_addr,
677
+ rm.set_ipv4_next_hop_peer_addr)
678
+ end
679
+
680
+ def test_set_ipv4_next_hop_redist
681
+ skip('platform not supported for this test') unless evergreen_or_later?
682
+ rm = lset_ip_next_hop_helper(v4red: true)
683
+ assert(rm.set_ipv4_next_hop_redist)
684
+ hash = {}
685
+ rm = lset_ip_next_hop_helper(hash)
686
+ assert_equal(rm.default_set_ipv4_next_hop_redist,
687
+ rm.set_ipv4_next_hop_redist)
688
+ end
689
+
690
+ def test_set_ipv4_next_hop_unchanged
691
+ rm = lset_ip_next_hop_helper(v4unc: true)
692
+ assert(rm.set_ipv4_next_hop_unchanged)
693
+ hash = {}
694
+ rm = lset_ip_next_hop_helper(hash)
695
+ assert_equal(rm.default_set_ipv4_next_hop_unchanged,
696
+ rm.set_ipv4_next_hop_unchanged)
697
+ end
698
+
699
+ def test_set_level
700
+ rm = create_route_map
701
+ assert_equal(rm.default_set_level, rm.set_level)
702
+ rm.set_level = 'level-1'
703
+ assert_equal('level-1', rm.set_level)
704
+ rm.set_level = 'level-1-2'
705
+ assert_equal('level-1-2', rm.set_level)
706
+ rm.set_level = 'level-2'
707
+ assert_equal('level-2', rm.set_level)
708
+ rm.set_level = rm.default_set_level
709
+ assert_equal(rm.default_set_level, rm.set_level)
710
+ end
711
+
712
+ def test_set_local_preference
713
+ rm = create_route_map
714
+ assert_equal(rm.default_set_local_preference, rm.set_local_preference)
715
+ rm.set_local_preference = 100
716
+ assert_equal(100, rm.set_local_preference)
717
+ rm.set_local_preference = rm.default_set_local_preference
718
+ assert_equal(rm.default_set_local_preference, rm.set_local_preference)
719
+ end
720
+
721
+ def test_set_metric_type
722
+ rm = create_route_map
723
+ assert_equal(rm.default_set_metric_type, rm.set_metric_type)
724
+ rm.set_metric_type = 'external'
725
+ assert_equal('external', rm.set_metric_type)
726
+ rm.set_metric_type = 'internal'
727
+ assert_equal('internal', rm.set_metric_type)
728
+ rm.set_metric_type = 'type-1'
729
+ assert_equal('type-1', rm.set_metric_type)
730
+ rm.set_metric_type = 'type-2'
731
+ assert_equal('type-2', rm.set_metric_type)
732
+ rm.set_metric_type = rm.default_set_metric_type
733
+ assert_equal(rm.default_set_metric_type, rm.set_metric_type)
734
+ end
735
+
736
+ def test_set_nssa_only
737
+ rm = create_route_map
738
+ assert_equal(rm.default_set_nssa_only, rm.set_nssa_only)
739
+ rm.set_nssa_only = true
740
+ assert(rm.set_nssa_only)
741
+ rm.set_nssa_only = rm.default_set_nssa_only
742
+ assert_equal(rm.default_set_nssa_only, rm.set_nssa_only)
743
+ end
744
+
745
+ def test_set_origin
746
+ rm = create_route_map
747
+ assert_equal(rm.default_set_origin, rm.set_origin)
748
+ rm.set_origin = 'egp'
749
+ assert_equal('egp', rm.set_origin)
750
+ rm.set_origin = 'incomplete'
751
+ assert_equal('incomplete', rm.set_origin)
752
+ rm.set_origin = 'igp'
753
+ assert_equal('igp', rm.set_origin)
754
+ rm.set_origin = rm.default_set_origin
755
+ assert_equal(rm.default_set_origin, rm.set_origin)
756
+ end
757
+
758
+ def test_set_path_selection
759
+ rm = create_route_map
760
+ assert_equal(rm.default_set_path_selection, rm.set_path_selection)
761
+ rm.set_path_selection = true
762
+ assert(rm.set_path_selection)
763
+ rm.set_path_selection = rm.default_set_path_selection
764
+ assert_equal(rm.default_set_path_selection, rm.set_path_selection)
765
+ end
766
+
767
+ def test_set_tag
768
+ rm = create_route_map
769
+ assert_equal(rm.default_set_tag, rm.set_tag)
770
+ rm.set_tag = 100
771
+ assert_equal(100, rm.set_tag)
772
+ rm.set_tag = rm.default_set_tag
773
+ assert_equal(rm.default_set_tag, rm.set_tag)
774
+ end
775
+
776
+ def test_set_vrf
777
+ rm = create_route_map
778
+ if validate_property_excluded?('route_map', 'set_vrf')
779
+ assert_nil(rm.set_vrf)
780
+ assert_raises(Cisco::UnsupportedError) do
781
+ rm.set_vrf = 'default'
782
+ end
783
+ return
784
+ end
785
+ assert_equal(rm.default_set_vrf, rm.set_vrf)
786
+ rm.set_vrf = 'default_vrf'
787
+ assert_equal('default_vrf', rm.set_vrf)
788
+ rm.set_vrf = 'management'
789
+ assert_equal('management', rm.set_vrf)
790
+ rm.set_vrf = 'igp'
791
+ assert_equal('igp', rm.set_vrf)
792
+ rm.set_vrf = rm.default_set_vrf
793
+ assert_equal(rm.default_set_vrf, rm.set_vrf)
794
+ end
795
+
796
+ def test_set_weight
797
+ rm = create_route_map
798
+ assert_equal(rm.default_set_weight, rm.set_weight)
799
+ rm.set_weight = 333
800
+ assert_equal(333, rm.set_weight)
801
+ rm.set_weight = rm.default_set_weight
802
+ assert_equal(rm.default_set_weight, rm.set_weight)
803
+ end
804
+
805
+ def test_set_metric
806
+ rm = create_route_map
807
+ assert_equal(rm.default_set_metric_additive, rm.set_metric_additive)
808
+ assert_equal(rm.default_set_metric_bandwidth, rm.set_metric_bandwidth)
809
+ assert_equal(rm.default_set_metric_delay, rm.set_metric_delay)
810
+ assert_equal(rm.default_set_metric_reliability,
811
+ rm.set_metric_reliability)
812
+ assert_equal(rm.default_set_metric_effective_bandwidth,
813
+ rm.set_metric_effective_bandwidth)
814
+ assert_equal(rm.default_set_metric_mtu, rm.set_metric_mtu)
815
+ rm.set_metric_set(false, 44, 55, 66, 77, 88)
816
+ refute(rm.set_metric_additive)
817
+ assert_equal(44, rm.set_metric_bandwidth)
818
+ assert_equal(55, rm.set_metric_delay)
819
+ assert_equal(66, rm.set_metric_reliability)
820
+ assert_equal(77, rm.set_metric_effective_bandwidth)
821
+ assert_equal(88, rm.set_metric_mtu)
822
+ rm.set_metric_set(true, 33, false, false, false, false)
823
+ assert(rm.set_metric_additive)
824
+ assert_equal(33, rm.set_metric_bandwidth)
825
+ refute(rm.set_metric_delay)
826
+ refute(rm.set_metric_reliability)
827
+ refute(rm.set_metric_effective_bandwidth)
828
+ refute(rm.set_metric_mtu)
829
+ rm.set_metric_set(false, false, false, false, false, false)
830
+ assert_equal(rm.default_set_metric_additive, rm.set_metric_additive)
831
+ assert_equal(rm.default_set_metric_bandwidth, rm.set_metric_bandwidth)
832
+ assert_equal(rm.default_set_metric_delay, rm.set_metric_delay)
833
+ assert_equal(rm.default_set_metric_reliability,
834
+ rm.set_metric_reliability)
835
+ assert_equal(rm.default_set_metric_effective_bandwidth,
836
+ rm.set_metric_effective_bandwidth)
837
+ assert_equal(rm.default_set_metric_mtu, rm.set_metric_mtu)
838
+ end
839
+
840
+ def test_set_dampening
841
+ rm = create_route_map
842
+ assert_equal(rm.default_set_dampening_half_life,
843
+ rm.set_dampening_half_life)
844
+ assert_equal(rm.default_set_dampening_reuse,
845
+ rm.set_dampening_reuse)
846
+ assert_equal(rm.default_set_dampening_suppress,
847
+ rm.set_dampening_suppress)
848
+ assert_equal(rm.default_set_dampening_max_duation,
849
+ rm.set_dampening_max_duation)
850
+ rm.set_dampening_set(6, 22, 44, 55)
851
+ assert_equal(6, rm.set_dampening_half_life)
852
+ assert_equal(22, rm.set_dampening_reuse)
853
+ assert_equal(44, rm.set_dampening_suppress)
854
+ assert_equal(55, rm.set_dampening_max_duation)
855
+ rm.set_dampening_set(false, false, false, false)
856
+ assert_equal(rm.default_set_dampening_half_life,
857
+ rm.set_dampening_half_life)
858
+ assert_equal(rm.default_set_dampening_reuse,
859
+ rm.set_dampening_reuse)
860
+ assert_equal(rm.default_set_dampening_suppress,
861
+ rm.set_dampening_suppress)
862
+ assert_equal(rm.default_set_dampening_max_duation,
863
+ rm.set_dampening_max_duation)
864
+ end
865
+
866
+ def test_set_distance
867
+ rm = create_route_map
868
+ assert_equal(rm.default_set_distance_igp_ebgp,
869
+ rm.set_distance_igp_ebgp)
870
+ assert_equal(rm.default_set_distance_internal,
871
+ rm.set_distance_internal)
872
+ assert_equal(rm.default_set_distance_local,
873
+ rm.set_distance_local)
874
+ rm.set_distance_set(1, 2, 3)
875
+ assert_equal(1, rm.set_distance_igp_ebgp)
876
+ assert_equal(2, rm.set_distance_internal)
877
+ assert_equal(3, rm.set_distance_local)
878
+ rm.set_distance_set(1, false, false)
879
+ assert_equal(1, rm.set_distance_igp_ebgp)
880
+ refute(rm.set_distance_internal)
881
+ refute(rm.set_distance_local)
882
+ rm.set_distance_set(1, 2, false)
883
+ assert_equal(1, rm.set_distance_igp_ebgp)
884
+ assert_equal(2, rm.set_distance_internal)
885
+ refute(rm.set_distance_local)
886
+ rm.set_distance_set(false, false, false)
887
+ assert_equal(rm.default_set_distance_igp_ebgp,
888
+ rm.set_distance_igp_ebgp)
889
+ assert_equal(rm.default_set_distance_internal,
890
+ rm.set_distance_internal)
891
+ assert_equal(rm.default_set_distance_local,
892
+ rm.set_distance_local)
893
+ end
894
+
895
+ def test_set_as_path_prepend_last_as
896
+ rm = create_route_map
897
+ assert_equal(rm.default_set_as_path_prepend_last_as,
898
+ rm.set_as_path_prepend_last_as)
899
+ rm.set_as_path_prepend_last_as = 1
900
+ assert_equal(1, rm.set_as_path_prepend_last_as)
901
+ rm.set_as_path_prepend_last_as = rm.default_set_as_path_prepend_last_as
902
+ assert_equal(rm.default_set_as_path_prepend_last_as,
903
+ rm.set_as_path_prepend_last_as)
904
+ end
905
+
906
+ def test_set_as_path_tag
907
+ rm = create_route_map
908
+ assert_equal(rm.default_set_as_path_tag,
909
+ rm.set_as_path_tag)
910
+ rm.set_as_path_tag = true
911
+ assert(rm.set_as_path_tag)
912
+ rm.set_as_path_tag = rm.default_set_as_path_tag
913
+ assert_equal(rm.default_set_as_path_tag,
914
+ rm.set_as_path_tag)
915
+ end
916
+
917
+ def test_set_as_path_prepend
918
+ rm = create_route_map
919
+ assert_equal(rm.default_set_as_path_prepend,
920
+ rm.set_as_path_prepend)
921
+ arr = ['55.77', '12', '45.3', '4.77', '5']
922
+ rm.set_as_path_prepend = arr
923
+ assert_equal(arr, rm.set_as_path_prepend)
924
+ rm.set_as_path_prepend = rm.default_set_as_path_prepend
925
+ assert_equal(rm.default_set_as_path_prepend,
926
+ rm.set_as_path_prepend)
927
+ end
928
+
929
+ def test_set_interface
930
+ rm = lset_ip_next_hop_helper(intf: 'Null0')
931
+ assert_equal('Null0', rm.set_interface)
932
+ hash = {}
933
+ rm = lset_ip_next_hop_helper(hash)
934
+ assert_equal(rm.default_set_interface,
935
+ rm.set_interface)
936
+ end
937
+
938
+ def test_set_ipv4_prefix
939
+ rm = create_route_map
940
+ if validate_property_excluded?('route_map', 'set_ipv4_prefix')
941
+ assert_nil(rm.set_ipv4_prefix)
942
+ assert_raises(Cisco::UnsupportedError) do
943
+ rm.set_ipv4_prefix = 'abcdef'
944
+ end
945
+ return
946
+ end
947
+ assert_equal(rm.default_set_ipv4_prefix, rm.set_ipv4_prefix)
948
+ rm.set_ipv4_prefix = 'abcdef'
949
+ assert_equal('abcdef', rm.set_ipv4_prefix)
950
+ rm.set_ipv4_prefix = rm.default_set_ipv4_prefix
951
+ assert_equal(rm.default_set_ipv4_prefix, rm.set_ipv4_prefix)
952
+ end
953
+
954
+ def test_set_ip_precedence
955
+ rm = create_route_map
956
+ assert_equal(rm.default_set_ipv4_precedence, rm.set_ipv4_precedence)
957
+ assert_equal(rm.default_set_ipv6_precedence, rm.set_ipv6_precedence)
958
+ rm.set_ip_precedence('critical', rm.default_set_ipv6_precedence)
959
+ assert_equal('critical', rm.set_ipv4_precedence)
960
+ assert_equal(rm.default_set_ipv6_precedence, rm.set_ipv6_precedence)
961
+ rm.set_ip_precedence(rm.default_set_ipv6_precedence, 'network')
962
+ assert_equal(rm.default_set_ipv4_precedence, rm.set_ipv4_precedence)
963
+ assert_equal('network', rm.set_ipv6_precedence)
964
+ rm.set_ip_precedence(rm.default_set_ipv4_precedence,
965
+ rm.default_set_ipv6_precedence)
966
+ assert_equal(rm.default_set_ipv4_precedence, rm.set_ipv4_precedence)
967
+ assert_equal(rm.default_set_ipv6_precedence, rm.set_ipv6_precedence)
968
+ end
969
+
970
+ def test_set_ipv4_default_next_hop
971
+ skip('platform not supported for this test') if node.product_id[/(N5|N6|N9|N9.*-F)/]
972
+ arr = %w(1.1.1.1 2.2.2.2 3.3.3.3)
973
+ rm = lset_ip_next_hop_helper(v4dnh: arr)
974
+ assert_equal(arr, rm.set_ipv4_default_next_hop)
975
+ assert_equal(rm.default_set_ipv4_default_next_hop_load_share,
976
+ rm.set_ipv4_default_next_hop_load_share)
977
+ rm = lset_ip_next_hop_helper(v4dnh: arr, v4dls: true)
978
+ assert_equal(arr, rm.set_ipv4_default_next_hop)
979
+ assert(rm.set_ipv4_default_next_hop_load_share)
980
+ rm = lset_ip_next_hop_helper(v4dls: true)
981
+ assert_equal(rm.default_set_ipv4_default_next_hop,
982
+ rm.set_ipv4_default_next_hop)
983
+ assert(rm.set_ipv4_default_next_hop_load_share)
984
+ hash = {}
985
+ rm = lset_ip_next_hop_helper(hash)
986
+ assert_equal(rm.default_set_ipv4_default_next_hop,
987
+ rm.set_ipv4_default_next_hop)
988
+ assert_equal(rm.default_set_ipv4_default_next_hop_load_share,
989
+ rm.set_ipv4_default_next_hop_load_share)
990
+ end
991
+
992
+ def test_set_ipv4_next_hop
993
+ arr = %w(1.1.1.1 2.2.2.2 3.3.3.3)
994
+ rm = lset_ip_next_hop_helper(v4nh: arr)
995
+ assert_equal(arr, rm.set_ipv4_next_hop)
996
+ hash = {}
997
+ rm = lset_ip_next_hop_helper(hash)
998
+ assert_equal(rm.default_set_ipv4_next_hop,
999
+ rm.set_ipv4_next_hop)
1000
+ end
1001
+
1002
+ def test_set_ipv4_next_hop_load_share
1003
+ # bug on fretta
1004
+ skip('platform not supported for this test') if node.product_id[/(N5|N6|N9.*-F)/]
1005
+ # bug on old n9k
1006
+ skip('platform not supported for this test') if older_n9k?
1007
+ arr = %w(1.1.1.1 2.2.2.2 3.3.3.3)
1008
+ rm = lset_ip_next_hop_helper(v4nh: arr)
1009
+ assert_equal(arr, rm.set_ipv4_next_hop)
1010
+ assert_equal(rm.default_set_ipv4_next_hop_load_share,
1011
+ rm.set_ipv4_next_hop_load_share)
1012
+ rm = lset_ip_next_hop_helper(v4nh: arr, v4ls: true)
1013
+ assert_equal(arr, rm.set_ipv4_next_hop)
1014
+ assert(rm.set_ipv4_next_hop_load_share)
1015
+ rm = lset_ip_next_hop_helper(v4ls: true)
1016
+ assert_equal(rm.default_set_ipv4_next_hop,
1017
+ rm.set_ipv4_next_hop)
1018
+ assert(rm.set_ipv4_next_hop_load_share)
1019
+ hash = {}
1020
+ rm = lset_ip_next_hop_helper(hash)
1021
+ assert_equal(rm.default_set_ipv4_next_hop,
1022
+ rm.set_ipv4_next_hop)
1023
+ assert_equal(rm.default_set_ipv4_next_hop_load_share,
1024
+ rm.set_ipv4_next_hop_load_share)
1025
+ end
1026
+
1027
+ def test_set_ipv6_next_hop_peer_addr
1028
+ rm = lset_ip_next_hop_helper(v6peer: true)
1029
+ assert(rm.set_ipv6_next_hop_peer_addr)
1030
+ hash = {}
1031
+ rm = lset_ip_next_hop_helper(hash)
1032
+ assert_equal(rm.default_set_ipv6_next_hop_peer_addr,
1033
+ rm.set_ipv6_next_hop_peer_addr)
1034
+ end
1035
+
1036
+ def test_set_ipv6_next_hop_redist
1037
+ skip('platform not supported for this test') unless evergreen_or_later?
1038
+ rm = lset_ip_next_hop_helper(v6red: true)
1039
+ assert(rm.set_ipv6_next_hop_redist)
1040
+ hash = {}
1041
+ rm = lset_ip_next_hop_helper(hash)
1042
+ assert_equal(rm.default_set_ipv6_next_hop_redist,
1043
+ rm.set_ipv6_next_hop_redist)
1044
+ end
1045
+
1046
+ def test_set_ipv6_next_hop_unchanged
1047
+ rm = lset_ip_next_hop_helper(v6unc: true)
1048
+ assert(rm.set_ipv6_next_hop_unchanged)
1049
+ hash = {}
1050
+ rm = lset_ip_next_hop_helper(hash)
1051
+ assert_equal(rm.default_set_ipv6_next_hop_unchanged,
1052
+ rm.set_ipv6_next_hop_unchanged)
1053
+ end
1054
+
1055
+ def test_set_ipv6_prefix
1056
+ rm = create_route_map
1057
+ if validate_property_excluded?('route_map', 'set_ipv6_prefix')
1058
+ assert_nil(rm.set_ipv6_prefix)
1059
+ assert_raises(Cisco::UnsupportedError) do
1060
+ rm.set_ipv6_prefix = 'abcdef'
1061
+ end
1062
+ return
1063
+ end
1064
+ assert_equal(rm.default_set_ipv6_prefix, rm.set_ipv6_prefix)
1065
+ rm.set_ipv6_prefix = 'abcdef'
1066
+ assert_equal('abcdef', rm.set_ipv6_prefix)
1067
+ rm.set_ipv6_prefix = rm.default_set_ipv6_prefix
1068
+ assert_equal(rm.default_set_ipv6_prefix, rm.set_ipv6_prefix)
1069
+ end
1070
+
1071
+ def test_set_ipv6_default_next_hop
1072
+ skip('platform not supported for this test') if node.product_id[/(N5|N6|N9|N9.*-F)/]
1073
+ arr = %w(2000::1 2000::11 2000::22)
1074
+ rm = lset_ip_next_hop_helper(v6dnh: arr)
1075
+ assert_equal(arr, rm.set_ipv6_default_next_hop)
1076
+ assert_equal(rm.default_set_ipv6_default_next_hop_load_share,
1077
+ rm.set_ipv6_default_next_hop_load_share)
1078
+ rm = lset_ip_next_hop_helper(v6dnh: arr, v6dls: true)
1079
+ assert_equal(arr, rm.set_ipv6_default_next_hop)
1080
+ assert(rm.set_ipv6_default_next_hop_load_share)
1081
+ rm = lset_ip_next_hop_helper(v6dls: true)
1082
+ assert_equal(rm.default_set_ipv6_default_next_hop,
1083
+ rm.set_ipv6_default_next_hop)
1084
+ assert(rm.set_ipv6_default_next_hop_load_share)
1085
+ hash = {}
1086
+ rm = lset_ip_next_hop_helper(hash)
1087
+ assert_equal(rm.default_set_ipv6_default_next_hop,
1088
+ rm.set_ipv6_default_next_hop)
1089
+ assert_equal(rm.default_set_ipv6_default_next_hop_load_share,
1090
+ rm.set_ipv6_default_next_hop_load_share)
1091
+ end
1092
+
1093
+ def test_set_ipv6_next_hop
1094
+ arr = %w(2000::1 2000::11 2000::22)
1095
+ rm = lset_ip_next_hop_helper(v6nh: arr)
1096
+ assert_equal(arr, rm.set_ipv6_next_hop)
1097
+ hash = {}
1098
+ rm = lset_ip_next_hop_helper(hash)
1099
+ assert_equal(rm.default_set_ipv6_next_hop,
1100
+ rm.set_ipv6_next_hop)
1101
+ end
1102
+
1103
+ def test_set_ipv6_next_hop_load_share
1104
+ # bug on fretta
1105
+ skip('platform not supported for this test') if node.product_id[/(N5|N6|N9.*-F)/]
1106
+ # bug on old n9k
1107
+ skip('platform not supported for this test') if older_n9k?
1108
+ arr = %w(2000::1 2000::11 2000::22)
1109
+ rm = lset_ip_next_hop_helper(v6nh: arr)
1110
+ assert_equal(arr, rm.set_ipv6_next_hop)
1111
+ assert_equal(rm.default_set_ipv6_next_hop_load_share,
1112
+ rm.set_ipv6_next_hop_load_share)
1113
+ rm = lset_ip_next_hop_helper(v6nh: arr, v6ls: true)
1114
+ assert_equal(arr, rm.set_ipv6_next_hop)
1115
+ assert(rm.set_ipv6_next_hop_load_share)
1116
+ rm = lset_ip_next_hop_helper(v6ls: true)
1117
+ assert_equal(rm.default_set_ipv6_next_hop,
1118
+ rm.set_ipv6_next_hop)
1119
+ assert(rm.set_ipv6_next_hop_load_share)
1120
+ hash = {}
1121
+ rm = lset_ip_next_hop_helper(hash)
1122
+ assert_equal(rm.default_set_ipv6_next_hop,
1123
+ rm.set_ipv6_next_hop)
1124
+ assert_equal(rm.default_set_ipv6_next_hop_load_share,
1125
+ rm.set_ipv6_next_hop_load_share)
1126
+ end
1127
+
1128
+ def test_set_community_no_asn
1129
+ # bug on n5/6k
1130
+ skip('platform not supported for this test') if node.product_id[/(N5|N6)/]
1131
+ # bug on old n9k
1132
+ skip('platform not supported for this test') if older_n9k?
1133
+ rm = create_route_map
1134
+ assert_equal(rm.default_set_community_additive,
1135
+ rm.set_community_additive)
1136
+ assert_equal(rm.default_set_community_asn,
1137
+ rm.set_community_asn)
1138
+ assert_equal(rm.default_set_community_internet,
1139
+ rm.set_community_internet)
1140
+ assert_equal(rm.default_set_community_local_as,
1141
+ rm.set_community_local_as)
1142
+ assert_equal(rm.default_set_community_no_advtertise,
1143
+ rm.set_community_no_advtertise)
1144
+ assert_equal(rm.default_set_community_no_export,
1145
+ rm.set_community_no_export)
1146
+ assert_equal(rm.default_set_community_none,
1147
+ rm.set_community_none)
1148
+ asn = rm.default_set_community_asn
1149
+ none = true
1150
+ noadv = false
1151
+ noexp = false
1152
+ add = false
1153
+ local = false
1154
+ inter = false
1155
+ rm.set_community_set(none, noadv, noexp, add, local, inter, asn)
1156
+ assert_equal(rm.default_set_community_additive,
1157
+ rm.set_community_additive)
1158
+ assert_equal(rm.default_set_community_asn,
1159
+ rm.set_community_asn)
1160
+ assert_equal(rm.default_set_community_internet,
1161
+ rm.set_community_internet)
1162
+ assert_equal(rm.default_set_community_local_as,
1163
+ rm.set_community_local_as)
1164
+ assert_equal(rm.default_set_community_no_advtertise,
1165
+ rm.set_community_no_advtertise)
1166
+ assert_equal(rm.default_set_community_no_export,
1167
+ rm.set_community_no_export)
1168
+ assert_equal(none, rm.set_community_none)
1169
+ none = false
1170
+ add = true
1171
+ rm.set_community_set(none, noadv, noexp, add, local, inter, asn)
1172
+ assert(rm.set_community_additive)
1173
+ assert_equal(rm.default_set_community_asn,
1174
+ rm.set_community_asn)
1175
+ assert_equal(rm.default_set_community_internet,
1176
+ rm.set_community_internet)
1177
+ assert_equal(rm.default_set_community_local_as,
1178
+ rm.set_community_local_as)
1179
+ assert_equal(rm.default_set_community_no_advtertise,
1180
+ rm.set_community_no_advtertise)
1181
+ assert_equal(rm.default_set_community_no_export,
1182
+ rm.set_community_no_export)
1183
+ assert_equal(rm.default_set_community_none,
1184
+ rm.set_community_none)
1185
+ noadv = true
1186
+ rm.set_community_set(none, noadv, noexp, add, local, inter, asn)
1187
+ assert(rm.set_community_additive)
1188
+ assert_equal(rm.default_set_community_asn,
1189
+ rm.set_community_asn)
1190
+ assert_equal(rm.default_set_community_internet,
1191
+ rm.set_community_internet)
1192
+ assert_equal(rm.default_set_community_local_as,
1193
+ rm.set_community_local_as)
1194
+ assert(rm.set_community_no_advtertise)
1195
+ assert_equal(rm.default_set_community_no_export,
1196
+ rm.set_community_no_export)
1197
+ assert_equal(rm.default_set_community_none,
1198
+ rm.set_community_none)
1199
+ noadv = true
1200
+ noexp = true
1201
+ add = true
1202
+ local = true
1203
+ inter = true
1204
+ rm.set_community_set(none, noadv, noexp, add, local, inter, asn)
1205
+ assert(rm.set_community_additive)
1206
+ assert_equal(rm.default_set_community_asn,
1207
+ rm.set_community_asn)
1208
+ assert(rm.set_community_internet)
1209
+ assert(rm.set_community_local_as)
1210
+ assert(rm.set_community_no_advtertise)
1211
+ assert(rm.set_community_no_export)
1212
+ assert_equal(rm.default_set_community_none,
1213
+ rm.set_community_none)
1214
+ rm.set_community_set(false, false, false, false, false, false, asn)
1215
+ assert_equal(rm.default_set_community_additive,
1216
+ rm.set_community_additive)
1217
+ assert_equal(rm.default_set_community_asn, rm.set_community_asn)
1218
+ assert_equal(rm.default_set_community_internet,
1219
+ rm.set_community_internet)
1220
+ assert_equal(rm.default_set_community_local_as,
1221
+ rm.set_community_local_as)
1222
+ assert_equal(rm.default_set_community_no_advtertise,
1223
+ rm.set_community_no_advtertise)
1224
+ assert_equal(rm.default_set_community_no_export,
1225
+ rm.set_community_no_export)
1226
+ assert_equal(rm.default_set_community_none,
1227
+ rm.set_community_none)
1228
+ end
1229
+
1230
+ def test_set_community_asn
1231
+ # bug on old n9k
1232
+ skip('platform not supported for this test') if older_n9k?
1233
+ rm = create_route_map
1234
+ none = false
1235
+ noadv = true
1236
+ noexp = true
1237
+ add = true
1238
+ local = true
1239
+ inter = true
1240
+ asn = ['11:22', '33:44', '123:11']
1241
+ rm.set_community_set(none, noadv, noexp, add, local, inter, asn)
1242
+ assert(rm.set_community_additive)
1243
+ assert_equal(asn, rm.set_community_asn)
1244
+ assert(rm.set_community_internet)
1245
+ assert(rm.set_community_local_as)
1246
+ assert(rm.set_community_no_advtertise)
1247
+ assert(rm.set_community_no_export)
1248
+ assert_equal(rm.default_set_community_none,
1249
+ rm.set_community_none)
1250
+ none = false
1251
+ noadv = false
1252
+ noexp = false
1253
+ add = false
1254
+ local = false
1255
+ inter = false
1256
+ rm.set_community_set(none, noadv, noexp, add, local, inter, asn)
1257
+ assert_equal(rm.default_set_community_additive,
1258
+ rm.set_community_additive)
1259
+ assert_equal(asn, rm.set_community_asn)
1260
+ assert_equal(rm.default_set_community_internet,
1261
+ rm.set_community_internet)
1262
+ assert_equal(rm.default_set_community_local_as,
1263
+ rm.set_community_local_as)
1264
+ assert_equal(rm.default_set_community_no_advtertise,
1265
+ rm.set_community_no_advtertise)
1266
+ assert_equal(rm.default_set_community_no_export,
1267
+ rm.set_community_no_export)
1268
+ assert_equal(rm.default_set_community_none,
1269
+ rm.set_community_none)
1270
+ asn = rm.default_set_community_asn
1271
+ rm.set_community_set(false, false, false, false, false, false, asn)
1272
+ assert_equal(rm.default_set_community_additive,
1273
+ rm.set_community_additive)
1274
+ assert_equal(rm.default_set_community_asn, rm.set_community_asn)
1275
+ assert_equal(rm.default_set_community_internet,
1276
+ rm.set_community_internet)
1277
+ assert_equal(rm.default_set_community_local_as,
1278
+ rm.set_community_local_as)
1279
+ assert_equal(rm.default_set_community_no_advtertise,
1280
+ rm.set_community_no_advtertise)
1281
+ assert_equal(rm.default_set_community_no_export,
1282
+ rm.set_community_no_export)
1283
+ assert_equal(rm.default_set_community_none,
1284
+ rm.set_community_none)
1285
+ end
1286
+
1287
+ def test_extcommunity_4bytes
1288
+ # bug on fretta
1289
+ skip('platform not supported for this test') if node.product_id[/N9.*-F/]
1290
+ rm = create_route_map
1291
+ assert_equal(rm.default_set_extcommunity_4bytes_transitive,
1292
+ rm.set_extcommunity_4bytes_transitive)
1293
+ assert_equal(rm.default_set_extcommunity_4bytes_non_transitive,
1294
+ rm.set_extcommunity_4bytes_non_transitive)
1295
+ assert_equal(rm.default_set_extcommunity_4bytes_none,
1296
+ rm.set_extcommunity_4bytes_none)
1297
+ assert_equal(rm.default_set_extcommunity_4bytes_additive,
1298
+ rm.set_extcommunity_4bytes_additive)
1299
+ none = true
1300
+ tr = ntr = []
1301
+ add = false
1302
+ rm.set_extcommunity_4bytes_set(none, tr, ntr, add)
1303
+ assert(rm.set_extcommunity_4bytes_none)
1304
+ assert_equal(rm.default_set_extcommunity_4bytes_transitive,
1305
+ rm.set_extcommunity_4bytes_transitive)
1306
+ assert_equal(rm.default_set_extcommunity_4bytes_non_transitive,
1307
+ rm.set_extcommunity_4bytes_non_transitive)
1308
+ assert_equal(rm.default_set_extcommunity_4bytes_additive,
1309
+ rm.set_extcommunity_4bytes_additive)
1310
+ none = false
1311
+ add = true
1312
+ rm.set_extcommunity_4bytes_set(none, tr, ntr, add)
1313
+ assert(rm.set_extcommunity_4bytes_additive)
1314
+ assert_equal(rm.default_set_extcommunity_4bytes_transitive,
1315
+ rm.set_extcommunity_4bytes_transitive)
1316
+ assert_equal(rm.default_set_extcommunity_4bytes_non_transitive,
1317
+ rm.set_extcommunity_4bytes_non_transitive)
1318
+ assert_equal(rm.default_set_extcommunity_4bytes_none,
1319
+ rm.set_extcommunity_4bytes_none)
1320
+ tr = ['11:22', '33:44', '66:77']
1321
+ rm.set_extcommunity_4bytes_set(none, tr, ntr, add)
1322
+ assert(rm.set_extcommunity_4bytes_additive)
1323
+ assert_equal(tr, rm.set_extcommunity_4bytes_transitive)
1324
+ assert_equal(rm.default_set_extcommunity_4bytes_non_transitive,
1325
+ rm.set_extcommunity_4bytes_non_transitive)
1326
+ assert_equal(rm.default_set_extcommunity_4bytes_none,
1327
+ rm.set_extcommunity_4bytes_none)
1328
+ ntr = ['21:42', '43:22', '59:17']
1329
+ rm.set_extcommunity_4bytes_set(none, tr, ntr, add)
1330
+ assert(rm.set_extcommunity_4bytes_additive)
1331
+ assert_equal(tr, rm.set_extcommunity_4bytes_transitive)
1332
+ assert_equal(ntr, rm.set_extcommunity_4bytes_non_transitive)
1333
+ assert_equal(rm.default_set_extcommunity_4bytes_none,
1334
+ rm.set_extcommunity_4bytes_none)
1335
+ add = false
1336
+ tr = ntr = []
1337
+ rm.set_extcommunity_4bytes_set(none, tr, ntr, add)
1338
+ assert_equal(rm.default_set_extcommunity_4bytes_transitive,
1339
+ rm.set_extcommunity_4bytes_transitive)
1340
+ assert_equal(rm.default_set_extcommunity_4bytes_non_transitive,
1341
+ rm.set_extcommunity_4bytes_non_transitive)
1342
+ assert_equal(rm.default_set_extcommunity_4bytes_none,
1343
+ rm.set_extcommunity_4bytes_none)
1344
+ assert_equal(rm.default_set_extcommunity_4bytes_additive,
1345
+ rm.set_extcommunity_4bytes_additive)
1346
+ end
1347
+
1348
+ def test_extcommunity_rt
1349
+ # bug CSCvc92395 on fretta and n9k
1350
+ skip('platform not supported for this test') if node.product_id[/N9/]
1351
+ rm = create_route_map
1352
+ assert_equal(rm.default_set_extcommunity_rt_additive,
1353
+ rm.set_extcommunity_rt_additive)
1354
+ assert_equal(rm.default_set_extcommunity_rt_asn,
1355
+ rm.set_extcommunity_rt_asn)
1356
+ asn = []
1357
+ add = true
1358
+ rm.set_extcommunity_rt_set(asn, add)
1359
+ assert(rm.set_extcommunity_rt_additive)
1360
+ assert_equal(rm.default_set_extcommunity_rt_asn,
1361
+ rm.set_extcommunity_rt_asn)
1362
+ asn = ['11:22', '33:44', '12.22.22.22:12', '123.256:543']
1363
+ rm.set_extcommunity_rt_set(asn, add)
1364
+ assert(rm.set_extcommunity_rt_additive)
1365
+ assert_equal(asn, rm.set_extcommunity_rt_asn)
1366
+ add = false
1367
+ rm.set_extcommunity_rt_set(asn, add)
1368
+ assert_equal(rm.default_set_extcommunity_rt_additive,
1369
+ rm.set_extcommunity_rt_additive)
1370
+ assert_equal(asn, rm.set_extcommunity_rt_asn)
1371
+ asn = []
1372
+ rm.set_extcommunity_rt_set(asn, add)
1373
+ assert_equal(rm.default_set_extcommunity_rt_additive,
1374
+ rm.set_extcommunity_rt_additive)
1375
+ assert_equal(rm.default_set_extcommunity_rt_asn,
1376
+ rm.set_extcommunity_rt_asn)
1377
+ end
1378
+
1379
+ def test_extcommunity_cost
1380
+ rm = create_route_map
1381
+ assert_equal(rm.default_set_extcommunity_cost_igp,
1382
+ rm.set_extcommunity_cost_igp)
1383
+ assert_equal(rm.default_set_extcommunity_cost_pre_bestpath,
1384
+ rm.set_extcommunity_cost_pre_bestpath)
1385
+ igp = [%w(0 23), %w(3 33), %w(100 10954)]
1386
+ pre = []
1387
+ rm.set_extcommunity_cost_set(igp, pre)
1388
+ assert_equal(igp, rm.set_extcommunity_cost_igp)
1389
+ assert_equal(rm.default_set_extcommunity_cost_pre_bestpath,
1390
+ rm.set_extcommunity_cost_pre_bestpath)
1391
+ pre = [%w(23 999), %w(88 482), %w(120 2323)]
1392
+ rm.set_extcommunity_cost_set(igp, pre)
1393
+ assert_equal(igp, rm.set_extcommunity_cost_igp)
1394
+ assert_equal(pre, rm.set_extcommunity_cost_pre_bestpath)
1395
+ igp = []
1396
+ rm.set_extcommunity_cost_set(igp, pre)
1397
+ assert_equal(rm.default_set_extcommunity_cost_igp,
1398
+ rm.set_extcommunity_cost_igp)
1399
+ assert_equal(pre, rm.set_extcommunity_cost_pre_bestpath)
1400
+ pre = []
1401
+ rm.set_extcommunity_cost_set(igp, pre)
1402
+ assert_equal(rm.default_set_extcommunity_cost_igp,
1403
+ rm.set_extcommunity_cost_igp)
1404
+ assert_equal(rm.default_set_extcommunity_cost_pre_bestpath,
1405
+ rm.set_extcommunity_cost_pre_bestpath)
1406
+ end
1407
+
1408
+ def test_set_ip_next_hop_defaults
1409
+ rm = create_route_map
1410
+ assert_equal(rm.default_set_interface, rm.set_interface)
1411
+ assert_equal(rm.default_set_ipv4_default_next_hop,
1412
+ rm.set_ipv4_default_next_hop) unless
1413
+ rm.default_set_ipv4_default_next_hop.nil?
1414
+ assert_equal(rm.default_set_ipv4_default_next_hop_load_share,
1415
+ rm.set_ipv4_default_next_hop_load_share) unless
1416
+ rm.default_set_ipv4_default_next_hop_load_share.nil?
1417
+ assert_equal(rm.default_set_ipv4_next_hop,
1418
+ rm.set_ipv4_next_hop) unless
1419
+ rm.default_set_ipv4_next_hop.nil?
1420
+ assert_equal(rm.default_set_ipv4_next_hop_load_share,
1421
+ rm.set_ipv4_next_hop_load_share) unless
1422
+ rm.default_set_ipv4_next_hop_load_share.nil?
1423
+ assert_equal(rm.default_set_ipv4_next_hop_peer_addr,
1424
+ rm.set_ipv4_next_hop_peer_addr)
1425
+ assert_equal(rm.default_set_ipv4_next_hop_redist,
1426
+ rm.set_ipv4_next_hop_redist)
1427
+ assert_equal(rm.default_set_ipv4_next_hop_unchanged,
1428
+ rm.set_ipv4_next_hop_unchanged)
1429
+ assert_equal(rm.default_set_ipv6_default_next_hop,
1430
+ rm.set_ipv6_default_next_hop) unless
1431
+ rm.default_set_ipv6_default_next_hop.nil?
1432
+ assert_equal(rm.default_set_ipv6_default_next_hop_load_share,
1433
+ rm.set_ipv6_default_next_hop_load_share) unless
1434
+ rm.default_set_ipv6_default_next_hop_load_share.nil?
1435
+ assert_equal(rm.default_set_ipv6_next_hop,
1436
+ rm.set_ipv6_next_hop) unless
1437
+ rm.default_set_ipv6_next_hop.nil?
1438
+ assert_equal(rm.default_set_ipv6_next_hop_load_share,
1439
+ rm.set_ipv6_next_hop_load_share) unless
1440
+ rm.default_set_ipv6_next_hop_load_share.nil?
1441
+ assert_equal(rm.default_set_ipv6_next_hop_peer_addr,
1442
+ rm.set_ipv6_next_hop_peer_addr)
1443
+ assert_equal(rm.default_set_ipv6_next_hop_redist,
1444
+ rm.set_ipv6_next_hop_redist)
1445
+ assert_equal(rm.default_set_ipv6_next_hop_unchanged,
1446
+ rm.set_ipv6_next_hop_unchanged)
1447
+ end
1448
+
1449
+ def lset_ip_next_hop_helper(props)
1450
+ rm = create_route_map
1451
+ if evergreen_or_later?
1452
+ attrs = {
1453
+ intf: rm.default_set_interface,
1454
+ v4nh: rm.default_set_ipv4_next_hop,
1455
+ v4ls: rm.default_set_ipv4_next_hop_load_share,
1456
+ v4dnh: rm.default_set_ipv4_default_next_hop,
1457
+ v4dls: rm.default_set_ipv4_default_next_hop_load_share,
1458
+ v4peer: rm.default_set_ipv4_next_hop_peer_addr,
1459
+ v4red: rm.default_set_ipv4_next_hop_redist,
1460
+ v4unc: rm.default_set_ipv4_next_hop_unchanged,
1461
+ v6nh: rm.default_set_ipv6_next_hop,
1462
+ v6ls: rm.default_set_ipv6_next_hop_load_share,
1463
+ v6dnh: rm.default_set_ipv6_default_next_hop,
1464
+ v6dls: rm.default_set_ipv6_default_next_hop_load_share,
1465
+ v6peer: rm.default_set_ipv6_next_hop_peer_addr,
1466
+ v6red: rm.default_set_ipv6_next_hop_redist,
1467
+ v6unc: rm.default_set_ipv6_next_hop_unchanged,
1468
+ }.merge!(props)
1469
+ else
1470
+ attrs = {
1471
+ intf: rm.default_set_interface,
1472
+ v4nh: rm.default_set_ipv4_next_hop,
1473
+ v4ls: rm.default_set_ipv4_next_hop_load_share,
1474
+ v4dnh: rm.default_set_ipv4_default_next_hop,
1475
+ v4dls: rm.default_set_ipv4_default_next_hop_load_share,
1476
+ v4peer: rm.default_set_ipv4_next_hop_peer_addr,
1477
+ v4unc: rm.default_set_ipv4_next_hop_unchanged,
1478
+ v6nh: rm.default_set_ipv6_next_hop,
1479
+ v6ls: rm.default_set_ipv6_next_hop_load_share,
1480
+ v6dnh: rm.default_set_ipv6_default_next_hop,
1481
+ v6dls: rm.default_set_ipv6_default_next_hop_load_share,
1482
+ v6peer: rm.default_set_ipv6_next_hop_peer_addr,
1483
+ v6unc: rm.default_set_ipv6_next_hop_unchanged,
1484
+ }.merge!(props)
1485
+ end
1486
+ rm.set_ip_next_hop_set(attrs)
1487
+ rm
1488
+ end
1489
+ end