cisco_node_utils 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/CHANGELOG.md +126 -1
  4. data/README.md +19 -12
  5. data/Rakefile +1 -0
  6. data/bin/git/hooks/commit-msg/enforce_style +8 -0
  7. data/cisco_node_utils.gemspec +4 -3
  8. data/docs/README-develop-best-practices.md +127 -109
  9. data/docs/README-develop-node-utils-APIs.md +47 -39
  10. data/docs/template-router.rb +3 -7
  11. data/lib/.rubocop.yml +4 -4
  12. data/lib/cisco_node_utils.rb +1 -1
  13. data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
  14. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
  15. data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
  16. data/lib/cisco_node_utils/ace.rb +196 -0
  17. data/lib/cisco_node_utils/acl.rb +100 -0
  18. data/lib/cisco_node_utils/bgp.rb +301 -163
  19. data/lib/cisco_node_utils/bgp_af.rb +187 -19
  20. data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
  21. data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
  22. data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
  23. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
  24. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
  25. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
  26. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
  27. data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
  28. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
  29. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
  30. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
  31. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
  32. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
  33. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
  34. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
  35. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
  36. data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
  37. data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
  38. data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
  39. data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
  40. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
  41. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
  42. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
  43. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
  44. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
  45. data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
  46. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
  47. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
  48. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
  49. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
  50. data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
  51. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
  52. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
  53. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
  54. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
  55. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
  56. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
  57. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
  58. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
  59. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
  60. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
  61. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
  62. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
  63. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
  64. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
  65. data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
  66. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
  67. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
  68. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
  69. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
  70. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
  71. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
  72. data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
  73. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
  74. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
  75. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
  76. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
  77. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
  78. data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
  79. data/lib/cisco_node_utils/command_reference.rb +359 -187
  80. data/lib/cisco_node_utils/configparser_lib.rb +1 -1
  81. data/lib/cisco_node_utils/dns_domain.rb +19 -5
  82. data/lib/cisco_node_utils/domain_name.rb +4 -8
  83. data/lib/cisco_node_utils/evpn_vni.rb +157 -0
  84. data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
  85. data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
  86. data/lib/cisco_node_utils/feature.rb +111 -0
  87. data/lib/cisco_node_utils/interface.rb +390 -97
  88. data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
  89. data/lib/cisco_node_utils/interface_ospf.rb +11 -34
  90. data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
  91. data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
  92. data/lib/cisco_node_utils/name_server.rb +1 -1
  93. data/lib/cisco_node_utils/node.rb +55 -249
  94. data/lib/cisco_node_utils/node_util.rb +5 -1
  95. data/lib/cisco_node_utils/ntp_config.rb +2 -2
  96. data/lib/cisco_node_utils/ntp_server.rb +14 -5
  97. data/lib/cisco_node_utils/overlay_global.rb +153 -0
  98. data/lib/cisco_node_utils/pim.rb +124 -0
  99. data/lib/cisco_node_utils/pim_group_list.rb +108 -0
  100. data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
  101. data/lib/cisco_node_utils/platform.rb +8 -9
  102. data/lib/cisco_node_utils/portchannel_global.rb +277 -0
  103. data/lib/cisco_node_utils/radius_global.rb +9 -19
  104. data/lib/cisco_node_utils/radius_server.rb +31 -41
  105. data/lib/cisco_node_utils/radius_server_group.rb +117 -0
  106. data/lib/cisco_node_utils/router_ospf.rb +1 -1
  107. data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
  108. data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
  109. data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
  110. data/lib/cisco_node_utils/snmpgroup.rb +1 -1
  111. data/lib/cisco_node_utils/snmpnotification.rb +57 -0
  112. data/lib/cisco_node_utils/snmpserver.rb +8 -17
  113. data/lib/cisco_node_utils/snmpuser.rb +67 -28
  114. data/lib/cisco_node_utils/syslog_server.rb +3 -9
  115. data/lib/cisco_node_utils/syslog_settings.rb +2 -10
  116. data/lib/cisco_node_utils/tacacs_server.rb +9 -14
  117. data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
  118. data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
  119. data/lib/cisco_node_utils/vdc.rb +88 -0
  120. data/lib/cisco_node_utils/version.rb +5 -2
  121. data/lib/cisco_node_utils/vlan.rb +71 -8
  122. data/lib/cisco_node_utils/vni.rb +227 -0
  123. data/lib/cisco_node_utils/vpc.rb +377 -0
  124. data/lib/cisco_node_utils/vrf.rb +60 -9
  125. data/lib/cisco_node_utils/vrf_af.rb +191 -0
  126. data/lib/cisco_node_utils/vtp.rb +8 -6
  127. data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
  128. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
  129. data/lib/cisco_node_utils/yum.rb +1 -1
  130. data/tests/.rubocop.yml +1 -1
  131. data/tests/basetest.rb +16 -7
  132. data/tests/ciscotest.rb +55 -13
  133. data/tests/cmd_config.yaml +2 -2
  134. data/tests/platform_info.rb +3 -2
  135. data/tests/test_aaa_authentication_login.rb +219 -0
  136. data/tests/test_aaa_authentication_login_service.rb +759 -0
  137. data/tests/test_aaa_authorization_service.rb +1041 -0
  138. data/tests/test_ace.rb +160 -0
  139. data/tests/test_acl.rb +176 -0
  140. data/tests/test_bgp_af.rb +269 -13
  141. data/tests/test_bgp_neighbor.rb +38 -40
  142. data/tests/test_bgp_neighbor_af.rb +92 -32
  143. data/tests/test_command_config.rb +5 -5
  144. data/tests/test_command_reference.rb +284 -101
  145. data/tests/test_dns_domain.rb +1 -1
  146. data/tests/test_domain_name.rb +1 -1
  147. data/tests/test_evpn_vni.rb +106 -0
  148. data/tests/test_fabricpath_global.rb +243 -0
  149. data/tests/test_fabricpath_topology.rb +98 -0
  150. data/tests/test_interface.rb +292 -74
  151. data/tests/test_interface_channel_group.rb +74 -0
  152. data/tests/test_interface_ospf.rb +9 -4
  153. data/tests/test_interface_portchannel.rb +105 -0
  154. data/tests/test_interface_service_vni.rb +232 -0
  155. data/tests/test_interface_svi.rb +77 -62
  156. data/tests/test_interface_switchport.rb +17 -5
  157. data/tests/test_name_server.rb +1 -1
  158. data/tests/test_node.rb +1 -1
  159. data/tests/test_node_ext.rb +10 -20
  160. data/tests/test_ntp_config.rb +1 -1
  161. data/tests/test_ntp_server.rb +18 -6
  162. data/tests/test_overlay_global.rb +102 -0
  163. data/tests/test_pim.rb +177 -0
  164. data/tests/test_pim_group_list.rb +181 -0
  165. data/tests/test_pim_rp_address.rb +153 -0
  166. data/tests/test_platform.rb +3 -3
  167. data/tests/test_portchannel_global.rb +202 -0
  168. data/tests/test_radius_global.rb +1 -1
  169. data/tests/test_radius_server.rb +92 -57
  170. data/tests/test_radius_server_group.rb +149 -0
  171. data/tests/test_router_bgp.rb +283 -112
  172. data/tests/test_router_ospf.rb +2 -2
  173. data/tests/test_router_ospf_vrf.rb +4 -4
  174. data/tests/test_snmp_notification_receiver.rb +167 -0
  175. data/tests/test_snmpcommunity.rb +1 -1
  176. data/tests/test_snmpgroup.rb +1 -1
  177. data/tests/test_snmpnotification.rb +72 -0
  178. data/tests/test_snmpserver.rb +29 -105
  179. data/tests/test_snmpuser.rb +32 -30
  180. data/tests/test_syslog_server.rb +36 -10
  181. data/tests/test_syslog_settings.rb +1 -1
  182. data/tests/test_tacacs_server.rb +1 -1
  183. data/tests/test_tacacs_server_group.rb +405 -0
  184. data/tests/test_tacacs_server_host.rb +1 -1
  185. data/tests/test_vdc.rb +78 -0
  186. data/tests/test_vlan.rb +74 -19
  187. data/tests/test_vlan_mt_full.rb +95 -0
  188. data/tests/test_vni.rb +106 -0
  189. data/tests/test_vpc.rb +361 -0
  190. data/tests/test_vrf.rb +172 -29
  191. data/tests/test_vtp.rb +1 -1
  192. data/tests/test_vxlan_vtep.rb +214 -0
  193. data/tests/test_vxlan_vtep_vni.rb +201 -0
  194. data/tests/test_yum.rb +1 -1
  195. metadata +120 -11
  196. data/lib/cisco_node_utils/README_YAML.md +0 -325
  197. data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
  198. data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
  199. data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
  200. data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
  201. data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
  202. data/tests/platform_info.yaml +0 -10
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # Jie Yang, August 2015
5
5
  #
6
- # Copyright (c) 2015 Cisco and/or its affiliates.
6
+ # Copyright (c) 2015-2016 Cisco and/or its affiliates.
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
9
9
  # you may not use this file except in compliance with the License.
@@ -21,22 +21,25 @@ require_relative 'ciscotest'
21
21
  require_relative '../lib/cisco_node_utils/bgp'
22
22
  require_relative '../lib/cisco_node_utils/bgp_neighbor'
23
23
 
24
- # TestRouterBgpNeighbor - Minitest for RouterBgpNeighbor node utility class
25
- class TestRouterBgpNeighbor < CiscoTestCase
24
+ # TestBgpNeighbor - Minitest for RouterBgpNeighbor node utility class
25
+ class TestBgpNeighbor < CiscoTestCase
26
26
  # rubocop:disable Style/ClassVars
27
27
  @@asn = 55
28
28
  @@addr = '1.1.1.1'
29
+ @@pre_clean_needed = true
29
30
  # rubocop:enable Style/ClassVars
30
31
 
31
32
  def setup
32
- # Disable feature bgp before each test to ensure we
33
- # are starting with a clean slate for each test.
34
33
  super
35
- config('no feature bgp', 'feature bgp', 'router bgp 55')
34
+ remove_all_bgps if @@pre_clean_needed
35
+ @@pre_clean_needed = false # rubocop:disable Style/ClassVars
36
+ # BGP Neighbor requires the presence of a basic bgp global config
37
+ RouterBgp.new(@@asn)
36
38
  end
37
39
 
38
40
  def teardown
39
- config('no feature bgp')
41
+ super
42
+ remove_all_bgps
40
43
  end
41
44
 
42
45
  def get_bgpneighbor_match_line(addr, vrf='default')
@@ -52,13 +55,13 @@ class TestRouterBgpNeighbor < CiscoTestCase
52
55
  line
53
56
  end
54
57
 
55
- def test_bgpneighbor_collection_empty
58
+ def test_collection_empty
56
59
  config('no feature bgp')
57
60
  neighbors = RouterBgpNeighbor.neighbors
58
61
  assert_empty(neighbors, 'BGP neighbor collection is not empty')
59
62
  end
60
63
 
61
- def test_bgpneighbor_collection_not_empty
64
+ def test_collection_not_empty
62
65
  config('router bgp 55',
63
66
  'neighbor 1.1.1.1',
64
67
  'vrf red',
@@ -84,7 +87,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
84
87
  end
85
88
  end
86
89
 
87
- def test_bgpneighbor_create_destroy
90
+ def test_create_destroy
88
91
  address = { '1.1.1.1' => '1.1.1.1',
89
92
  '2.2.2.2/24' => '2.2.2.0/24',
90
93
  '2000::2' => '2000::2',
@@ -103,7 +106,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
103
106
  end
104
107
  end
105
108
 
106
- def test_bgpneighbor_set_get_description
109
+ def test_description
107
110
  %w(default test_vrf).each do |vrf|
108
111
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
109
112
  description = "tested by mini test for vrf #{vrf}"
@@ -117,7 +120,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
117
120
  end
118
121
  end
119
122
 
120
- def test_bgpneighbor_set_get_multiple_descriptions
123
+ def test_multiple_descriptions
121
124
  # First create multiple routers with multiple desriptions.
122
125
  address = ['1.1.1.1', '2.2.2.0/24', '2000::2', '2000:123:38::/64']
123
126
  vrfs = %w(default red)
@@ -142,7 +145,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
142
145
  end
143
146
  end
144
147
 
145
- def test_bgpneighbor_set_get_connected_check
148
+ def test_connected_check
146
149
  %w(default test_vrf).each do |vrf|
147
150
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
148
151
  check = [true, false, neighbor.default_connected_check]
@@ -154,7 +157,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
154
157
  end
155
158
  end
156
159
 
157
- def test_bgpneighbor_set_get_capability_negotiation
160
+ def test_capability_negotiation
158
161
  %w(default test_vrf).each do |vrf|
159
162
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
160
163
  check = [true, false, neighbor.default_capability_negotiation]
@@ -166,7 +169,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
166
169
  end
167
170
  end
168
171
 
169
- def test_bgpneighbor_set_get_dynamic_capability
172
+ def test_dynamic_capability
170
173
  %w(default test_vrf).each do |vrf|
171
174
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
172
175
  check = [true, false, neighbor.default_dynamic_capability]
@@ -178,7 +181,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
178
181
  end
179
182
  end
180
183
 
181
- def test_bgpneighbor_set_get_ebgp_multihop
184
+ def test_ebgp_multihop
182
185
  %w(default test_vrf).each do |vrf|
183
186
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
184
187
  ttls = [24, neighbor.default_ebgp_multihop]
@@ -190,27 +193,23 @@ class TestRouterBgpNeighbor < CiscoTestCase
190
193
  end
191
194
  end
192
195
 
193
- def test_bgpneighbor_set_get_local_as
196
+ def test_local_as
194
197
  %w(default test_vrf).each do |vrf|
195
198
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
196
- local_asnum = [42, '52', '1.1', neighbor.default_local_as]
197
- local_asnum.each do |asnum|
199
+ [42, '52', '1.1', neighbor.default_local_as].each do |asnum|
198
200
  neighbor.local_as = asnum
199
- if asnum == '52'
200
- assert_equal(asnum.to_i, neighbor.local_as)
201
- else
202
- assert_equal(asnum, neighbor.local_as)
203
- end
201
+ assert_equal(asnum.to_s, neighbor.local_as)
204
202
  end
203
+
205
204
  # test a negative value
206
- assert_raises(ArgumentError) do
205
+ assert_raises(CliError) do
207
206
  neighbor.local_as = '52 15'
208
207
  end
209
208
  neighbor.destroy
210
209
  end
211
210
  end
212
211
 
213
- def test_bgpneighbor_set_get_log_neighbor_changes
212
+ def test_log_neighbor_changes
214
213
  %w(default test_vrf).each do |vrf|
215
214
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
216
215
  check = [:enable, :disable, :inherit, 'enable', 'disable', 'inherit',
@@ -223,7 +222,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
223
222
  end
224
223
  end
225
224
 
226
- def test_bgpneighbor_set_get_low_memory_exempt
225
+ def test_low_memory_exempt
227
226
  %w(default test_vrf).each do |vrf|
228
227
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
229
228
  check = [true, false, neighbor.default_low_memory_exempt]
@@ -235,7 +234,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
235
234
  end
236
235
  end
237
236
 
238
- def test_bgpneighbor_set_get_maximum_peers
237
+ def test_maximum_peers
239
238
  # only "address/prefix" type of neighbor address will accept
240
239
  # maximum_peers command
241
240
  addr = '1.1.1.0/24'
@@ -250,7 +249,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
250
249
  end
251
250
  end
252
251
 
253
- def test_bgpneighbor_set_get_password
252
+ def test_password
254
253
  %w(default test_vrf).each do |vrf|
255
254
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
256
255
  passwords = {}
@@ -278,7 +277,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
278
277
  end
279
278
  end
280
279
 
281
- def test_bgpneighbor_set_default_password_type
280
+ def test_set_default_password_type
282
281
  %w(default test_vrf).each do |vrf|
283
282
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
284
283
  password = 'test'
@@ -304,19 +303,18 @@ class TestRouterBgpNeighbor < CiscoTestCase
304
303
  end
305
304
  end
306
305
 
307
- def test_bgpneighbor_set_get_remote_as
306
+ def test_remote_as
308
307
  %w(default test_vrf).each do |vrf|
309
308
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
310
- remote_asnum = [42, '1.1', neighbor.default_remote_as]
311
- remote_asnum.each do |asnum|
309
+ [42, '1.1', neighbor.default_remote_as].each do |asnum|
312
310
  neighbor.remote_as = asnum
313
- assert_equal(asnum, neighbor.remote_as)
311
+ assert_equal(asnum.to_s, neighbor.remote_as)
314
312
  end
315
313
  neighbor.destroy
316
314
  end
317
315
  end
318
316
 
319
- def test_bgpneighbor_set_get_remove_private_as_options
317
+ def test_remove_private_as_options
320
318
  %w(default test_vrf).each do |vrf|
321
319
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
322
320
  options = [:enable, :disable, :all, :"replace-as", 'enable', 'disable',
@@ -333,7 +331,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
333
331
  end
334
332
  end
335
333
 
336
- def test_bgpneighbor_set_get_shutdown
334
+ def test_shutdown
337
335
  %w(default test_vrf).each do |vrf|
338
336
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
339
337
  check = [true, false, neighbor.default_shutdown]
@@ -345,7 +343,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
345
343
  end
346
344
  end
347
345
 
348
- def test_bgpneighbor_set_get_suppress_4_byte_as
346
+ def test_suppress_4_byte_as
349
347
  %w(default test_vrf).each do |vrf|
350
348
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
351
349
  check = [true, false, neighbor.default_suppress_4_byte_as]
@@ -357,7 +355,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
357
355
  end
358
356
  end
359
357
 
360
- def test_bgpneighbor_set_get_timers
358
+ def test_timers
361
359
  %w(default test_vrf).each do |vrf|
362
360
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
363
361
  timers = [{ keep: 40, hold: 90 },
@@ -376,7 +374,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
376
374
  end
377
375
  end
378
376
 
379
- def test_bgpneighbor_set_get_transport_passive_only
377
+ def test_transport_passive_only
380
378
  %w(default test_vrf).each do |vrf|
381
379
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
382
380
  check = [true, false, neighbor.default_transport_passive_only]
@@ -388,7 +386,7 @@ class TestRouterBgpNeighbor < CiscoTestCase
388
386
  end
389
387
  end
390
388
 
391
- def test_bgpneighbor_set_get_update_source
389
+ def test_update_source
392
390
  %w(default test_vrf).each do |vrf|
393
391
  neighbor = RouterBgpNeighbor.new(@@asn, vrf, @@addr)
394
392
  interfaces = ['loopback1', 'Ethernet1/1', 'ethernet1/1',
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # August 2015 Chris Van Heuveln
5
5
  #
6
- # Copyright (c) 2015 Cisco and/or its affiliates.
6
+ # Copyright (c) 2015-2016 Cisco and/or its affiliates.
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
9
9
  # you may not use this file except in compliance with the License.
@@ -22,20 +22,38 @@ require_relative '../lib/cisco_node_utils/cisco_cmn_utils'
22
22
  require_relative '../lib/cisco_node_utils/bgp'
23
23
  require_relative '../lib/cisco_node_utils/bgp_neighbor'
24
24
  require_relative '../lib/cisco_node_utils/bgp_neighbor_af'
25
+ require_relative '../lib/cisco_node_utils/feature'
25
26
 
26
- # TestRouterBgpNeighborAF - Minitest for RouterBgpNeighborAF class
27
- class TestRouterBgpNeighborAF < CiscoTestCase
28
- @@reset_feat = true # rubocop:disable Style/ClassVars
27
+ # TestBgpNeighborAF - Minitest for RouterBgpNeighborAF class
28
+ class TestBgpNeighborAF < CiscoTestCase
29
+ # rubocop:disable Style/ClassVars
30
+ @@pre_clean_needed = true
31
+ @@evpn_unsupported = false
32
+ # rubocop:enable Style/ClassVars
29
33
 
30
34
  def setup
31
35
  super
32
- if @@reset_feat
33
- config('no feature bgp', 'feature bgp')
34
- @@reset_feat = false # rubocop:disable Style/ClassVars
35
- else
36
- # Just ensure that feature is enabled
37
- config('feature bgp')
38
- end
36
+ remove_all_bgps if @@pre_clean_needed
37
+ @@pre_clean_needed = false # rubocop:disable Style/ClassVars
38
+ setup_nv_overlay_evpn
39
+ end
40
+
41
+ def teardown
42
+ super
43
+ remove_all_bgps
44
+ end
45
+
46
+ def setup_nv_overlay_evpn
47
+ Feature.bgp_enable
48
+
49
+ # l2vpn evpn tests require 'nv overlay evpn' but it is not supported on
50
+ # all platforms
51
+ Feature.nv_overlay_evpn_enable unless @@evpn_unsupported
52
+ rescue Cisco::UnsupportedError => e
53
+ @@evpn_unsupported = true if # rubocop:disable Style/ClassVars
54
+ e.message[/unsupported on this node/]
55
+ # Remove the evpn AF from the test matrix
56
+ @@matrix.delete(:evpn)
39
57
  end
40
58
 
41
59
  def clean_af(af_args, ebgp=true)
@@ -61,22 +79,23 @@ class TestRouterBgpNeighborAF < CiscoTestCase
61
79
 
62
80
  # AF test matrix
63
81
  @@matrix = { # rubocop:disable Style/ClassVars
64
- # 1 => [1, 'default', '10:1::1', %w(ipv4 multicast)], # UNSUPPORTED
65
- # 2 => [1, 'default', '10:1::1', %w(ipv4 unicast)],
66
- # 3 => [1, 'default', '10:1::1', %w(ipv6 multicast)],
67
- # 4 => [1, 'default', '10:1::1', %w(ipv6 unicast)],
68
- # 5 => [1, 'default', '1.1.1.1', %w(ipv4 multicast)],
69
- 6 => [1, 'default', '1.1.1.1', %w(ipv4 unicast)],
70
- # 7 => [1, 'default', '1.1.1.1', %w(ipv6 multicast)],
71
- 8 => [1, 'default', '1.1.1.1', %w(ipv6 unicast)],
72
- # 9 => [1, 'aa', '2.2.2.2', %w(ipv4 multicast)],
73
- # 10 => [1, 'aa', '2.2.2.2', %w(ipv4 unicast)],
74
- # 11 => [1, 'bb', '2.2.2.2', %w(ipv6 multicast)],
75
- # 12 => [1, 'bb', '2.2.2.2', %w(ipv6 unicast)],
76
- # 13 => [1, 'cc', '10:1::2', %w(ipv4 multicast)], # UNSUPPORTED
77
- # 14 => [1, 'cc', '10:1::2', %w(ipv4 unicast)],
78
- # 15 => [1, 'cc', '10:1::2', %w(ipv6 multicast)],
79
- # 16 => [1, 'cc', '10:1::2', %w(ipv6 unicast)],
82
+ # 1 => [1, 'default', '10:1::1', %w(ipv4 multicast)], # UNSUPPORTED
83
+ # 2 => [1, 'default', '10:1::1', %w(ipv4 unicast)],
84
+ # 3 => [1, 'default', '10:1::1', %w(ipv6 multicast)],
85
+ # 4 => [1, 'default', '10:1::1', %w(ipv6 unicast)],
86
+ # 5 => [1, 'default', '1.1.1.1', %w(ipv4 multicast)],
87
+ 6 => [1, 'default', '1.1.1.1', %w(ipv4 unicast)],
88
+ # 7 => [1, 'default', '1.1.1.1', %w(ipv6 multicast)],
89
+ 8 => [1, 'default', '1.1.1.1', %w(ipv6 unicast)],
90
+ # 9 => [1, 'aa', '2.2.2.2', %w(ipv4 multicast)],
91
+ # 10 => [1, 'aa', '2.2.2.2', %w(ipv4 unicast)],
92
+ # 11 => [1, 'bb', '2.2.2.2', %w(ipv6 multicast)],
93
+ # 12 => [1, 'bb', '2.2.2.2', %w(ipv6 unicast)],
94
+ # 13 => [1, 'cc', '10:1::2', %w(ipv4 multicast)], # UNSUPPORTED
95
+ # 14 => [1, 'cc', '10:1::2', %w(ipv4 unicast)],
96
+ # 15 => [1, 'cc', '10:1::2', %w(ipv6 multicast)],
97
+ # 16 => [1, 'cc', '10:1::2', %w(ipv6 unicast)],
98
+ :evpn => [1, 'default', '1.1.1.1', %w(l2vpn evpn)],
80
99
  }
81
100
 
82
101
  # ---------------------------------
@@ -133,7 +152,7 @@ class TestRouterBgpNeighborAF < CiscoTestCase
133
152
  refute(afs[asn][vrf][nbr_munged].key?(af),
134
153
  "#{dbg} Failed to destroy AF")
135
154
  end
136
- @@reset_feat = true # rubocop:disable Style/ClassVars
155
+ @@pre_clean_needed = true # rubocop:disable Style/ClassVars
137
156
  end
138
157
 
139
158
  # ---------------------------------
@@ -155,6 +174,8 @@ class TestRouterBgpNeighborAF < CiscoTestCase
155
174
  :suppress_inactive,
156
175
  ]
157
176
 
177
+ props = [:disable_peer_as_check] if dbg.include?('l2vpn/evpn')
178
+
158
179
  # Call setter to false, then validate with getter
159
180
  props.each { |k| af.send("#{k}=", false) }
160
181
  props.each do |k|
@@ -198,6 +219,8 @@ class TestRouterBgpNeighborAF < CiscoTestCase
198
219
  unsuppress_map: 'unsupp-map-name',
199
220
  }
200
221
 
222
+ props.delete(:unsuppress_map) if dbg.include?('l2vpn/evpn')
223
+
201
224
  props.each do |k, v|
202
225
  # Call setter.
203
226
  af.send("#{k}=", v)
@@ -222,10 +245,17 @@ class TestRouterBgpNeighborAF < CiscoTestCase
222
245
  # additional_paths_receive
223
246
  # additional_paths_send
224
247
  # soft_reconfiguration_in
248
+
249
+ def supports_soft_reconfig_always?
250
+ return true if node.product_id[/N(3|9)K/]
251
+ false
252
+ end
253
+
225
254
  def test_tri_states
226
255
  @@matrix.values.each do |af_args|
227
256
  af, dbg = clean_af(af_args)
228
257
 
258
+ next if dbg.include?('l2vpn/evpn')
229
259
  %w(additional_paths_receive additional_paths_send).each do |k|
230
260
  [:enable, :disable, :inherit, 'enable', 'disable', 'inherit',
231
261
  af.send("default_#{k}")
@@ -235,10 +265,17 @@ class TestRouterBgpNeighborAF < CiscoTestCase
235
265
  end
236
266
  end
237
267
 
268
+ # The 'always' keyword is not supported on N6K / N7K
238
269
  %w(soft_reconfiguration_in).each do |k|
239
- [:enable, :always, :inherit, 'enable', 'always', 'inherit',
240
- af.send("default_#{k}")
241
- ].each do |val|
270
+ if supports_soft_reconfig_always?
271
+ array = [:enable, :always, :inherit, 'enable', 'always', 'inherit',
272
+ af.send("default_#{k}")]
273
+ else
274
+ array = [:enable, :inherit, 'enable', 'inherit',
275
+ af.send("default_#{k}")]
276
+ end
277
+
278
+ array.each do |val|
242
279
  af.send("#{k}=", val)
243
280
  assert_equal(val.to_sym, af.send(k), "#{dbg} Error: #{k}")
244
281
  end
@@ -250,6 +287,7 @@ class TestRouterBgpNeighborAF < CiscoTestCase
250
287
  def test_advertise_map
251
288
  @@matrix.values.each do |af_args|
252
289
  af, dbg = clean_af(af_args)
290
+ next if dbg.include?('l2vpn/evpn')
253
291
  advertise_map(af, dbg)
254
292
  end
255
293
  end
@@ -319,6 +357,7 @@ class TestRouterBgpNeighborAF < CiscoTestCase
319
357
  def test_default_originate
320
358
  @@matrix.values.each do |af_args|
321
359
  af, dbg = clean_af(af_args)
360
+ next if dbg.include?('l2vpn/evpn')
322
361
  default_originate(af, dbg)
323
362
  end
324
363
  end
@@ -489,7 +528,7 @@ class TestRouterBgpNeighborAF < CiscoTestCase
489
528
  af, dbg = clean_af(af_args)
490
529
  send_community(af, dbg)
491
530
  end
492
- @@reset_feat = true # rubocop:disable Style/ClassVars
531
+ @@pre_clean_needed = true # rubocop:disable Style/ClassVars
493
532
  end
494
533
 
495
534
  def send_community(af, dbg)
@@ -586,4 +625,25 @@ class TestRouterBgpNeighborAF < CiscoTestCase
586
625
  assert_empty(af.soo,
587
626
  "Test 4. #{dbg} Failed to set default '#{val}'")
588
627
  end
628
+
629
+ # --------------------------------
630
+ def test_weight
631
+ @@matrix.values.each do |af_args|
632
+ af, dbg = clean_af(af_args)
633
+ weight(af, dbg) unless dbg.include?('l2vpn/evpn')
634
+ end
635
+ end
636
+
637
+ def weight(af, dbg)
638
+ # check the default value before set
639
+ assert_equal(af.default_weight, af.weight,
640
+ "Test 1. #{dbg} Error: should be default value")
641
+
642
+ af.weight = 22
643
+ assert_equal(22, af.weight, "Test 2. #{dbg} Failed to set weight")
644
+
645
+ af.weight = af.default_weight
646
+ assert_equal(af.default_weight, af.weight,
647
+ "Test 3. #{dbg} Failed to remove weight")
648
+ end
589
649
  end