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,780 @@
1
+ #
2
+ # NXAPI implementation of RouterBgpNeighborAF class
3
+ #
4
+ # August 2015 Chris Van Heuveln
5
+ #
6
+ # Copyright (c) 2015-2016 Cisco and/or its affiliates.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require_relative 'cisco_cmn_utils'
21
+ require_relative 'node_util'
22
+ require_relative 'feature'
23
+ require_relative 'bgp'
24
+
25
+ module Cisco
26
+ # RouterBgpNeighborAF - node utility class for BGP per-neighbor, per-AF config
27
+ class RouterBgpNeighborAF < NodeUtil
28
+ def initialize(asn, vrf, nbr, af, ra=nil, instantiate=true)
29
+ validate_args(asn, vrf, nbr, af, ra)
30
+ create if instantiate
31
+ end
32
+
33
+ def self.afs
34
+ af_hash = {}
35
+ RouterBgp.routers.each do |asn, vrfs|
36
+ af_hash[asn] = {}
37
+
38
+ vrfs.keys.each do |vrf|
39
+ af_hash[asn][vrf] = {}
40
+ get_args = { asnum: asn }
41
+ get_args[:vrf] = vrf unless vrf == 'default'
42
+
43
+ nbrs = config_get('bgp_neighbor', 'all_neighbors', get_args)
44
+ next if nbrs.nil?
45
+ nbrs.each do |nbr, ra|
46
+ af_hash[asn][vrf][nbr] = {}
47
+ get_args[:nbr] = nbr
48
+ get_args[:ra] = ra
49
+ afs = config_get('bgp_neighbor_af', 'all_afs', get_args)
50
+
51
+ next if afs.nil?
52
+ afs.each do |af|
53
+ af_hash[asn][vrf][nbr][af] =
54
+ RouterBgpNeighborAF.new(asn, vrf, nbr, af, ra, false)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ af_hash
60
+ rescue Cisco::CliError => e
61
+ # cmd will syntax reject when feature is not enabled
62
+ raise unless e.clierror =~ /Syntax error/
63
+ return {}
64
+ end
65
+
66
+ def validate_args(asn, vrf, nbr, af, ra)
67
+ fail ArgumentError unless
68
+ vrf.is_a?(String) && (vrf.length > 0)
69
+ fail ArgumentError unless
70
+ nbr.is_a?(String) && (nbr.length > 0)
71
+ fail ArgumentError, "'af' must be an array specifying afi and safi" unless
72
+ af.is_a?(Array) || af.length == 2
73
+
74
+ # XR BGP does not support <address>/<mask>
75
+ if platform == :ios_xr && nbr['/'] == '/'
76
+ fail UnsupportedError.new(
77
+ 'validate_args',
78
+ "IOS XR does not support 'slash' notation")
79
+ end
80
+
81
+ nbr = Utils.process_network_mask(nbr)
82
+ @asn = RouterBgp.validate_asnum(asn)
83
+ @vrf = vrf
84
+ @nbr = nbr
85
+ @ra = ra
86
+ @afi, @safi = af
87
+ set_args_keys_default
88
+ end
89
+
90
+ def set_args_keys_default
91
+ keys = { asnum: @asn, nbr: @nbr, ra: @ra, afi: @afi, safi: @safi }
92
+ keys[:vrf] = @vrf unless @vrf == 'default'
93
+ @get_args = @set_args = keys
94
+ end
95
+
96
+ # rubocop:disable Style/AccessorMethodName
97
+ def set_args_keys(hash={})
98
+ set_args_keys_default
99
+ @set_args = @get_args.merge!(hash) unless hash.empty?
100
+ end
101
+ # rubocop:enable Style/AccessorMethodNamefor
102
+
103
+ def create
104
+ if platform == :nexus
105
+ Feature.bgp_enable
106
+ Feature.nv_overlay_evpn_enable if @safi[/evpn/]
107
+ end
108
+ set_args_keys(state: '')
109
+ config_set('bgp_neighbor', 'af', @set_args)
110
+ end
111
+
112
+ def destroy
113
+ set_args_keys(state: 'no')
114
+ config_set('bgp_neighbor', 'af', @set_args)
115
+ end
116
+
117
+ ########################################################
118
+ # PROPERTIES #
119
+ ########################################################
120
+
121
+ # -----------------------
122
+ # <state> advertise-map <map1> exist-map <map2>
123
+
124
+ # Returns ['<map1>', '<map2>']
125
+ def advertise_map_exist
126
+ config_get('bgp_neighbor_af', 'advertise_map_exist', @get_args)
127
+ end
128
+
129
+ def advertise_map_exist=(arr)
130
+ if arr.empty?
131
+ state = 'no'
132
+ map1, map2 = advertise_map_exist
133
+ else
134
+ map1, map2 = arr
135
+ end
136
+ set_args_keys(state: state, map1: map1, map2: map2)
137
+ config_set('bgp_neighbor_af', 'advertise_map_exist', @set_args)
138
+ end
139
+
140
+ def default_advertise_map_exist
141
+ config_get_default('bgp_neighbor_af', 'advertise_map_exist')
142
+ end
143
+
144
+ # -----------------------
145
+ # <state> advertise-map <map1> non-exist-map <map2> }
146
+
147
+ # Returns ['<map1>', '<map2>']
148
+ def advertise_map_non_exist
149
+ config_get('bgp_neighbor_af', 'advertise_map_non_exist', @get_args)
150
+ end
151
+
152
+ def advertise_map_non_exist=(arr)
153
+ if arr.empty?
154
+ state = 'no'
155
+ map1, map2 = advertise_map_non_exist
156
+ else
157
+ map1, map2 = arr
158
+ end
159
+ set_args_keys(state: state, map1: map1, map2: map2)
160
+ config_set('bgp_neighbor_af', 'advertise_map_non_exist', @set_args)
161
+ end
162
+
163
+ def default_advertise_map_non_exist
164
+ config_get_default('bgp_neighbor_af', 'advertise_map_non_exist')
165
+ end
166
+
167
+ # -----------------------
168
+ # <state> allowas-in <max>
169
+ # Nvgens as True -OR- max-occurrences integer
170
+ def allowas_in_get
171
+ val = config_get('bgp_neighbor_af', 'allowas_in', @get_args)
172
+ return nil if val.nil?
173
+ val.split.last.to_i
174
+ end
175
+
176
+ def allowas_in
177
+ allowas_in_get.nil? ? false : true
178
+ end
179
+
180
+ def allowas_in_max
181
+ val = allowas_in_get
182
+ # val.zero? check below is needed to handle a cli defect wherein the
183
+ # default max value does not reliably nvgen
184
+ val = default_allowas_in_max if val.nil? || val.zero?
185
+ val
186
+ end
187
+
188
+ def allowas_in_set(state, max=nil)
189
+ set_args_keys(state: (state ? '' : 'no'), max: max)
190
+ config_set('bgp_neighbor_af', 'allowas_in', @set_args)
191
+ end
192
+
193
+ def default_allowas_in
194
+ config_get_default('bgp_neighbor_af', 'allowas_in')
195
+ end
196
+
197
+ def default_allowas_in_max
198
+ config_get_default('bgp_neighbor_af', 'allowas_in_max')
199
+ end
200
+
201
+ # -----------------------
202
+ # <state> as-override
203
+ def as_override
204
+ state = config_get('bgp_neighbor_af', 'as_override', @get_args)
205
+ state ? true : false
206
+ end
207
+
208
+ def as_override=(state)
209
+ set_args_keys(state: (state ? '' : 'no'))
210
+ config_set('bgp_neighbor_af', 'as_override', @set_args)
211
+ end
212
+
213
+ def default_as_override
214
+ config_get_default('bgp_neighbor_af', 'as_override')
215
+ end
216
+
217
+ # -----------------------
218
+ # <state> capability additional-paths receive <disable>
219
+ # :enable = capability additional-paths receive
220
+ # :disable = capability additional-paths receive disable
221
+ # :inherit = no capability additional-paths receive
222
+ def additional_paths_receive
223
+ val = config_get('bgp_neighbor_af', 'additional_paths_receive', @get_args)
224
+ return default_additional_paths_receive if val.nil?
225
+ /disable/.match(val) ? :disable : :enable
226
+ end
227
+
228
+ def additional_paths_receive=(val)
229
+ val = val.to_sym
230
+ if val == default_additional_paths_receive
231
+ set_args_keys(state: 'no', disable: '')
232
+ else
233
+ set_args_keys(state: '', disable: (val == :enable) ? '' : 'disable')
234
+ end
235
+ config_set('bgp_neighbor_af', 'additional_paths_receive', @set_args)
236
+ end
237
+
238
+ def default_additional_paths_receive
239
+ ret = config_get_default('bgp_neighbor_af', 'additional_paths_receive')
240
+ ret.to_sym unless ret.nil?
241
+ end
242
+
243
+ # -----------------------
244
+ # <state> capability additional-paths send <disable>
245
+ # :enable = capability additional-paths send
246
+ # :disable = capability additional-paths send disable
247
+ # :inherit = no capability additional-paths send
248
+ def additional_paths_send
249
+ val = config_get('bgp_neighbor_af', 'additional_paths_send', @get_args)
250
+ return default_additional_paths_send if val.nil?
251
+ /disable/.match(val) ? :disable : :enable
252
+ end
253
+
254
+ def additional_paths_send=(val)
255
+ val = val.to_sym
256
+ if val == default_additional_paths_send
257
+ set_args_keys(state: 'no', disable: '')
258
+ else
259
+ set_args_keys(state: '', disable: (val == :enable) ? '' : 'disable')
260
+ end
261
+ config_set('bgp_neighbor_af', 'additional_paths_send', @set_args)
262
+ end
263
+
264
+ def default_additional_paths_send
265
+ ret = config_get_default('bgp_neighbor_af', 'additional_paths_send')
266
+ ret.to_sym unless ret.to_s == ''
267
+ end
268
+
269
+ # -----------------------
270
+ # <state> default-originate [ route-map <map> ]
271
+ # Nvgens as True with optional 'route-map <map>'
272
+ def default_originate_get
273
+ val = config_get('bgp_neighbor_af', 'default_originate', @get_args)
274
+ return nil unless val
275
+ (val[/route-(map|policy)/]) ? val.split.last : true
276
+ end
277
+
278
+ def default_originate
279
+ default_originate_get.nil? ? false : true
280
+ end
281
+
282
+ def default_originate_route_map
283
+ val = default_originate_get
284
+ return default_default_originate_route_map if val.nil?
285
+ val.is_a?(String) ? val : nil
286
+ end
287
+
288
+ def default_originate_set(state, map=nil)
289
+ if platform == :ios_xr
290
+ map = "route-policy #{map}" unless map.nil?
291
+ else
292
+ map = "route-map #{map}" unless map.nil?
293
+ end
294
+ set_args_keys(state: (state ? '' : 'no'), map: map)
295
+ config_set('bgp_neighbor_af', 'default_originate', @set_args)
296
+ end
297
+
298
+ def default_default_originate
299
+ config_get_default('bgp_neighbor_af', 'default_originate')
300
+ end
301
+
302
+ def default_default_originate_route_map
303
+ config_get_default('bgp_neighbor_af', 'default_originate_route_map')
304
+ end
305
+
306
+ # -----------------------
307
+ # <state> disable-peer-as-check
308
+ def disable_peer_as_check
309
+ state = config_get('bgp_neighbor_af', 'disable_peer_as_check', @get_args)
310
+ state ? true : default_disable_peer_as_check
311
+ end
312
+
313
+ def disable_peer_as_check=(state)
314
+ set_args_keys(state: (state ? '' : 'no'))
315
+ config_set('bgp_neighbor_af', 'disable_peer_as_check', @set_args)
316
+ end
317
+
318
+ def default_disable_peer_as_check
319
+ config_get_default('bgp_neighbor_af', 'disable_peer_as_check')
320
+ end
321
+
322
+ # -----------------------
323
+ # <state> filter-list <str> in
324
+ def filter_list_in
325
+ config_get('bgp_neighbor_af', 'filter_list_in', @get_args)
326
+ end
327
+
328
+ def filter_list_in=(str)
329
+ str.strip! unless str.nil?
330
+ if str == default_filter_list_in
331
+ state = 'no'
332
+ # Current filter-list name is required for removal
333
+ str = filter_list_in
334
+ return if str.nil?
335
+ end
336
+ set_args_keys(state: state, str: str)
337
+ config_set('bgp_neighbor_af', 'filter_list_in', @set_args)
338
+ end
339
+
340
+ def default_filter_list_in
341
+ config_get_default('bgp_neighbor_af', 'filter_list_in')
342
+ end
343
+
344
+ # -----------------------
345
+ # <state> filter-list <str> out
346
+ def filter_list_out
347
+ config_get('bgp_neighbor_af', 'filter_list_out', @get_args)
348
+ end
349
+
350
+ def filter_list_out=(str)
351
+ str.strip! unless str.nil?
352
+ if str == default_filter_list_out
353
+ state = 'no'
354
+ # Current filter-list name is required for removal
355
+ str = filter_list_out
356
+ end
357
+ set_args_keys(state: state, str: str)
358
+ config_set('bgp_neighbor_af', 'filter_list_out', @set_args)
359
+ end
360
+
361
+ def default_filter_list_out
362
+ config_get_default('bgp_neighbor_af', 'filter_list_out')
363
+ end
364
+
365
+ # -----------------------
366
+ # <state> maximum-prefix <limit> <threshold> <opt>
367
+ #
368
+ # <threshold> : optional
369
+ # <opt> : optional = [ restart <interval> | warning-only ]
370
+ #
371
+ def max_prefix_get
372
+ str = config_get('bgp_neighbor_af', 'max_prefix', @get_args)
373
+ return nil if str.nil?
374
+
375
+ regexp = Regexp.new('maximum-prefix (?<limit>\d+)' \
376
+ ' *(?<threshold>\d+)?' \
377
+ ' *(?<opt>restart|warning-only)?' \
378
+ ' *(?<interval>\d+)?')
379
+ regexp.match(str)
380
+ end
381
+
382
+ def max_prefix_set(limit, threshold=nil, opt=nil)
383
+ state = limit.nil? ? 'no' : ''
384
+ unless opt.nil?
385
+ opt = opt.respond_to?(:to_i) ? "restart #{opt}" : 'warning-only'
386
+ end
387
+ set_args_keys(state: state, limit: limit,
388
+ threshold: threshold, opt: opt)
389
+ config_set('bgp_neighbor_af', 'max_prefix', @set_args)
390
+ end
391
+
392
+ def max_prefix_limit
393
+ val = max_prefix_get
394
+ return default_max_prefix_limit if val.nil?
395
+ val[:limit].to_i
396
+ end
397
+
398
+ def max_prefix_interval
399
+ val = max_prefix_get
400
+ return default_max_prefix_interval if val.nil?
401
+ (val[:interval].nil?) ? nil : val[:interval].to_i
402
+ end
403
+
404
+ def max_prefix_threshold
405
+ val = max_prefix_get
406
+ return default_max_prefix_threshold if val.nil?
407
+ (val[:threshold].nil?) ? nil : val[:threshold].to_i
408
+ end
409
+
410
+ def max_prefix_warning
411
+ val = max_prefix_get
412
+ return default_max_prefix_warning if val.nil?
413
+ (val[:opt] == 'warning-only') ? true : nil
414
+ end
415
+
416
+ def default_max_prefix_limit
417
+ config_get_default('bgp_neighbor_af', 'max_prefix_limit')
418
+ end
419
+
420
+ def default_max_prefix_interval
421
+ config_get_default('bgp_neighbor_af', 'max_prefix_interval')
422
+ end
423
+
424
+ def default_max_prefix_threshold
425
+ config_get_default('bgp_neighbor_af', 'max_prefix_threshold')
426
+ end
427
+
428
+ def default_max_prefix_warning
429
+ config_get_default('bgp_neighbor_af', 'max_prefix_warning')
430
+ end
431
+
432
+ # -----------------------
433
+ # <state> next-hop-self
434
+ def next_hop_self
435
+ state = config_get('bgp_neighbor_af', 'next_hop_self', @get_args)
436
+ state ? true : false
437
+ end
438
+
439
+ def next_hop_self=(state)
440
+ set_args_keys(state: (state ? '' : 'no'))
441
+ config_set('bgp_neighbor_af', 'next_hop_self', @set_args)
442
+ end
443
+
444
+ def default_next_hop_self
445
+ config_get_default('bgp_neighbor_af', 'next_hop_self')
446
+ end
447
+
448
+ # -----------------------
449
+ # <state> next-hop-third-party
450
+ def next_hop_third_party
451
+ state = config_get('bgp_neighbor_af', 'next_hop_third_party', @get_args)
452
+ state ? true : false
453
+ end
454
+
455
+ def next_hop_third_party=(state)
456
+ set_args_keys(state: (state ? '' : 'no'))
457
+ config_set('bgp_neighbor_af', 'next_hop_third_party', @set_args)
458
+ end
459
+
460
+ def default_next_hop_third_party
461
+ config_get_default('bgp_neighbor_af', 'next_hop_third_party')
462
+ end
463
+
464
+ # -----------------------
465
+ # <state> prefix-list <str> in
466
+ def prefix_list_in
467
+ config_get('bgp_neighbor_af', 'prefix_list_in', @get_args)
468
+ end
469
+
470
+ def prefix_list_in=(str)
471
+ str.strip! unless str.nil?
472
+ if str == default_prefix_list_in
473
+ state = 'no'
474
+ # Current prefix-list name is required for removal
475
+ str = prefix_list_in
476
+ return if str.nil?
477
+ end
478
+ set_args_keys(state: state, str: str)
479
+ config_set('bgp_neighbor_af', 'prefix_list_in', @set_args)
480
+ end
481
+
482
+ def default_prefix_list_in
483
+ config_get_default('bgp_neighbor_af', 'prefix_list_in')
484
+ end
485
+
486
+ # -----------------------
487
+ # <state> prefix-list <str> out
488
+ def prefix_list_out
489
+ config_get('bgp_neighbor_af', 'prefix_list_out', @get_args)
490
+ end
491
+
492
+ def prefix_list_out=(str)
493
+ str.strip! unless str.nil?
494
+ if str == default_prefix_list_out
495
+ state = 'no'
496
+ # Current prefix-list name is required for removal
497
+ str = prefix_list_out
498
+ end
499
+ set_args_keys(state: state, str: str)
500
+ config_set('bgp_neighbor_af', 'prefix_list_out', @set_args)
501
+ end
502
+
503
+ def default_prefix_list_out
504
+ config_get_default('bgp_neighbor_af', 'prefix_list_out')
505
+ end
506
+
507
+ # -----------------------
508
+ # <state> route-map <str> in
509
+ def route_map_in
510
+ config_get('bgp_neighbor_af', 'route_map_in', @get_args)
511
+ end
512
+
513
+ def route_map_in=(str)
514
+ str.strip! unless str.nil?
515
+ if str == default_route_map_in
516
+ state = 'no'
517
+ # Current route-map name is required for removal
518
+ str = route_map_in
519
+ return if str.nil?
520
+ end
521
+ set_args_keys(state: state, str: str)
522
+ config_set('bgp_neighbor_af', 'route_map_in', @set_args)
523
+ end
524
+
525
+ def default_route_map_in
526
+ config_get_default('bgp_neighbor_af', 'route_map_in')
527
+ end
528
+
529
+ # -----------------------
530
+ # <state> route-map <str> out
531
+ def route_map_out
532
+ config_get('bgp_neighbor_af', 'route_map_out', @get_args)
533
+ end
534
+
535
+ def route_map_out=(str)
536
+ str.strip! unless str.nil?
537
+ if str == default_route_map_out
538
+ state = 'no'
539
+ # Current route-map name is required for removal
540
+ str = route_map_out
541
+ end
542
+ set_args_keys(state: state, str: str)
543
+ config_set('bgp_neighbor_af', 'route_map_out', @set_args)
544
+ end
545
+
546
+ def default_route_map_out
547
+ config_get_default('bgp_neighbor_af', 'route_map_out')
548
+ end
549
+
550
+ # -----------------------
551
+ # <state route-reflector-client
552
+ def route_reflector_client
553
+ config_get('bgp_neighbor_af', 'route_reflector_client', @get_args)
554
+ end
555
+
556
+ def route_reflector_client=(state)
557
+ set_args_keys(state: (state ? '' : 'no'))
558
+ config_set('bgp_neighbor_af', 'route_reflector_client', @set_args)
559
+ end
560
+
561
+ def default_route_reflector_client
562
+ config_get_default('bgp_neighbor_af', 'route_reflector_client')
563
+ end
564
+
565
+ # -----------------------
566
+ # Nexus and XR implementations of send community differ enough that it makes
567
+ # sense to split up the individual methods to support them
568
+ def send_community
569
+ val = config_get('bgp_neighbor_af', 'send_community', @get_args)
570
+ return default_send_community if val.nil? || val.empty?
571
+ platform == :nexus ? send_community_nexus(val) : send_community_xr(val)
572
+ end
573
+
574
+ # Nexus: <state> send-community [ both | extended | standard ]
575
+ # NOTE: 'standard' is default but does not nvgen on some platforms
576
+ # Returns: none, both, extended, or standard
577
+ def send_community_nexus(val)
578
+ reg = 'send-community extended|send-community standard|send-community'
579
+ return 'both' if val.grep(/#{reg}/).size == 2
580
+ val = val[0].split.last
581
+ return 'standard' if val[/send-community/] # Workaround
582
+ val
583
+ end
584
+
585
+ # XR: 'send-community-ebgp' and 'send-extended-community-ebgp' are
586
+ # the equivalents of the NXOS: standard | extended functionality
587
+ # Returns: node, 'send-community-ebgp', 'send-extended-community-ebgp' or
588
+ # 'send-community-ebgp send-extended-community-ebgp' which is the 'both'
589
+ # keyword equivalent
590
+ def send_community_xr(val)
591
+ if val == ['send-community-ebgp', 'send-extended-community-ebgp']
592
+ val = 'both'
593
+ elsif val == ['send-community-ebgp']
594
+ val = 'standard'
595
+ else # val == ['send-extended-community-ebgp']
596
+ val = 'extended'
597
+ end
598
+ val
599
+ end
600
+
601
+ def send_community=(val)
602
+ platform == :nexus ? send_comm_nexus_set(val) : send_comm_ios_xr_set(val)
603
+ end
604
+
605
+ def send_comm_nexus_set(val)
606
+ if val[/none/]
607
+ state = 'no'
608
+ val = 'both'
609
+ end
610
+ if val[/extended|standard/]
611
+ # Case where already configured.
612
+ case send_community
613
+ when /both/
614
+ state = 'no'
615
+ # Unset the opposite property
616
+ val = val[/extended/] ? 'standard' : 'extended'
617
+
618
+ when /extended|standard/
619
+ # This is an additive property therefore remove the entire command
620
+ # when switching from: ext <--> std
621
+ set_args_keys(state: 'no', attr: 'both')
622
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
623
+ state = ''
624
+ end
625
+ end
626
+ set_args_keys(state: state, attr: val)
627
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
628
+ end
629
+
630
+ def send_comm_ios_xr_set(val)
631
+ case val.to_s
632
+ when 'none'
633
+ set_args_keys(state: 'no', attr: 'send-community-ebgp')
634
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
635
+ set_args_keys(state: 'no', attr: 'send-extended-community-ebgp')
636
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
637
+ when 'standard'
638
+ set_args_keys(state: '', attr: 'send-community-ebgp')
639
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
640
+ set_args_keys(state: 'no', attr: 'send-extended-community-ebgp')
641
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
642
+ when 'extended'
643
+ set_args_keys(state: 'no', attr: 'send-community-ebgp')
644
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
645
+ set_args_keys(state: '', attr: 'send-extended-community-ebgp')
646
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
647
+ when 'both'
648
+ set_args_keys(state: '', attr: 'send-community-ebgp')
649
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
650
+ set_args_keys(state: '', attr: 'send-extended-community-ebgp')
651
+ config_set('bgp_neighbor_af', 'send_community', @set_args)
652
+ else
653
+ fail ArgumentError, "Invalid value '#{val}'"
654
+ end
655
+ end
656
+
657
+ def default_send_community
658
+ config_get_default('bgp_neighbor_af', 'send_community')
659
+ end
660
+
661
+ # -----------------------
662
+ # <state> soft-reconfiguration inbound <always>
663
+ # :enable = soft-reconfiguration inbound
664
+ # :always = soft-reconfiguration inbound always
665
+ # :inherit = no soft-reconfiguration inbound
666
+ def soft_reconfiguration_in
667
+ val = config_get('bgp_neighbor_af', 'soft_reconfiguration_in', @get_args)
668
+ return default_soft_reconfiguration_in if val.nil?
669
+ /always/.match(val) ? :always : :enable
670
+ end
671
+
672
+ def soft_reconfiguration_in=(val)
673
+ val = val.to_sym
674
+ if val == default_soft_reconfiguration_in
675
+ set_args_keys(state: 'no', always: '')
676
+ else
677
+ set_args_keys(state: '', always: (val == :enable) ? '' : 'always')
678
+ end
679
+ config_set('bgp_neighbor_af', 'soft_reconfiguration_in', @set_args)
680
+ end
681
+
682
+ def default_soft_reconfiguration_in
683
+ config_get_default('bgp_neighbor_af', 'soft_reconfiguration_in').to_sym
684
+ end
685
+
686
+ # -----------------------
687
+ # <state> soo <str>
688
+ def soo
689
+ config_get('bgp_neighbor_af', 'soo', @get_args)
690
+ end
691
+
692
+ def soo=(str)
693
+ str.strip! unless str.nil?
694
+ if str == default_soo
695
+ state = 'no'
696
+ str = soo
697
+ end
698
+ set_args_keys(state: state, str: str)
699
+ config_set('bgp_neighbor_af', 'soo', @set_args)
700
+ end
701
+
702
+ def default_soo
703
+ config_get_default('bgp_neighbor_af', 'soo')
704
+ end
705
+
706
+ # -----------------------
707
+ # <state> suppress-inactive
708
+ def suppress_inactive
709
+ config_get('bgp_neighbor_af', 'suppress_inactive', @get_args)
710
+ end
711
+
712
+ def suppress_inactive=(state)
713
+ set_args_keys(state: (state ? '' : 'no'))
714
+ config_set('bgp_neighbor_af', 'suppress_inactive', @set_args)
715
+ end
716
+
717
+ def default_suppress_inactive
718
+ config_get_default('bgp_neighbor_af', 'suppress_inactive')
719
+ end
720
+
721
+ # -----------------------
722
+ # <state> unsuppress-map <str>
723
+ def unsuppress_map
724
+ config_get('bgp_neighbor_af', 'unsuppress_map', @get_args)
725
+ end
726
+
727
+ def unsuppress_map=(str)
728
+ str.strip! unless str.nil?
729
+ if str == default_unsuppress_map
730
+ state = 'no'
731
+ str = unsuppress_map
732
+ end
733
+ set_args_keys(state: state, str: str)
734
+ config_set('bgp_neighbor_af', 'unsuppress_map', @set_args)
735
+ end
736
+
737
+ def default_unsuppress_map
738
+ config_get_default('bgp_neighbor_af', 'unsuppress_map')
739
+ end
740
+
741
+ # -----------------------
742
+ # <state> weight <int>
743
+ def weight
744
+ config_get('bgp_neighbor_af', 'weight', @get_args)
745
+ end
746
+
747
+ def weight=(int)
748
+ if int == default_weight
749
+ state = 'no'
750
+ int = ''
751
+ end
752
+ set_args_keys(state: state, int: int)
753
+ config_set('bgp_neighbor_af', 'weight', @set_args)
754
+ end
755
+
756
+ def default_weight
757
+ config_get_default('bgp_neighbor_af', 'weight')
758
+ end
759
+
760
+ def rewrite_evpn_rt_asn
761
+ config_get('bgp_neighbor_af', 'rewrite_evpn_rt_asn', @get_args)
762
+ end
763
+
764
+ def rewrite_evpn_rt_asn=(state)
765
+ Feature.nv_overlay_evpn_enable if state
766
+ set_args_keys(state: (state ? '' : 'no'))
767
+ if @set_args[:state] == 'no'
768
+ unless rewrite_evpn_rt_asn == default_rewrite_evpn_rt_asn
769
+ config_set('bgp_neighbor_af', 'rewrite_evpn_rt_asn', @set_args)
770
+ end
771
+ else
772
+ config_set('bgp_neighbor_af', 'rewrite_evpn_rt_asn', @set_args)
773
+ end
774
+ end
775
+
776
+ def default_rewrite_evpn_rt_asn
777
+ config_get_default('bgp_neighbor_af', 'rewrite_evpn_rt_asn')
778
+ end
779
+ end
780
+ end