Skip to content

Commit 3c560ab

Browse files
committed
Merge pull request #392 from cisco/release_1.3.0
Merge 'release_1.3.0' to 'master'
2 parents 2b1a9f6 + b44613b commit 3c560ab

File tree

253 files changed

+22299
-8341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+22299
-8341
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
pkg/*
33
vendor/*
44
coverage
5+
ext/Rakefile
56
Gemfile.lock
67
*.gem
78
*.swp
9+
TAGS

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--require spec_helper

.rubocop.yml

+13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Rubocop configuration
2+
AllCops:
3+
Exclude:
4+
# Auto-generated files
5+
- lib/cisco_node_utils/client/grpc/ems.rb
6+
- lib/cisco_node_utils/client/grpc/ems_services.rb
7+
# Files we don't own
8+
- vendor/**/*
29

310
# Code complexity metrics are tracked separately for lib/ vs. tests/
411
# See lib/.rubocop.yml and tests/.rubocop.yml
@@ -40,6 +47,9 @@ Style/AlignHash:
4047
EnforcedHashRocketStyle: table
4148
EnforcedColonStyle: table
4249

50+
Style/ClassAndModuleChildren:
51+
Enabled: false
52+
4353
# Template files have wildcard strings in class names
4454
Style/ClassAndModuleCamelCase:
4555
Exclude:
@@ -75,6 +85,9 @@ Style/SpaceAroundEqualsInParameterDefault:
7585
Style/TrailingComma:
7686
EnforcedStyleForMultiline: comma
7787

88+
Style/TrivialAccessors:
89+
AllowPredicates: true
90+
7891
# Because an SnmpServer cannot be destroyed, we end most of the SnmpServer
7992
# test cases by explicitly returning the configuration to default.
8093
# Rubocop thinks this is a no-op but it isn't.

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ cache: bundler
66
rvm:
77
- 2.2.2
88
- 2.1.6
9-
- 2.0.0
9+
- 2.0.0-p648 # specify non-clang version of ruby
10+
11+
script:
12+
- bundle exec rake

CHANGELOG.md

+81-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,80 @@
11
Changelog
22
=========
33

4+
## [v1.3.0]
5+
6+
### New feature support
7+
8+
#### Cisco Resources
9+
* Itd
10+
* itd_device_group (@saichint)
11+
* itd_device_group_node (@saichint)
12+
* itd_service (@saichint)
13+
* Spanning Tree
14+
* stp_global (@saichint)
15+
* Bridge Domain
16+
* bridge_domain (@rkorlepa)
17+
* bridge_domain_vni (@rkorlepa)
18+
* Encapsulation Profile
19+
* vni_encapsulation_profile (@rkorlepa)
20+
21+
#### NetDev Resources
22+
*
23+
24+
### Added
25+
26+
* Added a new property fabric-control for vlan MT-FULL fabricpath
27+
* Added support for bdi interfaces to interface provider.
28+
* Added a new node util to handle bridge domain range cli for member vni
29+
* Added Bridge Domain, VNI and encapsulation profile node utils for MT-FULL on Nexus 7k.
30+
* Minitests can declare the YAML feature they are exercising, and if the feature is `_exclude`d on the node under test, the test case will automatically be skipped in full.
31+
* CliErrors raised by any `NodeUtil` subclass or instance will automatically prepend the `to_s` method output to make troubleshooting easier.
32+
* `test_feature` minitest
33+
* Extend interface with attributes:
34+
* `ipv4_forwarding`
35+
* `stp_bpdufilter`, `stp_bpduguard`, `stp_cost`, `stp_guard`, `stp_link_type`, `stp_mst_cost`
36+
* `stp_mst_port_priority`, `stp_port_priority`, `stp_port_type`, `stp_vlan_cost`, `stp_vlan_port_priority`
37+
* `switchport_private_vlan_trunk_allowed_vlan`, `switchport_private_vlan_trunk_native_vlan`
38+
* `switchport_mode_private_vlan_host`, `switchport_mode_private_vlan_host_association`
39+
* `switchport_mode_private_vlan_host_promiscous`, `switchport_mode_private_vlan_trunk_promiscous`, `switchport_mode_private_vlan_trunk_secondary`
40+
* `switchport_private_vlan_association_trunk`, `switchport_private_vlan_mapping_trunk`
41+
* `private_vlan_mapping`
42+
* Extend Feature class with a class method to list feature compatible interfaces
43+
* Extend vdc with interface_membership methods
44+
* Extend vpc with vpc+ attributes on Nexus 5k/6k/7k:
45+
* `fabricpath_emulated_switch_id`
46+
* `fabricpath_multicast_load_balance` (only on Nexus 7k)
47+
* `port_channel_limit` (only on Nexus 7k)
48+
* Extend vlan with attributes:
49+
* `private_vlan_association`, `private_vlan_type`
50+
* Added N3k native support for portchannel_global
51+
52+
### Changed
53+
54+
* Major refactor and enhancement of `CommandReference` YAML files:
55+
- Filtering by platform is now by platform name only.
56+
- Replaced `config_get(_token)?(_append)?` with `get_command`, `get_context`, and `get_value`
57+
- Replaced `config_set(_append)?` with `set_context`, and `set_value`
58+
- Individual token values can be explicitly marked as optional (e.g., VRF context); tokens not marked as optional are mandatory.
59+
- Data format (CLI, NXAPI structured) is now assumed to be CLI unless explicitly specified otherwise using the new `(get_|set_)?data_format` YAML key. No more guessing based on whether a key looks like a hash key or a Regexp.
60+
* `cisco_nxapi` Gem is no longer a dependency as the NXAPI client code has been merged into this Gem under the `Cisco::Client` namespace.
61+
* Improved minitest logging CLI.
62+
- `ruby test_foo.rb -l debug` instead of `ruby test_foo.rb -- <host> <user> <pass> debug`
63+
- `rake test TESTOPTS='--log-level=debug'`
64+
* Client connectivity is now specified in `/etc/cisco_node_utils.yaml` or `~/cisco_node_utils.yaml` instead of environment variables or command-line arguments to minitest.
65+
- `ruby test_foo.rb -e <node name defined in YAML>`
66+
- `rake test TESTOPTS='--environment=default'`
67+
68+
### Fixed
69+
70+
* Interface:
71+
- Correctly restore IP address when changing VRF membership
72+
- MTU is not supported on loopback interfaces
73+
74+
### Removed
75+
* Removed `Node.lazy_connect` internal API.
76+
* Removed `vni` node util class
77+
478
## [v1.2.0]
579

680
### New feature support
@@ -40,7 +114,7 @@ Changelog
40114
* vxlan_vtep (@dcheriancisco)
41115
* vxlan_vtep_vni (@mikewiebe)
42116

43-
117+
44118
### Additional platform support added to existing classes
45119
#### Cisco Nexus 56xx, 60xx and 7xxx
46120
* AAA
@@ -110,7 +184,11 @@ Changelog
110184
* `vpc_id`, `vpc_peer_link`
111185
* switchport mode `fabricpath`
112186
* Extend vrf with attributes:
187+
* `mhost_ipv4`
188+
* `mhost_ipv6`
189+
* `remote_route_filtering`
113190
* `vni`
191+
* `vpn_id`
114192
* Extend vlan with attribute:
115193
* `mode`
116194

@@ -119,7 +197,7 @@ Changelog
119197
* Major refactor and enhancement of `CommandReference` YAML files:
120198
- Added support for `auto_default`, `default_only`, `kind`, and `multiple`
121199
- 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).
200+
- `CommandReference` methods that do key-value style wildcard substitution now raise an `ArgumentError` if the result is empty (because not enough parameters were supplied).
123201

124202
## [v1.1.0]
125203

@@ -216,6 +294,7 @@ Changelog
216294
[git-flow]: https://github.com/petervanderdoes/gitflow-avh
217295
[SimpleCov]: https://github.com/colszowka/simplecov
218296

297+
[v1.3.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.2.0...v1.3.0
219298
[v1.2.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.1.0...v1.2.0
220299
[v1.1.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.1...v1.1.0
221300
[v1.0.1]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.0...v1.0.1

CONTRIBUTING.md

+2-17
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,13 @@ Cisco Network Elements support a rich set of features to make networks robust, e
99
## Making Changes
1010

1111
* Fork and clone the repository
12-
* Run the `bin/git/update-hooks` script to install our recommended Git hooks into your local repository.
12+
* Run the `bin/git/update-hooks` script to install our recommended Git hooks into your local repository. (Note: some of the hooks require additional tools, such as the `rubocop` ruby gem, be installed and available in your `$PATH`. See [Ruby Prerequisites](docs/README-develop-node-utils-APIs.md#prereq_ruby) for a list of recommended ruby gems.)
1313
* Pull a branch under the "develop" branch for your changes.
1414
* Follow all guidelines documented in [README-develop-node_utils-APIs](docs/README-develop-node-utils-APIs.md)
1515
* Make changes in your branch.
1616
* Testing
1717
* Create a minitest script for any new APIs or new functionality
18-
* Run all the tests to ensure there was no collateral damage to existing code. There are two ways you can specify the Nexus switch (virtual or physical) to test against when running the full test suite:
19-
1. Use the NODE environment variable to specify the address, username, and password:
20-
21-
```bash
22-
export NODE="192.168.100.1 user password"
23-
rake test
24-
```
25-
26-
2. Enter the connection information at runtime:
27-
28-
```
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-
```
18+
* Run all the tests to ensure there was no collateral damage to existing code. See [README-test-execution](docs/README-test-execution.md) for details.
3419

3520
* Committing
3621
* Check for unnecessary whitespace with `git diff --check` before committing.

Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
22

33
# Specify your gem's dependencies in cisco_node_utils.gemspec
44
gemspec
5+
6+
# These are optional dependencies in the Gem itself,
7+
# but we need them for Bundler to use.
8+
gem 'net_http_unix'
9+
gem 'grpc'

README.md

+92-47
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ Please see [Learning Resources](#resources) for additional references.
2323
#### Table of Contents
2424

2525
1. [Overview](#overview)
26-
2. [Installation](#installation)
27-
3. [Examples](#examples)
28-
4. [Documentation](#documentation)
29-
5. [Changelog](#changelog)
30-
6. [Learning Resources](#resources)
31-
7. [License Information](#license_info)
26+
1. [Installation](#installation)
27+
1. [Configuration](#configuration)
28+
1. [Documentation](#documentation)
29+
1. [Examples](#examples)
30+
1. [Changelog](#changelog)
31+
1. [Learning Resources](#resources)
32+
1. [License Information](#license_info)
3233

3334

3435
## <a name="overview">Overview</a>
@@ -39,17 +40,13 @@ open source management tools.
3940

4041
This CiscoNodeUtils gem release supports the following:
4142

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-
43+
Platform | OS | OS Version |
44+
-----------------|--------|----------------------|
45+
Cisco Nexus N9k | NX-OS | 7.0(3)I2(1) and later
46+
Cisco Nexus N3k | NX-OS | 7.0(3)I2(1) and later
47+
Cisco Nexus N5k | NX-OS | 7.3(0)N1(1) and later
48+
Cisco Nexus N6k | NX-OS | 7.3(0)N1(1) and later
49+
Cisco Nexus N7k | NX-OS | 7.3(0)D1(1) and later
5350

5451
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 <[email protected]>. 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)
5552

@@ -64,53 +61,41 @@ To install the CiscoNodeUtils, use the following command:
6461
Alternatively, if you've checked the source out directly, you can call
6562
`rake install` from the root project directory.
6663

67-
## <a name="examples">Examples</a>
64+
## Configuration
6865

66+
This gem may require configuration in order to be used. Two configuration file locations are supported:
6967

70-
These utilities can be used directly on a Cisco device (as used by Puppet
71-
and Chef) or can run on a workstation and point to a Cisco device (as used
72-
by the included minitest suite).
68+
* `/etc/cisco_node_utils.yaml` (system and/or root user configuration)
69+
* `~/cisco_node_utils.yaml` (per-user configuration)
7370

74-
### Usage on a Cisco device
71+
If both files exist and are readable, configuration in the user-specific file will take precedence over the system configuration.
7572

76-
```ruby
77-
require 'cisco_node_utils'
73+
This file specifies the host, port, username, and/or password to be used to connect to one or more nodes.
7874

79-
# get a connection to the local device
80-
node = Cisco::Node.instance()
81-
82-
version = node.config_get("show_version", "system_image")
83-
84-
node.config_set("vtp", "domain", "mycompany.com")
85-
```
86-
87-
### Remote usage
88-
89-
```ruby
90-
require 'cisco_node_utils'
75+
* When developing for or testing this gem, this file can specify one or more NX-OS nodes to run tests against. In this case:
76+
- A node labeled as `default` will be the default node to test against.
77+
- Nodes with other names can be selected at test execution time.
78+
- NX-OS nodes must be defined with a `host` (hostname or IP address), `username`, and `password`.
9179

92-
Cisco::Node.lazy_connect = true
80+
An example configuration file (illustrating each of the above scenarios) is provided with this gem at [`docs/cisco_node_utils.yaml.example`](docs/cisco_node_utils.yaml.example).
9381

94-
node = Cisco::Node.instance()
95-
node.connect("n3k.mycompany.com", "username", "password")
82+
## <a name="documentation">Documentation</a>
9683

97-
version = node.config_get("show_version", "system_image")
84+
### Client
9885

99-
node.config_set("vtp", "domain", "mycompany.com")
100-
```
86+
The `Client` class provides a low-level interface for communicating with the Cisco network node. It provides the base APIs `create`, `get`, and `set`.
10187

102-
## <a name="documentation">Documentation</a>
88+
* `Cisco::Client::NXAPI` - client for communicating with NX-OS 7.0(3)I2(1) and later, using NX-API.
10389

90+
For a greater level of abstraction, the `Node` class is generally used, but the `Client` classes can be invoked directly if desired.
10491

10592
### Node
10693

107-
The `Node` class is a singleton which provides for management of a given Cisco
108-
network node. It provides the base APIs `config_set`, `config_get`, and
109-
`config_get_default`.
94+
The `Node` class is a singleton which wraps around the `Client` class to provide for management of a given Cisco network node. It provides the base APIs `config_set`, `config_get`, and `config_get_default`.
11095

11196
### CommandReference
11297

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`.
98+
The `CommandReference` class abstracts away the differences between various supported `Node` types, be that API differences (CLI vs. YANG) or hardware differences (Nexus N9k vs. Nexus N3k). 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`.
11499

115100
See also [README_YAML](lib/cisco_node_utils/cmd_ref/README_YAML.md).
116101

@@ -132,6 +117,66 @@ code duplication between the Cisco Puppet modules and the Cisco Chef cookbooks.
132117
Generally speaking, Puppet and Chef should only interact with the feature
133118
provider classes, and not directly call into `CommandReference` or `Node`.
134119

120+
## <a name="examples">Examples</a>
121+
122+
123+
These utilities can be used directly on a Cisco device (as used by Puppet
124+
and Chef) or can run on a workstation and point to a Cisco device (as used
125+
by the included minitest suite).
126+
127+
### Usage on a Cisco device
128+
129+
#### Low-level Client API
130+
131+
```ruby
132+
require 'cisco_node_utils'
133+
134+
# get a connection to the local device
135+
client = Cisco::Client.create()
136+
137+
client.get(command: 'show version')
138+
client.set(values: 'vtp domain mycompany.com')
139+
```
140+
141+
#### High-level Node API
142+
143+
```ruby
144+
require 'cisco_node_utils'
145+
146+
# get a connection to the local device
147+
node = Cisco::Node.instance()
148+
149+
version = node.config_get("show_version", "system_image")
150+
151+
node.config_set("vtp", "domain", "mycompany.com")
152+
```
153+
154+
### Remote usage
155+
156+
#### Low-level Client API
157+
158+
```ruby
159+
require 'cisco_node_utils'
160+
161+
client = Cisco::Client.create('n3k.mycompany.com', 'username', 'password')
162+
163+
client.get(command: 'show version')
164+
client.set(values: 'vtp domain mycompany.com')
165+
```
166+
167+
#### High-level Node API
168+
169+
```ruby
170+
require 'cisco_node_utils'
171+
172+
node = Cisco::Node.new("n3k.mycompany.com", "username", "password")
173+
174+
version = node.config_get("show_version", "system_image")
175+
176+
node.config_set("vtp", "domain", "mycompany.com")
177+
```
178+
179+
135180
## <a name="changelog">Changelog</a>
136181

137182

0 commit comments

Comments
 (0)