cisco_node_utils 1.2.0 → 1.3.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 (255) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +13 -0
  5. data/.travis.yml +4 -1
  6. data/CHANGELOG.md +81 -2
  7. data/CONTRIBUTING.md +2 -17
  8. data/Gemfile +5 -0
  9. data/README.md +92 -47
  10. data/Rakefile +23 -1
  11. data/bin/git/hooks/hook_lib +7 -0
  12. data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
  13. data/bin/git/hooks/pre-commit/rubocop +7 -2
  14. data/bin/git/hooks/pre-commit/validate-diffs +18 -4
  15. data/bin/git/hooks/pre-commit/validate-yaml +18 -0
  16. data/bin/git/update-hooks +64 -6
  17. data/cisco_node_utils.gemspec +9 -6
  18. data/docs/README-develop-best-practices.md +149 -50
  19. data/docs/README-develop-node-utils-APIs.md +92 -42
  20. data/docs/README-maintainers.md +7 -4
  21. data/docs/README-test-execution.md +57 -0
  22. data/docs/cisco_node_utils.yaml.example +30 -0
  23. data/docs/template-router.rb +4 -0
  24. data/ext/mkrf_conf.rb +63 -0
  25. data/lib/.rubocop.yml +2 -2
  26. data/lib/cisco_node_utils.rb +5 -0
  27. data/lib/cisco_node_utils/aaa_authentication_login.rb +5 -6
  28. data/lib/cisco_node_utils/aaa_authorization_service.rb +1 -1
  29. data/lib/cisco_node_utils/ace.rb +165 -12
  30. data/lib/cisco_node_utils/acl.rb +2 -1
  31. data/lib/cisco_node_utils/bgp.rb +184 -21
  32. data/lib/cisco_node_utils/bgp_af.rb +94 -249
  33. data/lib/cisco_node_utils/bgp_neighbor.rb +94 -14
  34. data/lib/cisco_node_utils/bgp_neighbor_af.rb +75 -8
  35. data/lib/cisco_node_utils/bridge_domain.rb +183 -0
  36. data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
  37. data/lib/cisco_node_utils/cisco_cmn_utils.rb +85 -2
  38. data/lib/cisco_node_utils/client.rb +35 -0
  39. data/lib/cisco_node_utils/client/client.rb +234 -0
  40. data/lib/cisco_node_utils/client/grpc.rb +33 -0
  41. data/lib/cisco_node_utils/client/grpc/client.rb +311 -0
  42. data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
  43. data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
  44. data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
  45. data/lib/cisco_node_utils/client/nxapi.rb +31 -0
  46. data/lib/cisco_node_utils/client/nxapi/client.rb +305 -0
  47. data/lib/cisco_node_utils/client/utils.rb +164 -0
  48. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +222 -254
  49. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +11 -8
  50. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +22 -15
  51. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +11 -8
  52. data/lib/cisco_node_utils/cmd_ref/acl.yaml +21 -16
  53. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +239 -109
  54. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +114 -55
  55. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +76 -52
  56. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +106 -62
  57. data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +71 -0
  58. data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
  59. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +35 -14
  60. data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
  61. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +23 -17
  62. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +94 -83
  63. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +22 -17
  64. data/lib/cisco_node_utils/cmd_ref/feature.yaml +76 -26
  65. data/lib/cisco_node_utils/cmd_ref/images.yaml +3 -2
  66. data/lib/cisco_node_utils/cmd_ref/interface.yaml +381 -153
  67. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +21 -11
  68. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +21 -21
  69. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +30 -21
  70. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +18 -13
  71. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +26 -31
  72. data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
  73. data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
  74. data/lib/cisco_node_utils/cmd_ref/memory.yaml +17 -6
  75. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +10 -3
  76. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +17 -5
  77. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +33 -29
  78. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +12 -10
  79. data/lib/cisco_node_utils/cmd_ref/pim.yaml +16 -19
  80. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +40 -25
  81. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +17 -12
  82. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +71 -35
  83. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +10 -5
  84. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +6 -2
  85. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +47 -43
  86. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +13 -11
  87. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +4 -2
  88. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +23 -21
  89. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +26 -22
  90. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +19 -17
  91. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +18 -6
  92. data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +234 -0
  93. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +24 -9
  94. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +5 -3
  95. data/lib/cisco_node_utils/cmd_ref/system.yaml +4 -3
  96. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +22 -20
  97. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +27 -15
  98. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +45 -16
  99. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +21 -11
  100. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +3 -2
  101. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +60 -32
  102. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +118 -101
  103. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +54 -58
  104. data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +118 -0
  105. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +19 -25
  106. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +28 -18
  107. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +34 -17
  108. data/lib/cisco_node_utils/cmd_ref/yum.yaml +6 -4
  109. data/lib/cisco_node_utils/command_reference.rb +261 -142
  110. data/lib/cisco_node_utils/constants.rb +33 -0
  111. data/lib/cisco_node_utils/encapsulation.rb +112 -0
  112. data/lib/cisco_node_utils/environment.rb +102 -0
  113. data/lib/cisco_node_utils/evpn_vni.rb +5 -3
  114. data/lib/cisco_node_utils/exceptions.rb +111 -0
  115. data/lib/cisco_node_utils/fabricpath_global.rb +52 -35
  116. data/lib/cisco_node_utils/fabricpath_topology.rb +44 -57
  117. data/lib/cisco_node_utils/feature.rb +165 -3
  118. data/lib/cisco_node_utils/interface.rb +1051 -260
  119. data/lib/cisco_node_utils/interface_channel_group.rb +11 -10
  120. data/lib/cisco_node_utils/interface_ospf.rb +1 -2
  121. data/lib/cisco_node_utils/interface_portchannel.rb +4 -12
  122. data/lib/cisco_node_utils/interface_service_vni.rb +7 -7
  123. data/lib/cisco_node_utils/itd_device_group.rb +248 -0
  124. data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
  125. data/lib/cisco_node_utils/itd_service.rb +523 -0
  126. data/lib/cisco_node_utils/logger.rb +75 -0
  127. data/lib/cisco_node_utils/node.rb +62 -192
  128. data/lib/cisco_node_utils/node_util.rb +56 -10
  129. data/lib/cisco_node_utils/overlay_global.rb +2 -2
  130. data/lib/cisco_node_utils/pim.rb +2 -13
  131. data/lib/cisco_node_utils/pim_group_list.rb +1 -1
  132. data/lib/cisco_node_utils/pim_rp_address.rb +1 -1
  133. data/lib/cisco_node_utils/platform.rb +52 -21
  134. data/lib/cisco_node_utils/portchannel_global.rb +89 -19
  135. data/lib/cisco_node_utils/radius_server.rb +168 -37
  136. data/lib/cisco_node_utils/router_ospf.rb +20 -35
  137. data/lib/cisco_node_utils/router_ospf_vrf.rb +4 -4
  138. data/lib/cisco_node_utils/snmpserver.rb +1 -6
  139. data/lib/cisco_node_utils/snmpuser.rb +6 -4
  140. data/lib/cisco_node_utils/stp_global.rb +676 -0
  141. data/lib/cisco_node_utils/syslog_server.rb +77 -18
  142. data/lib/cisco_node_utils/syslog_settings.rb +1 -1
  143. data/lib/cisco_node_utils/tacacs_server_group.rb +8 -4
  144. data/lib/cisco_node_utils/tacacs_server_host.rb +115 -25
  145. data/lib/cisco_node_utils/vdc.rb +12 -0
  146. data/lib/cisco_node_utils/version.rb +1 -1
  147. data/lib/cisco_node_utils/vlan.rb +147 -29
  148. data/lib/cisco_node_utils/vpc.rb +55 -3
  149. data/lib/cisco_node_utils/vrf.rb +72 -11
  150. data/lib/cisco_node_utils/vrf_af.rb +114 -29
  151. data/lib/cisco_node_utils/vtp.rb +34 -52
  152. data/lib/cisco_node_utils/vxlan_vtep.rb +34 -8
  153. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +36 -4
  154. data/lib/minitest/environment_plugin.rb +31 -0
  155. data/lib/minitest/log_level_plugin.rb +41 -0
  156. data/spec/client_spec.rb +7 -0
  157. data/spec/environment_spec.rb +263 -0
  158. data/spec/grpc_client_spec.rb +23 -0
  159. data/spec/isolate/all_clients_spec.rb +9 -0
  160. data/spec/isolate/grpc_only_spec.rb +16 -0
  161. data/spec/isolate/no_clients_spec.rb +26 -0
  162. data/spec/isolate/nxapi_only_spec.rb +16 -0
  163. data/spec/nxapi_client_spec.rb +42 -0
  164. data/spec/schema.yaml +75 -0
  165. data/spec/shared_examples_for_clients.rb +14 -0
  166. data/spec/spec_helper.rb +91 -0
  167. data/spec/whitespace_spec.rb +10 -0
  168. data/spec/yaml_spec.rb +42 -0
  169. data/tests/.rubocop.yml +2 -2
  170. data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
  171. data/tests/basetest.rb +96 -36
  172. data/tests/ciscotest.rb +220 -12
  173. data/tests/cmd_config.yaml +71 -49
  174. data/tests/cmd_config_invalid.yaml +1 -1
  175. data/tests/test_aaa_authentication_login.rb +1 -0
  176. data/tests/test_aaa_authentication_login_service.rb +9 -0
  177. data/tests/test_aaa_authorization_service.rb +173 -367
  178. data/tests/test_ace.rb +171 -100
  179. data/tests/test_acl.rb +10 -1
  180. data/tests/test_bgp_af.rb +395 -728
  181. data/tests/test_bgp_neighbor.rb +274 -115
  182. data/tests/test_bgp_neighbor_af.rb +178 -77
  183. data/tests/test_bridge_domain.rb +191 -0
  184. data/tests/test_bridge_domain_vni.rb +116 -0
  185. data/tests/test_client_utils.rb +111 -0
  186. data/tests/test_command_config.rb +9 -5
  187. data/tests/test_command_reference.rb +380 -102
  188. data/tests/test_dns_domain.rb +13 -3
  189. data/tests/test_domain_name.rb +13 -3
  190. data/tests/test_encapsulation.rb +77 -0
  191. data/tests/test_evpn_vni.rb +25 -7
  192. data/tests/test_fabricpath_global.rb +167 -163
  193. data/tests/test_fabricpath_topology.rb +12 -33
  194. data/tests/test_feature.rb +215 -0
  195. data/tests/test_grpc.rb +166 -0
  196. data/tests/test_interface.rb +585 -344
  197. data/tests/test_interface_bdi.rb +80 -0
  198. data/tests/test_interface_channel_group.rb +6 -3
  199. data/tests/test_interface_ospf.rb +26 -24
  200. data/tests/test_interface_portchannel.rb +1 -0
  201. data/tests/test_interface_private_vlan.rb +724 -0
  202. data/tests/test_interface_service_vni.rb +37 -66
  203. data/tests/test_interface_svi.rb +98 -101
  204. data/tests/test_interface_switchport.rb +419 -549
  205. data/tests/test_itd_device_group.rb +145 -0
  206. data/tests/test_itd_device_group_node.rb +199 -0
  207. data/tests/test_itd_service.rb +298 -0
  208. data/tests/test_logger.rb +43 -0
  209. data/tests/test_name_server.rb +11 -2
  210. data/tests/test_node.rb +16 -75
  211. data/tests/test_node_ext.rb +174 -163
  212. data/tests/test_node_util.rb +119 -0
  213. data/tests/test_ntp_config.rb +5 -1
  214. data/tests/test_ntp_server.rb +2 -2
  215. data/tests/test_nxapi.rb +221 -0
  216. data/tests/test_overlay_global.rb +47 -38
  217. data/tests/test_pim.rb +2 -0
  218. data/tests/test_pim_group_list.rb +2 -0
  219. data/tests/test_pim_rp_address.rb +2 -0
  220. data/tests/test_platform.rb +86 -39
  221. data/tests/test_portchannel_global.rb +211 -135
  222. data/tests/test_radius_global.rb +13 -5
  223. data/tests/test_radius_server.rb +256 -104
  224. data/tests/test_radius_server_group.rb +2 -0
  225. data/tests/test_router_bgp.rb +781 -485
  226. data/tests/test_router_ospf.rb +26 -103
  227. data/tests/test_router_ospf_vrf.rb +52 -57
  228. data/tests/test_snmp_notification_receiver.rb +2 -0
  229. data/tests/test_snmpcommunity.rb +2 -0
  230. data/tests/test_snmpgroup.rb +2 -0
  231. data/tests/test_snmpnotification.rb +40 -21
  232. data/tests/test_snmpserver.rb +2 -0
  233. data/tests/test_snmpuser.rb +2 -0
  234. data/tests/test_stp_global.rb +563 -0
  235. data/tests/test_syslog_server.rb +32 -8
  236. data/tests/test_syslog_settings.rb +22 -9
  237. data/tests/test_tacacs_server.rb +32 -27
  238. data/tests/test_tacacs_server_group.rb +100 -45
  239. data/tests/test_tacacs_server_host.rb +135 -43
  240. data/tests/test_vdc.rb +2 -16
  241. data/tests/test_vlan.rb +106 -54
  242. data/tests/test_vlan_mt_full.rb +11 -21
  243. data/tests/test_vlan_private.rb +669 -0
  244. data/tests/test_vpc.rb +312 -159
  245. data/tests/test_vrf.rb +122 -113
  246. data/tests/test_vrf_af.rb +238 -0
  247. data/tests/test_vtp.rb +58 -102
  248. data/tests/test_vxlan_vtep.rb +38 -17
  249. data/tests/test_vxlan_vtep_vni.rb +61 -9
  250. data/tests/test_yum.rb +49 -25
  251. metadata +122 -36
  252. data/lib/cisco_node_utils/cmd_ref/fex.yaml +0 -9
  253. data/lib/cisco_node_utils/cmd_ref/vni.yaml +0 -76
  254. data/lib/cisco_node_utils/vni.rb +0 -227
  255. data/tests/test_vni.rb +0 -106
@@ -22,7 +22,6 @@ 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'
26
25
 
27
26
  # TestBgpNeighborAF - Minitest for RouterBgpNeighborAF class
28
27
  class TestBgpNeighborAF < CiscoTestCase
@@ -35,12 +34,16 @@ class TestBgpNeighborAF < CiscoTestCase
35
34
  super
36
35
  remove_all_bgps if @@pre_clean_needed
37
36
  @@pre_clean_needed = false # rubocop:disable Style/ClassVars
38
- setup_nv_overlay_evpn
37
+ if platform == :nexus
38
+ setup_nv_overlay_evpn
39
+ else
40
+ setup_ios_xr
41
+ end
39
42
  end
40
43
 
41
44
  def teardown
42
- super
43
45
  remove_all_bgps
46
+ super
44
47
  end
45
48
 
46
49
  def setup_nv_overlay_evpn
@@ -72,6 +75,58 @@ class TestBgpNeighborAF < CiscoTestCase
72
75
  [obj_af, dbg]
73
76
  end
74
77
 
78
+ # One time setup for XR
79
+ # this doesn't support the matrix very well but
80
+ # really only need to test 3 cases (ipv4 uni, l2vpn and a vrf)
81
+ def setup_ios_xr
82
+ return if platform == :nexus
83
+ asn = 1
84
+ vrf = 'aa'
85
+ nbr = '1.1.1.1'
86
+ af_v4 = 'ipv4 unicast'
87
+ af_v6 = 'ipv6 unicast'
88
+ vpn = 'vpnv4 unicast'
89
+ evpn = 'l2vpn evpn'
90
+
91
+ cfg = []
92
+
93
+ # Global requirements
94
+ # route policies
95
+ str1 = 'route-map-in-name'
96
+ str2 = 'route-map-out-name'
97
+ cfg << "route-policy #{str1}" << 'end-policy'
98
+ cfg << "route-policy #{str2}" << 'end-policy'
99
+ cfg << "route-policy #{str1.reverse}" << 'end-policy'
100
+ cfg << "route-policy #{str2.reverse}" << 'end-policy'
101
+ cfg << 'route-policy foo_bar' << 'end-policy'
102
+ cfg << 'route-policy baz_inga' << 'end-policy'
103
+ cfg << 'rd-set auto' << 'end-set'
104
+
105
+ # If any of the above config already exists, we will get a
106
+ # CLI warning message about replacing existing configuration.
107
+ # Ignore these warnings, as they're intentional.
108
+ config_no_warn(*cfg)
109
+
110
+ cfg = []
111
+
112
+ # router-id and address-family under the global bgp
113
+ # remote-as under the neighbor
114
+ # VRF statements
115
+ cfg << "router bgp #{asn}"
116
+ cfg << "router bgp #{asn} bgp router-id 1.1.1.1"
117
+ cfg << "router bgp #{asn} neighbor #{nbr} remote-as #{asn}"
118
+ cfg << "router bgp #{asn} address-family #{af_v4}"
119
+ cfg << "router bgp #{asn} address-family #{af_v6}"
120
+ cfg << "router bgp #{asn} address-family #{vpn}"
121
+ cfg << "router bgp #{asn} address-family vpnv6 unicast"
122
+ cfg << "router bgp #{asn} address-family #{evpn}"
123
+ cfg << "router bgp #{asn} vrf #{vrf} rd auto"
124
+ cfg << "router bgp #{asn} vrf #{vrf} address-family #{af_v4}"
125
+ cfg << "router bgp #{asn} vrf #{vrf} neighbor #{nbr} remote-as #{asn}"
126
+
127
+ config(*cfg)
128
+ end
129
+
75
130
  # def test_foo
76
131
  # af, dbg = clean_af([2, 'red', '1.1.1.1', %w(ipv4 unicast)])
77
132
  # foo(af, dbg)
@@ -80,7 +135,7 @@ class TestBgpNeighborAF < CiscoTestCase
80
135
  # AF test matrix
81
136
  @@matrix = { # rubocop:disable Style/ClassVars
82
137
  # 1 => [1, 'default', '10:1::1', %w(ipv4 multicast)], # UNSUPPORTED
83
- # 2 => [1, 'default', '10:1::1', %w(ipv4 unicast)],
138
+ # 2 => [1, 'default', '10:1::1', %w(ipv4 unicast)], # UNSUPPORTED in XR
84
139
  # 3 => [1, 'default', '10:1::1', %w(ipv6 multicast)],
85
140
  # 4 => [1, 'default', '10:1::1', %w(ipv6 unicast)],
86
141
  # 5 => [1, 'default', '1.1.1.1', %w(ipv4 multicast)],
@@ -88,7 +143,7 @@ class TestBgpNeighborAF < CiscoTestCase
88
143
  # 7 => [1, 'default', '1.1.1.1', %w(ipv6 multicast)],
89
144
  8 => [1, 'default', '1.1.1.1', %w(ipv6 unicast)],
90
145
  # 9 => [1, 'aa', '2.2.2.2', %w(ipv4 multicast)],
91
- # 10 => [1, 'aa', '2.2.2.2', %w(ipv4 unicast)],
146
+ 10 => [1, 'aa', '1.1.1.1', %w(ipv4 unicast)],
92
147
  # 11 => [1, 'bb', '2.2.2.2', %w(ipv6 multicast)],
93
148
  # 12 => [1, 'bb', '2.2.2.2', %w(ipv6 unicast)],
94
149
  # 13 => [1, 'cc', '10:1::2', %w(ipv4 multicast)], # UNSUPPORTED
@@ -100,14 +155,16 @@ class TestBgpNeighborAF < CiscoTestCase
100
155
 
101
156
  # ---------------------------------
102
157
  def test_nbr_af_create_destroy
103
- config('no feature bgp', 'feature bgp')
104
-
105
158
  # Creates
106
159
  obj = {}
107
160
  @@matrix.each do |k, v|
108
161
  asn, vrf, nbr, af = v
109
162
  dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af)
110
163
  obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af, true)
164
+ # TBD: This flush should not be needed but we see an intermittent problem
165
+ # with certain rake test seed values, where 'afs' below is not detecting
166
+ # vrf 'aa' AF.
167
+ node.cache_flush
111
168
  afs = RouterBgpNeighborAF.afs
112
169
  assert(afs[asn][vrf][nbr].key?(af),
113
170
  "#{dbg} Failed to create AF")
@@ -126,16 +183,28 @@ class TestBgpNeighborAF < CiscoTestCase
126
183
 
127
184
  # ---------------------------------
128
185
  def test_nbrs_with_masks
129
- config('no feature bgp', 'feature bgp')
130
-
131
186
  # Creates
132
187
  obj = {}
133
188
  @@matrix.each do |k, v|
134
189
  asn, vrf, nbr, af = v
135
190
  nbr += (nbr[/:/]) ? '/64' : '/16'
191
+ if platform == :ios_xr
192
+ # XR does not do slash masks and neighbors
193
+ # so make sure to catch the error
194
+ assert_raises(UnsupportedError,
195
+ 'Neighbors do not support slash notation') do
196
+ RouterBgpNeighborAF.new(asn, vrf, nbr, af, true)
197
+ end
198
+ next
199
+ end
200
+ next if platform == :ios_xr
136
201
  dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af.join('/'))
137
202
  obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af, true)
138
203
  nbr_munged = Utils.process_network_mask(nbr)
204
+ # TBD: This flush should not be needed but we see an intermittent problem
205
+ # with certain rake test seed values, where 'afs' below is not detecting
206
+ # vrf 'aa' AF.
207
+ node.cache_flush
139
208
  afs = RouterBgpNeighborAF.afs
140
209
  assert(afs[asn][vrf][nbr_munged].key?(af),
141
210
  "#{dbg} Failed to create AF")
@@ -145,6 +214,13 @@ class TestBgpNeighborAF < CiscoTestCase
145
214
  @@matrix.each do |k, v|
146
215
  asn, vrf, nbr, af = v
147
216
  nbr += (nbr[/:/]) ? '/64' : '/16'
217
+ if platform == :ios_xr
218
+ assert_raises(UnsupportedError,
219
+ 'Neighbors do not support slash notation') do
220
+ RouterBgpNeighborAF.new(asn, vrf, nbr, af, true)
221
+ end
222
+ next
223
+ end
148
224
  dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af.join('/'))
149
225
  obj[k].destroy
150
226
  nbr_munged = Utils.process_network_mask(nbr)
@@ -166,15 +242,21 @@ class TestBgpNeighborAF < CiscoTestCase
166
242
  def props_bool(af, dbg)
167
243
  # These properties have simple boolean states. As such we can use a common
168
244
  # set of tests to validate each property.
245
+ # XR the only properties supported (under all af's) are:
246
+ # :as_override,
247
+ # :next_hop_self,
248
+ # Nexus they are all supported, except when a l2vpn, in which case
249
+ # only disable_peer_as_check is supported.
169
250
  props = [
170
251
  :as_override,
171
- :disable_peer_as_check,
172
252
  :next_hop_self,
173
- :next_hop_third_party,
174
- :suppress_inactive,
175
253
  ]
176
254
 
177
- props = [:disable_peer_as_check] if dbg.include?('l2vpn/evpn')
255
+ if platform == :nexus
256
+ props << :next_hop_third_party
257
+ props << :suppress_inactive
258
+ props = [:disable_peer_as_check] if dbg.include?('l2vpn/evpn')
259
+ end
178
260
 
179
261
  # Call setter to false, then validate with getter
180
262
  props.each { |k| af.send("#{k}=", false) }
@@ -207,19 +289,23 @@ class TestBgpNeighborAF < CiscoTestCase
207
289
  end
208
290
 
209
291
  def props_string(af, dbg)
210
- # These properties have a common string value (route-map), allowing them
211
- # to use a common set of tests to validate each property.
212
- props = {
213
- filter_list_in: 'filt-in-name',
214
- filter_list_out: 'filt-out-name',
215
- prefix_list_in: 'pref-in-name',
216
- prefix_list_out: 'pref-out-name',
217
- route_map_in: 'route-map-in-name',
218
- route_map_out: 'route-map-out-name',
219
- unsuppress_map: 'unsupp-map-name',
220
- }
221
-
222
- props.delete(:unsuppress_map) if dbg.include?('l2vpn/evpn')
292
+ if platform == :nexus
293
+ props = {
294
+ filter_list_in: 'filt-in-name',
295
+ filter_list_out: 'filt-out-name',
296
+ prefix_list_in: 'pref-in-name',
297
+ prefix_list_out: 'pref-out-name',
298
+ route_map_in: 'route-map-in-name',
299
+ route_map_out: 'route-map-out-name',
300
+ unsuppress_map: 'unsupp-map-name',
301
+ }
302
+ props.delete(:unsuppress_map) if dbg.include?('l2vpn/evpn')
303
+ else
304
+ props = {
305
+ route_map_in: 'route-map-in-name',
306
+ route_map_out: 'route-map-out-name',
307
+ }
308
+ end
223
309
 
224
310
  props.each do |k, v|
225
311
  # Call setter.
@@ -247,32 +333,36 @@ class TestBgpNeighborAF < CiscoTestCase
247
333
  # soft_reconfiguration_in
248
334
 
249
335
  def supports_soft_reconfig_always?
250
- return true if node.product_id[/N(3|9)K/]
251
- false
336
+ str = node.cmd_ref.lookup('bgp_neighbor_af',
337
+ 'soft_reconfiguration_in').set_value
338
+ str.to_s[/always/]
252
339
  end
253
340
 
254
341
  def test_tri_states
255
342
  @@matrix.values.each do |af_args|
256
343
  af, dbg = clean_af(af_args)
257
-
258
344
  next if dbg.include?('l2vpn/evpn')
259
345
  %w(additional_paths_receive additional_paths_send).each do |k|
260
- [:enable, :disable, :inherit, 'enable', 'disable', 'inherit',
261
- af.send("default_#{k}")
262
- ].each do |val|
263
- af.send("#{k}=", val)
264
- assert_equal(val.to_sym, af.send(k), "#{dbg} Error: #{k}")
346
+ if validate_property_excluded?('bgp_neighbor_af', k)
347
+ assert_raises(UnsupportedError) { af.send("#{k}=", 'enable') }
348
+ else
349
+ [:enable, :disable, :inherit,
350
+ 'enable', 'disable', 'inherit',
351
+ af.send("default_#{k}")
352
+ ].each do |val|
353
+ af.send("#{k}=", val)
354
+ assert_equal(val.to_sym, af.send(k), "#{dbg} Error: #{k}")
355
+ end
265
356
  end
266
357
  end
267
358
 
268
- # The 'always' keyword is not supported on N6K / N7K
269
359
  %w(soft_reconfiguration_in).each do |k|
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}")]
360
+ array = [:enable, :always, :inherit,
361
+ 'enable', 'always', 'inherit',
362
+ af.send("default_#{k}")]
363
+ unless supports_soft_reconfig_always?
364
+ array.delete(:always)
365
+ array.delete('always')
276
366
  end
277
367
 
278
368
  array.each do |val|
@@ -287,7 +377,7 @@ class TestBgpNeighborAF < CiscoTestCase
287
377
  def test_advertise_map
288
378
  @@matrix.values.each do |af_args|
289
379
  af, dbg = clean_af(af_args)
290
- next if dbg.include?('l2vpn/evpn')
380
+ next if dbg.include?('l2vpn/evpn') && platform == :nexus
291
381
  advertise_map(af, dbg)
292
382
  end
293
383
  end
@@ -295,6 +385,12 @@ class TestBgpNeighborAF < CiscoTestCase
295
385
  def advertise_map(af, dbg)
296
386
  %w(advertise_map_exist advertise_map_non_exist).each do |k|
297
387
  v = %w(foo bar)
388
+ if platform == :ios_xr
389
+ assert_raises(UnsupportedError) do
390
+ af.send("#{k}=", v)
391
+ end
392
+ next
393
+ end
298
394
  af.send("#{k}=", v)
299
395
  assert_equal(v, af.send(k),
300
396
  "Test 1. #{dbg} [#{k}=] did not set strings '#{v}'")
@@ -367,7 +463,6 @@ class TestBgpNeighborAF < CiscoTestCase
367
463
  af.default_originate_set(true)
368
464
  assert(af.default_originate,
369
465
  "Test 1. #{dbg} Failed to set state to True")
370
-
371
466
  # Test true with route-map
372
467
  af.default_originate_set(true, 'foo_bar')
373
468
  assert_equal('foo_bar', af.default_originate_route_map,
@@ -388,8 +483,6 @@ class TestBgpNeighborAF < CiscoTestCase
388
483
  af.default_originate_set(true, af.default_default_originate_route_map)
389
484
  refute(af.default_originate_route_map,
390
485
  "Test 5. #{dbg} Failed to set default route-map from existing")
391
-
392
- # Test default_state
393
486
  af.default_originate_set(af.default_default_originate)
394
487
  refute(af.default_originate,
395
488
  "Test 6. #{dbg} Failed to set state to default")
@@ -430,7 +523,7 @@ class TestBgpNeighborAF < CiscoTestCase
430
523
  "Test 3c. #{dbg} Failed to set interval to '#{interval}'")
431
524
 
432
525
  limit = 97
433
- threshold = nil
526
+ threshold = platform == :nexus ? nil : 75
434
527
  warning = true
435
528
  af.max_prefix_set(limit, threshold, warning)
436
529
  assert_equal(limit, af.max_prefix_limit,
@@ -441,7 +534,7 @@ class TestBgpNeighborAF < CiscoTestCase
441
534
  "Test 4c. #{dbg} Failed to set warning to '#{warning}'")
442
535
 
443
536
  limit = 96
444
- threshold = nil
537
+ threshold = platform == :nexus ? nil : 75
445
538
  interval = 26
446
539
  af.max_prefix_set(limit, threshold, interval)
447
540
  assert_equal(limit, af.max_prefix_limit,
@@ -487,7 +580,7 @@ class TestBgpNeighborAF < CiscoTestCase
487
580
  "Test 9a. #{dbg} Failed to set limit to '#{limit}'")
488
581
  assert_equal(threshold, af.max_prefix_threshold,
489
582
  "Test 9b. #{dbg} Failed to set threshold to '#{threshold}'")
490
- assert_equal(warning, af.max_prefix_warning,
583
+ assert_equal((platform == :nexus ? warning : nil), af.max_prefix_warning,
491
584
  "Test 9c. #{dbg} Failed to set warning to '#{warning}'")
492
585
 
493
586
  af.max_prefix_set(nil)
@@ -522,16 +615,14 @@ class TestBgpNeighborAF < CiscoTestCase
522
615
 
523
616
  # ---------------------------------
524
617
  def test_send_community
525
- # iBGP only, do extra cleanup
526
- config('no feature bgp', 'feature bgp')
527
618
  @@matrix.values.each do |af_args|
528
619
  af, dbg = clean_af(af_args)
529
- send_community(af, dbg)
620
+ send_comm(af, dbg)
530
621
  end
531
622
  @@pre_clean_needed = true # rubocop:disable Style/ClassVars
532
623
  end
533
624
 
534
- def send_community(af, dbg)
625
+ def send_comm(af, dbg)
535
626
  v = 'both'
536
627
  af.send_community = v
537
628
  assert_equal(v, af.send_community,
@@ -553,7 +644,6 @@ class TestBgpNeighborAF < CiscoTestCase
553
644
  af.send_community = v
554
645
  assert_equal(v, af.send_community,
555
646
  "Test 3b. #{dbg} Failed to set '#{v}' from 'standard'")
556
-
557
647
  v = 'extended'
558
648
  af.send_community = v
559
649
  assert_equal(v, af.send_community,
@@ -563,7 +653,6 @@ class TestBgpNeighborAF < CiscoTestCase
563
653
  af.send_community = v
564
654
  assert_equal(v, af.send_community,
565
655
  "Test 5. #{dbg} Failed to set '#{v}' from 'extended'")
566
-
567
656
  v = 'standard'
568
657
  af.send_community = v
569
658
  assert_equal(v, af.send_community,
@@ -572,7 +661,6 @@ class TestBgpNeighborAF < CiscoTestCase
572
661
  af.send_community = v
573
662
  assert_equal(v, af.send_community,
574
663
  "Test 7. #{dbg} Failed to set '#{v}' from 'standard'")
575
-
576
664
  v = 'none'
577
665
  af.send_community = v
578
666
  assert_equal(v, af.send_community,
@@ -580,7 +668,7 @@ class TestBgpNeighborAF < CiscoTestCase
580
668
 
581
669
  v = 'both'
582
670
  af.send_community = v
583
- assert_equal(v, af.send_community,
671
+ assert_equal('both', af.send_community,
584
672
  "Test 9. #{dbg} Failed to set '#{v}' from None")
585
673
 
586
674
  v = af.default_send_community
@@ -600,37 +688,50 @@ class TestBgpNeighborAF < CiscoTestCase
600
688
  def soo(af, dbg)
601
689
  val = '1.1.1.1:1'
602
690
 
603
- if dbg.include?('default')
604
- assert_raises(CliError, "Test 1. #{dbg}[soo=] did not raise CliError") do
691
+ if platform == :ios_xr
692
+ assert_raises(Cisco::UnsupportedError) do
605
693
  af.soo = val
606
694
  end
607
- # SOO is only allowed in non-default VRF
608
- return
695
+ else
696
+ if dbg.include?('default')
697
+ str = "Test 1. #{dbg}[soo=] did not raise CliError"
698
+ assert_raises(CliError, str) do
699
+ af.soo = val
700
+ end
701
+ # SOO is only allowed in non-default VRF
702
+ return
703
+ end
609
704
  end
610
705
 
611
- # Set initial
612
- af.soo = val
613
- assert_equal(val, af.soo,
614
- "Test 2. #{dbg} Failed to set '#{val}'")
615
-
616
- # Change to new string
617
- val = '2:2'
618
- af.soo = val
619
- assert_equal(val, af.soo,
620
- "Test 3. #{dbg} Failed to change to '#{val}'")
621
-
622
- # Set to default
623
- val = af.default_soo
624
- af.soo = val
625
- assert_empty(af.soo,
626
- "Test 4. #{dbg} Failed to set default '#{val}'")
706
+ if platform == :nexus
707
+ # Set initial
708
+ af.soo = val
709
+ assert_equal(val, af.soo,
710
+ "Test 2. #{dbg} Failed to set '#{val}'")
711
+
712
+ # Change to new string
713
+ val = '2:2'
714
+ af.soo = val
715
+ assert_equal(val, af.soo,
716
+ "Test 3. #{dbg} Failed to change to '#{val}'")
717
+
718
+ # Set to default
719
+ val = af.default_soo
720
+ af.soo = val
721
+ assert_empty(af.soo,
722
+ "Test 4. #{dbg} Failed to set default '#{val}'")
723
+ else
724
+ assert_raises(Cisco::UnsupportedError) do
725
+ af.soo = val
726
+ end
727
+ end
627
728
  end
628
729
 
629
730
  # --------------------------------
630
731
  def test_weight
631
732
  @@matrix.values.each do |af_args|
632
733
  af, dbg = clean_af(af_args)
633
- weight(af, dbg) unless dbg.include?('l2vpn/evpn')
734
+ weight(af, dbg) unless dbg.include?('l2vpn/evpn') && platform == :nexus
634
735
  end
635
736
  end
636
737