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,254 @@
1
+ # Copyright (c) 2015-2016 Cisco and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/platform'
17
+
18
+ # TestPlatform - Minitest for Platform class
19
+ class TestPlatform < CiscoTestCase
20
+ def test_image_version
21
+ case platform
22
+ when :ios_xr
23
+ refute_empty(Platform.image_version)
24
+
25
+ when :nexus
26
+ # Supported Images:
27
+ # N3/9k: 7.0(3)I2(*), 7.0(3)I3(1)
28
+ # N7k: 7.3(1)D1(1)
29
+ # N5/6k: 7.3(0)N1(1)
30
+
31
+ in_pat = '(^ NXOS: version |^ system: version)'
32
+ s = @device.cmd("show version | i '#{in_pat}'")
33
+
34
+ out_pat = %r{/(\d\.\d\(\d\)[IDN])\d\(\d\)/}
35
+ show = s.match(out_pat).to_s
36
+ plat = Platform.image_version.match(out_pat).to_s
37
+ assert_equal(show, plat)
38
+ end
39
+ end
40
+
41
+ def test_system_image
42
+ if platform == :ios_xr
43
+ assert_nil(Platform.system_image)
44
+ elsif platform == :nexus
45
+ s = @device.cmd('show version | inc image | exc kickstart').scan(/ (\S+)$/).flatten.first
46
+ assert_equal(s, Platform.system_image)
47
+ end
48
+ end
49
+
50
+ def test_packages
51
+ # [['pack1', 'state1'], ['pack2', 'state2'], ...]
52
+ # 'state' should always be a variant of Active or Inactive
53
+ pkgs = @device.cmd('sh inst patch')
54
+ .scan(/\n(\S+)\s+(\S*[aA]ctive.*)/)
55
+ # convert to hash with key pkg_name and value pkg_state
56
+ pkg_hsh = {}
57
+ pkgs.each { |p| pkg_hsh[p[0]] = p[1].downcase }
58
+ assert_equal(pkg_hsh, Platform.packages)
59
+ end
60
+
61
+ def test_hardware_type
62
+ if platform == :ios_xr
63
+ s = @device.cmd('show inv | inc "Rack 0"').scan(/DESCR: "(.*)"/)
64
+ elsif platform == :nexus
65
+ s = @device.cmd('sh ver').scan(/Hardware\n\s+(.*)\n/)
66
+ end
67
+ s = s.flatten.first
68
+ refute_empty(Platform.hardware_type)
69
+ # hardware type returns a different value depending on whether you use the
70
+ # ascii or show output of nxapi, but show appears to be substring of ascii
71
+ assert(s.include?(Platform.hardware_type),
72
+ "Expected '#{s}' to contain '#{Platform.hardware_type}'")
73
+ end
74
+
75
+ def test_cpu
76
+ s = @device.cmd('sh ver').scan(
77
+ /Hardware\n\s+.*\n\s+(.*) with/).flatten.first
78
+ assert_equal(s, Platform.cpu)
79
+ end
80
+
81
+ def test_memory
82
+ if platform == :ios_xr
83
+ arr = @device.cmd('sh mem summ').scan(
84
+ /Physical Memory: (\S+) total.*\((\S+) available/).flatten
85
+ mem_hsh = { 'total' => arr[0],
86
+ 'used' => nil,
87
+ 'free' => arr[1] }
88
+ elsif platform == :nexus
89
+ arr = @device.cmd('sh sys reso').scan(
90
+ /(\S+) total.* (\S+) used.* (\S+) free/).flatten
91
+ mem_hsh = { 'total' => arr[0],
92
+ 'used' => arr[1],
93
+ 'free' => arr[2] }
94
+ end
95
+ assert_equal(mem_hsh['total'], Platform.memory['total'])
96
+ if platform == :nexus
97
+ # used and free mem change rapidly, compare total and sums of free + used
98
+ assert_equal(mem_hsh['used'].to_i + mem_hsh['free'].to_i,
99
+ Platform.memory['used'].to_i + Platform.memory['free'].to_i)
100
+ end
101
+ assert(Platform.memory.key?('used'),
102
+ "Platform memory has no key 'used'")
103
+ assert(Platform.memory.key?('free'),
104
+ "Platform memory has no key 'free'")
105
+ end
106
+
107
+ def test_board
108
+ s = @device.cmd('sh ver').scan(/Board ID (\S+)/).flatten.first
109
+ assert_equal(s, Platform.board)
110
+ end
111
+
112
+ def test_uptime
113
+ s = @device.cmd('sh system uptime').scan(/Kernel uptime:\s+(.*)/).flatten.first
114
+ # compare without seconds
115
+ assert_equal(s.gsub(/\d+ sec/, ''), Platform.uptime.gsub(/\d+ sec/, ''))
116
+ end
117
+
118
+ def test_reset_reason
119
+ s = @device.cmd('sh ver').scan(/Reason: (.*)/).flatten.first
120
+ assert_equal(s, Platform.reset_reason)
121
+ end
122
+
123
+ # switch#show inventory
124
+ # NAME: "Chassis", DESCR: "Nexus9000 C9396PX Chassis"
125
+ # PID: N9K-C9396PX , VID: V02 , SN: xxxxxxxxxxx
126
+ #
127
+ # NAME: "Slot 1", DESCR: "1/10G SFP+ Ethernet Module"
128
+ # PID: N9K-C9396PX , VID: V02 , SN: xxxxxxxxxxx
129
+ #
130
+ # NAME: "Slot 2", DESCR: "40G Ethernet Expansion Module"
131
+ # PID: N9K-M12PQ , VID: V01 , SN: xxxxxxxxxxx
132
+ # (...)
133
+ # NAME: "Power Supply 1", DESCR: "Nexus9000 C9396PX Chassis Power Supply"
134
+ # PID: N9K-PAC-650W , VID: V01 , SN: xxxxxxxxxxx
135
+ # (...)
136
+ # NAME: "Fan 1", DESCR: "Nexus9000 C9396PX Chassis Fan Module"
137
+ # PID: N9K-C9300-FAN2 , VID: V01 , SN: N/A
138
+ #
139
+ # Everything from DESCR onwards follows the same general format so we
140
+ # can define a single base regexp and extend it as needed for Chassis, Slot,
141
+ # Power Supply, and Fan inventory entries.
142
+ #
143
+ # On some platforms, some fields may be empty:
144
+ # NAME: "Chassis", DESCR: "NX-OSv Chassis"
145
+ # PID: N9K-NXOSV , VID: , SN:
146
+ def inv_cmn_re(name_expr)
147
+ /NAME:\s+"#{name_expr}",\s+
148
+ DESCR:\s+"(.*)"\s*
149
+ \n
150
+ PID:\s+(\S*)\s*,\s*
151
+ VID:\s+(\S*)\s*,\s*
152
+ SN:\s+(\S*)\s*
153
+ $/x
154
+ end
155
+
156
+ def test_chassis
157
+ arr = @device.cmd('sh inv').scan(inv_cmn_re('Chassis'))
158
+ arr = arr.flatten
159
+ # convert to hash
160
+ chas_hsh = { 'descr' => arr[0],
161
+ 'pid' => arr[1],
162
+ 'vid' => arr[2],
163
+ 'sn' => arr[3],
164
+ } unless arr.empty?
165
+ assert_equal(chas_hsh, Platform.chassis)
166
+ end
167
+
168
+ def test_slots
169
+ slots_arr_arr = @device.cmd('sh inv').scan(inv_cmn_re('(Slot\s+\d+)'))
170
+ # convert to array of slot hashes
171
+ slots_hsh_hsh = {}
172
+ slots_arr_arr.each do |slot|
173
+ slots_hsh_hsh[slot[0]] = { 'descr' => slot[1],
174
+ 'pid' => slot[2],
175
+ 'vid' => slot[3],
176
+ 'sn' => slot[4],
177
+ }
178
+ end
179
+ assert_equal(slots_hsh_hsh, Platform.slots)
180
+ end
181
+
182
+ def test_power_supplies
183
+ pwr_arr_arr = @device.cmd('sh inv')
184
+ .scan(inv_cmn_re('(Power\s+Supply\s+\d+)'))
185
+
186
+ # convert to array of power supply hashes
187
+ pwr_hsh_hsh = {}
188
+ pwr_arr_arr.each do |pwr|
189
+ pwr_hsh_hsh[pwr[0]] = { 'descr' => pwr[1],
190
+ 'pid' => pwr[2],
191
+ 'vid' => pwr[3],
192
+ 'sn' => pwr[4],
193
+ }
194
+ end
195
+ assert_equal(pwr_hsh_hsh, Platform.power_supplies)
196
+ end
197
+
198
+ def test_fans
199
+ fan_arr_arr = @device.cmd('sh inv').scan(inv_cmn_re('(Fan\s+\d+)'))
200
+
201
+ # convert to array of fan hashes
202
+ fan_hsh_hsh = {}
203
+ fan_arr_arr.each do |fan|
204
+ fan_hsh_hsh[fan[0]] = { 'descr' => fan[1],
205
+ 'pid' => fan[2],
206
+ 'vid' => fan[3],
207
+ 'sn' => fan[4],
208
+ }
209
+ end
210
+ assert_equal(fan_hsh_hsh, Platform.fans)
211
+ end
212
+
213
+ def test_virtual_services
214
+ if validate_property_excluded?('virtual_service', 'services')
215
+ assert_nil(node.config_get('virtual_service', 'services'))
216
+ return
217
+ end
218
+ # Only run this test if a virtual-service is installed
219
+ if config('show virtual-service global')[/services installed : 0$/]
220
+ skip('This test requires a virtual-service to be installed')
221
+ end
222
+ # this would be beyond ugly to parse from ascii, utilize config_get
223
+ vir_arr = node.config_get('virtual_service', 'services')
224
+ vir_arr = [vir_arr] if vir_arr.is_a? Hash
225
+ # convert to expected format
226
+ vir_hsh_hsh = {}
227
+ unless vir_arr.nil?
228
+ vir_arr.each do |serv|
229
+ # rubocop:disable Style/AlignHash
230
+ vir_hsh_hsh[serv['name']] = {
231
+ 'package_info' => { 'name' => serv['package_name'],
232
+ 'path' => serv['ova_path'],
233
+ },
234
+ 'application' => { 'name' => serv['application_name'],
235
+ 'version' => serv['application_version'],
236
+ 'descr' => serv['application_description'],
237
+ },
238
+ 'signing' => { 'key_type' => serv['key_type'],
239
+ 'method' => serv['signing_method'],
240
+ },
241
+ 'licensing' => { 'name' => serv['licensing_name'],
242
+ 'version' => serv['licensing_version'],
243
+ },
244
+ 'reservation' => { 'disk' => serv['disk_reservation'],
245
+ 'memory' => serv['memory_reservation'],
246
+ 'cpu' => serv['cpu_reservation'],
247
+ },
248
+ }
249
+ # rubocop:enable Style/AlignHash
250
+ end
251
+ end
252
+ assert_equal(vir_hsh_hsh, Platform.virtual_services)
253
+ end
254
+ end
@@ -0,0 +1,322 @@
1
+ # Copyright (c) 2014-2016 Cisco and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/portchannel_global'
17
+ require_relative '../lib/cisco_node_utils/platform'
18
+
19
+ # TestX__CLASS_NAME__X - Minitest for X__CLASS_NAME__X node utility class
20
+ class TestPortchannelGlobal < CiscoTestCase
21
+ @skip_unless_supported = 'portchannel_global'
22
+ @@cleaned = false # rubocop:disable Style/ClassVars
23
+ DEFAULT_NAME = 'default'
24
+
25
+ def setup
26
+ super
27
+ cleanup unless @@cleaned
28
+ @@cleaned = true # rubocop:disable Style/ClassVars
29
+ end
30
+
31
+ def teardown
32
+ cleanup
33
+ super
34
+ end
35
+
36
+ def cleanup
37
+ ethernet = node.product_id[/N(3|7|8|9)/] ? '' : 'ethernet'
38
+ config_no_warn "no port-channel load-balance #{ethernet}"
39
+ end
40
+
41
+ def n3k_is_t2?
42
+ return unless /N3/ =~ node.product_id
43
+ Platform.chassis['descr'][/(Nexus3000 C31|Nexus 31)/] ? true : false
44
+ end
45
+
46
+ def n3k_in_n3k_mode?
47
+ return unless /N3/ =~ node.product_id
48
+ return if node.product_id.include?('-F')
49
+ mode = config('show system switch-mode')
50
+ # note: an n3k in n9k mode displays: 'system switch-mode n9k'
51
+ patterns = ['system switch-mode n3k',
52
+ 'Switch mode configuration is not.*applicable']
53
+ mode.match("#{patterns[0]}|#{patterns[1]}") ? true : false
54
+ end
55
+
56
+ def create_portchannel_global(name=DEFAULT_NAME)
57
+ PortChannelGlobal.new(name)
58
+ end
59
+
60
+ def test_hash_distribution
61
+ global = create_portchannel_global
62
+ if validate_property_excluded?('portchannel_global', 'hash_distribution')
63
+ assert_raises(Cisco::UnsupportedError) do
64
+ global.hash_distribution = 'fixed'
65
+ end
66
+ assert_nil(global.hash_distribution)
67
+ else
68
+ global.hash_distribution = 'fixed'
69
+ assert_equal('fixed', global.hash_distribution)
70
+ global.hash_distribution =
71
+ global.default_hash_distribution
72
+ assert_equal(global.default_hash_distribution,
73
+ global.hash_distribution)
74
+ end
75
+ end
76
+
77
+ def test_load_defer
78
+ global = create_portchannel_global
79
+ if validate_property_excluded?('portchannel_global', 'load_defer')
80
+ assert_raises(Cisco::UnsupportedError) do
81
+ global.load_defer = 1000
82
+ end
83
+ assert_nil(global.load_defer)
84
+ else
85
+ global.load_defer = 1000
86
+ assert_equal(1000, global.load_defer)
87
+ global.load_defer =
88
+ global.default_load_defer
89
+ assert_equal(global.default_load_defer,
90
+ global.load_defer)
91
+ end
92
+ end
93
+
94
+ def test_resilient
95
+ global = create_portchannel_global
96
+ if validate_property_excluded?('portchannel_global', 'resilient')
97
+ assert_raises(Cisco::UnsupportedError) { global.resilient = true }
98
+ assert_nil(global.resilient)
99
+ return
100
+ end
101
+
102
+ # Verify that hardware supports feature. Unfortunately the current cli
103
+ # only displays a warning and does not raise an error so we have to
104
+ # test for it explicitly.
105
+ cmd = 'port-channel load-balance resilient'
106
+ skip('Skip test: Feature is not supported on this device') if
107
+ config(cmd)[/Resilient Hashing Mode unsupported/]
108
+ global = create_portchannel_global
109
+ # For n3k the default is different from n9k
110
+ if n3k_in_n3k_mode?
111
+ global.resilient = false
112
+ refute(global.resilient)
113
+ global.resilient = global.default_resilient
114
+ assert_equal(global.default_resilient, global.resilient)
115
+ else
116
+ config('no ' + cmd)
117
+ global = create_portchannel_global
118
+ global.resilient = true
119
+ assert(global.resilient)
120
+ global.resilient = global.default_resilient
121
+ assert_equal(global.default_resilient, global.resilient)
122
+ end
123
+ rescue Cisco::CliError => e
124
+ check_and_raise_error(e, 'This feature is not supported on this platform')
125
+ end
126
+
127
+ def test_load_balance_no_rotate_no_symmetry
128
+ skip('Test not supported on this platform') unless n3k_in_n3k_mode?
129
+
130
+ global = create_portchannel_global
131
+ global.send(:port_channel_load_balance=,
132
+ 'src-dst', 'ip-only', nil, nil, false, nil, nil)
133
+ assert_equal('src-dst',
134
+ global.bundle_select)
135
+ assert_equal('ip-only',
136
+ global.bundle_hash)
137
+ assert_equal(false, global.symmetry)
138
+ global.send(
139
+ :port_channel_load_balance=,
140
+ global.default_bundle_select,
141
+ global.default_bundle_hash,
142
+ nil,
143
+ nil,
144
+ global.default_symmetry,
145
+ nil,
146
+ nil)
147
+ assert_equal(
148
+ global.default_bundle_select,
149
+ global.bundle_select)
150
+ assert_equal(
151
+ global.default_bundle_hash,
152
+ global.bundle_hash)
153
+ assert_equal(
154
+ global.default_symmetry,
155
+ global.symmetry)
156
+ end
157
+
158
+ def test_load_balance_no_rotate
159
+ skip('Test not supported on this platform') unless
160
+ n3k_is_t2? && n3k_in_n3k_mode?
161
+
162
+ global = create_portchannel_global
163
+ global.send(:port_channel_load_balance=,
164
+ 'src-dst', 'ip-only', nil, nil, true, nil, nil)
165
+ assert_equal('src-dst',
166
+ global.bundle_select)
167
+ assert_equal('ip-only',
168
+ global.bundle_hash)
169
+ assert_equal(true, global.symmetry)
170
+ global.send(
171
+ :port_channel_load_balance=,
172
+ global.default_bundle_select,
173
+ global.default_bundle_hash,
174
+ nil,
175
+ nil,
176
+ global.default_symmetry,
177
+ nil,
178
+ nil)
179
+ assert_equal(
180
+ global.default_bundle_select,
181
+ global.bundle_select)
182
+ assert_equal(
183
+ global.default_bundle_hash,
184
+ global.bundle_hash)
185
+ assert_equal(
186
+ global.default_symmetry,
187
+ global.symmetry)
188
+ end
189
+
190
+ def test_load_balance_sym_concat_rot
191
+ # rubocop:disable Style/MultilineOperationIndentation
192
+ skip('Test not supported on this platform') if n3k_in_n3k_mode? ||
193
+ validate_property_excluded?('portchannel_global', 'symmetry')
194
+ # rubocop:enable Style/MultilineOperationIndentation
195
+ # TBD: concat not supported; add N9k-EX to allowed platforms list and
196
+ # use proper _exclude tags
197
+ skip('TBD: Limited support for N9k-EX') if node.product_id[/N9K.*EX/]
198
+
199
+ global = create_portchannel_global
200
+ global.send(:port_channel_load_balance=,
201
+ 'src-dst', 'ip-l4port', nil, nil, true, true, 4)
202
+ assert_equal('src-dst',
203
+ global.bundle_select)
204
+ assert_equal('ip-l4port',
205
+ global.bundle_hash)
206
+ assert_equal(true, global.symmetry)
207
+ assert_equal(true, global.concatenation)
208
+ assert_equal(4, global.rotate)
209
+ global.send(
210
+ :port_channel_load_balance=,
211
+ global.default_bundle_select,
212
+ global.default_bundle_hash,
213
+ nil,
214
+ nil,
215
+ global.default_symmetry,
216
+ global.default_concatenation,
217
+ global.default_rotate)
218
+ assert_equal(
219
+ global.default_bundle_select,
220
+ global.bundle_select)
221
+ assert_equal(
222
+ global.default_bundle_hash,
223
+ global.bundle_hash)
224
+ assert_equal(
225
+ global.default_symmetry,
226
+ global.symmetry)
227
+ assert_equal(
228
+ global.default_concatenation,
229
+ global.concatenation)
230
+ assert_equal(global.default_rotate,
231
+ global.rotate)
232
+ end
233
+
234
+ # assert_hash_poly_crc
235
+ # Depending on the chipset, hash_poly may have have a different
236
+ # default value within the same platform family (this is done to
237
+ # avoid polarization) but there is currently no command available
238
+ # to dynamically determine the default state. As a result the
239
+ # getter simply hard-codes a default value which means it may
240
+ # encounter occasional idempotence issues.
241
+ # For testing purposes this becomes a best-effort test; i.e. we expect the
242
+ # hash_poly test to pass for all asserts except the one that matches the
243
+ # default value for that chipset.
244
+ def assert_hash_poly_crc(exp, actual)
245
+ assert_equal(exp, actual) if exp == actual
246
+ end
247
+
248
+ def test_load_balance_hash_poly
249
+ global = create_portchannel_global
250
+ if validate_property_excluded?('portchannel_global', 'hash_poly')
251
+ skip('Test not supported on this platform')
252
+ return
253
+ end
254
+
255
+ global.send(:port_channel_load_balance=,
256
+ 'src-dst', 'ip-only', 'CRC10c', nil, nil, nil, nil)
257
+ assert_equal('src-dst', global.bundle_select)
258
+ assert_equal('ip-only', global.bundle_hash)
259
+ assert_hash_poly_crc('CRC10c', global.hash_poly)
260
+
261
+ global.send(:port_channel_load_balance=,
262
+ 'dst', 'mac', 'CRC10a', nil, nil, nil, nil)
263
+ assert_equal('dst', global.bundle_select)
264
+ assert_equal('mac', global.bundle_hash)
265
+ assert_hash_poly_crc('CRC10a', global.hash_poly)
266
+
267
+ global.send(:port_channel_load_balance=,
268
+ global.default_bundle_select,
269
+ global.default_bundle_hash,
270
+ 'CRC10b', nil, nil, nil, nil)
271
+ assert_equal(global.default_bundle_select, global.bundle_select)
272
+ assert_equal(global.default_bundle_hash, global.bundle_hash)
273
+ assert_hash_poly_crc('CRC10b', global.hash_poly)
274
+ end
275
+
276
+ def test_load_balance_asym_rot
277
+ global = create_portchannel_global
278
+ if validate_property_excluded?('portchannel_global', 'asymmetric')
279
+ skip('Test not supported on this platform')
280
+ return
281
+ end
282
+
283
+ global.send(:port_channel_load_balance=,
284
+ 'src-dst', 'ip-vlan', nil, true, nil, nil, 4)
285
+ assert_equal('src-dst', global.bundle_select)
286
+ assert_equal('ip-vlan', global.bundle_hash)
287
+ assert_equal(true, global.asymmetric)
288
+ assert_equal(4, global.rotate)
289
+
290
+ global.send(:port_channel_load_balance=,
291
+ global.default_bundle_select,
292
+ global.default_bundle_hash,
293
+ nil, global.default_asymmetric,
294
+ nil, nil, global.default_rotate)
295
+ assert_equal(global.default_bundle_select, global.bundle_select)
296
+ assert_equal(global.default_bundle_hash, global.bundle_hash)
297
+ assert_equal(global.default_asymmetric, global.asymmetric)
298
+ assert_equal(global.default_rotate, global.rotate)
299
+ end
300
+
301
+ def test_load_balance_no_hash_rot
302
+ global = create_portchannel_global
303
+ if validate_property_excluded?('portchannel_global', 'rotate')
304
+ skip('Test not supported on this platform')
305
+ return
306
+ end
307
+ global.send(:port_channel_load_balance=,
308
+ 'src-dst', 'ip-vlan', nil, nil, nil, nil, 4)
309
+ assert_equal('src-dst', global.bundle_select)
310
+ assert_equal('ip-vlan', global.bundle_hash)
311
+ assert_equal(4, global.rotate)
312
+
313
+ global.send(:port_channel_load_balance=,
314
+ global.default_bundle_select,
315
+ global.default_bundle_hash,
316
+ nil, nil,
317
+ nil, nil, global.default_rotate)
318
+ assert_equal(global.default_bundle_select, global.bundle_select)
319
+ assert_equal(global.default_bundle_hash, global.bundle_hash)
320
+ assert_equal(global.default_rotate, global.rotate)
321
+ end
322
+ end
@@ -0,0 +1,108 @@
1
+ #
2
+ # Minitest for RadiusGlobal class
3
+ #
4
+ # Copyright (c) 2014-2016 Cisco and/or its affiliates.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require_relative 'ciscotest'
19
+ require_relative '../lib/cisco_node_utils/radius_global'
20
+
21
+ # TestRadiusGlobal - Minitest for RadiusGlobal node utility.
22
+ class TestRadiusGlobal < CiscoTestCase
23
+ @skip_unless_supported = 'radius_global'
24
+
25
+ def setup
26
+ # setup runs at the beginning of each test
27
+ super
28
+ no_radius_global
29
+ end
30
+
31
+ def teardown
32
+ # teardown runs at the end of each test
33
+ no_radius_global
34
+ super
35
+ end
36
+
37
+ def no_radius_global
38
+ # Turn the feature off for a clean test.
39
+ config('no radius-server timeout 2',
40
+ 'no radius-server retransmit 3')
41
+ end
42
+
43
+ # TESTS
44
+
45
+ def test_radius_global
46
+ id = 'default'
47
+
48
+ global = Cisco::RadiusGlobal.new(id)
49
+ assert_includes(Cisco::RadiusGlobal.radius_global, id)
50
+ assert_equal(Cisco::RadiusGlobal.radius_global[id], global)
51
+
52
+ # Default Checking
53
+ assert_equal(global.timeout, global.default_timeout)
54
+ assert_equal(global.retransmit_count, global.default_retransmit_count)
55
+
56
+ global.retransmit_count = 3
57
+ assert_equal(Cisco::RadiusGlobal.radius_global[id].retransmit_count,
58
+ 3)
59
+ assert_equal(global.retransmit_count,
60
+ 3)
61
+
62
+ global.timeout = 2
63
+ assert_equal(Cisco::RadiusGlobal.radius_global[id].timeout,
64
+ 2)
65
+ assert_equal(global.timeout,
66
+ 2)
67
+
68
+ if platform == :nexus
69
+ key = 'aaaAAAGGTTYTYY 44444444 72'
70
+ global.key_set(key, 7)
71
+ assert_match(/#{key}/, global.key)
72
+ assert_match(/#{key}/, Cisco::RadiusGlobal.radius_global[id].key)
73
+ assert_equal(7, global.key_format)
74
+ unless Platform.image_version[/I2|I4/] # legacy defect CSCvb57180
75
+ # Change to type 6
76
+ key = 'JDYkqyIFWeBvzpljSfWmRZrmRSRE8'
77
+ global.key_set(key, 6)
78
+ assert_match(/#{key}/, global.key)
79
+ assert_equal(6, global.key_format)
80
+ end
81
+ elsif platform == :ios_xr
82
+ global.key_set('QsEfThUkO', nil)
83
+ assert(!global.key.nil?)
84
+ assert(!Cisco::RadiusGlobal.radius_global[id].key.nil?)
85
+ end
86
+
87
+ # Setting back to default and re-checking
88
+ global.timeout = nil
89
+ global.retransmit_count = nil
90
+ global.key_set(nil, nil)
91
+ assert_equal(global.timeout, global.default_timeout)
92
+ assert_equal(global.retransmit_count, global.default_retransmit_count)
93
+ assert_nil(global.key)
94
+
95
+ # Default source interface
96
+ global.source_interface = global.default_source_interface
97
+ assert_nil(global.source_interface)
98
+
99
+ # Set source interface
100
+ interface = 'loopback0'
101
+ global.source_interface = interface
102
+ assert_equal(interface, global.source_interface)
103
+
104
+ # Remove source interface
105
+ global.source_interface = nil
106
+ assert_nil(global.source_interface)
107
+ end
108
+ end