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,77 @@
1
+ # November 2014, Chris Van Heuveln
2
+ #
3
+ # Copyright (c) 2014-2016 Cisco and/or its affiliates.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require_relative 'node_util'
18
+
19
+ module Cisco
20
+ # RouterOspf - node utility class for process-level OSPF config management
21
+ class RouterOspf < NodeUtil
22
+ attr_reader :name
23
+
24
+ def initialize(name, instantiate=true)
25
+ fail ArgumentError unless name.length > 0
26
+ @name = name
27
+
28
+ create if instantiate
29
+ end
30
+
31
+ # Create a hash of all router ospf instances
32
+ def self.routers
33
+ ospf_ids = config_get('ospf', 'router')
34
+ return {} if ospf_ids.nil?
35
+
36
+ hash = {}
37
+ ospf_ids.each do |name|
38
+ hash[name] = RouterOspf.new(name, false)
39
+ end
40
+ return hash
41
+ rescue Cisco::CliError
42
+ # cmd will error when feature 'ospf' is not enabled
43
+ raise if Feature.ospf_enabled?
44
+ return {}
45
+ end
46
+
47
+ # Create one router ospf instance
48
+ def create
49
+ Feature.ospf_enable
50
+ config_set('ospf', 'router', state: '', name: @name)
51
+ wait_for_process_initialized
52
+ end
53
+
54
+ # Destroy one router ospf instance
55
+ def destroy
56
+ config_set('ospf', 'router', state: 'no', name: @name)
57
+ end
58
+
59
+ def process_initialized?
60
+ !config_get('ospf', 'process_initialized')
61
+ end
62
+
63
+ def wait_for_process_initialized
64
+ return unless node.product_id[/N(5|6|8)/]
65
+
66
+ # Hack for slow-start platforms which will have setter failures if the
67
+ # ospf instance is still initializing. To see this problem in a sandbox
68
+ # or even the cli do 'router ospf 1 ; router ospf 1 ; shutdown'.
69
+ 4.times do
70
+ return if process_initialized?
71
+ sleep 1
72
+ node.cache_flush
73
+ end
74
+ fail 'OSPF process is not initialized yet'
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,416 @@
1
+ #
2
+ # NXAPI implementation of Router OSPF Area class
3
+ #
4
+ # June 2016, Sai Chintalapudi
5
+ #
6
+ # Copyright (c) 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 'ipaddr'
21
+ require_relative 'node_util'
22
+ require_relative 'router_ospf'
23
+ require_relative 'router_ospf_vrf'
24
+
25
+ module Cisco
26
+ # node_utils class for ospf_area
27
+ class RouterOspfArea < NodeUtil
28
+ attr_reader :router, :vrf, :area_id
29
+
30
+ def initialize(ospf_router, vrf_name, area_id, instantiate=true)
31
+ fail TypeError unless ospf_router.is_a?(String)
32
+ fail TypeError unless vrf_name.is_a?(String)
33
+ fail ArgumentError unless ospf_router.length > 0
34
+ fail ArgumentError unless vrf_name.length > 0
35
+ @area_id = area_id.to_s
36
+ fail ArgumentError if @area_id.empty?
37
+
38
+ Feature.ospf_enable if instantiate
39
+ # Convert to dot-notation
40
+
41
+ @router = ospf_router
42
+ @vrf = vrf_name
43
+ @area_id = IPAddr.new(area_id.to_i, Socket::AF_INET) unless @area_id[/\./]
44
+
45
+ set_args_keys_default
46
+ end
47
+
48
+ def self.areas
49
+ hash = {}
50
+ RouterOspf.routers.each do |name, _obj|
51
+ # get all area ids under default vrf
52
+ area_ids = config_get('ospf_area', 'areas', name: name)
53
+ if area_ids
54
+ hash[name] = {}
55
+ hash[name]['default'] = {}
56
+ area_ids.uniq.each do |area|
57
+ hash[name]['default'][area] =
58
+ RouterOspfArea.new(name, 'default', area, false)
59
+ end
60
+ end
61
+ vrf_ids = config_get('ospf', 'vrf', name: name)
62
+ next if vrf_ids.nil?
63
+ vrf_ids.each do |vrf|
64
+ # get all area ids under each vrf
65
+ area_ids = config_get('ospf_area', 'areas', name: name, vrf: vrf)
66
+ next if area_ids.nil?
67
+ hash[name] ||= {}
68
+ hash[name][vrf] = {}
69
+ area_ids.uniq.each do |area|
70
+ hash[name][vrf][area] =
71
+ RouterOspfArea.new(name, vrf, area, false)
72
+ end
73
+ end
74
+ end
75
+ hash
76
+ end
77
+
78
+ # Helper method to delete @set_args hash keys
79
+ def set_args_keys_default
80
+ @set_args = { name: @router, area: @area_id }
81
+ @set_args[:vrf] = @vrf unless @vrf == 'default'
82
+ @get_args = @set_args
83
+ end
84
+
85
+ # rubocop:disable Style/AccessorMethodName
86
+ def set_args_keys(hash={})
87
+ set_args_keys_default
88
+ @set_args = @get_args.merge!(hash) unless hash.empty?
89
+ end
90
+
91
+ def destroy
92
+ return unless Feature.ospf_enabled?
93
+ [:authentication,
94
+ :default_cost,
95
+ :filter_list_in,
96
+ :filter_list_out,
97
+ :nssa,
98
+ :nssa_translate_type7,
99
+ :range,
100
+ :stub,
101
+ ].each do |prop|
102
+ send("#{prop}=", send("default_#{prop}")) unless
103
+ send("#{prop}") == send("default_#{prop}")
104
+ end
105
+ set_args_keys_default
106
+ end
107
+
108
+ def ==(other)
109
+ (ospf_router == other.ospf_router) &&
110
+ (vrf_name == other.vrf_name) && (area_id == other.area_id)
111
+ end
112
+
113
+ ########################################################
114
+ # PROPERTIES #
115
+ ########################################################
116
+
117
+ # CLI can be either of the following or none
118
+ # area 1.1.1.1 authentication
119
+ # area 1.1.1.1 authentication message-digest
120
+ def authentication
121
+ auth = config_get('ospf_area', 'authentication', @get_args)
122
+ return default_authentication unless auth
123
+ auth.include?('message-digest') ? 'md5' : 'cleartext'
124
+ end
125
+
126
+ def authentication=(val)
127
+ state = val ? '' : 'no'
128
+ auth = (val.to_s == 'md5') ? 'message-digest' : ''
129
+ set_args_keys(state: state, auth: auth)
130
+ config_set('ospf_area', 'authentication', @set_args)
131
+ end
132
+
133
+ def default_authentication
134
+ config_get_default('ospf_area', 'authentication')
135
+ end
136
+
137
+ # CLI can be the following or none
138
+ # area 1.1.1.1 default-cost 1000
139
+ def default_cost
140
+ config_get('ospf_area', 'default_cost', @get_args)
141
+ end
142
+
143
+ def default_cost=(val)
144
+ state = val == default_default_cost ? 'no' : ''
145
+ cost = val == default_default_cost ? '' : val
146
+ set_args_keys(state: state, cost: cost)
147
+ config_set('ospf_area', 'default_cost', @set_args)
148
+ end
149
+
150
+ def default_default_cost
151
+ config_get_default('ospf_area', 'default_cost')
152
+ end
153
+
154
+ # CLI can be the following or none
155
+ # area 1.1.1.1 filter-list route-map aaa in
156
+ def filter_list_in
157
+ config_get('ospf_area', 'filter_list_in', @get_args)
158
+ end
159
+
160
+ def filter_list_in=(val)
161
+ return if filter_list_in == false && val == false
162
+ state = val ? '' : 'no'
163
+ rm = val ? val : filter_list_in
164
+ set_args_keys(state: state, route_map: rm)
165
+ config_set('ospf_area', 'filter_list_in', @set_args)
166
+ end
167
+
168
+ def default_filter_list_in
169
+ config_get_default('ospf_area', 'filter_list_in')
170
+ end
171
+
172
+ # CLI can be the following or none
173
+ # area 1.1.1.1 filter-list route-map bbb out
174
+ def filter_list_out
175
+ config_get('ospf_area', 'filter_list_out', @get_args)
176
+ end
177
+
178
+ def filter_list_out=(val)
179
+ return if filter_list_out == false && val == false
180
+ state = val ? '' : 'no'
181
+ rm = val ? val : filter_list_out
182
+ set_args_keys(state: state, route_map: rm)
183
+ config_set('ospf_area', 'filter_list_out', @set_args)
184
+ end
185
+
186
+ def default_filter_list_out
187
+ config_get_default('ospf_area', 'filter_list_out')
188
+ end
189
+
190
+ # CLI can be the following or none
191
+ # area 1.1.1.1 nssa
192
+ # the above command can be appended with no-summary and/or
193
+ # no-redistribution and/or default-information-originate.
194
+ # route-map <map> can be appended with default-information-originate
195
+ # Basically, every property this CLI configures is optional
196
+ # example manifest:
197
+ # nssa => true,
198
+ # nssa_default_originate => true,
199
+ # nssa_no_redistribution => false,
200
+ # nssa_no_summary => false,
201
+ # nssa_route_map => 'aaa',
202
+ def nssa_get
203
+ hash = {}
204
+ output = config_get('ospf_area', 'nssa_get', @get_args)
205
+ return hash if output.nil?
206
+ output.each do |line|
207
+ next if line.include?('translate')
208
+ hash[:nssa] = true
209
+ hash[:no_summary] = true if line.include?('no-summary')
210
+ hash[:no_redistribution] = true if line.include?('no-redistribution')
211
+ hash[:def_info_origin] = true if
212
+ line.include?('default-information-originate')
213
+ if line.include?('route-map')
214
+ params = line.split
215
+ hash[:route_map] = params[params.index('route-map') + 1]
216
+ end
217
+ end
218
+ hash
219
+ end
220
+
221
+ def nssa
222
+ nssa_get[:nssa].nil? ? false : true
223
+ end
224
+
225
+ def default_nssa
226
+ config_get_default('ospf_area', 'nssa')
227
+ end
228
+
229
+ def nssa_default_originate
230
+ nssa_get[:def_info_origin].nil? ? false : true
231
+ end
232
+
233
+ def default_nssa_default_originate
234
+ config_get_default('ospf_area', 'nssa_default_originate')
235
+ end
236
+
237
+ def nssa_no_redistribution
238
+ nssa_get[:no_redistribution].nil? ? false : true
239
+ end
240
+
241
+ def default_nssa_no_redistribution
242
+ config_get_default('ospf_area', 'nssa_no_redistribution')
243
+ end
244
+
245
+ def nssa_no_summary
246
+ nssa_get[:no_summary].nil? ? false : true
247
+ end
248
+
249
+ def default_nssa_no_summary
250
+ config_get_default('ospf_area', 'nssa_no_summary')
251
+ end
252
+
253
+ def nssa_route_map
254
+ nssa_get[:route_map].nil? ? '' : nssa_get[:route_map]
255
+ end
256
+
257
+ def default_nssa_route_map
258
+ config_get_default('ospf_area', 'nssa_route_map')
259
+ end
260
+
261
+ def nssa_set(hash)
262
+ # The nssa cli is additive so it must be removed altogether
263
+ # when making changes.
264
+ config_set('ospf_area', 'nssa_destroy', @set_args) if nssa
265
+ return if hash.empty?
266
+
267
+ @set_args[:state] = ''
268
+ @set_args[:nssa_no_summary] = ''
269
+ @set_args[:nssa_no_redistribution] = ''
270
+ @set_args[:nssa_default_originate] = ''
271
+ @set_args[:nssa_route_map] = ''
272
+ # Process each nssa property
273
+ hash.keys.each do |k|
274
+ hash[k] = 'default-information-originate' if
275
+ k == :nssa_default_originate
276
+ hash[k] = 'no-summary' if k == :nssa_no_summary
277
+ hash[k] = 'no-redistribution' if k == :nssa_no_redistribution
278
+ hash[k] = "route-map #{hash[:nssa_route_map]}" if
279
+ k == :nssa_route_map
280
+ @set_args[k] = hash[k]
281
+ end
282
+ config_set('ospf_area', 'nssa_set', @set_args)
283
+ end
284
+
285
+ # CLI can be the following or none
286
+ # area 1.1.1.1 nssa translate type7 always
287
+ # area 1.1.1.1 nssa translate type7 always supress-fa
288
+ # area 1.1.1.1 nssa translate type7 never
289
+ # area 1.1.1.1 nssa translate type7 supress-fa
290
+ def nssa_translate_type7
291
+ str = config_get('ospf_area', 'nssa_translate_type7', @get_args)
292
+ str = 'always_supress_fa' if str == 'always supress-fa'
293
+ str = 'supress_fa' if str == 'supress-fa'
294
+ str
295
+ end
296
+
297
+ def nssa_translate_type7=(val)
298
+ state = val ? '' : 'no'
299
+ value = val ? val : ''
300
+ value = 'always supress-fa' if val.to_s == 'always_supress_fa'
301
+ value = 'supress-fa' if val.to_s == 'supress_fa'
302
+ set_args_keys(state: state, value: value)
303
+ config_set('ospf_area', 'nssa_translate_type7', @set_args)
304
+ end
305
+
306
+ def default_nssa_translate_type7
307
+ config_get_default('ospf_area', 'nssa_translate_type7')
308
+ end
309
+
310
+ # range can take multiple values for the same vrf
311
+ # area 1.1.1.1 range 10.3.0.0/32
312
+ # area 1.1.1.1 range 10.3.0.1/32
313
+ # area 1.1.1.1 range 10.3.3.0/24
314
+ # area 1.1.1.1 range 10.3.0.0/16 not-advertise cost 23
315
+ # sometimes the not-advertise and cost are reversed in the
316
+ # show command for reasons unknown!
317
+ # area 1.1.1.1 range 10.3.0.0/16 cost 23 not-advertise
318
+ # use positional way of getting the values as it is
319
+ # simple and there are only two properties which are
320
+ # optional. ip is mandatory
321
+ # the return list is of the form [ip, not-advertise, cost]
322
+ # ex: [['10.3.0.0/16', 'not-advertise', '23'],
323
+ # ['10.3.0.0/32', 'not-advertise'],
324
+ # ['10.3.0.1/32'],
325
+ # ['10.3.3.0/24', '450']]
326
+ def range
327
+ list = []
328
+ ranges = config_get('ospf_area', 'range', @get_args)
329
+ ranges.each do |line|
330
+ llist = []
331
+ params = line.split
332
+ llist[0] = params[0]
333
+ llist[1] = 'not_advertise' if line.include?('not-advertise')
334
+ if line.include?('cost')
335
+ arr_index = llist[1].nil? ? 1 : 2
336
+ llist[arr_index] = params[params.index('cost') + 1]
337
+ end
338
+ list << llist
339
+ end
340
+ list
341
+ end
342
+
343
+ def range=(set_list)
344
+ # fail if set_list contains duplicate ip values
345
+ ip_list = []
346
+ set_list.each do |ip, _not_advertise, _cval|
347
+ ip_list << ip
348
+ end
349
+ fail ArgumentError, 'Duplicate ip values for range' unless
350
+ ip_list.size == ip_list.uniq.size
351
+ # reset the current ranges first due to bug CSCuz98937
352
+ cur_list = range
353
+ cur_list.each do |ip, _not_advertise, _cval|
354
+ set_args_keys(state: 'no', ip: ip, not_advertise: '',
355
+ cost: '', value: '')
356
+ config_set('ospf_area', 'range', @set_args)
357
+ end
358
+ # now set the range from the set_list
359
+ set_list.each do |ip, noadv, cval|
360
+ na = noadv == 'not_advertise' ? 'not-advertise' : ''
361
+ cost = cval ? 'cost' : ''
362
+ value = cval ? cval : ''
363
+ # in case of 2 variables, ip and cost
364
+ if noadv && noadv != 'not_advertise'
365
+ cost = 'cost'
366
+ value = noadv
367
+ end
368
+ set_args_keys(state: '', ip: ip, not_advertise: na,
369
+ cost: cost, value: value)
370
+ config_set('ospf_area', 'range', @set_args)
371
+ end
372
+ end
373
+
374
+ def default_range
375
+ config_get_default('ospf_area', 'range')
376
+ end
377
+
378
+ def stub
379
+ config_get('ospf_area', 'stub', @get_args)
380
+ end
381
+
382
+ def stub=(val)
383
+ state = val ? '' : 'no'
384
+ set_args_keys(state: state)
385
+ config_set('ospf_area', 'stub', @set_args)
386
+ end
387
+
388
+ def default_stub
389
+ config_get_default('ospf_area', 'stub')
390
+ end
391
+
392
+ def stub_no_summary
393
+ config_get('ospf_area', 'stub_no_summary', @get_args)
394
+ end
395
+
396
+ def stub_no_summary=(val)
397
+ if val
398
+ state = ''
399
+ set_args_keys(state: state)
400
+ config_set('ospf_area', 'stub_no_summary', @set_args)
401
+ else
402
+ if stub
403
+ # reset and set stub
404
+ set_args_keys(state: 'no')
405
+ config_set('ospf_area', 'stub', @set_args)
406
+ set_args_keys(state: '')
407
+ config_set('ospf_area', 'stub', @set_args)
408
+ end
409
+ end
410
+ end
411
+
412
+ def default_stub_no_summary
413
+ config_get_default('ospf_area', 'stub_no_summary')
414
+ end
415
+ end # class
416
+ end # module