cisco_node_utils 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/CHANGELOG.md +126 -1
  4. data/README.md +19 -12
  5. data/Rakefile +1 -0
  6. data/bin/git/hooks/commit-msg/enforce_style +8 -0
  7. data/cisco_node_utils.gemspec +4 -3
  8. data/docs/README-develop-best-practices.md +127 -109
  9. data/docs/README-develop-node-utils-APIs.md +47 -39
  10. data/docs/template-router.rb +3 -7
  11. data/lib/.rubocop.yml +4 -4
  12. data/lib/cisco_node_utils.rb +1 -1
  13. data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
  14. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
  15. data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
  16. data/lib/cisco_node_utils/ace.rb +196 -0
  17. data/lib/cisco_node_utils/acl.rb +100 -0
  18. data/lib/cisco_node_utils/bgp.rb +301 -163
  19. data/lib/cisco_node_utils/bgp_af.rb +187 -19
  20. data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
  21. data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
  22. data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
  23. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
  24. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
  25. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
  26. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
  27. data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
  28. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
  29. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
  30. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
  31. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
  32. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
  33. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
  34. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
  35. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
  36. data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
  37. data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
  38. data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
  39. data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
  40. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
  41. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
  42. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
  43. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
  44. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
  45. data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
  46. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
  47. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
  48. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
  49. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
  50. data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
  51. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
  52. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
  53. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
  54. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
  55. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
  56. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
  57. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
  58. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
  59. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
  60. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
  61. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
  62. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
  63. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
  64. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
  65. data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
  66. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
  67. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
  68. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
  69. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
  70. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
  71. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
  72. data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
  73. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
  74. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
  75. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
  76. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
  77. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
  78. data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
  79. data/lib/cisco_node_utils/command_reference.rb +359 -187
  80. data/lib/cisco_node_utils/configparser_lib.rb +1 -1
  81. data/lib/cisco_node_utils/dns_domain.rb +19 -5
  82. data/lib/cisco_node_utils/domain_name.rb +4 -8
  83. data/lib/cisco_node_utils/evpn_vni.rb +157 -0
  84. data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
  85. data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
  86. data/lib/cisco_node_utils/feature.rb +111 -0
  87. data/lib/cisco_node_utils/interface.rb +390 -97
  88. data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
  89. data/lib/cisco_node_utils/interface_ospf.rb +11 -34
  90. data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
  91. data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
  92. data/lib/cisco_node_utils/name_server.rb +1 -1
  93. data/lib/cisco_node_utils/node.rb +55 -249
  94. data/lib/cisco_node_utils/node_util.rb +5 -1
  95. data/lib/cisco_node_utils/ntp_config.rb +2 -2
  96. data/lib/cisco_node_utils/ntp_server.rb +14 -5
  97. data/lib/cisco_node_utils/overlay_global.rb +153 -0
  98. data/lib/cisco_node_utils/pim.rb +124 -0
  99. data/lib/cisco_node_utils/pim_group_list.rb +108 -0
  100. data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
  101. data/lib/cisco_node_utils/platform.rb +8 -9
  102. data/lib/cisco_node_utils/portchannel_global.rb +277 -0
  103. data/lib/cisco_node_utils/radius_global.rb +9 -19
  104. data/lib/cisco_node_utils/radius_server.rb +31 -41
  105. data/lib/cisco_node_utils/radius_server_group.rb +117 -0
  106. data/lib/cisco_node_utils/router_ospf.rb +1 -1
  107. data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
  108. data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
  109. data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
  110. data/lib/cisco_node_utils/snmpgroup.rb +1 -1
  111. data/lib/cisco_node_utils/snmpnotification.rb +57 -0
  112. data/lib/cisco_node_utils/snmpserver.rb +8 -17
  113. data/lib/cisco_node_utils/snmpuser.rb +67 -28
  114. data/lib/cisco_node_utils/syslog_server.rb +3 -9
  115. data/lib/cisco_node_utils/syslog_settings.rb +2 -10
  116. data/lib/cisco_node_utils/tacacs_server.rb +9 -14
  117. data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
  118. data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
  119. data/lib/cisco_node_utils/vdc.rb +88 -0
  120. data/lib/cisco_node_utils/version.rb +5 -2
  121. data/lib/cisco_node_utils/vlan.rb +71 -8
  122. data/lib/cisco_node_utils/vni.rb +227 -0
  123. data/lib/cisco_node_utils/vpc.rb +377 -0
  124. data/lib/cisco_node_utils/vrf.rb +60 -9
  125. data/lib/cisco_node_utils/vrf_af.rb +191 -0
  126. data/lib/cisco_node_utils/vtp.rb +8 -6
  127. data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
  128. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
  129. data/lib/cisco_node_utils/yum.rb +1 -1
  130. data/tests/.rubocop.yml +1 -1
  131. data/tests/basetest.rb +16 -7
  132. data/tests/ciscotest.rb +55 -13
  133. data/tests/cmd_config.yaml +2 -2
  134. data/tests/platform_info.rb +3 -2
  135. data/tests/test_aaa_authentication_login.rb +219 -0
  136. data/tests/test_aaa_authentication_login_service.rb +759 -0
  137. data/tests/test_aaa_authorization_service.rb +1041 -0
  138. data/tests/test_ace.rb +160 -0
  139. data/tests/test_acl.rb +176 -0
  140. data/tests/test_bgp_af.rb +269 -13
  141. data/tests/test_bgp_neighbor.rb +38 -40
  142. data/tests/test_bgp_neighbor_af.rb +92 -32
  143. data/tests/test_command_config.rb +5 -5
  144. data/tests/test_command_reference.rb +284 -101
  145. data/tests/test_dns_domain.rb +1 -1
  146. data/tests/test_domain_name.rb +1 -1
  147. data/tests/test_evpn_vni.rb +106 -0
  148. data/tests/test_fabricpath_global.rb +243 -0
  149. data/tests/test_fabricpath_topology.rb +98 -0
  150. data/tests/test_interface.rb +292 -74
  151. data/tests/test_interface_channel_group.rb +74 -0
  152. data/tests/test_interface_ospf.rb +9 -4
  153. data/tests/test_interface_portchannel.rb +105 -0
  154. data/tests/test_interface_service_vni.rb +232 -0
  155. data/tests/test_interface_svi.rb +77 -62
  156. data/tests/test_interface_switchport.rb +17 -5
  157. data/tests/test_name_server.rb +1 -1
  158. data/tests/test_node.rb +1 -1
  159. data/tests/test_node_ext.rb +10 -20
  160. data/tests/test_ntp_config.rb +1 -1
  161. data/tests/test_ntp_server.rb +18 -6
  162. data/tests/test_overlay_global.rb +102 -0
  163. data/tests/test_pim.rb +177 -0
  164. data/tests/test_pim_group_list.rb +181 -0
  165. data/tests/test_pim_rp_address.rb +153 -0
  166. data/tests/test_platform.rb +3 -3
  167. data/tests/test_portchannel_global.rb +202 -0
  168. data/tests/test_radius_global.rb +1 -1
  169. data/tests/test_radius_server.rb +92 -57
  170. data/tests/test_radius_server_group.rb +149 -0
  171. data/tests/test_router_bgp.rb +283 -112
  172. data/tests/test_router_ospf.rb +2 -2
  173. data/tests/test_router_ospf_vrf.rb +4 -4
  174. data/tests/test_snmp_notification_receiver.rb +167 -0
  175. data/tests/test_snmpcommunity.rb +1 -1
  176. data/tests/test_snmpgroup.rb +1 -1
  177. data/tests/test_snmpnotification.rb +72 -0
  178. data/tests/test_snmpserver.rb +29 -105
  179. data/tests/test_snmpuser.rb +32 -30
  180. data/tests/test_syslog_server.rb +36 -10
  181. data/tests/test_syslog_settings.rb +1 -1
  182. data/tests/test_tacacs_server.rb +1 -1
  183. data/tests/test_tacacs_server_group.rb +405 -0
  184. data/tests/test_tacacs_server_host.rb +1 -1
  185. data/tests/test_vdc.rb +78 -0
  186. data/tests/test_vlan.rb +74 -19
  187. data/tests/test_vlan_mt_full.rb +95 -0
  188. data/tests/test_vni.rb +106 -0
  189. data/tests/test_vpc.rb +361 -0
  190. data/tests/test_vrf.rb +172 -29
  191. data/tests/test_vtp.rb +1 -1
  192. data/tests/test_vxlan_vtep.rb +214 -0
  193. data/tests/test_vxlan_vtep_vni.rb +201 -0
  194. data/tests/test_yum.rb +1 -1
  195. metadata +120 -11
  196. data/lib/cisco_node_utils/README_YAML.md +0 -325
  197. data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
  198. data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
  199. data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
  200. data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
  201. data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
  202. data/tests/platform_info.yaml +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6396905732ac665cf55bb63e17792c399a95c41f
4
- data.tar.gz: 0a007ab3337c8dfe52a35deabb9a7627ba539e0f
3
+ metadata.gz: 5972809d82dc9ad3991f11217e174556220418c6
4
+ data.tar.gz: abec7a2fbd8757cdf73bb5eb84c7e154e777ffbc
5
5
  SHA512:
6
- metadata.gz: dd703cf0f14758739bc2382296af32c2b4c202884a3fc53132e0e3e69e1de5135035b2a98afd2b2632d21062d605779fdf3506d0210056c5542a747c05419ade
7
- data.tar.gz: 4d52c817fd90803451306ab759de4b28b2dc17818291b2d14440299ded9d8fe5641c5e22e800508175ba20d5cb73bfc580044e920bcd3cdbb175a3c5c810965b
6
+ metadata.gz: f8d80e3c768ebbd436ce9d2d0f6e795941932c517834e5c644aa12bce22fddee6ee82efb545857900de5a0127bdfa58911d4e411bbf6dfc5dd887fbb52a1567c
7
+ data.tar.gz: 9a0ac0b2beb5cad046e28ba570f5afdf3c98543b1d11e76dadd1ca33fa3c57757d6e136e2fe55f984d3c6ed6e448f0f2e0cd07ba72088f024ab90a5ecd7033c3
data/.gitignore CHANGED
@@ -3,4 +3,5 @@ pkg/*
3
3
  vendor/*
4
4
  coverage
5
5
  Gemfile.lock
6
- *.gem
6
+ *.gem
7
+ *.swp
data/CHANGELOG.md CHANGED
@@ -1,6 +1,126 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## [v1.2.0]
5
+
6
+ ### New feature support
7
+ * ACL (platforms: Nexus 3k and Nexus 9k)
8
+ * acl (@saqibraza)
9
+ * ace (@yjyongz)
10
+ * remark ace (@bansalpradeep)
11
+ * EVPN (platforms: Nexus 3k and Nexus 9k)
12
+ * evpn_vni (@andish)
13
+ * Fabric Path (platforms: Nexus 7k)
14
+ * fabricpath_global (@dcheriancisco)
15
+ * fabricpath_topology (@dcheriancisco)
16
+ * Feature
17
+ * feature (@robert-w-gries)
18
+ * Interface (platforms: Nexus 3k, Nexus 5k, Nexus 6k, Nexus 7k and Nexus 9k)
19
+ * interface_channel_group (@chrisvanheuveln)
20
+ * interface_portchannel (@saichint)
21
+ * interface_service_vni (@chrisvanheuveln)
22
+ * PIM (platforms: Nexus 3k and Nexus 9k)
23
+ * pim (@smigopal)
24
+ * pim_group_list (@smigopal)
25
+ * pim_rp_address (@smigopal)
26
+ * Port Channel (platforms: Nexus 3k, Nexus 5k, Nexus 6k, Nexus 7k and Nexus 9k)
27
+ * interface_channel_group (@chrisvanheuveln)
28
+ * interface_portchannel (@saichint)
29
+ * portchannel_global (@saichint)
30
+ * SNMP (platforms: Nexus 3k, Nexus 5k, Nexus 6k, Nexus 7k and Nexus 9k)
31
+ * snmpnotification (@tphoney)
32
+ * VDC (platforms: Nexus 7k)
33
+ * vdc (@chrisvanheuveln)
34
+ * VPC (platforms: Nexus 3k, Nexus 5k, Nexus 6k, Nexus 7k and Nexus 9k)
35
+ * vpc (@dcheriancisco)
36
+ * VRF (platforms: Nexus 3k, Nexus 5k, Nexus 6k, Nexus 7k and Nexus 9k)
37
+ * vrf_af (@chrisvanheuveln)
38
+ * VXLAN (platforms: Nexus 9k)
39
+ * overlay_global (@alok-aggarwal)
40
+ * vxlan_vtep (@dcheriancisco)
41
+ * vxlan_vtep_vni (@mikewiebe)
42
+
43
+
44
+ ### Additional platform support added to existing classes
45
+ #### Cisco Nexus 56xx, 60xx and 7xxx
46
+ * AAA
47
+ * aaa_authentication_login
48
+ * aaa_authentication_login_service
49
+ * aaa_authentication_service
50
+ * BGP
51
+ * bgp
52
+ * bgp_af
53
+ * bgp_af_neighobr
54
+ * bgp_neighbor_af
55
+ * COMMAND_CONFIG
56
+ * command_config (config_parser)
57
+ * DOMAIN
58
+ * dns_domain
59
+ * domain_name
60
+ * name_server
61
+ * INTERFACE
62
+ * interface
63
+ * NTP
64
+ * ntp_config
65
+ * ntp_server
66
+ * OSPF
67
+ * interface_ospf
68
+ * ospf
69
+ * ospf_vrf
70
+ * RADIUS
71
+ * radius_global
72
+ * SNMP
73
+ * snmp_community
74
+ * snmp_group
75
+ * snmp_notification_receiver
76
+ * snmp_server
77
+ * snmp_user
78
+ * SYSLOG
79
+ * syslog_server
80
+ * syslog_setting
81
+ * TACACS
82
+ * tacacs_server
83
+ * tacacs_server_group
84
+ * tacacs_server_host
85
+ * VLAN
86
+ * vlan
87
+
88
+ ### Added
89
+
90
+ * `Cisco::UnsupportedError` exception class, raised when a command is explicitly marked as unsupported on a particular class of nodes.
91
+ * Extend bgp with attributes:
92
+ * `disable_policy_batching`, `disable_policy_batching_ipv4`, `disable_policy_batching_ipv6`
93
+ * `event_history_cli`, `event_history_detail`, `event_history_events`, `event_history_periodic`
94
+ * `fast_external_fallover`
95
+ * `flush_routes`
96
+ * `isolate`
97
+ * `neighbor_down_fib_accelerate`
98
+ * `route_distinguisher`
99
+ * Extend bgp_af with attributes:
100
+ * `default_metric`
101
+ * `distance_ebgp`, `distance_ibgp`, `distance_local`
102
+ * `inject_map`
103
+ * `suppress_inactive`
104
+ * `table_map`
105
+ * Extend interface with attributes:
106
+ * `fabric_forwarding_anycast_gateway`
107
+ * `ipv4_acl_in`, `ipv4_acl_out`, `ipv6_acl_in`, `ipv6_acl_out`
108
+ * `ipv4_address_secondary`, `ipv4_arp_timeout`
109
+ * `vlan_mapping`
110
+ * `vpc_id`, `vpc_peer_link`
111
+ * switchport mode `fabricpath`
112
+ * Extend vrf with attributes:
113
+ * `vni`
114
+ * Extend vlan with attribute:
115
+ * `mode`
116
+
117
+ ### Changed
118
+
119
+ * Major refactor and enhancement of `CommandReference` YAML files:
120
+ - Added support for `auto_default`, `default_only`, `kind`, and `multiple`
121
+ - Added filtering by product ID (`/N7K/`) and by client type (`cli_nexus`)
122
+ - `CommandReference` methods that do key-value style wildcard substitution now raise an `ArgumentError` if the result is empty (because not enough parameters were supplied).
123
+
4
124
  ## [v1.1.0]
5
125
 
6
126
  ### New feature support
@@ -15,10 +135,12 @@ Changelog
15
135
  * RADIUS
16
136
  * radius_global (@jonnytpuppet)
17
137
  * radius_server (@jonnytpuppet)
138
+ * SNMP
139
+ * snmp_notification_receiver (@jonnytpuppet)
18
140
  * SYSLOG
19
141
  * syslog_server (@jonnytpuppet)
20
142
  * syslog_setting (@jonnytpuppet)
21
- * Miscellaneous
143
+ * Miscellaneous
22
144
  * dns_domain (@hunner)
23
145
  * domain_name (@bmjen)
24
146
  * name_server (@hunner)
@@ -43,6 +165,8 @@ Changelog
43
165
  * Added `config` and `(assert|refute)_show_match` helper methods for testing.
44
166
  * Added `bin/check_metric_limits.rb` helper script in support of refactoring.
45
167
  * Added best practices development guide.
168
+ * Added support for radius_global (@jonnytpuppet)
169
+ * Added support for radius_server_group (@jonnytpuppet)
46
170
 
47
171
  ### Fixed
48
172
 
@@ -92,6 +216,7 @@ Changelog
92
216
  [git-flow]: https://github.com/petervanderdoes/gitflow-avh
93
217
  [SimpleCov]: https://github.com/colszowka/simplecov
94
218
 
219
+ [v1.2.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.1.0...v1.2.0
95
220
  [v1.1.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.1...v1.1.0
96
221
  [v1.0.1]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.0...v1.0.1
97
222
  [v1.0.0]: https://github.com/cisco/cisco-network-node-utils/compare/v0.9.0...v1.0.0
data/README.md CHANGED
@@ -35,10 +35,23 @@ Please see [Learning Resources](#resources) for additional references.
35
35
 
36
36
  The CiscoNodeUtils gem provides utilities for management of Cisco network
37
37
  nodes. It is designed to work with Puppet and Chef as well as other
38
- open source management tools. This release supports Cisco NX-OS nodes
39
- running NX-OS 7.0(3)I2(1) and later.
38
+ open source management tools.
40
39
 
41
- 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)
40
+ This CiscoNodeUtils gem release supports the following:
41
+
42
+ Platform | OS | OS Version |
43
+ -----------------|-------|----------------------|
44
+ Cisco Nexus 30xx | NX-OS | 7.0(3)I2(1) and later
45
+ Cisco Nexus 31xx | NX-OS | 7.0(3)I2(1) and later
46
+ Cisco Nexus 93xx | NX-OS | 7.0(3)I2(1) and later
47
+ Cisco Nexus 95xx | NX-OS | 7.0(3)I2(1) and later
48
+ Cisco N9kv | NX-OS | 7.0(3)I2(1) and later
49
+ Cisco Nexus 56xx | NX-OS | 7.3(0)N1(1) and later
50
+ Cisco Nexus 60xx | NX-OS | 7.3(0)N1(1) and later
51
+ Cisco Nexus 7xxx | NX-OS | 7.3(0)D1(1) and later
52
+
53
+
54
+ Please note: For Cisco Nexus 3k and 9k platforms, 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)
42
55
 
43
56
  ## <a name="installation">Installation</a>
44
57
 
@@ -97,15 +110,9 @@ network node. It provides the base APIs `config_set`, `config_get`, and
97
110
 
98
111
  ### CommandReference
99
112
 
100
- The `CommandReference` module provides for the abstraction of NX-OS CLI,
101
- especially to handle its variance between hardware platforms.
102
- A series of YAML files are used to describe the CLI corresponding to a given
103
- `(feature, attribute)` tuple for any given platform. When a `Node` is
104
- connected, the platform identification of the Node is used to construct a
105
- `CmdRef` object that corresponds to this platform. The `Node` APIs
106
- `config_set`, `config_get`, and `config_get_default` all rely on the `CmdRef`.
113
+ The `CommandReference` class abstracts away the differences between various supported `Node` types, be that API differences (CLI vs. YANG), platform differences (NX-OS vs. IOS XR), or hardware differences (Nexus 9xxx vs. Nexus 3xxx). A series of YAML files describe various `feature` groupings. Each file describes a set of `attributes` of the given feature and the specifics of how to inspect and manage these attributes for any supported `Node` types. When a `Node` is connected, the platform identification of the Node is used to construct a `CommandReference` instance containing a set of `CmdRef` objects specific to this `Node`. The `Node` APIs `config_set`, `config_get`, and `config_get_default` all rely on the `CmdRef`.
107
114
 
108
- See also [README_YAML](lib/cisco_node_utils/README_YAML.md).
115
+ See also [README_YAML](lib/cisco_node_utils/cmd_ref/README_YAML.md).
109
116
 
110
117
  ### Feature Providers
111
118
 
@@ -161,7 +168,7 @@ See [CHANGELOG](CHANGELOG.md) for a list of changes.
161
168
  ## <a name="license_info">License Information</a>
162
169
 
163
170
 
164
- Copyright (c) 2013-2015 Cisco and/or its affiliates.
171
+ Copyright (c) 2013-2016 Cisco and/or its affiliates.
165
172
 
166
173
  Licensed under the Apache License, Version 2.0 (the "License");
167
174
  you may not use this file except in compliance with the License.
data/Rakefile CHANGED
@@ -18,4 +18,5 @@ Rake::TestTask.new do |t|
18
18
  t.pattern = 'tests/test_*.rb'
19
19
  t.warning = true
20
20
  t.verbose = true
21
+ t.options = '-v'
21
22
  end
@@ -76,6 +76,14 @@ if $errors > 0 # rubocop:disable Style/GlobalVars
76
76
  puts '{'
77
77
  puts message_lines.join("\n")
78
78
  puts '}'
79
+
80
+ fd = IO.sysopen('/dev/tty', 'w+')
81
+ a = IO.new(fd, 'w+')
82
+ a.puts 'Continue anyway? [y/N] '
83
+ response = a.gets.chomp
84
+ # rubocop:disable Style/GlobalVars
85
+ $errors = 0 if response.downcase[0] == 'y'
86
+ # rubocop:enable Style/GlobalVars
79
87
  end
80
88
 
81
89
  exit $errors # rubocop:disable Style/GlobalVars
@@ -7,7 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'cisco_node_utils'
8
8
  spec.version = CiscoNodeUtils::VERSION
9
9
  spec.authors = ['Alex Hunsberger', 'Glenn Matthews',
10
- 'Chris Van Heuveln', 'Mike Wiebe', 'Jie Yang']
10
+ 'Chris Van Heuveln', 'Mike Wiebe', 'Jie Yang',
11
+ 'Rob Gries']
11
12
  spec.email = 'cisco_agent_gem@cisco.com'
12
13
  spec.summary = 'Utilities for management of Cisco network nodes'
13
14
  spec.description = <<-EOF
@@ -30,7 +31,7 @@ Currently supports NX-OS nodes.
30
31
  spec.add_development_dependency 'minitest', '~> 5.0'
31
32
  spec.add_development_dependency 'bundler', '~> 1.7'
32
33
  spec.add_development_dependency 'rake', '~> 10.0'
33
- spec.add_development_dependency 'rubocop', '= 0.34.2'
34
+ spec.add_development_dependency 'rubocop', '= 0.35.1'
34
35
  spec.add_development_dependency 'simplecov', '~> 0.9'
35
- spec.add_runtime_dependency 'cisco_nxapi', '~> 1.0'
36
+ spec.add_runtime_dependency 'cisco_nxapi', '~> 1.0', '>= 1.0.1'
36
37
  end
@@ -12,14 +12,16 @@ This document is intended to assist in developing cisco_node_utils API's that ar
12
12
 
13
13
  ## <a name="ydbp">YAML Development Best Practices</a>
14
14
 
15
- * [Y1](#yaml1): All yaml feature entries should be kept in alphabetical order.
16
- * [Y2](#yaml2): Use *regexp* anchors where needed for `config_get` and `config_get_token` entries.
17
- * Y3: Avoid nested optional matches.
18
- * [Y4](#yaml4): Use the `_template` feature when getting/setting the same property value at multiple levels.
19
- * [Y5](#yaml5): When possible include a `default_value` that represents the system default value.
20
- * [Y6](#yaml6): When possible, use the same `config_get` show command for all properties and document any anomalies.
21
- * [Y7](#yaml7): Use Key-value wildcards instead of Printf-style wildcards.
22
- * [Y8](#yaml8): Selection of `show` commands for `config_get`.
15
+ * [Y1](#yaml1): One feature per YAML file
16
+ * [Y2](#yaml2): All attribute entries must be kept in alphabetical order.
17
+ * [Y3](#yaml3): Use *regexp* anchors where needed for `config_get` and `config_get_token` entries.
18
+ * [Y4](#yaml4): Avoid nested optional matches.
19
+ * [Y5](#yaml5): Use the `_template` feature when getting/setting the same property value at multiple levels.
20
+ * [Y6](#yaml6): When possible include a `default_value` that represents the system default value.
21
+ * [Y7](#yaml7): When possible, use the same `config_get` show command for all properties and document any anomalies.
22
+ * [Y8](#yaml8): Use Key-value wildcards instead of Printf-style wildcards.
23
+ * [Y9](#yaml9): Selection of `show` commands for `config_get`.
24
+ * [Y10](#yaml10): Use `true` and `false` for boolean values.
23
25
 
24
26
 
25
27
 
@@ -43,132 +45,145 @@ This document is intended to assist in developing cisco_node_utils API's that ar
43
45
 
44
46
  ## YAML Best Practices:
45
47
 
46
- ### <a name="yaml1">Y1: All yaml feature entries should be kept in alphabetical order.
48
+ ### <a name="yaml1">Y1: One feature per YAML file
47
49
 
48
- Please keep all feature names in alphabetical order, and all options under a feature in alphabetical order as well. As YAML permits duplicate entries (in which case the last entry overrides any earlier entries), keeping a consistent order helps to prevent accidentally introducing such duplication.
50
+ Each YAML file should define a single 'feature' (a closely related set of configuration properties). Don't create "one YAML file to rule them all".
49
51
 
50
- Top level features in alpabetical order:
52
+ ### <a name="yaml2">Y2: All attribute entries must be kept in alphabetical order.
51
53
 
52
- ```
53
- aaa_authentication_login:
54
- ...
55
- dnsclient:
56
- ...
57
- interface:
58
- ```
59
-
60
- Options under a feature:
54
+ All attribute entries in a given YAML file must be kept in alphabetical order. As YAML permits duplicate entries (in which case the last entry overrides any earlier entries), keeping a consistent order helps to prevent accidentally introducing such duplication.
61
55
 
62
- ```
63
- interface:
64
- access_vlan:
65
- ...
66
- all_interfaces:
67
- ...
68
- create:
69
- ...
70
- description:
71
- ...
72
- ```
56
+ This rule is enforced by the `Cisco::CommandReference` class itself - it will raise an exception if it detects any out-of-order entries.
73
57
 
74
- ### <a name="yaml2">Y2: Use *regexp* anchors where needed for `config_get` and `config_get_token` entries.
58
+ ### <a name="yaml3">Y3: Use *regexp* anchors where needed for `config_get` and `config_get_token` entries.
75
59
 
76
60
  Please use *regexp* anchors `^$` to ensure you match the correct feature information in the `show` output.
77
61
 
62
+ ```yaml
63
+ # syslog_settings.yaml
64
+ timestamp:
65
+ config_get: "show running-config all | include '^logging timestamp'"
66
+ config_get_token: '/^logging timestamp (.*)$/'
67
+ config_set: '<state> logging timestamp <units>'
68
+ default_value: 'seconds'
78
69
  ```
79
- syslog_settings:
80
- timestamp:
81
- config_get: "show running-config all | include '^logging timestamp'"
82
- config_get_token: '/^logging timestamp (.*)$/'
83
- config_set: '<state> logging timestamp <units>'
84
- default_value: 'seconds'
70
+
71
+ ### <a name="yaml4">Y4: Avoid nested optional matches.
72
+
73
+ Regexps containing optional match strings inside other match strings become
74
+ complex to work with and difficult to maintain.
75
+
76
+ One case where this may crop up is in trying to match both affirmative and
77
+ negative variants of a config command:
78
+
79
+ ```yaml
80
+ config_get_token: ['/^interface <name>$/i', '/^((no )?switchport)$/']
81
+
82
+ config_get_token: '/^(no)? ?ip tacacs source-interface ?(\S+)?$/'
85
83
  ```
86
84
 
87
- ### <a name="yaml3">Y3: Avoid nested optional matches.
85
+ Instead, match the affirmative form of a command and treat its absence as
86
+ confirmation of the negative form:
88
87
 
89
- ### <a name="yaml4">Y4: Use the `_template` feature when getting/setting the same property value at multiple levels.
88
+ ```yaml
89
+ config_get_token: ['/^interface <name>$/i', '/^switchport$/']
90
+
91
+ config_get_token: '/^tacacs-server source-interface (\S+)$/'
92
+ ```
93
+
94
+ ### <a name="yaml5">Y5: Use the `_template` feature when getting/setting the same property value at multiple levels.
90
95
 
91
96
  Using the template below, `auto_cost` and `default_metric` can be set under `router ospf foo` and `router ospf foo; vrf blue`.
92
97
 
93
- ```
94
- ospf:
95
- _template:
96
- config_get: "show running ospf all"
97
- config_get_token: '/^router ospf <name>$/'
98
- config_get_token_append:
99
- - '/^vrf <vrf>$/'
100
- config_set: "router ospf <name>"
101
- config_set_append:
102
- - "vrf <vrf>"
103
-
104
- auto_cost:
105
- config_get_token_append: '/^auto-cost reference-bandwidth (\d+)\s*(\S+)?$/'
106
- config_set_append: "auto-cost reference-bandwidth <cost> <type>"
107
- default_value: [40, "Gbps"]
108
-
109
- default_metric:
110
- config_get_token_append: '/^default-metric (\d+)?$/'
111
- config_set_append: "<state> default-metric <metric>"
112
- default_value: 0
98
+ ```yaml
99
+ # ospf.yaml
100
+ _template:
101
+ config_get: "show running ospf all"
102
+ config_get_token: '/^router ospf <name>$/'
103
+ config_get_token_append:
104
+ - '/^vrf <vrf>$/'
105
+ config_set: "router ospf <name>"
106
+ config_set_append:
107
+ - "vrf <vrf>"
108
+
109
+ auto_cost:
110
+ config_get_token_append: '/^auto-cost reference-bandwidth (\d+)\s*(\S+)?$/'
111
+ config_set_append: "auto-cost reference-bandwidth <cost> <type>"
112
+ default_value: [40, "Gbps"]
113
+
114
+ default_metric:
115
+ config_get_token_append: '/^default-metric (\d+)?$/'
116
+ config_set_append: "<state> default-metric <metric>"
117
+ default_value: 0
113
118
  ```
114
119
 
115
- ### <a name="yaml5">Y5: When possible include a `default_value` that represents the system default value.
120
+ ### <a name="yaml6">Y6: When possible include a `default_value` that represents the system default value.
116
121
 
117
122
  Please make sure to specify a `default_value` and document properties that don't have a system default. System defaults may differ between cisco platforms making it important to define for lookup in the cisco_node_utils common object methods.
118
123
 
119
124
 
120
125
  Default value for `message_digest_alg_type` is `md5`
121
126
 
122
- ```
127
+ ```yaml
123
128
  message_digest_alg_type:
124
- config_get: 'show running interface all'
125
- config_get_token: ['/^interface %s$/i', '/^\s*ip ospf message-digest-key \d+ (\S+)/']
126
- default_value: 'md5'
129
+ config_get: 'show running interface all'
130
+ config_get_token: ['/^interface <name>$/i', '/^\s*ip ospf message-digest-key \d+ (\S+)/']
131
+ default_value: 'md5'
127
132
  ```
128
133
 
129
134
  **NOTE1: Use strings rather then symbols when applicable**.
130
135
 
131
- If the `default_value` differs between cisco platforms, the more specific `command_reference_[platform].yaml` file should be used.
136
+ If the `default_value` differs between cisco platforms, use per-API or per-platform keys in the YAML as needed. For example, if the default value on all platforms except the N9K is `md5` then you might do something like this:
137
+
138
+ ```yaml
139
+ message_digest_alg_type:
140
+ config_get: 'show running interface all'
141
+ config_get_token: ['/^interface <name>$/i', '/^\s*ip ospf message-digest-key \d+ (\S+)/']
142
+ /N9K/:
143
+ default_value: 'sha2'
144
+ else:
145
+ default_value: 'md5'
146
+ ```
132
147
 
133
- For example, if the default value on all platforms except the n9k is `md5` then set the entry in `command_reference_common.yaml` to `md5` and set the entry in `command_reference_n9k.yaml` to it's default `sha2`.
148
+ See [README_YAML](../lib/cisco_node_utils/cmd_ref/README_YAML.md) for more details about this advanced feature.
134
149
 
135
- ### <a name="yaml6">Y6: When possible, use the same `config_get` show command for all properties and document any anomalies.
150
+ ### <a name="yaml7">Y7: When possible, use the same `config_get` show command for all properties and document any anomalies.
136
151
 
137
152
  All properties below use the `show run tacacs all` command except `directed_request` which is documented.
138
153
 
139
- ```
140
- tacacs_server:
141
- deadtime:
142
- config_get: "show run tacacs all"
143
- config_get_token: '/^tacacs-server deadtime\s+(\d+)/'
144
- config_set: "%s tacacs-server deadtime %d"
145
- default_value: 0
146
-
147
- directed_request:
148
- # oddly, directed request must be retrieved from aaa output
149
- config_get: "show running aaa all"
150
- config_get_token: '/(?:no)?\s*tacacs-server directed-request/'
151
- config_set: "%s tacacs-server directed-request"
152
- default_value: false
153
-
154
- encryption_type:
155
- config_get: "show run tacacs all"
156
- config_get_token: '/^tacacs-server key (\d+)\s+(\S+)/'
157
- default_value: 0
158
-
159
- encryption_password:
160
- config_get: "show run tacacs all"
161
- config_get_token: '/^tacacs-server key (\d+)\s+(\S+)/'
162
- default_value: ""
154
+ ```yaml
155
+ # tacacs_server.yaml
156
+ deadtime:
157
+ config_get: "show run tacacs all"
158
+ config_get_token: '/^tacacs-server deadtime\s+(\d+)/'
159
+ config_set: "<state> tacacs-server deadtime <time>"
160
+ default_value: 0
161
+
162
+ directed_request:
163
+ # oddly, directed request must be retrieved from aaa output
164
+ config_get: "show running aaa all"
165
+ config_get_token: '/(?:no)?\s*tacacs-server directed-request/'
166
+ config_set: "<state> tacacs-server directed-request"
167
+ default_value: false
168
+
169
+ encryption_type:
170
+ config_get: "show run tacacs all"
171
+ config_get_token: '/^tacacs-server key (\d+)\s+(\S+)/'
172
+ default_value: 0
173
+
174
+ encryption_password:
175
+ config_get: "show run tacacs all"
176
+ config_get_token: '/^tacacs-server key (\d+)\s+(\S+)/'
177
+ default_value: ""
163
178
  ```
164
179
 
165
- ### <a name="yaml7">Y7: Use Key-value wildcards instead of Printf-style wildcards.
180
+ ### <a name="yaml8">Y8: Use Key-value wildcards instead of Printf-style wildcards.
166
181
 
167
- The following approach is moderately more complex to implement but is more readable in the ruby code and is flexible enough to handle significant platform differences in CLI. It is therefore the recommended approach for new development.
182
+ Key-value wildcards are moderately more complex to implement than Printf-style wildcards but they are more readable in the Ruby code and are flexible enough to handle significant platform differences in CLI. Key-value wildcards are therefore the recommended approach for new development.
168
183
 
169
184
  **Key-value wildcards**
170
185
 
171
- ```
186
+ ```yaml
172
187
  config_set_append: "<state> log-adjacency-changes <type>"
173
188
  ```
174
189
 
@@ -176,17 +191,20 @@ This following approach is quick to implement and concise, but less flexible - i
176
191
 
177
192
  **Printf-style wildcards**
178
193
 
179
- ```
194
+ ```yaml
180
195
  config_set_append: "%s log-adjacency-changes %s"
181
196
  ```
182
197
 
183
- ### <a name="yaml8">Y8: Selection of `show` commands for `config_get`.
198
+ ### <a name="yaml9">Y9: Selection of `show` commands for `config_get`.
184
199
 
185
200
  The following commands should be preferred over `show [feature]` commands since not all `show [feature]` commands behave in the same manner across cisco platforms.
186
201
 
187
202
  * `show running [feature] all` if available.
188
203
  * `show running all` if `show running [feature] all` is *not* available.
189
204
 
205
+ ### <a name="yaml10">Y10: Use `true` and `false` for boolean values.
206
+
207
+ YAML allows various synonyms for `true` and `false` such as `yes` and `no`, but for consistency and readability (especially to users more familiar with Ruby than with YAML), we recommend using `true` and `false` rather than any of their synonyms.
190
208
 
191
209
  ## Common Object Best Practices:
192
210
 
@@ -196,7 +214,7 @@ Many cisco features can be configured under the default or global vrf and also u
196
214
 
197
215
  The following `initialize` and `self.vrfs` methods account for configuration under `default` and `non-default vrfs`.
198
216
 
199
- ```
217
+ ```ruby
200
218
  def initialize(router, name, instantiate=true)
201
219
  fail TypeError if router.nil?
202
220
  fail TypeError if name.nil?
@@ -237,9 +255,9 @@ The following `initialize` and `self.vrfs` methods account for configuration und
237
255
 
238
256
  Having this logic defined in the common object lets the minitest easily check the specific instances.
239
257
 
240
- Without this equality operator `==` only passes if they are the same instance object. With this equality operator `==` passes if they are different objects referring to the same configuration on the node.
258
+ The built-in equality operator `==` returns true only if they are the same instance object. The `==` method below is used to override the built-in equality operator and return true even if they are different objects referring to the same configuration on the node.
241
259
 
242
- ```
260
+ ```ruby
243
261
  def ==(other)
244
262
  (name == other.name) && (vrf == other.vrf)
245
263
  end
@@ -247,7 +265,7 @@ Without this equality operator `==` only passes if they are the same instance ob
247
265
 
248
266
  Example Usage:
249
267
 
250
- ```
268
+ ```ruby
251
269
  def test_dnsdomain_create_destroy_multiple
252
270
  id1 = 'aoeu.com'
253
271
  id2 = 'asdf.com'
@@ -272,7 +290,7 @@ Example Usage:
272
290
 
273
291
  Our convention is to let `''` represent 'not configured at all' rather than `nil`. For example, `interface.rb`:
274
292
 
275
- ```
293
+ ```ruby
276
294
  def vrf
277
295
  vrf = config_get('interface', 'vrf', @name)
278
296
  return '' if vrf.nil?
@@ -290,7 +308,7 @@ def vrf=(vrf)
290
308
 
291
309
  However, if a property has a default value (it is never truly 'removed'), then we should do this instead:
292
310
 
293
- ```
311
+ ```ruby
294
312
  def access_vlan
295
313
  vlan = config_get('interface', 'access_vlan', @name)
296
314
  return default_access_vlan if vlan.nil?
@@ -307,7 +325,7 @@ In order to have a complete set of api's for each property it is important that
307
325
 
308
326
  This can be seen in the following `router_id` property.
309
327
 
310
- ```
328
+ ```ruby
311
329
  # Getter Method
312
330
  def router_id
313
331
  match = config_get('ospf', 'router_id', @get_args)
@@ -362,7 +380,7 @@ The more specific assertions also produce more helpful failure messages if somet
362
380
  Rather then hardcode an interface name that may or may not exist, instead use
363
381
  the `interfaces[]` array.
364
382
 
365
- ```
383
+ ```ruby
366
384
  def create_interface(ifname=interfaces[0])
367
385
  @default_show_command = show_cmd(ifname)
368
386
  Interface.new(ifname)
@@ -375,11 +393,11 @@ If additional interfaces are needed array index `1` and `2` may be used.
375
393
 
376
394
  For conveninence the `config` helper method has been provided for device configuration within the minitests.
377
395
 
378
- ```
396
+ ```ruby
379
397
  config('no feature ospf')
380
398
  ```
381
399
 
382
- ```
400
+ ```ruby
383
401
  config('feature ospf'; 'router ospf green')
384
402
  ```
385
403
 
@@ -387,7 +405,7 @@ config('feature ospf'; 'router ospf green')
387
405
 
388
406
  We have a very common pattern in minitest where we execute some show command over the telnet connection, match it against some regexp pattern, and succeed or fail based on the result. Helper methods `assert_show_match` and `refute_show_match` support this pattern.
389
407
 
390
- ```
408
+ ```ruby
391
409
  assert_show_match(command: 'show run all | no-more',
392
410
  pattern: /interface port-channel 1/,
393
411
  msg: 'port-channel is not present but it should be')
@@ -395,7 +413,7 @@ assert_show_match(command: 'show run all | no-more',
395
413
 
396
414
  If your `command` and/or `pattern` are the same throughout a test case or throughout a test suite, you can set the test case instance variables `@default_show_command` and/or `@default_output_pattern` which serve as defaults for these parameters:
397
415
 
398
- ```
416
+ ```ruby
399
417
  @default_show_command = 'show run interface all | include "interface" | no-more'
400
418
  assert_output_match(pattern: /interface port-channel 10/)
401
419
  refute_output_match(pattern: /interface port-channel 11/)