cisco_node_utils 1.0.1 → 1.1.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.
- 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
data/docs/README-maintainers.md
CHANGED
|
@@ -30,17 +30,47 @@ Either run `git flow init` from the repository root directory, or manually edit
|
|
|
30
30
|
|
|
31
31
|
Most of these are default for git-flow except for the `versiontag` setting.
|
|
32
32
|
|
|
33
|
+
## Release Checklist
|
|
34
|
+
|
|
35
|
+
When we are considering publishing a new release, all of the following steps must be carried out (using the latest code base in `develop`):
|
|
36
|
+
|
|
37
|
+
1. Review cisco_node_utils.gemspec
|
|
38
|
+
* Is the data still relevant?
|
|
39
|
+
* Do the version dependencies need to be updated? (e.g. rubocop)
|
|
40
|
+
|
|
41
|
+
2. Run full minitest suite with various Ruby versions and hardware platforms:
|
|
42
|
+
* Ruby versions:
|
|
43
|
+
- REQUIRED: the Ruby version(s) bundled with Chef and Puppet (currently 2.1.6)
|
|
44
|
+
- OPTIONAL: any/all other Ruby major versions currently supported by this gem (2.0, 2.2.2)
|
|
45
|
+
* Platforms (all with latest released software or release candidate)
|
|
46
|
+
- N30xx
|
|
47
|
+
- N31xx
|
|
48
|
+
- N9xxx
|
|
49
|
+
|
|
50
|
+
3. Triage any minitest failures.
|
|
51
|
+
|
|
52
|
+
4. Check code coverage results from minitest to see if there are any critical gaps in coverage.
|
|
53
|
+
|
|
54
|
+
5. Build gem and test it in combination with the latest released Puppet module (using Beaker and demo manifests) to make sure no backward compatibility issues have been introduced.
|
|
55
|
+
|
|
56
|
+
6. Make sure CHANGELOG.md accurately reflects all changes since the last release.
|
|
57
|
+
* Add any significant changes that weren't documented in the changelog
|
|
58
|
+
* Clean up any entries that are overly verbose, unclear, or otherwise could be improved.
|
|
59
|
+
|
|
33
60
|
## Release Process
|
|
34
61
|
|
|
35
|
-
When
|
|
62
|
+
When the release checklist above has been fully completed, the process for publishing a new release is as follows:
|
|
36
63
|
|
|
37
|
-
1. Create a release branch. Follow [semantic versioning](http://semver.org)
|
|
64
|
+
1. Create a release branch. Follow [semantic versioning](http://semver.org):
|
|
65
|
+
* 0.0.x - a bugfix release
|
|
66
|
+
* 0.x.0 - new feature(s)
|
|
67
|
+
* x.0.0 - backward-incompatible change (if unvoidable!)
|
|
38
68
|
|
|
39
69
|
```
|
|
40
70
|
git flow release start 1.0.1
|
|
41
71
|
```
|
|
42
72
|
|
|
43
|
-
2. In the newly created release branch, update `CHANGELOG.md
|
|
73
|
+
2. In the newly created release branch, update `CHANGELOG.md` (this *should* be automatic if you have installed the Git hooks for this repository):
|
|
44
74
|
|
|
45
75
|
```diff
|
|
46
76
|
Changelog
|
data/docs/template-router.rb
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
#
|
|
2
|
-
# NXAPI implementation of X__CLASS_NAME__X class
|
|
3
|
-
#
|
|
4
1
|
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
|
5
2
|
#
|
|
6
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,111 +12,112 @@
|
|
|
15
12
|
# See the License for the specific language governing permissions and
|
|
16
13
|
# limitations under the License.
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
require_relative 'node_util'
|
|
19
16
|
|
|
20
17
|
module Cisco
|
|
21
|
-
class X__CLASS_NAME__X
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
create if instantiate
|
|
33
|
-
end
|
|
18
|
+
# X__CLASS_NAME__X - node utility class for X__CLASS_NAME__X config mgmt.
|
|
19
|
+
class X__CLASS_NAME__X < NodeUtil
|
|
20
|
+
attr_reader :name
|
|
21
|
+
|
|
22
|
+
# name: name of the router instance
|
|
23
|
+
# instantiate: true = create router instance
|
|
24
|
+
def initialize(name, instantiate=true)
|
|
25
|
+
fail ArgumentError unless name.length > 0
|
|
26
|
+
@name = name
|
|
27
|
+
create if instantiate
|
|
28
|
+
end
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
# Create a hash of all current router instances.
|
|
31
|
+
def self.routers
|
|
32
|
+
instances = config_get('X__RESOURCE_NAME__X', 'router')
|
|
33
|
+
return {} if instances.nil?
|
|
34
|
+
hash = {}
|
|
35
|
+
instances.each do |name|
|
|
36
|
+
hash[name] = X__CLASS_NAME__X.new(name, false)
|
|
37
|
+
end
|
|
38
|
+
return hash
|
|
39
|
+
rescue Cisco::CliError => e
|
|
40
|
+
# CLI will syntax reject when feature is not enabled
|
|
41
|
+
raise unless e.clierror =~ /Syntax error/
|
|
42
|
+
return {}
|
|
42
43
|
end
|
|
43
|
-
return hash
|
|
44
|
-
rescue Cisco::CliError => e
|
|
45
|
-
# cmd will syntax reject when feature is not enabled
|
|
46
|
-
raise unless e.clierror =~ /Syntax error/
|
|
47
|
-
return {}
|
|
48
|
-
end
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
def feature_enabled
|
|
46
|
+
feat = config_get('X__RESOURCE_NAME__X', 'feature')
|
|
47
|
+
return !(feat.nil? || feat.empty?)
|
|
48
|
+
rescue Cisco::CliError => e
|
|
49
|
+
# This cmd will syntax reject if feature is not
|
|
50
|
+
# enabled. Just catch the reject and return false.
|
|
51
|
+
return false if e.clierror =~ /Syntax error/
|
|
52
|
+
raise
|
|
53
|
+
end
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
def feature_enable
|
|
56
|
+
config_set('X__RESOURCE_NAME__X', 'feature', state: '')
|
|
57
|
+
end
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
def feature_disable
|
|
60
|
+
config_set('X__RESOURCE_NAME__X', 'feature', state: 'no')
|
|
61
|
+
end
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
# Enable feature and create router instance
|
|
64
|
+
def create
|
|
65
|
+
feature_enable unless feature_enabled
|
|
66
|
+
X__RESOURCE_NAME__X_router
|
|
67
|
+
end
|
|
73
68
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
# Destroy a router instance; disable feature on last instance
|
|
70
|
+
def destroy
|
|
71
|
+
ids = config_get('X__RESOURCE_NAME__X', 'router')
|
|
72
|
+
return if ids.nil?
|
|
73
|
+
if ids.size == 1
|
|
74
|
+
feature_disable
|
|
75
|
+
else
|
|
76
|
+
X__RESOURCE_NAME__X_router('no')
|
|
77
|
+
end
|
|
78
|
+
rescue Cisco::CliError => e
|
|
79
|
+
# CLI will syntax reject when feature is not enabled
|
|
80
|
+
raise unless e.clierror =~ /Syntax error/
|
|
82
81
|
end
|
|
83
|
-
rescue Cisco::CliError => e
|
|
84
|
-
# cmd will syntax reject when feature is not enabled
|
|
85
|
-
raise unless e.clierror =~ /Syntax error/
|
|
86
|
-
end
|
|
87
82
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
def X__RESOURCE_NAME__X_router(state='')
|
|
84
|
+
config_set('X__RESOURCE_NAME__X', 'router', name: @name, state: state)
|
|
85
|
+
end
|
|
91
86
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
# ----------
|
|
88
|
+
# PROPERTIES
|
|
89
|
+
# ----------
|
|
95
90
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
# Property methods for boolean property
|
|
92
|
+
def default_X__PROPERTY_BOOL__X
|
|
93
|
+
config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X')
|
|
94
|
+
end
|
|
100
95
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
def X__PROPERTY_BOOL__X
|
|
97
|
+
state = config_get('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X',
|
|
98
|
+
name: @name)
|
|
99
|
+
state ? true : false
|
|
100
|
+
end
|
|
105
101
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
def X__PROPERTY_BOOL__X=(state)
|
|
103
|
+
state = (state ? '' : 'no')
|
|
104
|
+
config_set('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X',
|
|
105
|
+
name: @name, state: state)
|
|
106
|
+
end
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
# Property methods for integer property
|
|
109
|
+
def default_X__PROPERTY_INT__X
|
|
110
|
+
config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X')
|
|
111
|
+
end
|
|
115
112
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
def X__PROPERTY_INT__X
|
|
114
|
+
val = config_get('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X', name: @name)
|
|
115
|
+
val.nil? ? default_X__PROPERTY_INT__X : val.first.to_i
|
|
116
|
+
end
|
|
120
117
|
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
def X__PROPERTY_INT__X=(val)
|
|
119
|
+
config_set('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X',
|
|
120
|
+
name: @name, val: val)
|
|
121
|
+
end
|
|
123
122
|
end
|
|
124
123
|
end
|
|
125
|
-
end
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Minitest for __CLASS_NAME__ class
|
|
3
|
-
#
|
|
4
1
|
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
|
5
2
|
#
|
|
6
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,93 +12,93 @@
|
|
|
15
12
|
# See the License for the specific language governing permissions and
|
|
16
13
|
# limitations under the License.
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/router_X__RESOURCE_NAME__X'
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
# TestX__CLASS_NAME__X - Minitest for X__CLASS_NAME__X node utility class
|
|
19
|
+
class TestX__CLASS_NAME__X < CiscoTestCase
|
|
22
20
|
def setup
|
|
23
21
|
# setup runs at the beginning of each test
|
|
24
22
|
super
|
|
25
|
-
|
|
23
|
+
no_feature_X__RESOURCE_NAME__X
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
def teardown
|
|
29
27
|
# teardown runs at the end of each test
|
|
30
|
-
|
|
28
|
+
no_feature_X__RESOURCE_NAME__X
|
|
31
29
|
super
|
|
32
30
|
end
|
|
33
31
|
|
|
34
|
-
def
|
|
32
|
+
def no_feature_X__RESOURCE_NAME__X
|
|
35
33
|
# Turn the feature off for a clean test.
|
|
36
|
-
|
|
37
|
-
# Flush the cache since we've modified the device outside of the node_utils APIs
|
|
38
|
-
node.cache_flush()
|
|
34
|
+
config('no feature X__RESOURCE_NAME__X')
|
|
39
35
|
end
|
|
40
36
|
|
|
41
37
|
# TESTS
|
|
42
38
|
|
|
43
39
|
def test_router_create_destroy_one
|
|
44
|
-
id =
|
|
45
|
-
rtr =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
id = 'blue'
|
|
41
|
+
rtr = X__CLASS_NAME__X.new(id)
|
|
42
|
+
@default_show_command = "show runn | i 'router X__RESOURCE_NAME__X #{id}'"
|
|
43
|
+
assert_show_match(pattern: /^router X__RESOURCE_NAME__X #{id}$/,
|
|
44
|
+
msg: "failed to create router X__RESOURCE_NAME__X #{id}")
|
|
49
45
|
|
|
50
46
|
rtr.destroy
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"Error: failed to destroy router __RESOURCE_NAME__ #{id}")
|
|
47
|
+
refute_show_match(pattern: /^router X__RESOURCE_NAME__X #{id}$/,
|
|
48
|
+
msg: "failed to destroy router X__RESOURCE_NAME__X #{id}")
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
refute_show_match(command: "show runn | i 'feature X__RESOURCE_NAME__X'",
|
|
51
|
+
pattern: /^feature X__RESOURCE_NAME__X$/,
|
|
52
|
+
msg: 'failed to disable feature X__RESOURCE_NAME__X')
|
|
58
53
|
end
|
|
59
54
|
|
|
60
55
|
def test_router_create_destroy_multiple
|
|
61
|
-
id1 =
|
|
62
|
-
rtr1 =
|
|
63
|
-
id2 =
|
|
64
|
-
rtr2 =
|
|
56
|
+
id1 = 'blue'
|
|
57
|
+
rtr1 = X__CLASS_NAME__X.new(id1)
|
|
58
|
+
id2 = 'red'
|
|
59
|
+
rtr2 = X__CLASS_NAME__X.new(id2)
|
|
60
|
+
|
|
61
|
+
@default_show_command = "show runn | i 'router X__RESOURCE_NAME__X'"
|
|
62
|
+
|
|
63
|
+
assert_show_match(pattern: /^router X__RESOURCE_NAME__X #{id1}$/,
|
|
64
|
+
msg: "failed to create router X__RESOURCE_NAME__X #{id1}")
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
assert_match(s, /^router __RESOURCE_NAME__ #{id2}$/)
|
|
66
|
+
assert_show_match(pattern: /^router X__RESOURCE_NAME__X #{id2}$/,
|
|
67
|
+
msg: "failed to create router X__RESOURCE_NAME__X #{id2}")
|
|
69
68
|
|
|
70
69
|
rtr1.destroy
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"Error: failed to destroy router __RESOURCE_NAME__ #{id1}")
|
|
70
|
+
refute_show_match(pattern: /^router X__RESOURCE_NAME__X #{id1}$/,
|
|
71
|
+
msg: "failed to destroy router X__RESOURCE_NAME__X #{id1}")
|
|
74
72
|
|
|
75
73
|
rtr2.destroy
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"Error: failed to destroy router __RESOURCE_NAME__ #{id2}")
|
|
74
|
+
refute_show_match(pattern: /^router X__RESOURCE_NAME__X #{id2}$/,
|
|
75
|
+
msg: "failed to destroy router X__RESOURCE_NAME__X #{id2}")
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
refute_show_match(command: "show runn | i 'feature X__RESOURCE_NAME__X'",
|
|
78
|
+
pattern: /^feature X__RESOURCE_NAME__X$/,
|
|
79
|
+
msg: 'failed to disable feature X__RESOURCE_NAME__X')
|
|
83
80
|
end
|
|
84
81
|
|
|
85
|
-
def
|
|
86
|
-
id =
|
|
87
|
-
rtr =
|
|
88
|
-
val = 5
|
|
89
|
-
rtr.
|
|
90
|
-
assert_equal(rtr.
|
|
82
|
+
def test_router_X__PROPERTY_INT__X
|
|
83
|
+
id = 'blue'
|
|
84
|
+
rtr = X__CLASS_NAME__X.new(id)
|
|
85
|
+
val = 5 # This value depends on property bounds
|
|
86
|
+
rtr.X__PROPERTY_INT__X = val
|
|
87
|
+
assert_equal(rtr.X__PROPERTY_INT__X, val, "X__PROPERTY_INT__X is not #{val}")
|
|
91
88
|
|
|
92
89
|
# Get default value from yaml
|
|
93
|
-
val = node.config_get_default(
|
|
94
|
-
rtr.
|
|
95
|
-
assert_equal(rtr.
|
|
90
|
+
val = node.config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X')
|
|
91
|
+
rtr.X__PROPERTY_INT__X = val
|
|
92
|
+
assert_equal(rtr.X__PROPERTY_INT__X, val, "X__PROPERTY_INT__X is not #{val}")
|
|
96
93
|
end
|
|
97
94
|
|
|
98
|
-
def
|
|
99
|
-
id =
|
|
100
|
-
rtr =
|
|
101
|
-
rtr.
|
|
102
|
-
assert(rtr.
|
|
95
|
+
def test_router_X__PROPERTY_BOOL__X
|
|
96
|
+
id = 'blue'
|
|
97
|
+
rtr = X__CLASS_NAME__X.new(id)
|
|
98
|
+
rtr.X__PROPERTY_BOOL__X = true
|
|
99
|
+
assert(rtr.X__PROPERTY_BOOL__X, 'X__PROPERTY_BOOL__X state is not true')
|
|
103
100
|
|
|
104
|
-
rtr.
|
|
105
|
-
refute(rtr.
|
|
101
|
+
rtr.X__PROPERTY_BOOL__X = false
|
|
102
|
+
refute(rtr.X__PROPERTY_BOOL__X, 'X__PROPERTY_BOOL__X state is not false')
|
|
106
103
|
end
|
|
107
104
|
end
|
data/lib/.rubocop.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
inherit_from: ../.rubocop.yml
|
|
2
|
+
|
|
3
|
+
# Baseline code complexity metrics for the lib/ subdirectory:
|
|
4
|
+
|
|
5
|
+
Metrics/AbcSize:
|
|
6
|
+
Max: 47
|
|
7
|
+
|
|
8
|
+
Metrics/CyclomaticComplexity:
|
|
9
|
+
Max: 17
|
|
10
|
+
|
|
11
|
+
Metrics/MethodLength:
|
|
12
|
+
Max: 39
|
|
13
|
+
|
|
14
|
+
Metrics/ParameterLists:
|
|
15
|
+
Max: 9
|
|
16
|
+
|
|
17
|
+
Metrics/PerceivedComplexity:
|
|
18
|
+
Max: 19
|
data/lib/cisco_node_utils.rb
CHANGED
|
@@ -12,22 +12,5 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
require
|
|
17
|
-
require "cisco_node_utils/configparser_lib"
|
|
18
|
-
require "cisco_node_utils/interface"
|
|
19
|
-
require "cisco_node_utils/interface_ospf"
|
|
20
|
-
require "cisco_node_utils/node"
|
|
21
|
-
require "cisco_node_utils/platform"
|
|
22
|
-
require "cisco_node_utils/router_ospf"
|
|
23
|
-
require "cisco_node_utils/router_ospf_vrf"
|
|
24
|
-
require "cisco_node_utils/snmpcommunity"
|
|
25
|
-
require "cisco_node_utils/snmpgroup"
|
|
26
|
-
require "cisco_node_utils/snmpserver"
|
|
27
|
-
require "cisco_node_utils/snmpuser"
|
|
28
|
-
require "cisco_node_utils/tacacs_server"
|
|
29
|
-
require "cisco_node_utils/tacacs_server_host"
|
|
30
|
-
require "cisco_node_utils/version"
|
|
31
|
-
require "cisco_node_utils/vlan"
|
|
32
|
-
require "cisco_node_utils/vtp"
|
|
33
|
-
require "cisco_node_utils/yum"
|
|
15
|
+
# Automatically load all Ruby files in the cisco_node_utils subdirectory
|
|
16
|
+
Dir.glob(__dir__ + '/cisco_node_utils/*.rb') { |file| require file }
|