cisco_node_utils_mgx 2.1.0.1

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 (357) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +96 -0
  5. data/.travis.yml +17 -0
  6. data/CHANGELOG.md +676 -0
  7. data/CONTRIBUTING.md +43 -0
  8. data/Gemfile +10 -0
  9. data/LICENSE +201 -0
  10. data/README.md +246 -0
  11. data/Rakefile +44 -0
  12. data/SUPPORT.md +3 -0
  13. data/bin/.rubocop.yml +18 -0
  14. data/bin/check_metric_limits.rb +109 -0
  15. data/bin/git/hooks/commit-msg/enforce_style +89 -0
  16. data/bin/git/hooks/hook_lib +115 -0
  17. data/bin/git/hooks/hooks-wrapper +38 -0
  18. data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
  19. data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
  20. data/bin/git/hooks/post-flow-release-start/update-version +19 -0
  21. data/bin/git/hooks/post-merge/update-hooks +6 -0
  22. data/bin/git/hooks/post-rewrite/update-hooks +6 -0
  23. data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
  24. data/bin/git/hooks/pre-commit/rubocop +25 -0
  25. data/bin/git/hooks/pre-commit/validate-diffs +45 -0
  26. data/bin/git/hooks/pre-commit/validate-yaml +18 -0
  27. data/bin/git/hooks/pre-push/check-changelog +24 -0
  28. data/bin/git/hooks/pre-push/rubocop +7 -0
  29. data/bin/git/update-hooks +123 -0
  30. data/bin/show_running_yang.rb +233 -0
  31. data/cisco_node_utils.gemspec +41 -0
  32. data/docs/README-develop-best-practices.md +521 -0
  33. data/docs/README-develop-node-utils-APIs.md +570 -0
  34. data/docs/README-maintainers.md +77 -0
  35. data/docs/README-test-execution.md +57 -0
  36. data/docs/README-utilities.md +14 -0
  37. data/docs/agent_files.png +0 -0
  38. data/docs/cisco_node_utils.yaml.example +36 -0
  39. data/docs/template-router.rb +123 -0
  40. data/docs/template-test_router.rb +104 -0
  41. data/ext/mkrf_conf.rb +63 -0
  42. data/lib/.rubocop.yml +18 -0
  43. data/lib/cisco_node_utils/aaa_authentication_login.rb +95 -0
  44. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +138 -0
  45. data/lib/cisco_node_utils/aaa_authorization_service.rb +156 -0
  46. data/lib/cisco_node_utils/ace.rb +467 -0
  47. data/lib/cisco_node_utils/acl.rb +101 -0
  48. data/lib/cisco_node_utils/banner.rb +63 -0
  49. data/lib/cisco_node_utils/bfd_global.rb +305 -0
  50. data/lib/cisco_node_utils/bgp.rb +988 -0
  51. data/lib/cisco_node_utils/bgp_af.rb +545 -0
  52. data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
  53. data/lib/cisco_node_utils/bgp_neighbor.rb +527 -0
  54. data/lib/cisco_node_utils/bgp_neighbor_af.rb +780 -0
  55. data/lib/cisco_node_utils/bridge_domain.rb +178 -0
  56. data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
  57. data/lib/cisco_node_utils/cisco_cmn_utils.rb +444 -0
  58. data/lib/cisco_node_utils/client/client.rb +238 -0
  59. data/lib/cisco_node_utils/client/grpc/client.rb +395 -0
  60. data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
  61. data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
  62. data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
  63. data/lib/cisco_node_utils/client/grpc.rb +33 -0
  64. data/lib/cisco_node_utils/client/nxapi/client.rb +368 -0
  65. data/lib/cisco_node_utils/client/nxapi.rb +31 -0
  66. data/lib/cisco_node_utils/client/utils.rb +180 -0
  67. data/lib/cisco_node_utils/client.rb +35 -0
  68. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +590 -0
  69. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +25 -0
  70. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +38 -0
  71. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +40 -0
  72. data/lib/cisco_node_utils/cmd_ref/acl.yaml +48 -0
  73. data/lib/cisco_node_utils/cmd_ref/banner.yaml +11 -0
  74. data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
  75. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +383 -0
  76. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +223 -0
  77. data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
  78. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +174 -0
  79. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +236 -0
  80. data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +49 -0
  81. data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
  82. data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +128 -0
  83. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +55 -0
  84. data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
  85. data/lib/cisco_node_utils/cmd_ref/evpn_multicast.yaml +12 -0
  86. data/lib/cisco_node_utils/cmd_ref/evpn_multisite.yaml +18 -0
  87. data/lib/cisco_node_utils/cmd_ref/evpn_stormcontrol.yaml +18 -0
  88. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +48 -0
  89. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +183 -0
  90. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +40 -0
  91. data/lib/cisco_node_utils/cmd_ref/feature.yaml +126 -0
  92. data/lib/cisco_node_utils/cmd_ref/hostname.yaml +8 -0
  93. data/lib/cisco_node_utils/cmd_ref/hsrp_global.yaml +25 -0
  94. data/lib/cisco_node_utils/cmd_ref/images.yaml +8 -0
  95. data/lib/cisco_node_utils/cmd_ref/interface.yaml +781 -0
  96. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +45 -0
  97. data/lib/cisco_node_utils/cmd_ref/interface_evpn_multisite.yaml +17 -0
  98. data/lib/cisco_node_utils/cmd_ref/interface_hsrp_group.yaml +120 -0
  99. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +112 -0
  100. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +87 -0
  101. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +42 -0
  102. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
  103. data/lib/cisco_node_utils/cmd_ref/ip_multicast.yaml +22 -0
  104. data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
  105. data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
  106. data/lib/cisco_node_utils/cmd_ref/memory.yaml +24 -0
  107. data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
  108. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +27 -0
  109. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +34 -0
  110. data/lib/cisco_node_utils/cmd_ref/object_group.yaml +32 -0
  111. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +91 -0
  112. data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
  113. data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
  114. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +37 -0
  115. data/lib/cisco_node_utils/cmd_ref/pim.yaml +43 -0
  116. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +86 -0
  117. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +37 -0
  118. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +100 -0
  119. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +19 -0
  120. data/lib/cisco_node_utils/cmd_ref/route_map.yaml +601 -0
  121. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +9 -0
  122. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +84 -0
  123. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +81 -0
  124. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +9 -0
  125. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +74 -0
  126. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +91 -0
  127. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +57 -0
  128. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +23 -0
  129. data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
  130. data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +235 -0
  131. data/lib/cisco_node_utils/cmd_ref/syslog_facility.yaml +10 -0
  132. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +34 -0
  133. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +45 -0
  134. data/lib/cisco_node_utils/cmd_ref/system.yaml +7 -0
  135. data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +37 -0
  136. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +63 -0
  137. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +45 -0
  138. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +64 -0
  139. data/lib/cisco_node_utils/cmd_ref/upgrade.yaml +38 -0
  140. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +52 -0
  141. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +8 -0
  142. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +106 -0
  143. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +233 -0
  144. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +86 -0
  145. data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +139 -0
  146. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +32 -0
  147. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +114 -0
  148. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +71 -0
  149. data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
  150. data/lib/cisco_node_utils/cmd_ref/yum.yaml +68 -0
  151. data/lib/cisco_node_utils/command_reference.rb +724 -0
  152. data/lib/cisco_node_utils/configparser_lib.rb +195 -0
  153. data/lib/cisco_node_utils/constants.rb +40 -0
  154. data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
  155. data/lib/cisco_node_utils/dns_domain.rb +93 -0
  156. data/lib/cisco_node_utils/domain_name.rb +82 -0
  157. data/lib/cisco_node_utils/encapsulation.rb +112 -0
  158. data/lib/cisco_node_utils/environment.rb +110 -0
  159. data/lib/cisco_node_utils/evpn_multicast.rb +66 -0
  160. data/lib/cisco_node_utils/evpn_multisite.rb +96 -0
  161. data/lib/cisco_node_utils/evpn_stormcontrol.rb +84 -0
  162. data/lib/cisco_node_utils/evpn_vni.rb +159 -0
  163. data/lib/cisco_node_utils/exceptions.rb +140 -0
  164. data/lib/cisco_node_utils/fabricpath_global.rb +405 -0
  165. data/lib/cisco_node_utils/fabricpath_topology.rb +137 -0
  166. data/lib/cisco_node_utils/feature.rb +377 -0
  167. data/lib/cisco_node_utils/hostname.rb +62 -0
  168. data/lib/cisco_node_utils/hsrp_global.rb +97 -0
  169. data/lib/cisco_node_utils/interface.rb +2128 -0
  170. data/lib/cisco_node_utils/interface_channel_group.rb +142 -0
  171. data/lib/cisco_node_utils/interface_evpn_multisite.rb +72 -0
  172. data/lib/cisco_node_utils/interface_hsrp_group.rb +557 -0
  173. data/lib/cisco_node_utils/interface_ospf.rb +378 -0
  174. data/lib/cisco_node_utils/interface_portchannel.rb +180 -0
  175. data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
  176. data/lib/cisco_node_utils/ip_multicast.rb +90 -0
  177. data/lib/cisco_node_utils/itd_device_group.rb +228 -0
  178. data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
  179. data/lib/cisco_node_utils/itd_service.rb +511 -0
  180. data/lib/cisco_node_utils/logger.rb +78 -0
  181. data/lib/cisco_node_utils/name_server.rb +64 -0
  182. data/lib/cisco_node_utils/node.rb +443 -0
  183. data/lib/cisco_node_utils/node_util.rb +111 -0
  184. data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
  185. data/lib/cisco_node_utils/ntp_config.rb +83 -0
  186. data/lib/cisco_node_utils/ntp_server.rb +86 -0
  187. data/lib/cisco_node_utils/object_group.rb +75 -0
  188. data/lib/cisco_node_utils/object_group_entry.rb +143 -0
  189. data/lib/cisco_node_utils/overlay_global.rb +142 -0
  190. data/lib/cisco_node_utils/pim.rb +131 -0
  191. data/lib/cisco_node_utils/pim_group_list.rb +109 -0
  192. data/lib/cisco_node_utils/pim_rp_address.rb +103 -0
  193. data/lib/cisco_node_utils/platform.rb +217 -0
  194. data/lib/cisco_node_utils/portchannel_global.rb +347 -0
  195. data/lib/cisco_node_utils/radius_global.rb +165 -0
  196. data/lib/cisco_node_utils/radius_server.rb +421 -0
  197. data/lib/cisco_node_utils/radius_server_group.rb +117 -0
  198. data/lib/cisco_node_utils/route_map.rb +2540 -0
  199. data/lib/cisco_node_utils/router_ospf.rb +77 -0
  200. data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
  201. data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
  202. data/lib/cisco_node_utils/router_ospf_vrf.rb +342 -0
  203. data/lib/cisco_node_utils/snmp_notification_receiver.rb +176 -0
  204. data/lib/cisco_node_utils/snmpcommunity.rb +109 -0
  205. data/lib/cisco_node_utils/snmpgroup.rb +54 -0
  206. data/lib/cisco_node_utils/snmpnotification.rb +57 -0
  207. data/lib/cisco_node_utils/snmpserver.rb +132 -0
  208. data/lib/cisco_node_utils/snmpuser.rb +403 -0
  209. data/lib/cisco_node_utils/span_session.rb +149 -0
  210. data/lib/cisco_node_utils/stp_global.rb +676 -0
  211. data/lib/cisco_node_utils/syslog_facility.rb +64 -0
  212. data/lib/cisco_node_utils/syslog_server.rb +146 -0
  213. data/lib/cisco_node_utils/syslog_settings.rb +174 -0
  214. data/lib/cisco_node_utils/tacacs_global.rb +137 -0
  215. data/lib/cisco_node_utils/tacacs_server.rb +173 -0
  216. data/lib/cisco_node_utils/tacacs_server_group.rb +149 -0
  217. data/lib/cisco_node_utils/tacacs_server_host.rb +216 -0
  218. data/lib/cisco_node_utils/upgrade.rb +122 -0
  219. data/lib/cisco_node_utils/vdc.rb +118 -0
  220. data/lib/cisco_node_utils/version.rb +21 -0
  221. data/lib/cisco_node_utils/vlan.rb +301 -0
  222. data/lib/cisco_node_utils/vpc.rb +466 -0
  223. data/lib/cisco_node_utils/vrf.rb +192 -0
  224. data/lib/cisco_node_utils/vrf_af.rb +327 -0
  225. data/lib/cisco_node_utils/vtp.rb +125 -0
  226. data/lib/cisco_node_utils/vxlan_vtep.rb +286 -0
  227. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +331 -0
  228. data/lib/cisco_node_utils/yang.rb +160 -0
  229. data/lib/cisco_node_utils/yum.rb +213 -0
  230. data/lib/cisco_node_utils.rb +21 -0
  231. data/lib/minitest/environment_plugin.rb +31 -0
  232. data/lib/minitest/log_level_plugin.rb +41 -0
  233. data/spec/client_spec.rb +7 -0
  234. data/spec/environment_spec.rb +384 -0
  235. data/spec/grpc_client_spec.rb +23 -0
  236. data/spec/isolate/all_clients_spec.rb +9 -0
  237. data/spec/isolate/grpc_only_spec.rb +16 -0
  238. data/spec/isolate/no_clients_spec.rb +26 -0
  239. data/spec/isolate/nxapi_only_spec.rb +16 -0
  240. data/spec/nxapi_client_spec.rb +42 -0
  241. data/spec/schema.yaml +82 -0
  242. data/spec/shared_examples_for_clients.rb +14 -0
  243. data/spec/spec_helper.rb +91 -0
  244. data/spec/whitespace_spec.rb +10 -0
  245. data/spec/yaml_spec.rb +42 -0
  246. data/tests/.rubocop.yml +18 -0
  247. data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
  248. data/tests/basetest.rb +243 -0
  249. data/tests/ciscotest.rb +577 -0
  250. data/tests/cmd_config.yaml +75 -0
  251. data/tests/cmd_config_invalid.yaml +16 -0
  252. data/tests/n9000_sample-1.0.0-7.0.3.x86_64.rpm +0 -0
  253. data/tests/noop.rb +7 -0
  254. data/tests/platform_info.rb +63 -0
  255. data/tests/tacacs_server.yaml.example +6 -0
  256. data/tests/test_aaa_authentication_login.rb +243 -0
  257. data/tests/test_aaa_authentication_login_service.rb +761 -0
  258. data/tests/test_aaa_authorization_service.rb +874 -0
  259. data/tests/test_ace.rb +304 -0
  260. data/tests/test_acl.rb +185 -0
  261. data/tests/test_banner.rb +85 -0
  262. data/tests/test_bfd_global.rb +272 -0
  263. data/tests/test_bgp_af.rb +875 -0
  264. data/tests/test_bgp_af_aa.rb +108 -0
  265. data/tests/test_bgp_neighbor.rb +596 -0
  266. data/tests/test_bgp_neighbor_af.rb +781 -0
  267. data/tests/test_bridge_domain.rb +198 -0
  268. data/tests/test_bridge_domain_vni.rb +109 -0
  269. data/tests/test_client_utils.rb +111 -0
  270. data/tests/test_cmn_utils.rb +76 -0
  271. data/tests/test_command_config.rb +206 -0
  272. data/tests/test_command_reference.rb +669 -0
  273. data/tests/test_dhcp_relay_global.rb +286 -0
  274. data/tests/test_dns_domain.rb +123 -0
  275. data/tests/test_domain_name.rb +96 -0
  276. data/tests/test_encapsulation.rb +75 -0
  277. data/tests/test_evpn_multicast.rb +65 -0
  278. data/tests/test_evpn_multisite.rb +70 -0
  279. data/tests/test_evpn_stormcontrol.rb +56 -0
  280. data/tests/test_evpn_vni.rb +131 -0
  281. data/tests/test_fabricpath_global.rb +246 -0
  282. data/tests/test_fabricpath_topology.rb +77 -0
  283. data/tests/test_feature.rb +272 -0
  284. data/tests/test_grpc.rb +166 -0
  285. data/tests/test_hostname.rb +64 -0
  286. data/tests/test_hsrp_global.rb +79 -0
  287. data/tests/test_interface.rb +1958 -0
  288. data/tests/test_interface_bdi.rb +80 -0
  289. data/tests/test_interface_channel_group.rb +131 -0
  290. data/tests/test_interface_evpn_multisite.rb +94 -0
  291. data/tests/test_interface_hsrp.rb +134 -0
  292. data/tests/test_interface_hsrp_group.rb +570 -0
  293. data/tests/test_interface_ospf.rb +820 -0
  294. data/tests/test_interface_portchannel.rb +135 -0
  295. data/tests/test_interface_private_vlan.rb +365 -0
  296. data/tests/test_interface_service_vni.rb +203 -0
  297. data/tests/test_interface_svi.rb +210 -0
  298. data/tests/test_interface_switchport.rb +468 -0
  299. data/tests/test_ip_multicast.rb +80 -0
  300. data/tests/test_itd_device_group.rb +145 -0
  301. data/tests/test_itd_device_group_node.rb +199 -0
  302. data/tests/test_itd_service.rb +314 -0
  303. data/tests/test_logger.rb +43 -0
  304. data/tests/test_name_server.rb +94 -0
  305. data/tests/test_node.rb +50 -0
  306. data/tests/test_node_ext.rb +406 -0
  307. data/tests/test_node_util.rb +119 -0
  308. data/tests/test_ntp_auth_key.rb +77 -0
  309. data/tests/test_ntp_config.rb +100 -0
  310. data/tests/test_ntp_server.rb +146 -0
  311. data/tests/test_nxapi.rb +236 -0
  312. data/tests/test_object_group.rb +122 -0
  313. data/tests/test_overlay_global.rb +108 -0
  314. data/tests/test_pim.rb +203 -0
  315. data/tests/test_pim_group_list.rb +147 -0
  316. data/tests/test_pim_rp_address.rb +155 -0
  317. data/tests/test_platform.rb +254 -0
  318. data/tests/test_portchannel_global.rb +322 -0
  319. data/tests/test_radius_global.rb +108 -0
  320. data/tests/test_radius_server.rb +377 -0
  321. data/tests/test_radius_server_group.rb +151 -0
  322. data/tests/test_route_map.rb +1479 -0
  323. data/tests/test_router_bgp.rb +1325 -0
  324. data/tests/test_router_ospf.rb +56 -0
  325. data/tests/test_router_ospf_area.rb +433 -0
  326. data/tests/test_router_ospf_area_vlink.rb +298 -0
  327. data/tests/test_router_ospf_vrf.rb +690 -0
  328. data/tests/test_snmp_notification_receiver.rb +169 -0
  329. data/tests/test_snmpcommunity.rb +422 -0
  330. data/tests/test_snmpgroup.rb +71 -0
  331. data/tests/test_snmpnotification.rb +91 -0
  332. data/tests/test_snmpserver.rb +251 -0
  333. data/tests/test_snmpuser.rb +666 -0
  334. data/tests/test_span_session.rb +155 -0
  335. data/tests/test_stp_global.rb +575 -0
  336. data/tests/test_syslog_facility.rb +80 -0
  337. data/tests/test_syslog_server.rb +119 -0
  338. data/tests/test_syslog_settings.rb +123 -0
  339. data/tests/test_tacacs_global.rb +109 -0
  340. data/tests/test_tacacs_server.rb +436 -0
  341. data/tests/test_tacacs_server_group.rb +434 -0
  342. data/tests/test_tacacs_server_host.rb +427 -0
  343. data/tests/test_upgrade.rb +105 -0
  344. data/tests/test_vdc.rb +64 -0
  345. data/tests/test_vlan.rb +386 -0
  346. data/tests/test_vlan_private.rb +656 -0
  347. data/tests/test_vpc.rb +548 -0
  348. data/tests/test_vrf.rb +248 -0
  349. data/tests/test_vrf_af.rb +288 -0
  350. data/tests/test_vtp.rb +278 -0
  351. data/tests/test_vxlan_vtep.rb +327 -0
  352. data/tests/test_vxlan_vtep_vni.rb +326 -0
  353. data/tests/test_yang.rb +369 -0
  354. data/tests/test_yum.rb +109 -0
  355. data/tests/upgrade_info.yaml.example +3 -0
  356. data/tests/yum_package.yaml +94 -0
  357. metadata +534 -0
@@ -0,0 +1,781 @@
1
+ #!/usr/bin/env ruby
2
+ # RouterBgpNeighborAF Unit Tests
3
+ #
4
+ # August 2015 Chris Van Heuveln
5
+ #
6
+ # Copyright (c) 2015-2016 Cisco and/or its affiliates.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require_relative 'ciscotest'
21
+ require_relative '../lib/cisco_node_utils/cisco_cmn_utils'
22
+ require_relative '../lib/cisco_node_utils/bgp'
23
+ require_relative '../lib/cisco_node_utils/bgp_neighbor'
24
+ require_relative '../lib/cisco_node_utils/bgp_neighbor_af'
25
+
26
+ # TestBgpNeighborAF - Minitest for RouterBgpNeighborAF class
27
+ class TestBgpNeighborAF < CiscoTestCase
28
+ # rubocop:disable Style/ClassVars
29
+ @@pre_clean_needed = true
30
+ @@evpn_unsupported = false
31
+ # rubocop:enable Style/ClassVars
32
+
33
+ def setup
34
+ super
35
+ remove_all_bgps if @@pre_clean_needed
36
+ @@pre_clean_needed = false # rubocop:disable Style/ClassVars
37
+ if platform == :nexus
38
+ setup_nv_overlay_evpn
39
+ else
40
+ setup_ios_xr
41
+ end
42
+ end
43
+
44
+ def teardown
45
+ remove_all_bgps
46
+ super
47
+ end
48
+
49
+ def setup_nv_overlay_evpn
50
+ Feature.bgp_enable
51
+
52
+ # l2vpn evpn tests require 'nv overlay evpn' but it is not supported on
53
+ # all platforms
54
+ Feature.nv_overlay_evpn_enable unless @@evpn_unsupported
55
+ rescue Cisco::UnsupportedError => e
56
+ @@evpn_unsupported = true if # rubocop:disable Style/ClassVars
57
+ e.message[/unsupported on this node/]
58
+ # Remove the evpn AF from the test matrix
59
+ @@matrix.delete(:evpn)
60
+ end
61
+
62
+ def clean_af(af_args, ebgp=true)
63
+ # Most tests only need an address-family cleanup
64
+ asn, vrf, nbr, af = af_args
65
+ dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af.join('/'))
66
+
67
+ obj_nbr = RouterBgpNeighbor.new(asn, vrf, nbr)
68
+ obj_nbr.remote_as = ebgp ? asn + 1 : asn
69
+
70
+ obj_af = RouterBgpNeighborAF.new(asn, vrf, nbr, af)
71
+
72
+ # clean up address-family only
73
+ obj_af.destroy
74
+ obj_af.create
75
+ [obj_af, dbg]
76
+ end
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
+
130
+ # def test_foo
131
+ # af, dbg = clean_af([2, 'red', '1.1.1.1', %w(ipv4 unicast)])
132
+ # foo(af, dbg)
133
+ # end
134
+
135
+ # AF test matrix
136
+ @@matrix = { # rubocop:disable Style/ClassVars
137
+ # 1 => [1, 'default', '10:1::1', %w(ipv4 multicast)], # UNSUPPORTED
138
+ # 2 => [1, 'default', '10:1::1', %w(ipv4 unicast)], # UNSUPPORTED in XR
139
+ # 3 => [1, 'default', '10:1::1', %w(ipv6 multicast)],
140
+ # 4 => [1, 'default', '10:1::1', %w(ipv6 unicast)],
141
+ # 5 => [1, 'default', '1.1.1.1', %w(ipv4 multicast)],
142
+ 6 => [1, 'default', '1.1.1.1', %w(ipv4 unicast)],
143
+ # 7 => [1, 'default', '1.1.1.1', %w(ipv6 multicast)],
144
+ 8 => [1, 'default', '1.1.1.1', %w(ipv6 unicast)],
145
+ # 9 => [1, 'aa', '2.2.2.2', %w(ipv4 multicast)],
146
+ 10 => [1, 'aa', '1.1.1.1', %w(ipv4 unicast)],
147
+ # 11 => [1, 'bb', '2.2.2.2', %w(ipv6 multicast)],
148
+ # 12 => [1, 'bb', '2.2.2.2', %w(ipv6 unicast)],
149
+ # 13 => [1, 'cc', '10:1::2', %w(ipv4 multicast)], # UNSUPPORTED
150
+ # 14 => [1, 'cc', '10:1::2', %w(ipv4 unicast)],
151
+ # 15 => [1, 'cc', '10:1::2', %w(ipv6 multicast)],
152
+ # 16 => [1, 'cc', '10:1::2', %w(ipv6 unicast)],
153
+ :evpn => [1, 'default', '1.1.1.1', %w(l2vpn evpn)],
154
+ }
155
+
156
+ # ---------------------------------
157
+ def test_nbr_af_create_destroy
158
+ # Creates
159
+ obj = {}
160
+ @@matrix.each do |k, v|
161
+ asn, vrf, nbr, af = v
162
+ dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af)
163
+ obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af)
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
168
+ afs = RouterBgpNeighborAF.afs
169
+ assert(afs[asn][vrf][nbr].key?(af),
170
+ "#{dbg} Failed to create AF")
171
+ end
172
+
173
+ # Destroys
174
+ @@matrix.each do |k, v|
175
+ asn, vrf, nbr, af = v
176
+ dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af)
177
+ obj[k].destroy
178
+ afs = RouterBgpNeighborAF.afs
179
+ refute(afs[asn][vrf][nbr].key?(af),
180
+ "#{dbg} Failed to destroy AF")
181
+ end
182
+ end
183
+
184
+ # ---------------------------------
185
+ def test_nbrs_with_masks
186
+ # Creates
187
+ obj = {}
188
+ @@matrix.each do |k, v|
189
+ asn, vrf, nbr, af = v
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)
197
+ end
198
+ next
199
+ end
200
+ next if platform == :ios_xr
201
+ dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af.join('/'))
202
+ obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af)
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
208
+ afs = RouterBgpNeighborAF.afs
209
+ assert(afs[asn][vrf][nbr_munged].key?(af),
210
+ "#{dbg} Failed to create AF")
211
+ end
212
+
213
+ # Destroys
214
+ @@matrix.each do |k, v|
215
+ asn, vrf, nbr, af = v
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)
221
+ end
222
+ next
223
+ end
224
+ dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af.join('/'))
225
+ obj[k].destroy
226
+ nbr_munged = Utils.process_network_mask(nbr)
227
+ afs = RouterBgpNeighborAF.afs
228
+ refute(afs[asn][vrf][nbr_munged].key?(af),
229
+ "#{dbg} Failed to destroy AF")
230
+ end
231
+ @@pre_clean_needed = true # rubocop:disable Style/ClassVars
232
+ end
233
+
234
+ # ---------------------------------
235
+ def test_props_bool
236
+ @@matrix.values.each do |af_args|
237
+ af, dbg = clean_af(af_args)
238
+ props_bool(af, dbg)
239
+ end
240
+ end
241
+
242
+ def props_bool(af, dbg)
243
+ # These properties have simple boolean states. As such we can use a common
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.
250
+ props = [
251
+ :as_override,
252
+ :next_hop_self,
253
+ ]
254
+
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
260
+
261
+ # Call setter to false, then validate with getter
262
+ props.each { |k| af.send("#{k}=", false) }
263
+ props.each do |k|
264
+ refute(af.send(k), "Test 1. #{dbg} [#{k}=] did not set false")
265
+ end
266
+
267
+ # Call setter to true, then validate with getter
268
+ props.each { |k| af.send("#{k}=", true) }
269
+ props.each do |k|
270
+ assert(af.send(k), "Test 2. #{dbg} [#{k}=] did not set true")
271
+ end
272
+
273
+ # Set to default and validate
274
+ def_val = {}
275
+ props.each { |k| def_val[k] = af.send("default_#{k}") }
276
+ props.each { |k| af.send("#{k}=", def_val[k]) }
277
+ props.each do |k|
278
+ assert_equal(def_val[k], af.send(k),
279
+ "Test 3. #{dbg} [#{k}=] did not set to default")
280
+ end
281
+ end
282
+
283
+ # ---------------------------------
284
+ def test_props_string
285
+ @@matrix.values.each do |af_args|
286
+ af, dbg = clean_af(af_args)
287
+ props_string(af, dbg)
288
+ end
289
+ end
290
+
291
+ def props_string(af, dbg)
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
309
+
310
+ props.each do |k, v|
311
+ # Call setter.
312
+ af.send("#{k}=", v)
313
+
314
+ # Validate with getter
315
+ assert_equal(v, af.send(k),
316
+ "Test 1. #{dbg} [#{k}=] did not set string '#{v}'")
317
+
318
+ af.send("#{k}=", v.reverse!)
319
+ assert_equal(v, af.send(k),
320
+ "Test 2. #{dbg} [#{k}=] did not set string '#{v}'")
321
+
322
+ # Set to default
323
+ af.send("#{k}=", af.send("default_#{k}"))
324
+ assert_empty(af.send(k),
325
+ "Test 3. #{dbg} [#{k}=] did not set default [default_#{k}]")
326
+ end
327
+ end
328
+
329
+ # ---------------------------------
330
+ # tri-state properties:
331
+ # additional_paths_receive
332
+ # additional_paths_send
333
+ # soft_reconfiguration_in
334
+
335
+ def supports_soft_reconfig_always?
336
+ str = node.cmd_ref.lookup('bgp_neighbor_af',
337
+ 'soft_reconfiguration_in').set_value
338
+ str.to_s[/always/]
339
+ end
340
+
341
+ def test_tri_states
342
+ @@matrix.values.each do |af_args|
343
+ af, dbg = clean_af(af_args)
344
+ next if dbg.include?('l2vpn/evpn')
345
+ %w(additional_paths_receive additional_paths_send).each do |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
356
+ end
357
+ end
358
+
359
+ %w(soft_reconfiguration_in).each do |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')
366
+ end
367
+
368
+ array.each do |val|
369
+ af.send("#{k}=", val)
370
+ assert_equal(val.to_sym, af.send(k), "#{dbg} Error: #{k}")
371
+ end
372
+ end
373
+ end
374
+ end
375
+
376
+ # ---------------------------------
377
+ def test_advertise_map
378
+ @@matrix.values.each do |af_args|
379
+ af, dbg = clean_af(af_args)
380
+ next if dbg.include?('l2vpn/evpn') && platform == :nexus
381
+ advertise_map(af, dbg)
382
+ end
383
+ end
384
+
385
+ def advertise_map(af, dbg)
386
+ %w(advertise_map_exist advertise_map_non_exist).each do |k|
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
394
+ af.send("#{k}=", v)
395
+ assert_equal(v, af.send(k),
396
+ "Test 1. #{dbg} [#{k}=] did not set strings '#{v}'")
397
+
398
+ # Change to new strings
399
+ v = %w(baz inga)
400
+ af.send("#{k}=", v)
401
+ assert_equal(v, af.send(k),
402
+ "Test 2. #{dbg} [#{k}=] did not set strings '#{v}'")
403
+
404
+ # Set to default
405
+ af.send("#{k}=", af.send("default_#{k}"))
406
+ assert_empty(af.send(k),
407
+ "Test 3. #{dbg} [#{k}] did not set to default " \
408
+ "'[default_#{k}]'")
409
+ end
410
+ end
411
+
412
+ # ---------------------------------
413
+ def test_allowas_in
414
+ @@matrix.values.each do |af_args|
415
+ af, dbg = clean_af(af_args)
416
+ allowas_in(af, dbg)
417
+ end
418
+ end
419
+
420
+ def allowas_in(af, dbg)
421
+ af.allowas_in_set(true)
422
+ assert(af.allowas_in,
423
+ "Test 1. #{dbg} Failed to set state to True")
424
+
425
+ # Test true with value
426
+ af.allowas_in_set(true, 5)
427
+ assert_equal(5, af.allowas_in_max,
428
+ "Test 2. #{dbg} Failed to set True with Value")
429
+
430
+ # Test false with value
431
+ af.allowas_in_set(false)
432
+ # skip setting this to false due to bug CSCve58319
433
+ refute(af.allowas_in,
434
+ "Test 3. #{dbg} Failed to set state to False") unless
435
+ Platform.image_version[/I5|I6|F3.3/]
436
+
437
+ # Test true with value, from false
438
+ af.allowas_in_set(true, 4)
439
+ assert_equal(4, af.allowas_in_max,
440
+ "Test 4. #{dbg} Failed to set True with Value, " \
441
+ 'from false state')
442
+
443
+ # Test default_state
444
+ af.allowas_in_set(af.default_allowas_in)
445
+ # skip setting this to false due to bug CSCve58319
446
+ refute(af.allowas_in,
447
+ "Test 5. #{dbg} Failed to set state to default") unless
448
+ Platform.image_version[/I5|I6|F3.3/]
449
+
450
+ # Test true with value set to default
451
+ af.allowas_in_set(true, af.default_allowas_in_max)
452
+ assert_equal(af.default_allowas_in_max, af.allowas_in_max,
453
+ "Test 6. #{dbg} Failed to set True with default Value")
454
+ end
455
+
456
+ # ---------------------------------
457
+ def test_default_originate
458
+ @@matrix.values.each do |af_args|
459
+ af, dbg = clean_af(af_args)
460
+ next if dbg.include?('l2vpn/evpn')
461
+ default_originate(af, dbg)
462
+ end
463
+ end
464
+
465
+ def default_originate(af, dbg)
466
+ # Test basic true
467
+ af.default_originate_set(true)
468
+ assert(af.default_originate,
469
+ "Test 1. #{dbg} Failed to set state to True")
470
+ # Test true with route-map
471
+ af.default_originate_set(true, 'foo_bar')
472
+ assert_equal('foo_bar', af.default_originate_route_map,
473
+ "Test 2. #{dbg} Failed to set True with Route-map")
474
+
475
+ # Test false with route-map
476
+ af.default_originate_set(false)
477
+ refute(af.default_originate,
478
+ "Test 3. #{dbg} Failed to set state to False")
479
+
480
+ # Test true with route-map, from false
481
+ af.default_originate_set(true, 'baz_inga')
482
+ assert_equal('baz_inga', af.default_originate_route_map,
483
+ "Test 4. #{dbg} Failed to set True with Route-map, " \
484
+ 'from false state')
485
+
486
+ # Test default route-map, from true
487
+ af.default_originate_set(true, af.default_default_originate_route_map)
488
+ refute(af.default_originate_route_map,
489
+ "Test 5. #{dbg} Failed to set default route-map from existing")
490
+ af.default_originate_set(af.default_default_originate)
491
+ refute(af.default_originate,
492
+ "Test 6. #{dbg} Failed to set state to default")
493
+ end
494
+
495
+ # ---------------------------------
496
+ def test_max_prefix
497
+ @@matrix.values.each do |af_args|
498
+ af, dbg = clean_af(af_args)
499
+ max_prefix(af, dbg)
500
+ max_prefix_defaults(af, dbg)
501
+ end
502
+ end
503
+
504
+ def max_prefix(af, dbg)
505
+ limit = 100
506
+ af.max_prefix_set(limit)
507
+ assert_equal(limit, af.max_prefix_limit,
508
+ "Test 1. #{dbg} Failed to set limit to '#{limit}'")
509
+
510
+ limit = 99
511
+ threshold = 49
512
+ af.max_prefix_set(limit, threshold)
513
+ assert_equal(limit, af.max_prefix_limit,
514
+ "Test 2a. #{dbg} Failed to set limit to '#{limit}'")
515
+ assert_equal(threshold, af.max_prefix_threshold,
516
+ "Test 2b. #{dbg} Failed to set threshold to '#{threshold}'")
517
+
518
+ limit = 98
519
+ threshold = 48
520
+ interval = 28
521
+ af.max_prefix_set(limit, threshold, interval)
522
+ assert_equal(limit, af.max_prefix_limit,
523
+ "Test 3a. #{dbg} Failed to set limit to '#{limit}'")
524
+ assert_equal(threshold, af.max_prefix_threshold,
525
+ "Test 3b. #{dbg} Failed to set threshold to '#{threshold}'")
526
+ assert_equal(interval, af.max_prefix_interval,
527
+ "Test 3c. #{dbg} Failed to set interval to '#{interval}'")
528
+
529
+ limit = 97
530
+ threshold = platform == :nexus ? nil : 75
531
+ warning = true
532
+ af.max_prefix_set(limit, threshold, warning)
533
+ assert_equal(limit, af.max_prefix_limit,
534
+ "Test 4a. #{dbg} Failed to set limit to '#{limit}'")
535
+ assert_equal(threshold, af.max_prefix_threshold,
536
+ "Test 4b. #{dbg} Failed to set threshold to '#{threshold}'")
537
+ assert_equal(warning, af.max_prefix_warning,
538
+ "Test 4c. #{dbg} Failed to set warning to '#{warning}'")
539
+
540
+ limit = 96
541
+ threshold = platform == :nexus ? nil : 75
542
+ interval = 26
543
+ af.max_prefix_set(limit, threshold, interval)
544
+ assert_equal(limit, af.max_prefix_limit,
545
+ "Test 5a. #{dbg} Failed to set limit to '#{limit}'")
546
+ assert_equal(threshold, af.max_prefix_threshold,
547
+ "Test 5b. #{dbg} Failed to set threshold to '#{threshold}'")
548
+ assert_equal(interval, af.max_prefix_interval,
549
+ "Test 5c. #{dbg} Failed to set interval to '#{interval}'")
550
+
551
+ limit = 95
552
+ threshold = 45
553
+ warning = true
554
+ af.max_prefix_set(limit, threshold, warning)
555
+ assert_equal(limit, af.max_prefix_limit,
556
+ "Test 6a. #{dbg} Failed to set limit to '#{limit}'")
557
+ assert_equal(threshold, af.max_prefix_threshold,
558
+ "Test 6b. #{dbg} Failed to set threshold to '#{threshold}'")
559
+ assert_equal(warning, af.max_prefix_warning,
560
+ "Test 6c. #{dbg} Failed to set warning to '#{warning}'")
561
+
562
+ af.max_prefix_set(af.default_max_prefix_limit)
563
+ refute(af.max_prefix_limit,
564
+ "Test 7. #{dbg} Failed to remove maximum_prefix")
565
+ end
566
+
567
+ def max_prefix_defaults(af, dbg)
568
+ limit = 94
569
+ threshold = af.default_max_prefix_threshold
570
+ interval = af.default_max_prefix_interval
571
+ af.max_prefix_set(limit, threshold, interval)
572
+ assert_equal(limit, af.max_prefix_limit,
573
+ "Test 8a. #{dbg} Failed to set limit to '#{limit}'")
574
+ assert_equal(threshold, af.max_prefix_threshold,
575
+ "Test 8b. #{dbg} Failed to set threshold to '#{threshold}'")
576
+ assert_equal(interval, af.max_prefix_interval,
577
+ "Test 8c. #{dbg} Failed to set interval to '#{interval}'")
578
+
579
+ limit = 93
580
+ threshold = af.default_max_prefix_threshold
581
+ warning = af.default_max_prefix_warning
582
+ af.max_prefix_set(limit, threshold, warning)
583
+ assert_equal(limit, af.max_prefix_limit,
584
+ "Test 9a. #{dbg} Failed to set limit to '#{limit}'")
585
+ assert_equal(threshold, af.max_prefix_threshold,
586
+ "Test 9b. #{dbg} Failed to set threshold to '#{threshold}'")
587
+ assert_equal((platform == :nexus ? warning : nil), af.max_prefix_warning,
588
+ "Test 9c. #{dbg} Failed to set warning to '#{warning}'")
589
+
590
+ af.max_prefix_set(nil)
591
+ refute(af.max_prefix_limit,
592
+ "Test 10. #{dbg} Failed to remove maximum_prefix")
593
+ end
594
+
595
+ # ---------------------------------
596
+ def test_route_reflector_client
597
+ @@matrix.values.each do |af_args|
598
+ # clean_af needs false since route_reflector_client is ibgp only
599
+ af, dbg = clean_af(af_args, false)
600
+ route_reflector_client(af, dbg)
601
+ end
602
+ end
603
+
604
+ def route_reflector_client(af, dbg)
605
+ # iBGP only
606
+ af.route_reflector_client = false
607
+ refute(af.route_reflector_client,
608
+ "Test 1. #{dbg} Did not set false")
609
+
610
+ af.route_reflector_client = true
611
+ assert(af.route_reflector_client,
612
+ "Test 2. #{dbg} Did not set true")
613
+
614
+ def_val = af.default_route_reflector_client
615
+ af.route_reflector_client = def_val
616
+ assert_equal(def_val, af.route_reflector_client,
617
+ "Test 3. #{dbg} Did not set to default")
618
+ end
619
+
620
+ # ---------------------------------
621
+ def test_send_community
622
+ @@matrix.values.each do |af_args|
623
+ af, dbg = clean_af(af_args)
624
+ send_comm(af, dbg)
625
+ end
626
+ @@pre_clean_needed = true # rubocop:disable Style/ClassVars
627
+ end
628
+
629
+ def send_comm(af, dbg)
630
+ v = 'both'
631
+ af.send_community = v
632
+ assert_equal(v, af.send_community,
633
+ "Test 1a. #{dbg} Failed to set '#{v}' from None")
634
+ af.send_community = v
635
+ assert_equal(v, af.send_community,
636
+ "Test 1b. #{dbg} Failed to set '#{v}' from 'both'")
637
+ v = 'extended'
638
+ af.send_community = v
639
+ assert_equal(v, af.send_community,
640
+ "Test 2a. #{dbg} Failed to set '#{v}' from 'both'")
641
+ af.send_community = v
642
+ assert_equal(v, af.send_community,
643
+ "Test 2b. #{dbg} Failed to set '#{v}' from 'extended'")
644
+ v = 'standard'
645
+ af.send_community = v
646
+ assert_equal(v, af.send_community,
647
+ "Test 3a. #{dbg} Failed to set '#{v}' from 'extended'")
648
+ af.send_community = v
649
+ assert_equal(v, af.send_community,
650
+ "Test 3b. #{dbg} Failed to set '#{v}' from 'standard'")
651
+ v = 'extended'
652
+ af.send_community = v
653
+ assert_equal(v, af.send_community,
654
+ "Test 4. #{dbg} Failed to set '#{v}' from 'standard'")
655
+
656
+ v = 'both'
657
+ af.send_community = v
658
+ assert_equal(v, af.send_community,
659
+ "Test 5. #{dbg} Failed to set '#{v}' from 'extended'")
660
+ v = 'standard'
661
+ af.send_community = v
662
+ assert_equal(v, af.send_community,
663
+ "Test 6. #{dbg} Failed to set '#{v}' from 'both'")
664
+ v = 'both'
665
+ af.send_community = v
666
+ assert_equal(v, af.send_community,
667
+ "Test 7. #{dbg} Failed to set '#{v}' from 'standard'")
668
+ v = 'none'
669
+ af.send_community = v
670
+ assert_equal(v, af.send_community,
671
+ "Test 8. #{dbg} Failed to remove send-community")
672
+
673
+ v = 'both'
674
+ af.send_community = v
675
+ assert_equal('both', af.send_community,
676
+ "Test 9. #{dbg} Failed to set '#{v}' from None")
677
+
678
+ v = af.default_send_community
679
+ af.send_community = af.default_send_community
680
+ assert_equal(v, af.send_community,
681
+ "Test 10. #{dbg} Failed to set state to default")
682
+ end
683
+
684
+ # ---------------------------------
685
+ def test_soo
686
+ @@matrix.values.each do |af_args|
687
+ af, dbg = clean_af(af_args)
688
+ soo(af, dbg)
689
+ end
690
+ end
691
+
692
+ def soo(af, dbg)
693
+ val = '1.1.1.1:1'
694
+
695
+ if platform == :ios_xr
696
+ assert_raises(Cisco::UnsupportedError) do
697
+ af.soo = val
698
+ end
699
+ else
700
+ if dbg.include?('default')
701
+ str = "Test 1. #{dbg}[soo=] did not raise CliError"
702
+ assert_raises(CliError, str) do
703
+ af.soo = val
704
+ end
705
+ # SOO is only allowed in non-default VRF
706
+ return
707
+ end
708
+ end
709
+
710
+ if platform == :nexus
711
+ # Set initial
712
+ af.soo = val
713
+ assert_equal(val, af.soo,
714
+ "Test 2. #{dbg} Failed to set '#{val}'")
715
+
716
+ # Change to new string
717
+ val = '2:2'
718
+ af.soo = val
719
+ assert_equal(val, af.soo,
720
+ "Test 3. #{dbg} Failed to change to '#{val}'")
721
+
722
+ # Set to default
723
+ val = af.default_soo
724
+ af.soo = val
725
+ assert_empty(af.soo,
726
+ "Test 4. #{dbg} Failed to set default '#{val}'")
727
+ else
728
+ assert_raises(Cisco::UnsupportedError) do
729
+ af.soo = val
730
+ end
731
+ end
732
+ end
733
+
734
+ # --------------------------------
735
+ def test_weight
736
+ @@matrix.values.each do |af_args|
737
+ af, dbg = clean_af(af_args)
738
+ weight(af, dbg) unless dbg.include?('l2vpn/evpn') && platform == :nexus
739
+ end
740
+ end
741
+
742
+ def weight(af, dbg)
743
+ # check the default value before set
744
+ assert_equal(af.default_weight, af.weight,
745
+ "Test 1. #{dbg} Error: should be default value")
746
+
747
+ af.weight = 22
748
+ assert_equal(22, af.weight, "Test 2. #{dbg} Failed to set weight")
749
+
750
+ af.weight = af.default_weight
751
+ assert_equal(af.default_weight, af.weight,
752
+ "Test 3. #{dbg} Failed to remove weight")
753
+ end
754
+
755
+ def test_rewrite_evpn_rt_asn
756
+ skip("#{node.product_id} doesn't support this feature") unless
757
+ node.product_id[/N9K.*EX/]
758
+ af_args = @@matrix[:evpn]
759
+ # clean_af needs true since rewrite_rt_asn is ebgp only
760
+ af, dbg = clean_af(af_args, true)
761
+ rewrite_evpn_rt_asn(af, dbg)
762
+ end
763
+
764
+ def rewrite_evpn_rt_asn(af, dbg)
765
+ # eBGP only
766
+ af.rewrite_evpn_rt_asn = true
767
+ assert(af.rewrite_evpn_rt_asn,
768
+ "Test 1. #{dbg} Did not set true")
769
+
770
+ af.rewrite_evpn_rt_asn = false
771
+ refute(af.rewrite_evpn_rt_asn,
772
+ "Test 2. #{dbg} Did not set false")
773
+
774
+ af.rewrite_evpn_rt_asn = true
775
+
776
+ def_val = af.default_rewrite_evpn_rt_asn
777
+ af.rewrite_evpn_rt_asn = def_val
778
+ assert_equal(def_val, af.rewrite_evpn_rt_asn,
779
+ "Test 3. #{dbg} Did not set to default")
780
+ end
781
+ end