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
data/docs/.rubocop.yml
DELETED
data/docs/template-feature.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# NXAPI implementation of X__CLASS_NAME__X class
|
3
|
-
#
|
4
|
-
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__), 'node')
|
19
|
-
module Cisco
|
20
|
-
# Class name syntax will typically be the resource name in camelCase
|
21
|
-
# format; for example: 'tacacs server host' becomes TacacsServerHost.
|
22
|
-
class X__CLASS_NAME__X
|
23
|
-
# Establish connection to node
|
24
|
-
@@node = Cisco::Node.instance
|
25
|
-
|
26
|
-
def feature_enable
|
27
|
-
@@node.config_set('X__RESOURCE_NAME__X', 'feature', { :state => '' })
|
28
|
-
end
|
29
|
-
|
30
|
-
def feature_disable
|
31
|
-
@@node.config_set('X__RESOURCE_NAME__X', 'feature', { :state => 'no' })
|
32
|
-
end
|
33
|
-
|
34
|
-
# Check current state of the configuration
|
35
|
-
def X__CLASS_NAME__X.feature_enabled
|
36
|
-
feat = @@node.config_get('X__RESOURCE_NAME__X', 'feature')
|
37
|
-
return (!feat.nil? and !feat.empty?)
|
38
|
-
rescue Cisco::CliError => e
|
39
|
-
# This cmd will syntax reject if feature is not
|
40
|
-
# enabled. Just catch the reject and return false.
|
41
|
-
return false if e.clierror =~ /Syntax error/
|
42
|
-
raise
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Minitest for X__CLASS_NAME__X class
|
3
|
-
#
|
4
|
-
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
require File.expand_path("../ciscotest", __FILE__)
|
19
|
-
require File.expand_path("../../lib/cisco_node_utils/X__RESOURCE_NAME__X", __FILE__)
|
20
|
-
|
21
|
-
class TestX__CLASS_NAME__X < CiscoTestCase
|
22
|
-
def setup
|
23
|
-
# setup automatically runs at the beginning of each test
|
24
|
-
super
|
25
|
-
no_feature
|
26
|
-
end
|
27
|
-
|
28
|
-
def teardown
|
29
|
-
# teardown automatically runs at the end of each test
|
30
|
-
no_feature
|
31
|
-
super
|
32
|
-
end
|
33
|
-
|
34
|
-
def no_feature
|
35
|
-
# setup/teardown helper. Turn the feature off for a clean testbed.
|
36
|
-
@device.cmd('conf t ; no feature X__CLI_NAME__X ; end')
|
37
|
-
# Flush the cache since we've modified the device outside of the node_utils APIs
|
38
|
-
node.cache_flush()
|
39
|
-
end
|
40
|
-
|
41
|
-
# TESTS
|
42
|
-
|
43
|
-
def test_feature_on_off
|
44
|
-
feat = X__CLASS_NAME__X.new()
|
45
|
-
feat.feature_enable
|
46
|
-
assert(BashShell.feature_enabled)
|
47
|
-
|
48
|
-
feat.feature_disable
|
49
|
-
refute(BashShell.feature_enabled)
|
50
|
-
end
|
51
|
-
end
|
data/tests/test_all_cisco.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# One-stop shop for running all of our current test cases.
|
4
|
-
# December 2014, Glenn F. Matthews
|
5
|
-
#
|
6
|
-
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
7
|
-
#
|
8
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
-
# See the License for the specific language governing permissions and
|
18
|
-
# limitations under the License.
|
19
|
-
|
20
|
-
require 'rubygems'
|
21
|
-
gem 'minitest', '>= 2.5.1', '< 5.0.0'
|
22
|
-
require 'minitest/autorun'
|
23
|
-
|
24
|
-
# Basic sanity
|
25
|
-
require File.expand_path("../test_command_reference", __FILE__)
|
26
|
-
require File.expand_path("../test_node", __FILE__)
|
27
|
-
require File.expand_path("../test_node_ext", __FILE__)
|
28
|
-
|
29
|
-
# Feature tests - please keep in alphabetical order
|
30
|
-
require File.expand_path("../test_command_config", __FILE__)
|
31
|
-
require File.expand_path("../test_interface", __FILE__)
|
32
|
-
require File.expand_path("../test_interface_ospf", __FILE__)
|
33
|
-
require File.expand_path("../test_interface_svi", __FILE__)
|
34
|
-
require File.expand_path("../test_interface_switchport", __FILE__)
|
35
|
-
require File.expand_path("../test_platform", __FILE__)
|
36
|
-
require File.expand_path("../test_router_ospf", __FILE__)
|
37
|
-
require File.expand_path("../test_router_ospf_vrf", __FILE__)
|
38
|
-
require File.expand_path("../test_snmpcommunity", __FILE__)
|
39
|
-
require File.expand_path("../test_snmpgroup", __FILE__)
|
40
|
-
require File.expand_path("../test_snmpserver", __FILE__)
|
41
|
-
require File.expand_path("../test_snmpuser", __FILE__)
|
42
|
-
require File.expand_path("../test_tacacs_server", __FILE__)
|
43
|
-
require File.expand_path("../test_tacacs_server_host", __FILE__)
|
44
|
-
require File.expand_path("../test_vlan", __FILE__)
|
45
|
-
require File.expand_path("../test_vtp", __FILE__)
|
46
|
-
require File.expand_path("../test_yum", __FILE__)
|