cisco_node_utils 1.2.0 → 1.3.0

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 (255) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +13 -0
  5. data/.travis.yml +4 -1
  6. data/CHANGELOG.md +81 -2
  7. data/CONTRIBUTING.md +2 -17
  8. data/Gemfile +5 -0
  9. data/README.md +92 -47
  10. data/Rakefile +23 -1
  11. data/bin/git/hooks/hook_lib +7 -0
  12. data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
  13. data/bin/git/hooks/pre-commit/rubocop +7 -2
  14. data/bin/git/hooks/pre-commit/validate-diffs +18 -4
  15. data/bin/git/hooks/pre-commit/validate-yaml +18 -0
  16. data/bin/git/update-hooks +64 -6
  17. data/cisco_node_utils.gemspec +9 -6
  18. data/docs/README-develop-best-practices.md +149 -50
  19. data/docs/README-develop-node-utils-APIs.md +92 -42
  20. data/docs/README-maintainers.md +7 -4
  21. data/docs/README-test-execution.md +57 -0
  22. data/docs/cisco_node_utils.yaml.example +30 -0
  23. data/docs/template-router.rb +4 -0
  24. data/ext/mkrf_conf.rb +63 -0
  25. data/lib/.rubocop.yml +2 -2
  26. data/lib/cisco_node_utils.rb +5 -0
  27. data/lib/cisco_node_utils/aaa_authentication_login.rb +5 -6
  28. data/lib/cisco_node_utils/aaa_authorization_service.rb +1 -1
  29. data/lib/cisco_node_utils/ace.rb +165 -12
  30. data/lib/cisco_node_utils/acl.rb +2 -1
  31. data/lib/cisco_node_utils/bgp.rb +184 -21
  32. data/lib/cisco_node_utils/bgp_af.rb +94 -249
  33. data/lib/cisco_node_utils/bgp_neighbor.rb +94 -14
  34. data/lib/cisco_node_utils/bgp_neighbor_af.rb +75 -8
  35. data/lib/cisco_node_utils/bridge_domain.rb +183 -0
  36. data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
  37. data/lib/cisco_node_utils/cisco_cmn_utils.rb +85 -2
  38. data/lib/cisco_node_utils/client.rb +35 -0
  39. data/lib/cisco_node_utils/client/client.rb +234 -0
  40. data/lib/cisco_node_utils/client/grpc.rb +33 -0
  41. data/lib/cisco_node_utils/client/grpc/client.rb +311 -0
  42. data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
  43. data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
  44. data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
  45. data/lib/cisco_node_utils/client/nxapi.rb +31 -0
  46. data/lib/cisco_node_utils/client/nxapi/client.rb +305 -0
  47. data/lib/cisco_node_utils/client/utils.rb +164 -0
  48. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +222 -254
  49. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +11 -8
  50. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +22 -15
  51. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +11 -8
  52. data/lib/cisco_node_utils/cmd_ref/acl.yaml +21 -16
  53. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +239 -109
  54. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +114 -55
  55. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +76 -52
  56. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +106 -62
  57. data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +71 -0
  58. data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
  59. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +35 -14
  60. data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
  61. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +23 -17
  62. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +94 -83
  63. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +22 -17
  64. data/lib/cisco_node_utils/cmd_ref/feature.yaml +76 -26
  65. data/lib/cisco_node_utils/cmd_ref/images.yaml +3 -2
  66. data/lib/cisco_node_utils/cmd_ref/interface.yaml +381 -153
  67. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +21 -11
  68. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +21 -21
  69. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +30 -21
  70. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +18 -13
  71. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +26 -31
  72. data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
  73. data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
  74. data/lib/cisco_node_utils/cmd_ref/memory.yaml +17 -6
  75. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +10 -3
  76. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +17 -5
  77. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +33 -29
  78. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +12 -10
  79. data/lib/cisco_node_utils/cmd_ref/pim.yaml +16 -19
  80. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +40 -25
  81. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +17 -12
  82. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +71 -35
  83. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +10 -5
  84. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +6 -2
  85. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +47 -43
  86. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +13 -11
  87. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +4 -2
  88. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +23 -21
  89. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +26 -22
  90. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +19 -17
  91. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +18 -6
  92. data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +234 -0
  93. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +24 -9
  94. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +5 -3
  95. data/lib/cisco_node_utils/cmd_ref/system.yaml +4 -3
  96. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +22 -20
  97. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +27 -15
  98. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +45 -16
  99. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +21 -11
  100. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +3 -2
  101. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +60 -32
  102. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +118 -101
  103. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +54 -58
  104. data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +118 -0
  105. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +19 -25
  106. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +28 -18
  107. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +34 -17
  108. data/lib/cisco_node_utils/cmd_ref/yum.yaml +6 -4
  109. data/lib/cisco_node_utils/command_reference.rb +261 -142
  110. data/lib/cisco_node_utils/constants.rb +33 -0
  111. data/lib/cisco_node_utils/encapsulation.rb +112 -0
  112. data/lib/cisco_node_utils/environment.rb +102 -0
  113. data/lib/cisco_node_utils/evpn_vni.rb +5 -3
  114. data/lib/cisco_node_utils/exceptions.rb +111 -0
  115. data/lib/cisco_node_utils/fabricpath_global.rb +52 -35
  116. data/lib/cisco_node_utils/fabricpath_topology.rb +44 -57
  117. data/lib/cisco_node_utils/feature.rb +165 -3
  118. data/lib/cisco_node_utils/interface.rb +1051 -260
  119. data/lib/cisco_node_utils/interface_channel_group.rb +11 -10
  120. data/lib/cisco_node_utils/interface_ospf.rb +1 -2
  121. data/lib/cisco_node_utils/interface_portchannel.rb +4 -12
  122. data/lib/cisco_node_utils/interface_service_vni.rb +7 -7
  123. data/lib/cisco_node_utils/itd_device_group.rb +248 -0
  124. data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
  125. data/lib/cisco_node_utils/itd_service.rb +523 -0
  126. data/lib/cisco_node_utils/logger.rb +75 -0
  127. data/lib/cisco_node_utils/node.rb +62 -192
  128. data/lib/cisco_node_utils/node_util.rb +56 -10
  129. data/lib/cisco_node_utils/overlay_global.rb +2 -2
  130. data/lib/cisco_node_utils/pim.rb +2 -13
  131. data/lib/cisco_node_utils/pim_group_list.rb +1 -1
  132. data/lib/cisco_node_utils/pim_rp_address.rb +1 -1
  133. data/lib/cisco_node_utils/platform.rb +52 -21
  134. data/lib/cisco_node_utils/portchannel_global.rb +89 -19
  135. data/lib/cisco_node_utils/radius_server.rb +168 -37
  136. data/lib/cisco_node_utils/router_ospf.rb +20 -35
  137. data/lib/cisco_node_utils/router_ospf_vrf.rb +4 -4
  138. data/lib/cisco_node_utils/snmpserver.rb +1 -6
  139. data/lib/cisco_node_utils/snmpuser.rb +6 -4
  140. data/lib/cisco_node_utils/stp_global.rb +676 -0
  141. data/lib/cisco_node_utils/syslog_server.rb +77 -18
  142. data/lib/cisco_node_utils/syslog_settings.rb +1 -1
  143. data/lib/cisco_node_utils/tacacs_server_group.rb +8 -4
  144. data/lib/cisco_node_utils/tacacs_server_host.rb +115 -25
  145. data/lib/cisco_node_utils/vdc.rb +12 -0
  146. data/lib/cisco_node_utils/version.rb +1 -1
  147. data/lib/cisco_node_utils/vlan.rb +147 -29
  148. data/lib/cisco_node_utils/vpc.rb +55 -3
  149. data/lib/cisco_node_utils/vrf.rb +72 -11
  150. data/lib/cisco_node_utils/vrf_af.rb +114 -29
  151. data/lib/cisco_node_utils/vtp.rb +34 -52
  152. data/lib/cisco_node_utils/vxlan_vtep.rb +34 -8
  153. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +36 -4
  154. data/lib/minitest/environment_plugin.rb +31 -0
  155. data/lib/minitest/log_level_plugin.rb +41 -0
  156. data/spec/client_spec.rb +7 -0
  157. data/spec/environment_spec.rb +263 -0
  158. data/spec/grpc_client_spec.rb +23 -0
  159. data/spec/isolate/all_clients_spec.rb +9 -0
  160. data/spec/isolate/grpc_only_spec.rb +16 -0
  161. data/spec/isolate/no_clients_spec.rb +26 -0
  162. data/spec/isolate/nxapi_only_spec.rb +16 -0
  163. data/spec/nxapi_client_spec.rb +42 -0
  164. data/spec/schema.yaml +75 -0
  165. data/spec/shared_examples_for_clients.rb +14 -0
  166. data/spec/spec_helper.rb +91 -0
  167. data/spec/whitespace_spec.rb +10 -0
  168. data/spec/yaml_spec.rb +42 -0
  169. data/tests/.rubocop.yml +2 -2
  170. data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
  171. data/tests/basetest.rb +96 -36
  172. data/tests/ciscotest.rb +220 -12
  173. data/tests/cmd_config.yaml +71 -49
  174. data/tests/cmd_config_invalid.yaml +1 -1
  175. data/tests/test_aaa_authentication_login.rb +1 -0
  176. data/tests/test_aaa_authentication_login_service.rb +9 -0
  177. data/tests/test_aaa_authorization_service.rb +173 -367
  178. data/tests/test_ace.rb +171 -100
  179. data/tests/test_acl.rb +10 -1
  180. data/tests/test_bgp_af.rb +395 -728
  181. data/tests/test_bgp_neighbor.rb +274 -115
  182. data/tests/test_bgp_neighbor_af.rb +178 -77
  183. data/tests/test_bridge_domain.rb +191 -0
  184. data/tests/test_bridge_domain_vni.rb +116 -0
  185. data/tests/test_client_utils.rb +111 -0
  186. data/tests/test_command_config.rb +9 -5
  187. data/tests/test_command_reference.rb +380 -102
  188. data/tests/test_dns_domain.rb +13 -3
  189. data/tests/test_domain_name.rb +13 -3
  190. data/tests/test_encapsulation.rb +77 -0
  191. data/tests/test_evpn_vni.rb +25 -7
  192. data/tests/test_fabricpath_global.rb +167 -163
  193. data/tests/test_fabricpath_topology.rb +12 -33
  194. data/tests/test_feature.rb +215 -0
  195. data/tests/test_grpc.rb +166 -0
  196. data/tests/test_interface.rb +585 -344
  197. data/tests/test_interface_bdi.rb +80 -0
  198. data/tests/test_interface_channel_group.rb +6 -3
  199. data/tests/test_interface_ospf.rb +26 -24
  200. data/tests/test_interface_portchannel.rb +1 -0
  201. data/tests/test_interface_private_vlan.rb +724 -0
  202. data/tests/test_interface_service_vni.rb +37 -66
  203. data/tests/test_interface_svi.rb +98 -101
  204. data/tests/test_interface_switchport.rb +419 -549
  205. data/tests/test_itd_device_group.rb +145 -0
  206. data/tests/test_itd_device_group_node.rb +199 -0
  207. data/tests/test_itd_service.rb +298 -0
  208. data/tests/test_logger.rb +43 -0
  209. data/tests/test_name_server.rb +11 -2
  210. data/tests/test_node.rb +16 -75
  211. data/tests/test_node_ext.rb +174 -163
  212. data/tests/test_node_util.rb +119 -0
  213. data/tests/test_ntp_config.rb +5 -1
  214. data/tests/test_ntp_server.rb +2 -2
  215. data/tests/test_nxapi.rb +221 -0
  216. data/tests/test_overlay_global.rb +47 -38
  217. data/tests/test_pim.rb +2 -0
  218. data/tests/test_pim_group_list.rb +2 -0
  219. data/tests/test_pim_rp_address.rb +2 -0
  220. data/tests/test_platform.rb +86 -39
  221. data/tests/test_portchannel_global.rb +211 -135
  222. data/tests/test_radius_global.rb +13 -5
  223. data/tests/test_radius_server.rb +256 -104
  224. data/tests/test_radius_server_group.rb +2 -0
  225. data/tests/test_router_bgp.rb +781 -485
  226. data/tests/test_router_ospf.rb +26 -103
  227. data/tests/test_router_ospf_vrf.rb +52 -57
  228. data/tests/test_snmp_notification_receiver.rb +2 -0
  229. data/tests/test_snmpcommunity.rb +2 -0
  230. data/tests/test_snmpgroup.rb +2 -0
  231. data/tests/test_snmpnotification.rb +40 -21
  232. data/tests/test_snmpserver.rb +2 -0
  233. data/tests/test_snmpuser.rb +2 -0
  234. data/tests/test_stp_global.rb +563 -0
  235. data/tests/test_syslog_server.rb +32 -8
  236. data/tests/test_syslog_settings.rb +22 -9
  237. data/tests/test_tacacs_server.rb +32 -27
  238. data/tests/test_tacacs_server_group.rb +100 -45
  239. data/tests/test_tacacs_server_host.rb +135 -43
  240. data/tests/test_vdc.rb +2 -16
  241. data/tests/test_vlan.rb +106 -54
  242. data/tests/test_vlan_mt_full.rb +11 -21
  243. data/tests/test_vlan_private.rb +669 -0
  244. data/tests/test_vpc.rb +312 -159
  245. data/tests/test_vrf.rb +122 -113
  246. data/tests/test_vrf_af.rb +238 -0
  247. data/tests/test_vtp.rb +58 -102
  248. data/tests/test_vxlan_vtep.rb +38 -17
  249. data/tests/test_vxlan_vtep_vni.rb +61 -9
  250. data/tests/test_yum.rb +49 -25
  251. metadata +122 -36
  252. data/lib/cisco_node_utils/cmd_ref/fex.yaml +0 -9
  253. data/lib/cisco_node_utils/cmd_ref/vni.yaml +0 -76
  254. data/lib/cisco_node_utils/vni.rb +0 -227
  255. data/tests/test_vni.rb +0 -106
@@ -22,47 +22,92 @@ There are multiple components involved when creating new resources. This documen
22
22
 
23
23
  ## <a name="prerequisites">Before You Begin</a>
24
24
 
25
- Please note: A virtual Nexus N9000/N3000 may be helpful for development and testing. Users with a valid [cisco.com](http://cisco.com) user ID can obtain a copy of a virtual Nexus N9000/N3000 by sending their [cisco.com](http://cisco.com) user ID in an email to <get-n9kv@cisco.com>. If you do not have a [cisco.com](http://cisco.com) user ID please register for one at [https://tools.cisco.com/IDREG/guestRegistration](https://tools.cisco.com/IDREG/guestRegistration)
25
+ ### <a name="prereq_git">Git Configuration</a>
26
26
 
27
- This development guide uses tools that are packaged as gems that need to be installed on your server.
27
+ Any code commits must be associated with your github account and email address. If you intend to commit code to this repository then you must configure `git` with your identity. If you have not already done so, use the following commands to configure the default identity that `git` will use for all projects on your system:
28
28
 
29
29
  ```bash
30
- gem install cisco_nxapi
31
- gem install rake
32
- gem install rubocop
33
- gem install simplecov
34
- gem install minitest
30
+ git config --global user.name "John Doe"
31
+ git config --global user.email johndoe@example.com
32
+ ```
33
+ If you do not wish to change the global configuration on your system, you can set your identity for a single local repository by using the above commands without the ``--global`` flag.
34
+
35
+ ### <a name="prereq_ruby">Ruby Prerequisites</a>
36
+
37
+ This project requires Ruby 2.0 or later.
38
+
39
+ This development guide uses tools that are packaged as gems that need to be installed in your development environment. You can install the gems manually but it's recommended to use [Bundler](https://rubygems.org/gems/bundler) to guarantee the dependencies are all present.
40
+
41
+ ```bash
42
+ gem install bundler
43
+ ```
44
+ At present the following gems are needed to work on this code base - if you wish to install them all manually instead of through Bundler, you can run:
45
+
46
+ ```bash
47
+ gem install grpc kwalify minitest net_http_unix rake rspec simplecov
48
+ gem install rubocop --version 0.35.1
49
+ ```
50
+
51
+ **NOTE:** If you are working from a server where you don't have admin/root privileges, use the following commands to install the gems:
52
+
53
+ ```bash
54
+ gem install --user-install bundler
55
+ gem install --user-install grpc kwalify minitest net_http_unix rake rspec simplecov
56
+ gem install --user-install rubocop --version 0.35.1
35
57
  ```
58
+ or add `--user-install` to your `.gemrc` to make this the default behavior:
36
59
 
37
- **NOTE:** If you are working from a server where you don't have admin/root privilages, use the following commands to install the gems and then update the `PATH` to include `~/.gem/ruby/x.x.x/bin`
60
+ ```bash
61
+ echo 'gem: --user-install' >> ~/.gemrc
62
+ ```
63
+ and then update the `PATH` to include `~/.gem/ruby/x.x.x/bin`. For example, you could add this to your `.bashrc` or `.profile`:
38
64
 
39
65
  ```bash
40
- gem install --user-install cisco_nxapi
41
- gem install --user-install rake
42
- gem install --user-install rubocop
43
- gem install --user-install simplecov
44
- gem install --user-install minitest
66
+ if which ruby >/dev/null && which gem >/dev/null; then
67
+ PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
68
+ fi
45
69
  ```
46
70
 
71
+ ### <a name="prereq_vm">Nexus VM (optional)</a>
72
+
73
+ A virtual Nexus N9000/N3000 may be helpful for development and testing. Users with a valid [cisco.com](http://cisco.com) user ID can obtain a copy of a virtual Nexus N9000/N3000 by sending their [cisco.com](http://cisco.com) user ID in an email to <get-n9kv@cisco.com>. If you do not have a [cisco.com](http://cisco.com) user ID please register for one at [https://tools.cisco.com/IDREG/guestRegistration](https://tools.cisco.com/IDREG/guestRegistration)
74
+
75
+
47
76
  ## <a name="clone">Start here: Fork and Clone the Repo</a>
48
77
 
49
- First [fork](https://help.github.com/articles/fork-a-repo) the [cisco-network-node-utils](https://github.com/cisco/cisco-network-node-utils) git repository
78
+ First [fork](https://help.github.com/articles/fork-a-repo) the [cisco-network-node-utils](https://github.com/cisco/cisco-network-node-utils) repository on GitHub.
50
79
 
51
- Next install the code base. Clone the cisco-network-node-utils repo from your fork into a workspace:
80
+ Next create your local repository. Clone the cisco-network-node-utils repo from your fork into a workspace:
52
81
 
53
82
  ```bash
54
83
  git clone https://github.com/YOUR-USERNAME/cisco-network-node-utils.git
55
84
  cd cisco-network-node-utils/
56
85
  ```
57
86
 
58
- Please note that any code commits must be associated with your github account and email address. If you intend to commit code to this repository then use the following commands to update your workspace with your credentials:
87
+ If you're using Bundler, invoke it to ensure all of the development dependencies are installed on your system:
59
88
 
60
89
  ```bash
61
- git config --global user.name "John Doe"
62
- git config --global user.email johndoe@example.com
90
+ bundle install
91
+ ```
92
+
93
+ or (if you don't have admin/root privileges and have used `--user-install` to install Bundler):
94
+
95
+ ```bash
96
+ ~/.gem/ruby/$RUBY_VERSION/bin/bundle install --path ~/.gem
63
97
  ```
64
98
 
65
- As a best practice create a topic/feature branch for your feature work using the `git branch feature/<feature_name>` command.
99
+ Optionally create the file `~/cisco_node_utils.yaml` to specify how the test scripts will connect to your Nexus VM or other node under test. Refer to the project [README](../README.md#configuration) for details.
100
+
101
+ If you intend to contribute your code back to the project then you should install the git hooks that are checked in with the project source code. These hooks check your commits for conformance with various style guidelines. To install them in your local repository (or to update them to match the files currently in the repository, in case they are out of sync), simply run the `update-hooks` script:
102
+
103
+ ```bash
104
+ bin/git/update-hooks
105
+ ```
106
+
107
+
108
+ ## <a name="complex">Example: router eigrp</a>
109
+
110
+ As a best practice, create a topic branch (also sometimes called a feature branch) for your feature work using the `git branch feature/<feature_name>` command.
66
111
 
67
112
  ```bash
68
113
  git branch feature/eigrp
@@ -71,10 +116,7 @@ git branch
71
116
  feature/eigrp
72
117
  ```
73
118
 
74
-
75
- ## <a name="complex">Example: router eigrp</a>
76
-
77
- Before you start working on the eigrp feature, checkout the feature branch you created earlier.
119
+ Before you start working on the eigrp feature, checkout its topic branch, `feature/eigrp`.
78
120
 
79
121
  ```bash
80
122
  git checkout feature/eigrp
@@ -111,15 +153,15 @@ YAML files in the `/cmd_ref/` subdirectory are automatically discovered at runti
111
153
 
112
154
  The following basic command_reference parameters will be defined for each resource property:
113
155
 
114
- 1. `config_get:` This defines the NX-OS CLI command (usually a 'show...' command) used to retrieve the property's current configuration state. Note that some commands may not be present until a feature is enabled.
115
- 2. `config_get_token:` A regexp pattern for extracting state values from the config_get output.
116
- 3. `config_set:` The NX-OS CLI configuration command(s) used to set the property configuration. May contain wildcards for variable parameters.
156
+ 1. `get_command:` This defines the CLI command (usually a 'show...' command) or similar request string used to retrieve the property's current configuration state. Note that some commands may not be present on NX-OS until a pre-requisite feature is enabled.
157
+ 2. `get_value:` A regexp pattern for extracting state values from the get_command output.
158
+ 3. `set_value:` The configuration command(s) used to set the property configuration. May contain wildcards for variable parameters.
117
159
  4. `default_value:` This is typically the "factory" default state of the property, expressed as an actual value (true, 12, "off", etc)
118
160
  5. `kind:` The data type of this property. If omitted, the property will be a string by default. Commonly used values for this property are `int` and `boolean`.
119
- 6. `multiple:` By default a property is assumed to be found once or not at all by the `config_get`/`config_get_token` lookup, and an error will be raised if multiple matches are found. If multiple matches are valid and expected, you must set `multiple: true` for this property.
161
+ 6. `multiple:` By default a property is assumed to be found once or not at all by the `get_command`/`get_value` lookup, and an error will be raised if multiple matches are found. If multiple matches are valid and expected, you must set `multiple: true` for this property.
120
162
 
121
163
  There are additional YAML command parameters available which are not covered by this document. Please see the [README_YAML.md](../lib/cisco_node_utils/cmd_ref/README_YAML.md) document for more information on the structure and semantics of these files.
122
- The properties in this example require additional context for their config_get_token values because they need to differentiate between different eigrp instances. Most properties will also have a default value.
164
+ The properties in this example require additional context for their `get_value` and `set_value` because they need to differentiate between different eigrp instances. This is done with the `context` parameter. (For more complex properties, you can define `get_context` and `set_context` separately if needed.) Most properties will also have a default value.
123
165
 
124
166
  *Note: Eigrp also has vrf and address-family contexts. These contexts require additional coding and are beyond the scope of this document.*
125
167
 
@@ -135,31 +177,35 @@ The properties in this example require additional context for their config_get_t
135
177
  feature:
136
178
  # feature eigrp must be enabled before configuring router eigrp
137
179
  kind: boolean
138
- config_get: 'show running eigrp all'
139
- config_get_token: '/^feature eigrp$/'
140
- config_set: '<state> feature eigrp'
180
+ get_command: 'show running eigrp all'
181
+ get_value: 'feature eigrp'
182
+ set_value: '<state> feature eigrp'
141
183
 
142
184
  maximum_paths:
143
185
  # This is an integer property
144
186
  kind: int
145
- config_get: 'show running eigrp all'
146
- config_get_token: ['/^router eigrp <name>$/', '/^maximum-paths (\d+)/']
147
- config_set: ['router eigrp <name>', 'maximum-paths <val>']
187
+ context:
188
+ - 'router eigrp <name>'
189
+ get_command: 'show running eigrp all'
190
+ get_value: 'maximum-paths (\d+)'
191
+ set_value: 'maximum-paths <val>'
148
192
  default_value: 8
149
193
 
150
194
  router:
151
195
  # There can be multiple eigrp instances
152
196
  multiple: true
153
- config_get: 'show running eigrp all' # all eigrp-related configs
154
- config_get_token: '/^router eigrp (\S+)$/' # Match instance name
155
- config_set: '<state> router eigrp <name>' # config to add or remove
197
+ get_command: 'show running eigrp all' # all eigrp-related configs
198
+ get_value: 'router eigrp (\S+)' # Match instance name
199
+ set_value: '<state> router eigrp <name>' # config to add or remove
156
200
 
157
201
  shutdown:
158
202
  # This is a boolean property
159
203
  kind: boolean
160
- config_get: 'show running eigrp all'
161
- config_get_token: ['/^router eigrp <name>$/', '/^shutdown$/']
162
- config_set: ['router eigrp <name>', '<state> shutdown']
204
+ context:
205
+ - 'router eigrp <name>'
206
+ get_command: 'show running eigrp all'
207
+ get_value: 'shutdown'
208
+ set_value: '<state> shutdown'
163
209
  default_value: false
164
210
  ```
165
211
 
@@ -218,6 +264,10 @@ module Cisco
218
264
  create if instantiate
219
265
  end
220
266
 
267
+ def to_s
268
+ "RouterEigrp '#{name}'"
269
+ end
270
+
221
271
  # Create a hash of all current router instances.
222
272
  def self.routers
223
273
  instances = config_get('eigrp', 'router')
@@ -443,10 +493,10 @@ class TestRouterEigrp < CiscoTestCase
443
493
  end
444
494
  ```
445
495
 
446
- Now run the test:
496
+ Now run the test (see [README-test-execution](README-test-execution.md) for detailed instructions):
447
497
 
448
498
  ```bash
449
- % ruby test_router_eigrp.rb -v -- 192.168.0.1 admin admin
499
+ % ruby test_router_eigrp.rb -v --environment my_nexus_vm
450
500
  Run options: -v -- --seed 56593
451
501
 
452
502
  # Running:
@@ -8,7 +8,7 @@ Guidelines for the core maintainers of the cisco-network-node-utils project - ab
8
8
  * Does `rubocop` pass? (TODO - this will be part of our CI integration to run automatically)
9
9
  * Is `CHANGELOG.md` updated appropriately?
10
10
  * Are new minitests added? Do they provide sufficient coverage and consistent results?
11
- * Do minitests pass on both N9K and N3K?
11
+ * Do minitests pass on all supported platforms
12
12
 
13
13
  ## Setting up git-flow
14
14
 
@@ -45,6 +45,9 @@ When we are considering publishing a new release, all of the following steps mus
45
45
  * Platforms (all with latest released software or release candidate)
46
46
  - N30xx
47
47
  - N31xx
48
+ - N56xx
49
+ - N6xxx
50
+ - N7xxx
48
51
  - N9xxx
49
52
 
50
53
  3. Triage any minitest failures.
@@ -75,15 +78,15 @@ When the release checklist above has been fully completed, the process for publi
75
78
  ```diff
76
79
  Changelog
77
80
  =========
78
-
81
+
79
82
  -(unreleased)
80
83
  -------------
81
84
  +1.0.1
82
85
  +-----
83
86
  ```
84
-
87
+
85
88
  and also update `version.rb`:
86
-
89
+
87
90
  ```diff
88
91
  - VERSION = '1.0.0'
89
92
  + VERSION = '1.0.1'
@@ -0,0 +1,57 @@
1
+ # Executing the tests provided for this gem
2
+
3
+ ## RSpec tests
4
+
5
+ The test files located in the `spec/` directory use [RSpec](http://rspec.info/) as their test framework. These tests are generally standalone and do not generally require any actual Cisco hardware or virtual machines to test against.
6
+
7
+ ### Running a single RSpec test
8
+
9
+ You can execute a single spec file by name:
10
+
11
+ ```bash
12
+ rspec spec/environment_spec.rb
13
+ ```
14
+
15
+ ### Running all RSpec tests
16
+
17
+
18
+ ```bash
19
+ rake spec
20
+ ```
21
+
22
+ ## Minitest tests
23
+
24
+ The test files located in the `tests/` directory use [minitest](https://github.com/seattlerb/minitest/) as their test framework. These tests generally require one or more Cisco routers, switches, or virtual machines to test against.
25
+
26
+ It is recommended that you create a `cisco_node_utils.yaml` file (as described in [README.md](../README.md#configuration) to specify the node(s) under test, but if you do not create such a file, the test will prompt you to enter the required information at runtime:
27
+
28
+ ```bash
29
+ $ rake test
30
+ Enter address or hostname of node under test: 192.168.100.1
31
+ Enter username for node under test: user
32
+ Enter password for node under test: password
33
+ ```
34
+
35
+ ### Running a single minitest test
36
+
37
+ You can execute a single test file by name. If you do not specify the `-e` / `--environment` option, the node labeled as `default` in `cisco_node_utils.yaml` will be used (or, if no such entry exists, you will be prompted to enter the required information as shown above):
38
+
39
+ ```bash
40
+ # Run test against the 'default' node:
41
+ $ ruby tests/test_node.rb
42
+ # Run test against node 'n7k':
43
+ $ ruby tests/test_node.rb --environment n7k
44
+ # Run test against node 'n9k':
45
+ $ ruby tests/test_node.rb -e n9k
46
+ ```
47
+
48
+ ### Running all minitest tests
49
+
50
+ As above, if you do not specify the `--environment` option, the `default` node will be used or you will be prompted if necessary.
51
+
52
+ ```bash
53
+ # Run all tests against the 'default' node:
54
+ $ rake test
55
+ # Run all tests against 'n7k':
56
+ $ rake test TEST_OPTS='--environment=n7k'
57
+ ```
@@ -0,0 +1,30 @@
1
+ # The entry labeled 'default' will be used by default.
2
+ # The user can select a different entry by name if desired.
3
+ #
4
+ # default:
5
+ # host: foo
6
+
7
+ # Example config for running NXAPI remotely:
8
+ nxapi_remote:
9
+ host: 192.168.1.100
10
+ username: devops
11
+ password: devops
12
+
13
+ # Example config for running NXAPI on a node:
14
+ nxapi_local:
15
+ # (none needed)
16
+
17
+ # Example config for running gRPC remotely:
18
+ grpc_remote:
19
+ host: 192.168.1.100
20
+ # gRPC port defaults to 57400 if unset
21
+ # port: 57400
22
+ username: admin
23
+ password: admin
24
+
25
+ # Example config for running gRPC on a node:
26
+ grpc_local:
27
+ port: 57999
28
+ username: admin
29
+ password: admin
30
+
@@ -27,6 +27,10 @@ module Cisco
27
27
  create if instantiate
28
28
  end
29
29
 
30
+ def to_s
31
+ "X__CLASS_NAME__X '#{name}'"
32
+ end
33
+
30
34
  # Create a hash of all current router instances.
31
35
  def self.routers
32
36
  instances = config_get('X__RESOURCE_NAME__X', 'router')
data/ext/mkrf_conf.rb ADDED
@@ -0,0 +1,63 @@
1
+ # Inspired by:
2
+ # https://github.com/ruby-debug/ruby-debug-ide/blob/master/ext/mkrf_conf.rb
3
+
4
+ # This file needs to be named mkrf_conf.rb
5
+ # so that rubygems will recognize it as a ruby extension
6
+ # file and not think it is a C extension file
7
+
8
+ require 'rubygems/specification'
9
+ require 'rubygems/dependency'
10
+ require 'rubygems/dependency_installer'
11
+
12
+ # Load up the rubygems dependency installer to install the dependencies
13
+ # we need based on the platform we are running under.
14
+ installer = Gem::DependencyInstaller.new
15
+ deps = []
16
+ begin
17
+ # Try to detect Cisco NX-OS and IOS XR environments
18
+ os = nil
19
+ if File.exist?('/etc/os-release')
20
+ cisco_release_file = nil
21
+ File.foreach('/etc/os-release') do |line|
22
+ next unless line[/^CISCO_RELEASE_INFO=/]
23
+ cisco_release_file = line[/^CISCO_RELEASE_INFO=(.*)$/, 1]
24
+ break
25
+ end
26
+ unless cisco_release_file.nil?
27
+ File.foreach(cisco_release_file) do |line|
28
+ next unless line[/^ID=/]
29
+ os = line[/^ID=(.*)$/, 1]
30
+ break
31
+ end
32
+ end
33
+ end
34
+ puts "Detected client OS as '#{os}'" unless os.nil?
35
+
36
+ # IOS XR doesn't need net_http_unix
37
+ os == 'ios_xr' || deps << Gem::Dependency.new('net_http_unix',
38
+ '~> 0.2', '>= 0.2.1')
39
+ # NX-OS doesn't need gRPC
40
+ os == 'nexus' || deps << Gem::Dependency.new('grpc', '~> 0.12')
41
+
42
+ deps.each do |dep|
43
+ installed = dep.matching_specs
44
+ if installed.empty?
45
+ puts "Installing #{dep}"
46
+ installed = installer.install dep
47
+ fail installer.errors[0] unless installer.errors.empty?
48
+ fail "Did not install #{dep}" if installed.empty?
49
+ else
50
+ puts "Found installed gems matching #{dep}:"
51
+ installed.each { |i| puts " #{i.name} (#{i.version})" }
52
+ end
53
+ end
54
+ rescue StandardError => e
55
+ puts e
56
+ puts e.backtrace.join("\n ")
57
+ exit(1)
58
+ end
59
+
60
+ # Create a dummy Rakefile to report successful 'compilation'
61
+ f = File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w')
62
+ f.write("task :default\n")
63
+ f.close
data/lib/.rubocop.yml CHANGED
@@ -3,13 +3,13 @@ inherit_from: ../.rubocop.yml
3
3
  # Baseline code complexity metrics for the lib/ subdirectory:
4
4
 
5
5
  Metrics/AbcSize:
6
- Max: 45
6
+ Max: 49
7
7
 
8
8
  Metrics/CyclomaticComplexity:
9
9
  Max: 23
10
10
 
11
11
  Metrics/MethodLength:
12
- Max: 48
12
+ Max: 50
13
13
 
14
14
  Metrics/ParameterLists:
15
15
  Max: 9
@@ -12,5 +12,10 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ # Declare module here as files referenced in glob-order below may assume
16
+ # module already exists.
17
+ module Cisco
18
+ end
19
+
15
20
  # Automatically load all Ruby files in the cisco_node_utils subdirectory
16
21
  Dir.glob(__dir__ + '/cisco_node_utils/*.rb') { |file| require file }
@@ -23,11 +23,10 @@ require_relative 'node_util'
23
23
  module Cisco
24
24
  # NXAPI implementation of AAA Authentication Login class
25
25
  class AaaAuthenticationLogin < NodeUtil
26
- # rubocop:disable DoubleNegation
27
26
  # There is no "feature aaa" or "aaa new-model" on nxos, and only one
28
27
  # instance which is always available
29
28
  def self.ascii_authentication
30
- !!config_get('aaa_authentication_login', 'ascii_authentication')
29
+ config_get('aaa_authentication_login', 'ascii_authentication')
31
30
  end
32
31
 
33
32
  def self.ascii_authentication=(val)
@@ -42,7 +41,7 @@ module Cisco
42
41
  end
43
42
 
44
43
  def self.chap
45
- !!config_get('aaa_authentication_login', 'chap')
44
+ config_get('aaa_authentication_login', 'chap')
46
45
  end
47
46
 
48
47
  def self.chap=(val)
@@ -55,7 +54,7 @@ module Cisco
55
54
  end
56
55
 
57
56
  def self.error_display
58
- !!config_get('aaa_authentication_login', 'error_display')
57
+ config_get('aaa_authentication_login', 'error_display')
59
58
  end
60
59
 
61
60
  def self.error_display=(val)
@@ -68,7 +67,7 @@ module Cisco
68
67
  end
69
68
 
70
69
  def self.mschap
71
- !!config_get('aaa_authentication_login', 'mschap')
70
+ config_get('aaa_authentication_login', 'mschap')
72
71
  end
73
72
 
74
73
  def self.mschap=(val)
@@ -81,7 +80,7 @@ module Cisco
81
80
  end
82
81
 
83
82
  def self.mschapv2
84
- !!config_get('aaa_authentication_login', 'mschapv2')
83
+ config_get('aaa_authentication_login', 'mschapv2')
85
84
  end
86
85
 
87
86
  def self.mschapv2=(val)