cisco_node_utils 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +81 -1
- data/.travis.yml +9 -0
- data/CHANGELOG.md +72 -6
- data/CONTRIBUTING.md +32 -7
- data/README.md +70 -7
- data/Rakefile +17 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +81 -0
- data/bin/git/hooks/hook_lib +108 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/rubocop +20 -0
- data/bin/git/hooks/pre-commit/validate-diffs +31 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +65 -0
- data/cisco_node_utils.gemspec +9 -3
- data/docs/README-develop-best-practices.md +404 -0
- data/docs/README-develop-node-utils-APIs.md +215 -365
- data/docs/README-maintainers.md +33 -3
- data/docs/template-router.rb +89 -91
- data/docs/template-test_router.rb +52 -55
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils.rb +2 -19
- data/lib/cisco_node_utils/README_YAML.md +1 -9
- data/lib/cisco_node_utils/bgp.rb +664 -0
- data/lib/cisco_node_utils/bgp_af.rb +530 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +425 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +709 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +59 -25
- data/lib/cisco_node_utils/command_reference.rb +72 -74
- data/lib/cisco_node_utils/command_reference_common.yaml +174 -9
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +535 -0
- data/lib/cisco_node_utils/command_reference_n7k.yaml +4 -0
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -9
- data/lib/cisco_node_utils/configparser_lib.rb +152 -147
- data/lib/cisco_node_utils/dns_domain.rb +79 -0
- data/lib/cisco_node_utils/domain_name.rb +71 -0
- data/lib/cisco_node_utils/interface.rb +167 -161
- data/lib/cisco_node_utils/interface_ospf.rb +78 -81
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +154 -198
- data/lib/cisco_node_utils/node_util.rb +61 -0
- data/lib/cisco_node_utils/ntp_config.rb +65 -0
- data/lib/cisco_node_utils/ntp_server.rb +76 -0
- data/lib/cisco_node_utils/platform.rb +174 -165
- data/lib/cisco_node_utils/radius_global.rb +146 -0
- data/lib/cisco_node_utils/radius_server.rb +295 -0
- data/lib/cisco_node_utils/router_ospf.rb +59 -63
- data/lib/cisco_node_utils/router_ospf_vrf.rb +226 -210
- data/lib/cisco_node_utils/snmpcommunity.rb +52 -58
- data/lib/cisco_node_utils/snmpgroup.rb +22 -23
- data/lib/cisco_node_utils/snmpserver.rb +99 -103
- data/lib/cisco_node_utils/snmpuser.rb +294 -274
- data/lib/cisco_node_utils/syslog_server.rb +92 -0
- data/lib/cisco_node_utils/syslog_settings.rb +69 -0
- data/lib/cisco_node_utils/tacacs_server.rb +137 -133
- data/lib/cisco_node_utils/tacacs_server_host.rb +84 -87
- data/lib/cisco_node_utils/version.rb +2 -1
- data/lib/cisco_node_utils/vlan.rb +28 -31
- data/lib/cisco_node_utils/vrf.rb +80 -0
- data/lib/cisco_node_utils/vtp.rb +100 -97
- data/lib/cisco_node_utils/yum.rb +15 -17
- data/tests/.rubocop.yml +15 -0
- data/tests/basetest.rb +81 -36
- data/tests/ciscotest.rb +38 -78
- data/{lib/cisco_node_utils → tests}/platform_info.rb +12 -8
- data/{lib/cisco_node_utils → tests}/platform_info.yaml +1 -1
- data/tests/test_bgp_af.rb +920 -0
- data/tests/test_bgp_neighbor.rb +403 -0
- data/tests/test_bgp_neighbor_af.rb +589 -0
- data/tests/test_command_config.rb +65 -62
- data/tests/test_command_reference.rb +31 -45
- data/tests/test_dns_domain.rb +113 -0
- data/tests/test_domain_name.rb +86 -0
- data/tests/test_interface.rb +424 -548
- data/tests/test_interface_ospf.rb +248 -432
- data/tests/test_interface_svi.rb +56 -79
- data/tests/test_interface_switchport.rb +196 -272
- data/tests/test_name_server.rb +85 -0
- data/tests/test_node.rb +7 -6
- data/tests/test_node_ext.rb +133 -186
- data/tests/test_ntp_config.rb +49 -0
- data/tests/test_ntp_server.rb +74 -0
- data/tests/test_platform.rb +58 -37
- data/tests/test_radius_global.rb +78 -0
- data/tests/test_radius_server.rb +185 -0
- data/tests/test_router_bgp.rb +838 -0
- data/tests/test_router_ospf.rb +49 -80
- data/tests/test_router_ospf_vrf.rb +274 -392
- data/tests/test_snmpcommunity.rb +128 -172
- data/tests/test_snmpgroup.rb +12 -14
- data/tests/test_snmpserver.rb +160 -189
- data/tests/test_snmpuser.rb +568 -717
- data/tests/test_syslog_server.rb +88 -0
- data/tests/test_syslog_settings.rb +54 -0
- data/tests/test_tacacs_server.rb +113 -148
- data/tests/test_tacacs_server_host.rb +108 -161
- data/tests/test_vlan.rb +63 -79
- data/tests/test_vrf.rb +92 -0
- data/tests/test_vtp.rb +108 -126
- data/tests/test_yum.rb +47 -41
- metadata +92 -56
- data/.rubocop_todo.yml +0 -293
- data/docs/.rubocop.yml +0 -13
- data/docs/template-feature.rb +0 -45
- data/docs/template-test_feature.rb +0 -51
- data/tests/test_all_cisco.rb +0 -46
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6396905732ac665cf55bb63e17792c399a95c41f
|
4
|
+
data.tar.gz: 0a007ab3337c8dfe52a35deabb9a7627ba539e0f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd703cf0f14758739bc2382296af32c2b4c202884a3fc53132e0e3e69e1de5135035b2a98afd2b2632d21062d605779fdf3506d0210056c5542a747c05419ade
|
7
|
+
data.tar.gz: 4d52c817fd90803451306ab759de4b28b2dc17818291b2d14440299ded9d8fe5641c5e22e800508175ba20d5cb73bfc580044e920bcd3cdbb175a3c5c810965b
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,3 +1,83 @@
|
|
1
1
|
# Rubocop configuration
|
2
2
|
|
3
|
-
|
3
|
+
# Code complexity metrics are tracked separately for lib/ vs. tests/
|
4
|
+
# See lib/.rubocop.yml and tests/.rubocop.yml
|
5
|
+
Metrics/AbcSize:
|
6
|
+
Enabled: true
|
7
|
+
|
8
|
+
Metrics/CyclomaticComplexity:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Metrics/MethodLength:
|
12
|
+
Enabled: true
|
13
|
+
Exclude:
|
14
|
+
- docs/*.rb
|
15
|
+
|
16
|
+
Metrics/ParameterLists:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Metrics/PerceivedComplexity:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
# Template files have long lines before tag replacement
|
23
|
+
Metrics/LineLength:
|
24
|
+
Exclude:
|
25
|
+
- docs/*.rb
|
26
|
+
|
27
|
+
#
|
28
|
+
# Team preferences different from Rubocop defaults:
|
29
|
+
#
|
30
|
+
|
31
|
+
# We don't find either of these to be useful:
|
32
|
+
Metrics/ClassLength:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Metrics/ModuleLength:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
# We like table alignment for readability
|
39
|
+
Style/AlignHash:
|
40
|
+
EnforcedHashRocketStyle: table
|
41
|
+
EnforcedColonStyle: table
|
42
|
+
|
43
|
+
# Template files have wildcard strings in class names
|
44
|
+
Style/ClassAndModuleCamelCase:
|
45
|
+
Exclude:
|
46
|
+
- docs/*.rb
|
47
|
+
|
48
|
+
# Permit is_a? and kind_of? interchangeably
|
49
|
+
Style/ClassCheck:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
# Template files have atypical file names on purpose
|
53
|
+
Style/FileName:
|
54
|
+
Exclude:
|
55
|
+
- docs/*.rb
|
56
|
+
|
57
|
+
# As a team we like 'sprintf' rather than 'format'
|
58
|
+
Style/FormatString:
|
59
|
+
EnforcedStyle: sprintf
|
60
|
+
|
61
|
+
# Mixed keys are ugly. Use one or the other as needed
|
62
|
+
Style/HashSyntax:
|
63
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
64
|
+
|
65
|
+
# Template files have wildcard strings in method names
|
66
|
+
Style/MethodName:
|
67
|
+
Exclude:
|
68
|
+
- docs/*.rb
|
69
|
+
|
70
|
+
# "def foo(bar=baz)" not "def foo(bar = baz)"
|
71
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
72
|
+
EnforcedStyle: no_space
|
73
|
+
|
74
|
+
# Make it neater to extend multi-line arrays and hashes
|
75
|
+
Style/TrailingComma:
|
76
|
+
EnforcedStyleForMultiline: comma
|
77
|
+
|
78
|
+
# Because an SnmpServer cannot be destroyed, we end most of the SnmpServer
|
79
|
+
# test cases by explicitly returning the configuration to default.
|
80
|
+
# Rubocop thinks this is a no-op but it isn't.
|
81
|
+
Lint/UselessSetterCall:
|
82
|
+
Exclude:
|
83
|
+
- 'tests/test_snmpserver.rb'
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,72 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
-
1.0
|
5
|
-
|
4
|
+
## [v1.1.0]
|
5
|
+
|
6
|
+
### New feature support
|
7
|
+
* BGP
|
8
|
+
* bgp (@mikewiebe)
|
9
|
+
* bgp_af (@richwellum)
|
10
|
+
* bgp_neighbor (@jyang09)
|
11
|
+
* bgp_neighbor_af (@chrisvanheuveln)
|
12
|
+
* NTP
|
13
|
+
* ntp_config (@jonnytpuppet)
|
14
|
+
* ntp_server (@jonnytpuppet)
|
15
|
+
* RADIUS
|
16
|
+
* radius_global (@jonnytpuppet)
|
17
|
+
* radius_server (@jonnytpuppet)
|
18
|
+
* SYSLOG
|
19
|
+
* syslog_server (@jonnytpuppet)
|
20
|
+
* syslog_setting (@jonnytpuppet)
|
21
|
+
* Miscellaneous
|
22
|
+
* dns_domain (@hunner)
|
23
|
+
* domain_name (@bmjen)
|
24
|
+
* name_server (@hunner)
|
25
|
+
* network_snmp (@jonnytpuppet)
|
26
|
+
|
27
|
+
### Added
|
28
|
+
|
29
|
+
* Enabled [Travis-CI](https://travis-ci.org) integration to automatically run [rubocop](https://github.com/bbatsov/rubocop). Fixed all baseline rubocop warnings.
|
30
|
+
* Added git hooks to streamline certain processes:
|
31
|
+
* Validate commit message format for consistency
|
32
|
+
* Don't allow commit of code failing RuboCop `--lint` checks
|
33
|
+
* If RuboCop is failing any check, warn on commit (but don't fail), and fail on push.
|
34
|
+
* Don't allow push without updating CHANGELOG.md
|
35
|
+
* Once git hooks are installed, automatically update them on pull/merge (if possible).
|
36
|
+
* If using [git-flow]:
|
37
|
+
* `git flow release start` and `git flow hotfix start` will automatically update `CHANGELOG.md` and `version.rb` for the new release version
|
38
|
+
* `git flow release finish` will automatically bump the version number for the develop branch.
|
39
|
+
* Minitest enhancements:
|
40
|
+
* Code coverage calculation using [SimpleCov]
|
41
|
+
* Full Minitest suite can be run by `rake test`
|
42
|
+
* UUT can be specified by the `NODE` environment variable or at runtime, in addition to the classic method of command line arguments to `ruby test_my_file.rb`
|
43
|
+
* Added `config` and `(assert|refute)_show_match` helper methods for testing.
|
44
|
+
* Added `bin/check_metric_limits.rb` helper script in support of refactoring.
|
45
|
+
* Added best practices development guide.
|
46
|
+
|
47
|
+
### Fixed
|
48
|
+
|
49
|
+
* Fixed several bugs in `SnmpUser.(auth|priv)_password_equal?`
|
50
|
+
* Fixed a bug in `test_interface.rb` that was keeping it from properly exercising the `negotiate_auto` functionality.
|
51
|
+
* Added a cache_flush call in `Platform.chassis` to work around an infrequent issue.
|
52
|
+
|
53
|
+
### Changed
|
54
|
+
|
55
|
+
* Added missing steps to CONTRIBUTING.md and README-develop-node-utils-APIs.md
|
56
|
+
* Added git config comments
|
57
|
+
* Moved `platform_info.(rb|yaml)` from `lib/` to `tests/` as it is test-only code.
|
58
|
+
* Now requires Minitest ~> 5.0 instead of Minitest < 5.0.
|
59
|
+
|
60
|
+
### Removed
|
61
|
+
|
62
|
+
* Dropped support for Ruby 1.9.3 as it is end-of-life.
|
63
|
+
* Removed `test_all_cisco.rb` as `rake test` can auto-discover all tests.
|
64
|
+
|
65
|
+
## [v1.0.1]
|
6
66
|
|
7
67
|
* Updated to fix broken documentation links.
|
8
68
|
|
9
|
-
|
10
|
-
-----
|
69
|
+
## [v1.0.0]
|
11
70
|
|
12
71
|
* Improved logic in Vtp class to handle the presence or absence of
|
13
72
|
'feature vtp' and 'vtp domain' configuration.
|
@@ -25,8 +84,15 @@ Changelog
|
|
25
84
|
* vrf member
|
26
85
|
* Move misc READMEs into /docs
|
27
86
|
|
28
|
-
0.9.0
|
29
|
-
-----
|
87
|
+
## 0.9.0
|
30
88
|
|
31
89
|
* First public release, corresponding to Early Field Trial (EFT) of
|
32
90
|
Cisco NX-OS 7.0(3)I2(1).
|
91
|
+
|
92
|
+
[git-flow]: https://github.com/petervanderdoes/gitflow-avh
|
93
|
+
[SimpleCov]: https://github.com/colszowka/simplecov
|
94
|
+
|
95
|
+
[v1.1.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.1...v1.1.0
|
96
|
+
[v1.0.1]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.0...v1.0.1
|
97
|
+
[v1.0.0]: https://github.com/cisco/cisco-network-node-utils/compare/v0.9.0...v1.0.0
|
98
|
+
|
data/CONTRIBUTING.md
CHANGED
@@ -4,28 +4,53 @@ Cisco Network Elements support a rich set of features to make networks robust, e
|
|
4
4
|
## Getting Started
|
5
5
|
|
6
6
|
* Create a [GitHub account](https://github.com/signup/free)
|
7
|
-
*
|
7
|
+
* 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)
|
8
8
|
|
9
9
|
## Making Changes
|
10
10
|
|
11
|
-
* Fork the repository
|
11
|
+
* Fork and clone the repository
|
12
|
+
* Run the `bin/git/update-hooks` script to install our recommended Git hooks into your local repository.
|
12
13
|
* Pull a branch under the "develop" branch for your changes.
|
13
14
|
* Follow all guidelines documented in [README-develop-node_utils-APIs](docs/README-develop-node-utils-APIs.md)
|
14
15
|
* Make changes in your branch.
|
15
16
|
* Testing
|
16
|
-
* Create a minitest for new APIs or new functionality
|
17
|
-
* Run all the tests to ensure there was no collateral damage to existing code
|
17
|
+
* 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
|
+
```
|
34
|
+
|
18
35
|
* Committing
|
19
36
|
* Check for unnecessary whitespace with `git diff --check` before committing.
|
20
|
-
* Run `rubocop
|
37
|
+
* Run `rubocop` against all changed files. See [https://rubygems.org/gems/rubocop](https://rubygems.org/gems/rubocop)
|
21
38
|
* Make sure your commit messages clearly describe the problem you are trying to solve and the proposed solution.
|
39
|
+
* Be sure to update `CHANGELOG.md` with a note about what you have added or fixed.
|
22
40
|
|
23
41
|
## Submitting Changes
|
24
42
|
|
25
|
-
|
43
|
+
All contributions submitted to this project are voluntary and subject to the terms of the Apache 2.0 license
|
26
44
|
* Submit a pull request to the repository
|
27
|
-
*
|
45
|
+
* Include output of all added or modified minitest scripts.
|
46
|
+
* A core team consisting of Cisco and Cisco-Partner employees will review the Pull Request and provide feedback.
|
28
47
|
* After feedback has been given we expect responses within two weeks. After two weeks we may close the pull request if it isn't showing any activity.
|
48
|
+
* All code commits must be associated with your github account and email address. Before committing any code use the following commands to update your workspace with your credentials:
|
49
|
+
|
50
|
+
```bash
|
51
|
+
git config --global user.name "John Doe"
|
52
|
+
git config --global user.email johndoe@example.com
|
53
|
+
```
|
29
54
|
|
30
55
|
# Additional Resources
|
31
56
|
|
data/README.md
CHANGED
@@ -1,11 +1,46 @@
|
|
1
1
|
# CiscoNodeUtils - Cisco Node Utilities
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/cisco_node_utils.svg)](http://badge.fury.io/rb/cisco_node_utils)
|
4
|
+
[![Build Status](https://travis-ci.org/cisco/cisco-network-node-utils.svg?branch=develop)](https://travis-ci.org/cisco/cisco-network-node-utils)
|
5
|
+
|
6
|
+
--
|
7
|
+
##### Documentation Workflow Map
|
8
|
+
|
9
|
+
This workflow map aids *users*, *developers* and *maintainers* of the CiscoNodeUtils project in selecting the appropriate document(s) for their task.
|
10
|
+
|
11
|
+
* User Guides - the remainder of this document is aimed at end users
|
12
|
+
* Developer Guides
|
13
|
+
* [CONTRIBUTING.md](CONTRIBUTING.md) : Contribution guidelines
|
14
|
+
* [README-develop-node-utils-APIs.md](docs/README-develop-node-utils-APIs.md) : Developing new CiscoNodeUtils APIs
|
15
|
+
* [README-develop-best-practices.md](docs/README-develop-best-practices.md) : Development best practices
|
16
|
+
* Maintainers Guides
|
17
|
+
* [README-maintainers.md](docs/README-maintainers.md) : Guidelines for core maintainers of the CiscoNodeUtils project
|
18
|
+
* All developer guides apply to maintainers as well
|
19
|
+
|
20
|
+
Please see [Learning Resources](#resources) for additional references.
|
21
|
+
|
22
|
+
--
|
23
|
+
#### Table of Contents
|
24
|
+
|
25
|
+
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)
|
32
|
+
|
33
|
+
|
34
|
+
## <a name="overview">Overview</a>
|
35
|
+
|
3
36
|
The CiscoNodeUtils gem provides utilities for management of Cisco network
|
4
37
|
nodes. It is designed to work with Puppet and Chef as well as other
|
5
38
|
open source management tools. This release supports Cisco NX-OS nodes
|
6
39
|
running NX-OS 7.0(3)I2(1) and later.
|
7
40
|
|
8
|
-
|
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)
|
42
|
+
|
43
|
+
## <a name="installation">Installation</a>
|
9
44
|
|
10
45
|
To install the CiscoNodeUtils, use the following command:
|
11
46
|
|
@@ -16,7 +51,8 @@ To install the CiscoNodeUtils, use the following command:
|
|
16
51
|
Alternatively, if you've checked the source out directly, you can call
|
17
52
|
`rake install` from the root project directory.
|
18
53
|
|
19
|
-
## Examples
|
54
|
+
## <a name="examples">Examples</a>
|
55
|
+
|
20
56
|
|
21
57
|
These utilities can be used directly on a Cisco device (as used by Puppet
|
22
58
|
and Chef) or can run on a workstation and point to a Cisco device (as used
|
@@ -50,7 +86,8 @@ version = node.config_get("show_version", "system_image")
|
|
50
86
|
node.config_set("vtp", "domain", "mycompany.com")
|
51
87
|
```
|
52
88
|
|
53
|
-
## Documentation
|
89
|
+
## <a name="documentation">Documentation</a>
|
90
|
+
|
54
91
|
|
55
92
|
### Node
|
56
93
|
|
@@ -88,15 +125,41 @@ code duplication between the Cisco Puppet modules and the Cisco Chef cookbooks.
|
|
88
125
|
Generally speaking, Puppet and Chef should only interact with the feature
|
89
126
|
provider classes, and not directly call into `CommandReference` or `Node`.
|
90
127
|
|
91
|
-
## Changelog
|
128
|
+
## <a name="changelog">Changelog</a>
|
129
|
+
|
92
130
|
|
93
131
|
See [CHANGELOG](CHANGELOG.md) for a list of changes.
|
94
132
|
|
95
|
-
## Contributing
|
96
133
|
|
97
|
-
|
134
|
+
## <a name="resources">Learning Resources</a>
|
135
|
+
|
136
|
+
|
137
|
+
* Chef
|
138
|
+
* [https://learn.chef.io/](https://learn.chef.io/)
|
139
|
+
* [https://en.wikipedia.org/wiki/Chef_(software)](https://en.wikipedia.org/wiki/Chef_(software))
|
140
|
+
* Puppet
|
141
|
+
* [https://learn.puppetlabs.com/](https://learn.puppetlabs.com/)
|
142
|
+
* [https://en.wikipedia.org/wiki/Puppet_(software)](https://en.wikipedia.org/wiki/Puppet_(software))
|
143
|
+
* Markdown (for editing documentation)
|
144
|
+
* [https://help.github.com/articles/markdown-basics/](https://help.github.com/articles/markdown-basics/)
|
145
|
+
* Ruby
|
146
|
+
* [https://en.wikipedia.org/wiki/Ruby_(programming_language)](https://en.wikipedia.org/wiki/Ruby_(programming_language))
|
147
|
+
* [https://www.codecademy.com/tracks/ruby](https://www.codecademy.com/tracks/ruby)
|
148
|
+
* [https://rubymonk.com/](https://rubymonk.com/)
|
149
|
+
* [https://www.codeschool.com/paths/ruby](https://www.codeschool.com/paths/ruby)
|
150
|
+
* Ruby Gems
|
151
|
+
* [http://guides.rubygems.org/](http://guides.rubygems.org/)
|
152
|
+
* [https://en.wikipedia.org/wiki/RubyGems](https://en.wikipedia.org/wiki/RubyGems)
|
153
|
+
* YAML
|
154
|
+
* [https://en.wikipedia.org/wiki/YAML](https://en.wikipedia.org/wiki/YAML)
|
155
|
+
* [http://www.yaml.org/start.html](http://www.yaml.org/start.html)
|
156
|
+
* Yum
|
157
|
+
* [https://en.wikipedia.org/wiki/Yellowdog_Updater,_Modified](https://en.wikipedia.org/wiki/Yellowdog_Updater,_Modified)
|
158
|
+
* [https://www.centos.org/docs/5/html/yum/](https://www.centos.org/docs/5/html/yum/)
|
159
|
+
* [http://www.linuxcommand.org/man_pages](http://www.linuxcommand.org/man_pages/yum8.html)
|
160
|
+
|
161
|
+
## <a name="license_info">License Information</a>
|
98
162
|
|
99
|
-
## License
|
100
163
|
|
101
164
|
Copyright (c) 2013-2015 Cisco and/or its affiliates.
|
102
165
|
|
data/Rakefile
CHANGED
@@ -1,4 +1,21 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rubocop/rake_task'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
# test task is not part of default task list,
|
6
|
+
# because it requires a node to test against
|
7
|
+
task default: %w(rubocop build)
|
3
8
|
|
4
9
|
RuboCop::RakeTask.new
|
10
|
+
|
11
|
+
task :build do
|
12
|
+
system 'gem build cisco_node_utils.gemspec'
|
13
|
+
end
|
14
|
+
|
15
|
+
Rake::TestTask.new do |t|
|
16
|
+
t.libs << 'lib'
|
17
|
+
t.libs << 'tests'
|
18
|
+
t.pattern = 'tests/test_*.rb'
|
19
|
+
t.warning = true
|
20
|
+
t.verbose = true
|
21
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# October 2015, Glenn F. Matthews
|
4
|
+
#
|
5
|
+
# Copyright (c) 2015 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
# This is a helper script for developers.
|
20
|
+
# If you're doing refactoring work to reduce the code complexity metrics,
|
21
|
+
# you can run this script to report the worst offenders for each metric
|
22
|
+
# and whether you've managed to improve any metrics compared to the baseline.
|
23
|
+
|
24
|
+
require 'pathname'
|
25
|
+
require 'yaml'
|
26
|
+
|
27
|
+
base = Pathname.new(File.expand_path('../..', __FILE__))
|
28
|
+
|
29
|
+
['lib/', 'tests/'].each do |subdir|
|
30
|
+
# Read in the base config file:
|
31
|
+
base_config = {}
|
32
|
+
File.open(base + subdir + '.rubocop.yml', 'r') do |f|
|
33
|
+
base_config = YAML.parse(f).transform
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create a fake config file that's identical to baseline except for the
|
37
|
+
# metric Max limits:
|
38
|
+
|
39
|
+
new_config = {}
|
40
|
+
base_config.each do |cop, options|
|
41
|
+
next unless options.is_a?(Hash)
|
42
|
+
new_config[cop] = {}
|
43
|
+
options.each do |option, value|
|
44
|
+
new_config[cop][option] = value unless option == 'Max'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
tempfile = base + '.rubocop_temp.yml'
|
49
|
+
|
50
|
+
File.open(tempfile, 'w') do |f|
|
51
|
+
f.write new_config.to_yaml
|
52
|
+
end
|
53
|
+
|
54
|
+
output = `rubocop -c #{tempfile} --only Metrics -f emacs \
|
55
|
+
-D #{subdir} 2>/dev/null`
|
56
|
+
`rm -f #{tempfile}`
|
57
|
+
|
58
|
+
results = {}
|
59
|
+
output.split("\n").each do |line|
|
60
|
+
# emacs output format:
|
61
|
+
# foo/bar.rb:92:81: C: Metrics/LineLength: Line is too long. [81/80]
|
62
|
+
file, row, col, _err, cop, msg = line.split(':')
|
63
|
+
file = Pathname.new(file).relative_path_from(base).to_s
|
64
|
+
cop.strip!
|
65
|
+
value = msg[/\[([0-9.]+)/, 1].to_f.ceil
|
66
|
+
results[cop] ||= {}
|
67
|
+
results[cop][value] ||= []
|
68
|
+
results[cop][value] << {
|
69
|
+
file: file,
|
70
|
+
row: row.to_i,
|
71
|
+
col: col.to_i,
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# Print each failing cop in alphabetical order...
|
76
|
+
results.keys.sort.each do |cop|
|
77
|
+
puts "\n#{cop}"
|
78
|
+
offenses = results[cop]
|
79
|
+
# List the two highest failing values...
|
80
|
+
offenses.keys.sort.reverse[0..1].each do |value|
|
81
|
+
puts " #{value}:"
|
82
|
+
offenses[value].each do |offender|
|
83
|
+
# and list the file and line where each failure was seen
|
84
|
+
puts " #{offender[:file]}:#{offender[:row]}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
puts "\n"
|
90
|
+
|
91
|
+
base_config.keys.sort.each do |cop|
|
92
|
+
next unless cop =~ /Metrics/
|
93
|
+
base_val = base_config[cop]['Max']
|
94
|
+
base_val ||= 0
|
95
|
+
actual_val = results[cop].keys.sort.last if results[cop]
|
96
|
+
actual_val ||= 0
|
97
|
+
if base_val == actual_val
|
98
|
+
if base_val == 0
|
99
|
+
puts "#{cop}: still passing in full"
|
100
|
+
else
|
101
|
+
puts "#{cop}: value unchanged (#{base_val})"
|
102
|
+
end
|
103
|
+
elsif base_val > actual_val
|
104
|
+
puts "#{cop}: value improved! (#{base_val} -> #{actual_val})"
|
105
|
+
else
|
106
|
+
puts "#{cop}: value WORSENED (#{base_val} -> #{actual_val})"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|