cisco_node_utils_mgx 2.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,384 @@
1
+ require_relative 'spec_helper.rb'
2
+ require 'cisco_node_utils/environment'
3
+ require 'cisco_node_utils/client'
4
+
5
+ class << Cisco::Environment
6
+ attr_writer :environments
7
+ end
8
+
9
+ describe Cisco::Environment do
10
+ after(:each) do
11
+ # Revert to default environment data
12
+ Cisco::Environment.environments = {}
13
+ end
14
+
15
+ describe '.data_from_file' do
16
+ it 'handles File.expand_path errors' do
17
+ expect(File).to receive(:expand_path).and_raise(ArgumentError)
18
+ expect(Cisco::Environment.data_from_file('~/foo/bar.yaml')).to be_empty
19
+ end
20
+
21
+ it 'handles nonexistent files' do
22
+ expect(File).to receive(:file?).and_return(false)
23
+ expect(Cisco::Environment.data_from_file('/foo/bar.yaml')).to be_empty
24
+ end
25
+
26
+ it 'handles unreadable files' do
27
+ expect(File).to receive(:file?).and_return(true)
28
+ expect(File).to receive(:readable?).and_return(false)
29
+ expect(Cisco::Environment.data_from_file('/foo/bar.yaml')).to be_empty
30
+ end
31
+
32
+ it 'handles YAML errors' do
33
+ expect(File).to receive(:file?).and_return(true)
34
+ expect(File).to receive(:readable?).and_return(true)
35
+ error = Psych::SyntaxError.new('/foo/bar.yaml', 1, 1, 0, 'foo', 'bar')
36
+ expect(YAML).to receive(:load_file).and_raise(error)
37
+ # Catch the error log message Environment will generate:
38
+ expect(Cisco::Logger).to receive(:error).once
39
+ expect(Cisco::Environment.data_from_file('/foo/bar.yaml')).to eq({})
40
+ end
41
+ end
42
+
43
+ describe '.merge_config' do
44
+ it 'merges valid content' do
45
+ base = { 'hello' => {
46
+ host: '2.2.2.2',
47
+ port: 57_799,
48
+ username: nil,
49
+ password: nil,
50
+ cookie: nil,
51
+ } }
52
+ expect(Cisco::Environment).to receive(:data_from_file).and_return(
53
+ 'hello' => { host: '1.1.1.1' }, 'goodbye' => { password: 'foo' })
54
+ expect(Cisco::Environment.merge_config('/foo/bar.yaml', base)).to eq(
55
+ 'hello' => {
56
+ host: '1.1.1.1',
57
+ port: 57_799,
58
+ username: nil,
59
+ password: nil,
60
+ cookie: nil,
61
+ },
62
+ 'goodbye' => {
63
+ host: nil,
64
+ port: nil,
65
+ username: nil,
66
+ password: 'foo',
67
+ cookie: nil,
68
+ },
69
+ )
70
+ end
71
+ end
72
+
73
+ describe '.add_env' do
74
+ it 'rejects empty environment name' do
75
+ expect { described_class.add_env('', {}) }.to \
76
+ raise_error(ArgumentError, 'empty environment name')
77
+ end
78
+
79
+ it 'rejects incorrectly typed environment hash' do
80
+ expect { described_class.add_env('default', 'hash') }.to \
81
+ raise_error(TypeError, 'invalid environment hash')
82
+ end
83
+
84
+ context 'environment can be loaded by funcion' do
85
+ expected = {
86
+ host: '192.168.1.1',
87
+ port: nil,
88
+ username: 'admin',
89
+ password: 'admin',
90
+ cookie: nil,
91
+ }
92
+ it 'can be loaded explicitly by name' do
93
+ described_class.add_env('test', expected)
94
+ expect(Cisco::Environment.environment('test')).to eq(expected)
95
+ end
96
+
97
+ it 'can be default' do
98
+ described_class.add_env('default', expected)
99
+ expect(Cisco::Environment.environment).to eq(expected)
100
+ end
101
+ end
102
+ end
103
+
104
+ describe '.environments' do
105
+ before(:each) do
106
+ allow(Cisco::Environment).to receive(:data_from_file).and_return({})
107
+ end
108
+
109
+ it 'is empty by default' do
110
+ expect(Cisco::Environment.environments).to be_empty
111
+ end
112
+
113
+ global_config = {
114
+ 'default' => {
115
+ host: '127.0.0.1',
116
+ port: 57_400,
117
+ cookie: nil,
118
+ },
119
+ 'global' => {
120
+ username: 'global',
121
+ password: 'global',
122
+ cookie: nil,
123
+ },
124
+ }
125
+
126
+ user_config = {
127
+ 'default' => {
128
+ port: 57_799,
129
+ username: 'user',
130
+ cookie: nil,
131
+ },
132
+ 'user' => {
133
+ username: 'user',
134
+ password: 'user',
135
+ cookie: nil,
136
+ },
137
+ }
138
+
139
+ it 'loads data from global config if present' do
140
+ expect(Cisco::Environment).to receive(:data_from_file).with(
141
+ '/etc/cisco_node_utils.yaml').and_return(global_config)
142
+ env = Cisco::Environment.environments
143
+ env.each do |key, hash|
144
+ # The env hash should be fully populated with keys
145
+ # Any keys unspecified in the data should be nil
146
+ %I(host port username password).each do |hash_key|
147
+ expect(hash.fetch(hash_key)).to \
148
+ eq(global_config[key].fetch(hash_key, nil))
149
+ end
150
+ end
151
+ end
152
+
153
+ it 'loads data from user config if present' do
154
+ expect(Cisco::Environment).to receive(:data_from_file).with(
155
+ '~/cisco_node_utils.yaml').and_return(user_config)
156
+ env = Cisco::Environment.environments
157
+ env.each do |key, hash|
158
+ # The env hash should be fully populated with keys
159
+ # Any keys unspecified in the data should be nil
160
+ %I(host port username password).each do |hash_key|
161
+ expect(hash.fetch(hash_key)).to \
162
+ eq(user_config[key].fetch(hash_key, nil))
163
+ end
164
+ end
165
+ end
166
+
167
+ it 'uses both files if present but user data takes precedence' do
168
+ expect(Cisco::Environment).to receive(:data_from_file).with(
169
+ '/etc/cisco_node_utils.yaml').and_return(global_config)
170
+ expect(Cisco::Environment).to receive(:data_from_file).with(
171
+ '~/cisco_node_utils.yaml').and_return(user_config)
172
+ expect(Cisco::Environment.environments).to eq(
173
+ 'default' => {
174
+ host: '127.0.0.1', # global config
175
+ port: 57_799, # user overrides global
176
+ username: 'user', # user config
177
+ password: nil, # auto-populated with nil
178
+ cookie: nil,
179
+ },
180
+ 'global' => { # global config
181
+ host: nil,
182
+ port: nil,
183
+ username: 'global',
184
+ password: 'global',
185
+ cookie: nil,
186
+ },
187
+ 'user' => { # user config
188
+ host: nil,
189
+ port: nil,
190
+ username: 'user',
191
+ password: 'user',
192
+ cookie: nil,
193
+ },
194
+ )
195
+ end
196
+
197
+ it 'loaded file can be overridden by add_env' do
198
+ expect(Cisco::Environment).to receive(:data_from_file).with(
199
+ '/etc/cisco_node_utils.yaml').and_return(global_config)
200
+ expect(Cisco::Environment).to receive(:data_from_file).with(
201
+ '~/cisco_node_utils.yaml').and_return(user_config)
202
+ expect(Cisco::Environment.environments).to eq(
203
+ 'default' => {
204
+ host: '127.0.0.1', # global config
205
+ port: 57_799, # user overrides global
206
+ username: 'user', # user config
207
+ password: nil, # auto-populated with nil
208
+ cookie: nil,
209
+ },
210
+ 'global' => { # global config
211
+ host: nil,
212
+ port: nil,
213
+ username: 'global',
214
+ password: 'global',
215
+ cookie: nil,
216
+ },
217
+ 'user' => { # user config
218
+ host: nil,
219
+ port: nil,
220
+ username: 'user',
221
+ password: 'user',
222
+ cookie: nil,
223
+ },
224
+ )
225
+ added_env = {
226
+ host: '192.168.1.1',
227
+ port: nil,
228
+ username: 'admin',
229
+ password: 'admin',
230
+ cookie: nil,
231
+ }
232
+ overide_defult = {
233
+ host: '192.168.2.2',
234
+ port: nil,
235
+ username: 'overridden',
236
+ password: 'overridden',
237
+ cookie: nil,
238
+ }
239
+ described_class.add_env('added', added_env)
240
+ described_class.add_env('default', overide_defult)
241
+ expect(Cisco::Environment.environments).to eq(
242
+ 'added' => { # added by method
243
+ host: '192.168.1.1',
244
+ port: nil,
245
+ username: 'admin',
246
+ password: 'admin',
247
+ cookie: nil,
248
+ },
249
+ 'default' => {
250
+ host: '192.168.2.2', # method overrides files
251
+ port: nil, # method overrides files
252
+ username: 'overridden', # method overrides files
253
+ password: 'overridden', # method overrides files
254
+ cookie: nil, # auto-popuplated with nil
255
+ },
256
+ 'global' => { # global config
257
+ host: nil,
258
+ port: nil,
259
+ username: 'global',
260
+ password: 'global',
261
+ cookie: nil,
262
+ },
263
+ 'user' => { # user config
264
+ host: nil,
265
+ port: nil,
266
+ username: 'user',
267
+ password: 'user',
268
+ cookie: nil,
269
+ },
270
+ )
271
+ end
272
+ end
273
+
274
+ context '.environment' do
275
+ context 'with no config files available' do
276
+ before(:each) do
277
+ allow(Cisco::Environment).to receive(:data_from_file).and_return({})
278
+ end
279
+
280
+ it 'returns DEFAULT_ENVIRONMENT when called with no args' do
281
+ expect(Cisco::Environment.environment).to \
282
+ eq(Cisco::Environment::DEFAULT_ENVIRONMENT)
283
+ end
284
+ it 'returns DEFAULT_ENVIRONMENT when requested by name as "default"' do
285
+ expect(Cisco::Environment.environment('default')).to \
286
+ eq(Cisco::Environment::DEFAULT_ENVIRONMENT)
287
+ end
288
+ end
289
+
290
+ context 'with examples in docs/cisco_node_utils.yaml.example' do
291
+ before(:each) do
292
+ allow(File).to receive(:file?).and_return(true)
293
+ allow(File).to receive(:readable?).and_return(true)
294
+ allow(YAML).to receive(:load_file).and_wrap_original do |orig|
295
+ orig.call(File.expand_path('docs/cisco_node_utils.yaml.example'))
296
+ end
297
+ end
298
+
299
+ context 'the "nxapi_local" example' do
300
+ expected = {
301
+ host: nil,
302
+ port: nil,
303
+ username: nil,
304
+ password: nil,
305
+ cookie: nil,
306
+ }
307
+ it 'can be loaded explicitly by name' do
308
+ expect(Cisco::Environment.environment('nxapi_local')).to eq(expected)
309
+ end
310
+ it 'can be specified as the default then loaded implicitly' do
311
+ Cisco::Environment.default_environment_name = 'nxapi_local'
312
+ expect(Cisco::Environment.environment).to eq(expected)
313
+ end
314
+ it 'is valid configuration for the NXAPI client' do
315
+ hash = Cisco::Environment.environment('nxapi_local')
316
+ Cisco::Client::NXAPI.validate_args(hash)
317
+ end
318
+ end
319
+
320
+ context 'the "nxapi_remote" example' do
321
+ expected = {
322
+ host: '192.168.1.100',
323
+ port: nil,
324
+ username: 'devops',
325
+ password: 'devops',
326
+ cookie: nil,
327
+ }
328
+ it 'can be loaded explicitly by name' do
329
+ expect(Cisco::Environment.environment('nxapi_remote')).to eq(expected)
330
+ end
331
+ it 'can be specified as the default then loaded implicitly' do
332
+ Cisco::Environment.default_environment_name = 'nxapi_remote'
333
+ expect(Cisco::Environment.environment).to eq(expected)
334
+ end
335
+ it 'is valid configuration for the NXAPI client' do
336
+ hash = Cisco::Environment.environment('nxapi_remote')
337
+ Cisco::Client::NXAPI.validate_args(hash)
338
+ end
339
+ end
340
+
341
+ context 'the "grpc_local" example' do
342
+ expected = {
343
+ host: nil,
344
+ port: 57_999,
345
+ username: 'admin',
346
+ password: 'admin',
347
+ cookie: nil,
348
+ }
349
+ it 'can be loaded explicitly by name' do
350
+ expect(Cisco::Environment.environment('grpc_local')).to eq(expected)
351
+ end
352
+ it 'can be specified as default then loaded implicitly' do
353
+ Cisco::Environment.default_environment_name = 'grpc_local'
354
+ expect(Cisco::Environment.environment).to eq(expected)
355
+ end
356
+ it 'is valid configuration for the gRPC client' do
357
+ hash = Cisco::Environment.environment('grpc_local')
358
+ Cisco::Client::GRPC.validate_args(hash)
359
+ end
360
+ end
361
+
362
+ context 'the "grpc_remote" example' do
363
+ expected = {
364
+ host: '192.168.1.100',
365
+ port: nil,
366
+ username: 'admin',
367
+ password: 'admin',
368
+ cookie: nil,
369
+ }
370
+ it 'can be loaded explicitly by name' do
371
+ expect(Cisco::Environment.environment('grpc_remote')).to eq(expected)
372
+ end
373
+ it 'can be specified as default then loaded implicitly' do
374
+ Cisco::Environment.default_environment_name = 'grpc_remote'
375
+ expect(Cisco::Environment.environment).to eq(expected)
376
+ end
377
+ it 'is valid configuration for the gRPC client' do
378
+ hash = Cisco::Environment.environment('grpc_remote')
379
+ Cisco::Client::GRPC.validate_args(hash)
380
+ end
381
+ end
382
+ end
383
+ end
384
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'spec_helper.rb'
2
+ require 'shared_examples_for_clients'
3
+ require 'cisco_node_utils/client/grpc'
4
+
5
+ describe Cisco::Client::GRPC do
6
+ it_behaves_like 'all clients'
7
+
8
+ describe '.validate_args' do
9
+ it 'rejects nil username' do
10
+ kwargs = { host: '1.1.1.1', username: nil, password: 'bye' }
11
+ expect { described_class.validate_args(**kwargs) }.to \
12
+ raise_error(TypeError,
13
+ 'gRPC client creation failure: username must be specified')
14
+ end
15
+
16
+ it 'rejects nil password' do
17
+ kwargs = { host: '1.1.1.1', username: 'hi', password: nil }
18
+ expect { described_class.validate_args(**kwargs) }.to \
19
+ raise_error(TypeError,
20
+ 'gRPC client creation failure: password must be specified')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../spec_helper.rb'
2
+
3
+ context 'when both clients are installed' do
4
+ it 'should have both clients' do
5
+ require 'cisco_node_utils'
6
+ expect(Cisco::Client.clients).to eql [Cisco::Client::NXAPI,
7
+ Cisco::Client::GRPC]
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../spec_helper.rb'
2
+
3
+ context 'when only gRPC client is installed' do
4
+ let(:main_self) { TOPLEVEL_BINDING.eval('self') }
5
+ before(:example) do
6
+ allow(main_self).to receive(:require).and_wrap_original do |orig, pkg|
7
+ fail LoadError, pkg if pkg['cisco_node_utils/client/nxapi']
8
+ orig.call(pkg)
9
+ end
10
+ end
11
+
12
+ it 'should have gRPC client' do
13
+ require 'cisco_node_utils'
14
+ expect(Cisco::Client.clients).to eql [Cisco::Client::GRPC]
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../spec_helper.rb'
2
+ require 'rspec/core'
3
+
4
+ context 'when no client implementations are installed' do
5
+ let(:main_self) { TOPLEVEL_BINDING.eval('self') }
6
+
7
+ before(:example) do
8
+ allow(main_self).to receive(:require).and_wrap_original do |orig, pkg|
9
+ fail LoadError, pkg if pkg['client/nxapi']
10
+ fail LoadError, pkg if pkg['client/grpc']
11
+ orig.call(pkg)
12
+ end
13
+ end
14
+
15
+ it 'should not have any clients' do
16
+ require 'cisco_node_utils'
17
+ expect(Cisco::Client.clients).to eql []
18
+ end
19
+
20
+ it 'should fail Client.create' do
21
+ require 'cisco_node_utils'
22
+ expect { Cisco::Client.create }.to \
23
+ raise_error(RuntimeError, 'No client implementations available!')
24
+ end
25
+ # TODO
26
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../spec_helper.rb'
2
+
3
+ context 'when only NXAPI client is installed' do
4
+ let(:main_self) { TOPLEVEL_BINDING.eval('self') }
5
+ before(:example) do
6
+ allow(main_self).to receive(:require).and_wrap_original do |orig, pkg|
7
+ fail LoadError, pkg if pkg['cisco_node_utils/client/grpc']
8
+ orig.call(pkg)
9
+ end
10
+ end
11
+
12
+ it 'should have NXAPI client' do
13
+ require 'cisco_node_utils/client'
14
+ expect(Cisco::Client.clients).to eql [Cisco::Client::NXAPI]
15
+ end
16
+ end
@@ -0,0 +1,42 @@
1
+ require_relative 'spec_helper.rb'
2
+ require 'shared_examples_for_clients'
3
+ require 'cisco_node_utils/client/nxapi'
4
+
5
+ describe Cisco::Client::NXAPI do
6
+ it_behaves_like 'all clients'
7
+
8
+ describe '.validate_args' do
9
+ it 'accepts nil host, username, and password together' do
10
+ described_class.validate_args
11
+ end
12
+
13
+ it 'rejects the combination of nil host with non-nil username' do
14
+ kwargs = { host: nil, username: 'hi', password: nil }
15
+ expect { described_class.validate_args(**kwargs) }.to \
16
+ raise_error(ArgumentError)
17
+ end
18
+
19
+ it 'rejects the combination of nil host with non-nil password' do
20
+ kwargs = { host: nil, username: nil, password: 'bye' }
21
+ expect { described_class.validate_args(**kwargs) }.to \
22
+ raise_error(ArgumentError)
23
+ end
24
+
25
+ it 'accepts a host with username and password' do
26
+ kwargs = { host: '1.1.1.1', username: 'hi', password: 'bye' }
27
+ described_class.validate_args(**kwargs)
28
+ end
29
+
30
+ it 'rejects a host with nil username' do
31
+ kwargs = { host: '1.1.1.1', username: nil, password: 'bye' }
32
+ expect { described_class.validate_args(**kwargs) }.to \
33
+ raise_error(TypeError, 'username is required')
34
+ end
35
+
36
+ it 'rejects a host with nil password' do
37
+ kwargs = { host: '1.1.1.1', username: 'hi', password: nil }
38
+ expect { described_class.validate_args(**kwargs) }.to \
39
+ raise_error(TypeError, 'password is required')
40
+ end
41
+ end
42
+ end
data/spec/schema.yaml ADDED
@@ -0,0 +1,82 @@
1
+ # Kwalify schema for cmd_ref YAML files
2
+
3
+ type: map
4
+ mapping:
5
+ # List of cases to specifically exclude
6
+ _exclude: &exclude
7
+ type: seq
8
+ sequence:
9
+ - type: str
10
+ enum: &filters # Things we can filter by
11
+ # Platform classes
12
+ - 'ios_xr'
13
+ - 'nexus'
14
+ # Product IDs
15
+ - 'C3048'
16
+ - 'C3064'
17
+ - 'C3132'
18
+ - 'C3172'
19
+ - 'N35'
20
+ - 'N3k'
21
+ - 'N3k-F'
22
+ - 'N5k'
23
+ - 'N6k'
24
+ - 'N7k'
25
+ - 'N9k'
26
+ - 'N9k-F'
27
+
28
+ =: &base # default rule - apply to all properties
29
+ type: map
30
+ mapping:
31
+ _exclude: *exclude
32
+ # Platform and product filters
33
+ ios_xr: *base
34
+ nexus: *base
35
+ C3048: *base
36
+ C3064: *base
37
+ C3132: *base
38
+ C3172: *base
39
+ N3k: *base
40
+ N3k-F: *base
41
+ N5k: *base
42
+ N6k: *base
43
+ N7k: *base
44
+ N9k: *base
45
+ N9k-F: *base
46
+ # 'else' case if not matching any filter above
47
+ else: *base
48
+ # Generally applicable attributes
49
+ data_format: &data_format
50
+ type: str
51
+ enum: [cli, nxapi_structured]
52
+ context: &context
53
+ type: seq
54
+ sequence:
55
+ - type: str
56
+ value:
57
+ type: str
58
+ default_only:
59
+ type: any
60
+ # Getter-specific attributes
61
+ auto_default:
62
+ type: bool
63
+ default_value:
64
+ type: any
65
+ get_command:
66
+ type: str
67
+ get_data_format: *data_format
68
+ get_context: *context
69
+ get_value:
70
+ type: any
71
+ kind:
72
+ type: str
73
+ enum: [boolean, int, string, symbol]
74
+ multiple:
75
+ type: bool
76
+ os_version:
77
+ type: str
78
+ # Setter-specific attributes
79
+ set_data_format: *data_format
80
+ set_context: *context
81
+ set_value:
82
+ type: str
@@ -0,0 +1,14 @@
1
+ shared_examples_for 'all clients' do
2
+ describe '.validate_args' do
3
+ %i(host username password).each do |sym|
4
+ it "rejects non-String #{sym}" do
5
+ expect { described_class.validate_args(sym => 12) }.to \
6
+ raise_error(TypeError)
7
+ end
8
+ it "rejects empty #{sym}" do
9
+ expect { described_class.validate_args(sym => '') }.to \
10
+ raise_error(ArgumentError)
11
+ end
12
+ end
13
+ end
14
+ end