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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +81 -1
  4. data/.travis.yml +9 -0
  5. data/CHANGELOG.md +72 -6
  6. data/CONTRIBUTING.md +32 -7
  7. data/README.md +70 -7
  8. data/Rakefile +17 -0
  9. data/bin/check_metric_limits.rb +109 -0
  10. data/bin/git/hooks/commit-msg/enforce_style +81 -0
  11. data/bin/git/hooks/hook_lib +108 -0
  12. data/bin/git/hooks/hooks-wrapper +38 -0
  13. data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
  14. data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
  15. data/bin/git/hooks/post-flow-release-start/update-version +19 -0
  16. data/bin/git/hooks/post-merge/update-hooks +6 -0
  17. data/bin/git/hooks/post-rewrite/update-hooks +6 -0
  18. data/bin/git/hooks/pre-commit/rubocop +20 -0
  19. data/bin/git/hooks/pre-commit/validate-diffs +31 -0
  20. data/bin/git/hooks/pre-push/check-changelog +24 -0
  21. data/bin/git/hooks/pre-push/rubocop +7 -0
  22. data/bin/git/update-hooks +65 -0
  23. data/cisco_node_utils.gemspec +9 -3
  24. data/docs/README-develop-best-practices.md +404 -0
  25. data/docs/README-develop-node-utils-APIs.md +215 -365
  26. data/docs/README-maintainers.md +33 -3
  27. data/docs/template-router.rb +89 -91
  28. data/docs/template-test_router.rb +52 -55
  29. data/lib/.rubocop.yml +18 -0
  30. data/lib/cisco_node_utils.rb +2 -19
  31. data/lib/cisco_node_utils/README_YAML.md +1 -9
  32. data/lib/cisco_node_utils/bgp.rb +664 -0
  33. data/lib/cisco_node_utils/bgp_af.rb +530 -0
  34. data/lib/cisco_node_utils/bgp_neighbor.rb +425 -0
  35. data/lib/cisco_node_utils/bgp_neighbor_af.rb +709 -0
  36. data/lib/cisco_node_utils/cisco_cmn_utils.rb +59 -25
  37. data/lib/cisco_node_utils/command_reference.rb +72 -74
  38. data/lib/cisco_node_utils/command_reference_common.yaml +174 -9
  39. data/lib/cisco_node_utils/command_reference_common_bgp.yaml +535 -0
  40. data/lib/cisco_node_utils/command_reference_n7k.yaml +4 -0
  41. data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -9
  42. data/lib/cisco_node_utils/configparser_lib.rb +152 -147
  43. data/lib/cisco_node_utils/dns_domain.rb +79 -0
  44. data/lib/cisco_node_utils/domain_name.rb +71 -0
  45. data/lib/cisco_node_utils/interface.rb +167 -161
  46. data/lib/cisco_node_utils/interface_ospf.rb +78 -81
  47. data/lib/cisco_node_utils/name_server.rb +64 -0
  48. data/lib/cisco_node_utils/node.rb +154 -198
  49. data/lib/cisco_node_utils/node_util.rb +61 -0
  50. data/lib/cisco_node_utils/ntp_config.rb +65 -0
  51. data/lib/cisco_node_utils/ntp_server.rb +76 -0
  52. data/lib/cisco_node_utils/platform.rb +174 -165
  53. data/lib/cisco_node_utils/radius_global.rb +146 -0
  54. data/lib/cisco_node_utils/radius_server.rb +295 -0
  55. data/lib/cisco_node_utils/router_ospf.rb +59 -63
  56. data/lib/cisco_node_utils/router_ospf_vrf.rb +226 -210
  57. data/lib/cisco_node_utils/snmpcommunity.rb +52 -58
  58. data/lib/cisco_node_utils/snmpgroup.rb +22 -23
  59. data/lib/cisco_node_utils/snmpserver.rb +99 -103
  60. data/lib/cisco_node_utils/snmpuser.rb +294 -274
  61. data/lib/cisco_node_utils/syslog_server.rb +92 -0
  62. data/lib/cisco_node_utils/syslog_settings.rb +69 -0
  63. data/lib/cisco_node_utils/tacacs_server.rb +137 -133
  64. data/lib/cisco_node_utils/tacacs_server_host.rb +84 -87
  65. data/lib/cisco_node_utils/version.rb +2 -1
  66. data/lib/cisco_node_utils/vlan.rb +28 -31
  67. data/lib/cisco_node_utils/vrf.rb +80 -0
  68. data/lib/cisco_node_utils/vtp.rb +100 -97
  69. data/lib/cisco_node_utils/yum.rb +15 -17
  70. data/tests/.rubocop.yml +15 -0
  71. data/tests/basetest.rb +81 -36
  72. data/tests/ciscotest.rb +38 -78
  73. data/{lib/cisco_node_utils → tests}/platform_info.rb +12 -8
  74. data/{lib/cisco_node_utils → tests}/platform_info.yaml +1 -1
  75. data/tests/test_bgp_af.rb +920 -0
  76. data/tests/test_bgp_neighbor.rb +403 -0
  77. data/tests/test_bgp_neighbor_af.rb +589 -0
  78. data/tests/test_command_config.rb +65 -62
  79. data/tests/test_command_reference.rb +31 -45
  80. data/tests/test_dns_domain.rb +113 -0
  81. data/tests/test_domain_name.rb +86 -0
  82. data/tests/test_interface.rb +424 -548
  83. data/tests/test_interface_ospf.rb +248 -432
  84. data/tests/test_interface_svi.rb +56 -79
  85. data/tests/test_interface_switchport.rb +196 -272
  86. data/tests/test_name_server.rb +85 -0
  87. data/tests/test_node.rb +7 -6
  88. data/tests/test_node_ext.rb +133 -186
  89. data/tests/test_ntp_config.rb +49 -0
  90. data/tests/test_ntp_server.rb +74 -0
  91. data/tests/test_platform.rb +58 -37
  92. data/tests/test_radius_global.rb +78 -0
  93. data/tests/test_radius_server.rb +185 -0
  94. data/tests/test_router_bgp.rb +838 -0
  95. data/tests/test_router_ospf.rb +49 -80
  96. data/tests/test_router_ospf_vrf.rb +274 -392
  97. data/tests/test_snmpcommunity.rb +128 -172
  98. data/tests/test_snmpgroup.rb +12 -14
  99. data/tests/test_snmpserver.rb +160 -189
  100. data/tests/test_snmpuser.rb +568 -717
  101. data/tests/test_syslog_server.rb +88 -0
  102. data/tests/test_syslog_settings.rb +54 -0
  103. data/tests/test_tacacs_server.rb +113 -148
  104. data/tests/test_tacacs_server_host.rb +108 -161
  105. data/tests/test_vlan.rb +63 -79
  106. data/tests/test_vrf.rb +92 -0
  107. data/tests/test_vtp.rb +108 -126
  108. data/tests/test_yum.rb +47 -41
  109. metadata +92 -56
  110. data/.rubocop_todo.yml +0 -293
  111. data/docs/.rubocop.yml +0 -13
  112. data/docs/template-feature.rb +0 -45
  113. data/docs/template-test_feature.rb +0 -51
  114. data/tests/test_all_cisco.rb +0 -46
data/docs/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- # Rubocop configuration
2
-
3
- inherit_from: ../.rubocop.yml
4
-
5
- Style/ClassAndModuleCamelCase:
6
- Enabled: false
7
-
8
- Style/FileName:
9
- Enabled: false
10
-
11
- Metrics/LineLength:
12
- Enabled: false
13
-
@@ -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
@@ -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__)