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,326 @@
1
+ # Copyright (c) 2013-2018 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/vxlan_vtep'
17
+ require_relative '../lib/cisco_node_utils/vxlan_vtep_vni'
18
+ require_relative '../lib/cisco_node_utils/evpn_multisite'
19
+
20
+ include Cisco
21
+
22
+ # TestVxlanVtepVni - Minitest for VxlanVtepVni node utility
23
+ class TestVxlanVtepVni < CiscoTestCase
24
+ @skip_unless_supported = 'vxlan_vtep_vni'
25
+ @@pre_clean_needed = true # rubocop:disable Style/ClassVars
26
+ @@feature_unsupported = false # rubocop:disable Style/ClassVars
27
+
28
+ def setup
29
+ super
30
+ skip('setup: Feature is unsupported on this device') if @@feature_unsupported
31
+ vdc_limit_f3_no_intf_needed(:set) if VxlanVtep.mt_full_support
32
+ Interface.interfaces(:nve).each { |_nve, obj| obj.destroy }
33
+ feature_cleanup if @@pre_clean_needed
34
+ Feature.nv_overlay_enable
35
+ config_no_warn('feature vn-segment-vlan-based') if VxlanVtep.mt_lite_support
36
+ @@pre_clean_needed = false # rubocop:disable Style/ClassVars
37
+ rescue RuntimeError => e
38
+ # Skip locally to shortcut the dependencies above for the next test
39
+ @@feature_unsupported = hardware_supports_feature?(e.message, status_only: true) # rubocop:disable Style/ClassVars
40
+ @@feature_unsupported ? skip(e.message) : raise(e.message)
41
+ end
42
+
43
+ def teardown
44
+ if first_or_last_teardown
45
+ vdc_limit_f3_no_intf_needed(:clear)
46
+ feature_cleanup
47
+ end
48
+ super
49
+ end
50
+
51
+ def feature_cleanup
52
+ config_no_warn('no feature-set fabricpath')
53
+ config_no_warn('no feature vni')
54
+ config_no_warn('no feature vn-segment-vlan-based')
55
+ config_no_warn('no nv overlay evpn ; no feature nv overlay')
56
+ # Rapid nv feature toggle can cause failures on some platforms;
57
+ # symptom e.g. 'show runn | i ^feature' will hang
58
+ sleep 5
59
+ end
60
+
61
+ def test_create_with_existing
62
+ VxlanVtep.new('nve1').host_reachability = 'evpn'
63
+ associate_vrf = true
64
+ member = '5000'
65
+
66
+ VxlanVtepVni.new('nve1', member)
67
+ assert_includes(VxlanVtepVni.vnis['nve1'], member)
68
+
69
+ VxlanVtepVni.new('nve1', member, associate_vrf)
70
+ assert_includes(VxlanVtepVni.vnis['nve1'], member)
71
+ assert(VxlanVtepVni.vnis['nve1'], associate_vrf)
72
+
73
+ VxlanVtepVni.new('nve1', member)
74
+ assert_includes(VxlanVtepVni.vnis['nve1'], member)
75
+ end
76
+
77
+ def test_vnis
78
+ VxlanVtep.new('nve1')
79
+ skip('Platform does not support vnis') if VxlanVtepVni.vnis['nve1'].nil?
80
+
81
+ # Test empty case
82
+ assert_empty(VxlanVtepVni.vnis['nve1'])
83
+
84
+ # Host reachablity must be set to evpn for associate_vrf
85
+ # testing.
86
+ VxlanVtep.new('nve1').host_reachability = 'evpn'
87
+ associate_vrf = true
88
+
89
+ # Create one
90
+ member1 = '5000'
91
+ vni1 = VxlanVtepVni.new('nve1', member1, associate_vrf)
92
+ assert_includes(VxlanVtepVni.vnis['nve1'], member1)
93
+ assert(VxlanVtepVni.vnis['nve1'], associate_vrf)
94
+ assert_equal(VxlanVtepVni.vnis['nve1'][member1], vni1)
95
+
96
+ # Create several
97
+ member2 = '5001-6001'
98
+ member3 = '8888'
99
+ refute_includes(VxlanVtepVni.vnis['nve1'], member2)
100
+ refute_includes(VxlanVtepVni.vnis['nve1'], member3)
101
+
102
+ vni2 = VxlanVtepVni.new('nve1', member2)
103
+ vni3 = VxlanVtepVni.new('nve1', member3)
104
+ assert_includes(VxlanVtepVni.vnis['nve1'], member2)
105
+ assert_equal(VxlanVtepVni.vnis['nve1'][member2], vni2)
106
+ assert_includes(VxlanVtepVni.vnis['nve1'], member3)
107
+ assert_equal(VxlanVtepVni.vnis['nve1'][member3], vni3)
108
+
109
+ # Destroy one
110
+ vni2.destroy
111
+ refute_includes(VxlanVtepVni.vnis['nve1'], member2)
112
+ refute_equal(VxlanVtepVni.vnis['nve1'][member2], vni2)
113
+
114
+ # Destroy all
115
+ vni1.destroy
116
+ vni3.destroy
117
+ assert_empty(VxlanVtepVni.vnis['nve1'])
118
+ end
119
+
120
+ def test_ingress_replication
121
+ skip_legacy_defect?('7.0.3.I3.1',
122
+ 'CSCuy27700: Validation failed for vni mcast group configured')
123
+
124
+ vni = VxlanVtepVni.new('nve1', '5000')
125
+ if validate_property_excluded?('vxlan_vtep_vni', 'ingress_replication')
126
+ assert_raises(Cisco::UnsupportedError) { vni.ingress_replication = 'bgp' }
127
+ return
128
+ end
129
+
130
+ # Test non-default values
131
+ vni.ingress_replication = 'static'
132
+ assert_equal('static', vni.ingress_replication)
133
+
134
+ vni.ingress_replication = 'bgp'
135
+ assert_equal('bgp', vni.ingress_replication)
136
+
137
+ # Test default case
138
+ ir = vni.default_ingress_replication
139
+ vni.ingress_replication = ir
140
+ assert_equal(ir, vni.ingress_replication)
141
+
142
+ # Test the case where an existing multicast_group is removed before
143
+ # configuring ingress_replication
144
+ vni.multicast_group = '224.1.1.1'
145
+ assert_equal('224.1.1.1', vni.multicast_group)
146
+
147
+ vni.ingress_replication = 'static'
148
+ assert_equal('static', vni.ingress_replication)
149
+ end
150
+
151
+ def test_multicast_group
152
+ skip_legacy_defect?('7.0.3.I3.1',
153
+ 'CSCuy27700: Validation failed for vni mcast group configured')
154
+
155
+ vni1 = VxlanVtepVni.new('nve1', '6000')
156
+ vni2 = VxlanVtepVni.new('nve1', '8001-8200')
157
+
158
+ # No multicast groups configured
159
+ assert_empty(vni1.multicast_group)
160
+
161
+ # Test single multicast group
162
+ vni1.multicast_group = '224.1.1.1'
163
+ assert_equal('224.1.1.1', vni1.multicast_group)
164
+
165
+ # Test the case where an existing ingress_replication is removed before
166
+ # configuring multicast_group
167
+ unless validate_property_excluded?('vxlan_vtep_vni', 'ingress_replication')
168
+ vni1.ingress_replication = 'static'
169
+ assert_equal('static', vni1.ingress_replication)
170
+
171
+ vni1.multicast_group = '224.1.1.1'
172
+ assert_equal('224.1.1.1', vni1.multicast_group)
173
+ end
174
+
175
+ # Test multicast group range
176
+ vni2.multicast_group = '224.1.1.1 224.1.1.200'
177
+ assert_equal('224.1.1.1 224.1.1.200', vni2.multicast_group)
178
+
179
+ # Test default
180
+ vni1.multicast_group = vni1.default_multicast_group
181
+ assert_empty(vni1.multicast_group)
182
+ vni2.multicast_group = vni2.default_multicast_group
183
+ assert_empty(vni2.multicast_group)
184
+ end
185
+
186
+ def test_peer_list
187
+ vni = VxlanVtepVni.new('nve1', '6000')
188
+ if validate_property_excluded?('vxlan_vtep_vni', 'peer_list')
189
+ assert_raises(Cisco::UnsupportedError) { vni.peer_list = ['1.1.1.1'] }
190
+ return
191
+ end
192
+
193
+ peer_list = ['1.1.1.1', '2.2.2.2', '3.3.3.3', '4.4.4.4']
194
+
195
+ # Test: all peers when current is empty
196
+ should = peer_list.clone
197
+ vni.peer_list = should
198
+ result = vni.peer_list
199
+ assert_equal(should.sort, result.sort,
200
+ 'Test 1. From empty, to all peers')
201
+
202
+ # Test: remove half of the peers
203
+ should.shift(2)
204
+ vni.peer_list = should
205
+ result = vni.peer_list
206
+ assert_equal(should.sort, result.sort,
207
+ 'Test 2. Remove half of the peers')
208
+
209
+ # Test: restore removed peers
210
+ should = peer_list.clone
211
+ vni.peer_list = should
212
+ result = vni.peer_list
213
+ assert_equal(should.sort, result.sort,
214
+ 'Test 3. Restore removed peers')
215
+
216
+ # Test: default
217
+ should = vni.default_peer_list
218
+ vni.peer_list = should
219
+ result = vni.peer_list
220
+ assert_equal(should.sort, result.sort,
221
+ 'Test 4. Default')
222
+ end
223
+
224
+ def test_suppress_arp
225
+ vni = VxlanVtepVni.new('nve1', '6000')
226
+ VxlanVtep.new('nve1').host_reachability = 'evpn'
227
+
228
+ # Test: Check suppress_arp is not configured.
229
+ refute(vni.suppress_arp, 'suppress_arp should be disabled')
230
+
231
+ begin
232
+ # Test: Enable suppress_arp
233
+ vni.suppress_arp = true
234
+ assert(vni.suppress_arp, 'suppress_arp should be enabled')
235
+ rescue CliError => e
236
+ msg = 'TCAM reconfiguration required followed by reload' \
237
+ " Skipping test case.\n#{e}"
238
+ skip(msg) if /ERROR: Please configure TCAM/.match(e.to_s)
239
+ end
240
+
241
+ # Test: Default
242
+ vni.suppress_arp = vni.default_suppress_arp
243
+ refute(vni.suppress_arp, 'suppress_arp should be disabled')
244
+ end
245
+
246
+ def test_suppress_arp_disable
247
+ skip_incompat_version?('vxlan_vtep_vni', 'suppress_arp_disable')
248
+ vni = VxlanVtepVni.new('nve1', '6000')
249
+ VxlanVtep.new('nve1').host_reachability = 'evpn'
250
+
251
+ if validate_property_excluded?('vxlan_vtep_vni', 'suppress_arp_disable')
252
+ assert_raises(Cisco::UnsupportedError) { vni.suppress_arp_disable = true }
253
+ return
254
+ end
255
+
256
+ # Test: Check suppress_arp_disable is not configured.
257
+ refute(vni.suppress_arp_disable, 'suppress_arp_disable should be disabled')
258
+
259
+ begin
260
+ # Test: Enable suppress_arp_disable
261
+ vni.suppress_arp_disable = true
262
+ assert(vni.suppress_arp_disable, 'suppress_arp_disable should be enabled')
263
+ rescue CliError => e
264
+ msg = 'TCAM reconfiguration required followed by reload' \
265
+ " Skipping test case.\n#{e}"
266
+ skip(msg) if /ERROR: Please configure TCAM/.match(e.to_s)
267
+ end
268
+
269
+ # Test: Default
270
+ vni.suppress_arp_disable = vni.default_suppress_arp_disable
271
+ refute(vni.suppress_arp_disable, 'suppress_arp_disable should be disabled')
272
+ end
273
+
274
+ def test_suppress_uuc
275
+ vni = VxlanVtepVni.new('nve1', '6000')
276
+ VxlanVtep.new('nve1').host_reachability = 'evpn'
277
+ if validate_property_excluded?('vxlan_vtep_vni', 'suppress_uuc')
278
+ assert_nil(vni.suppress_uuc)
279
+ assert_nil(vni.default_suppress_uuc)
280
+ assert_raises(Cisco::UnsupportedError) { vni.suppress_uuc = true }
281
+ return
282
+ end
283
+
284
+ skip_incompat_version?('vxlan_vtep_vni', 'suppress_uuc')
285
+ # Test: Check suppress_uuc is not configured.
286
+ refute(vni.suppress_uuc, 'suppress_uuc should be disabled')
287
+
288
+ # Test: Enable suppress_uuc
289
+ vni.suppress_uuc = true
290
+ assert(vni.suppress_uuc, 'suppress_uuc should be enabled')
291
+
292
+ # Test: Default
293
+ vni.suppress_uuc = vni.default_suppress_uuc
294
+ refute(vni.suppress_uuc, 'suppress_uuc should be disabled')
295
+ end
296
+
297
+ def test_multisite_ingress_replication
298
+ skip("#{node.product_id} doesn't support this feature") unless
299
+ node.product_id[/N9K.*EX/]
300
+
301
+ vni = VxlanVtepVni.new('nve1', '6000')
302
+ ms = EvpnMultisite.new(100)
303
+
304
+ # Test: Default
305
+ vni.multisite_ingress_replication =
306
+ vni.default_multisite_ingress_replication
307
+ refute(vni.multisite_ingress_replication,
308
+ 'multisite ingress-replication should be disabled')
309
+
310
+ # Test: Enable multisite_ingress_replication
311
+ vni.multisite_ingress_replication = true
312
+ assert(vni.multisite_ingress_replication,
313
+ 'multisite ingress-replication should be enabled')
314
+
315
+ # Test: Disable multisite_ingress_replication
316
+ vni.multisite_ingress_replication = false
317
+ refute(vni.multisite_ingress_replication,
318
+ 'multisite ingress-replication should be disabled')
319
+
320
+ ms.destroy
321
+ # Test: enabling multisite ingress-replication without a multisite bg errors
322
+ assert_raises(Cisco::CliError) do
323
+ vni.multisite_ingress_replication = true
324
+ end
325
+ end
326
+ end
@@ -0,0 +1,369 @@
1
+ #!/usr/bin/env ruby
2
+ # Yang Unit Tests
3
+ #
4
+ # Charles Burkett, May, 2016
5
+ #
6
+ # Copyright (c) 2015-2016 Cisco and/or its affiliates.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require_relative 'ciscotest'
21
+ require_relative '../lib/cisco_node_utils/yang'
22
+
23
+ # TestYang - Minitest for Yang class
24
+ class TestYang < CiscoTestCase
25
+ BLUE_VRF = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
26
+ "vrf":[
27
+ {
28
+ "vrf-name":"BLUE",
29
+ "description":"Generic external traffic",
30
+ "create":[
31
+ null
32
+ ]
33
+ }
34
+ ]
35
+ }}'
36
+
37
+ RED_VRF = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
38
+ "vrf":[
39
+ {
40
+ "vrf-name":"RED",
41
+ "create":[
42
+ null
43
+ ]
44
+ }
45
+ ]
46
+ }}'
47
+
48
+ GREEN_VRF = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
49
+ "vrf":[
50
+ {
51
+ "vrf-name":"GREEN",
52
+ "create": [null]
53
+ }
54
+ ]
55
+ }}'
56
+
57
+ BLUE_GREEN_VRF = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
58
+ "vrf":[
59
+ {
60
+ "vrf-name":"BLUE",
61
+ "create":[null],
62
+ "description":"Generic external traffic"
63
+ },
64
+ {
65
+ "vrf-name":"GREEN",
66
+ "create":[null]
67
+ }
68
+ ]
69
+ }}'
70
+
71
+ BLUE_VRF_NO_PROPERTIES = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
72
+ "vrf":[
73
+ {
74
+ "vrf-name":"BLUE",
75
+ "create":[
76
+ null
77
+ ]
78
+ }
79
+ ]
80
+ }}'
81
+
82
+ BLUE_VRF_PROPERTIES1 = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
83
+ "vrf":[
84
+ {
85
+ "vrf-name":"BLUE",
86
+ "create":[
87
+ null
88
+ ],
89
+ "vpn-id":{
90
+ "vpn-oui":0,
91
+ "vpn-index":0
92
+ }
93
+ }
94
+ ]
95
+ }}'
96
+
97
+ BLUE_VRF_PROPERTIES2 = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
98
+ "vrf":[
99
+ {
100
+ "vrf-name":"BLUE",
101
+ "description":"Generic external traffic",
102
+ "create":[
103
+ null
104
+ ],
105
+ "vpn-id":{
106
+ "vpn-oui":0,
107
+ "vpn-index":0
108
+ }
109
+ }
110
+ ]
111
+ }}'
112
+
113
+ BLUE_VRF_PROPERTIES3 = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs":{
114
+ "vrf":[
115
+ {
116
+ "vrf-name":"BLUE",
117
+ "description":"Generic ext traffic",
118
+ "create":[
119
+ null
120
+ ],
121
+ "vpn-id":{
122
+ "vpn-oui":8,
123
+ "vpn-index":9
124
+ }
125
+ }
126
+ ]
127
+ }}'
128
+
129
+ NO_VRFS = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs": [null]}'
130
+ PATH_VRFS = '{"Cisco-IOS-XR-infra-rsi-cfg:vrfs": [null]}'
131
+
132
+ def self.runnable_methods
133
+ return [:all_skipped] unless platform == :ios_xr
134
+ super
135
+ end
136
+
137
+ def all_skipped
138
+ puts 'Node under test does not appear to use the gRPC client'
139
+ assert(validate_property_excluded?('yang', 'support'))
140
+ end
141
+
142
+ def setup
143
+ super
144
+ clear_vrfs
145
+ end
146
+
147
+ def teardown
148
+ super
149
+ clear_vrfs
150
+ end
151
+
152
+ def clear_vrfs
153
+ return unless platform == :ios_xr
154
+ current_vrfs = node.get_yang(PATH_VRFS)
155
+
156
+ # remove all vrfs
157
+ node.delete_yang(PATH_VRFS) unless Yang.empty?(current_vrfs)
158
+ end
159
+
160
+ def test_delete_vrfs
161
+ node.merge_yang(BLUE_VRF) # ensure at least one VRF is there
162
+ assert(node.get_yang(PATH_VRFS).match('BLUE'), 'Did not find the BLUE vrf')
163
+
164
+ clear_vrfs
165
+ assert_equal('', node.get_yang(PATH_VRFS),
166
+ 'There are still vrfs configured')
167
+ end
168
+
169
+ def test_add_vrf
170
+ node.merge_yang(BLUE_VRF) # create a single VRF
171
+ assert(node.get_yang(PATH_VRFS).match('BLUE'), 'Did not find the BLUE vrf')
172
+
173
+ node.replace_yang(GREEN_VRF) # create a single VRF
174
+ assert(node.get_yang(PATH_VRFS).match('GREEN'),
175
+ 'Did not find the GREEN vrf')
176
+ refute(node.get_yang(PATH_VRFS).match('BLUE'),
177
+ 'Found the BLUE vrf')
178
+ end
179
+
180
+ def test_errors
181
+ # Note: Originally, we were checking for YangErrors and ClientErrors,
182
+ # but the type of error raised seemed to change from one XR image to the
183
+ # next, so now we check for the more general CiscoError in these tests.
184
+
185
+ # === test get_yang ===========
186
+
187
+ # Request is not wellformed
188
+ assert_raises(Cisco::CiscoError) { node.get_yang('aabbcc') }
189
+
190
+ # parse error: object key and value must be separated by a colon
191
+ assert_raises(Cisco::CiscoError) { node.get_yang('{"aabbcc"}') }
192
+
193
+ # unknown-namespace
194
+ assert_raises(Cisco::CiscoError) { node.get_yang('{"aabbcc": "foo"}') }
195
+
196
+ # unknown-element
197
+ assert_raises(Cisco::CiscoError) do
198
+ node.get_yang('{"Cisco-IOS-XR-infra-rsi-cfg:aabbcc": "foo"}')
199
+ end
200
+
201
+ # parse error: premature EOF
202
+ assert_raises(Cisco::CiscoError) { node.get_yang('{') }
203
+
204
+ # parse error: invalid object key (must be a string)
205
+ assert_raises(Cisco::CiscoError) { node.get_yang('{: "foo"}') }
206
+
207
+ # === test merge_yang ===========
208
+
209
+ # Request is not wellformed
210
+ assert_raises(Cisco::CiscoError) { node.merge_yang('aabbcc') }
211
+
212
+ # unknown-element
213
+ assert_raises(Cisco::CiscoError) do
214
+ node.merge_yang('{"Cisco-IOS-XR-infra-rsi-cfg:aabbcc": "foo"}')
215
+ end
216
+
217
+ # bad-element
218
+ assert_raises(Cisco::CiscoError) do
219
+ node.merge_yang('{"Cisco-IOS-XR-infra-rsi-cfg:vrfs": "foo"}')
220
+ end
221
+
222
+ # missing-element
223
+ assert_raises(Cisco::CiscoError) do
224
+ node.merge_yang('{"Cisco-IOS-XR-infra-rsi-cfg:vrfs": {"vrf":[{}]}}')
225
+ end
226
+
227
+ # === test replace_yang ===========
228
+
229
+ # unknown-namespace
230
+ assert_raises(Cisco::CiscoError) do
231
+ node.replace_yang('{"Cisco-IOS-XR-infra-rsi-cfg:aabbcc": "foo"}')
232
+ end
233
+
234
+ # Request is not wellformed
235
+ assert_raises(Cisco::CiscoError) do
236
+ node.replace_yang('{"Cisco-IOS-XR-infra-rsi-cfg:vrfs": }')
237
+ end
238
+ end
239
+
240
+ def test_merge_diff
241
+ # ensure we think that a merge is needed (in-sinc = false)
242
+ refute(Yang.insync_for_merge?(BLUE_VRF, node.get_yang(PATH_VRFS)),
243
+ 'Expected not in-sync')
244
+
245
+ node.merge_yang(BLUE_VRF) # create the blue VRF
246
+
247
+ # ensure we think that a merge is NOT needed (in-sinc = true)
248
+ assert(Yang.insync_for_merge?(BLUE_VRF, node.get_yang(PATH_VRFS)),
249
+ 'Expected in-sync')
250
+
251
+ # ensure we think that the merge is needed (in-sinc = false)
252
+ refute(Yang.insync_for_merge?(RED_VRF, node.get_yang(PATH_VRFS)),
253
+ 'Expected not in-sync')
254
+
255
+ node.merge_yang(RED_VRF) # create the red VRF
256
+
257
+ # ensure we think that a merge is NOT needed (in-sinc = true)
258
+ assert(Yang.insync_for_merge?(RED_VRF, node.get_yang(PATH_VRFS)),
259
+ 'Expected in-sync')
260
+
261
+ node.merge_yang(GREEN_VRF) # create green VRF
262
+ # ensure we think that a merge is NOT needed (in-sinc = true)
263
+ assert(Yang.insync_for_merge?(GREEN_VRF, node.get_yang(PATH_VRFS)),
264
+ 'Expected in-sync')
265
+ end
266
+
267
+ def test_replace_diff
268
+ # ensure we think that a merge is needed (in-sinc = false)
269
+ refute(Yang.insync_for_replace?(BLUE_VRF, node.get_yang(PATH_VRFS)),
270
+ 'Expected not in-sync')
271
+
272
+ node.replace_yang(BLUE_VRF) # create the blue VRF
273
+ # ensure we think that a replace is NOT needed (in-sinc = true)
274
+ assert(Yang.insync_for_replace?(BLUE_VRF, node.get_yang(PATH_VRFS)),
275
+ 'Expected in-sync')
276
+
277
+ node.replace_yang(RED_VRF) # create the red VRF
278
+ # ensure we think that a replace is NOT needed (in-sinc = true)
279
+ assert(Yang.insync_for_replace?(RED_VRF, node.get_yang(PATH_VRFS)),
280
+ 'Expected in-sync')
281
+
282
+ node.replace_yang(GREEN_VRF) # create green VRF
283
+ # ensure we think that a replace is NOT needed (in-sinc = true)
284
+ assert(Yang.insync_for_replace?(GREEN_VRF, node.get_yang(PATH_VRFS)),
285
+ 'Expected in-sync')
286
+
287
+ node.merge_yang(BLUE_VRF)
288
+
289
+ # ensure we think that a replace is NOT needed (in-sinc = true)
290
+ assert(Yang.insync_for_replace?(BLUE_GREEN_VRF, node.get_yang(PATH_VRFS)),
291
+ 'Expected in sync')
292
+ # ensure we think that a replace is needed (in-sinc = true)
293
+ refute(Yang.insync_for_replace?(BLUE_VRF, node.get_yang(PATH_VRFS)),
294
+ 'Expected not in sync')
295
+ refute(Yang.insync_for_replace?(GREEN_VRF, node.get_yang(PATH_VRFS)),
296
+ 'Expected not in sync')
297
+
298
+ node.replace_yang(BLUE_VRF)
299
+ # ensure we think that a replace is NOT needed (in-sinc = true)
300
+ assert(Yang.insync_for_replace?(BLUE_VRF, node.get_yang(PATH_VRFS)),
301
+ 'Expected in-sync')
302
+ # ensure we think that a replace is needed (in-sinc = true)
303
+ refute(Yang.insync_for_replace?(GREEN_VRF, node.get_yang(PATH_VRFS)),
304
+ 'Expected not in-sync')
305
+ refute(Yang.insync_for_replace?(BLUE_GREEN_VRF, node.get_yang(PATH_VRFS)),
306
+ 'Expected not in-sync')
307
+ end
308
+
309
+ def test_merge_leaves
310
+ node.merge_yang(BLUE_VRF) # create blue vrf with description
311
+
312
+ # merge blue vrf with vpn id to blue vrf with description
313
+ node.merge_yang(BLUE_VRF_PROPERTIES1)
314
+
315
+ # ensure that new leaves are merged with old.
316
+ assert(Yang.insync_for_merge?(BLUE_VRF_PROPERTIES2,
317
+ node.get_yang(PATH_VRFS)), 'Expected in-sync')
318
+
319
+ # update description and vpn-id
320
+ node.merge_yang(BLUE_VRF_PROPERTIES3)
321
+ assert(Yang.insync_for_merge?(BLUE_VRF_PROPERTIES3,
322
+ node.get_yang(PATH_VRFS)), 'Expected in-sync')
323
+ end
324
+
325
+ def test_replace_leaves
326
+ node.replace_yang(BLUE_VRF) # create blue vrf with description
327
+
328
+ # replace blue vrf (description) by blue vrf (vpn-id)
329
+ node.replace_yang(BLUE_VRF_PROPERTIES1)
330
+
331
+ # ensure that new properties are replaced by old.
332
+ assert(Yang.insync_for_replace?(BLUE_VRF_PROPERTIES1,
333
+ node.get_yang(PATH_VRFS)),
334
+ 'Expected in-sync')
335
+
336
+ # replace description and vpn-id
337
+ node.replace_yang(BLUE_VRF_PROPERTIES3)
338
+ assert(Yang.insync_for_replace?(BLUE_VRF_PROPERTIES3,
339
+ node.get_yang(PATH_VRFS)),
340
+ 'Expected in-sync')
341
+ end
342
+
343
+ def test_merge
344
+ node.merge_yang(BLUE_VRF) # create blue vrf
345
+ node.merge_yang(GREEN_VRF) # create green vrf
346
+
347
+ yang = node.get_yang(PATH_VRFS)
348
+
349
+ assert_yang_equal(BLUE_GREEN_VRF, yang)
350
+ end
351
+
352
+ def test_replace
353
+ node.merge_yang(BLUE_VRF) # create blue vrf
354
+ node.replace_yang(GREEN_VRF) # create green vrf
355
+
356
+ yang = node.get_yang(PATH_VRFS)
357
+
358
+ assert_yang_equal(GREEN_VRF, yang)
359
+ end
360
+
361
+ def assert_yang_equal(expected, actual)
362
+ equal = Yang.insync_for_replace?(expected, actual) &&
363
+ Yang.insync_for_replace?(actual, expected)
364
+ assert(equal,
365
+ "Expected: '#{expected}',\n"\
366
+ "Actual: '#{actual}',\n",
367
+ )
368
+ end
369
+ end