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.
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
@@ -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 we agree as a team that a new release should be published, the process is as follows:
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) - a bugfix release is a 0.0.x version bump, a new feature is a 0.x.0 bump, and a backward-incompatible change is a new x.0.0 version.
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
@@ -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
- require File.join(File.dirname(__FILE__), 'node')
15
+ require_relative 'node_util'
19
16
 
20
17
  module Cisco
21
- class X__CLASS_NAME__X
22
- attr_reader :name
23
-
24
- # Establish connection to node
25
- @@node = Cisco::Node.instance
26
-
27
- # name: name of the router instance
28
- # instantiate: true = create router instance
29
- def initialize(name, instantiate=true)
30
- raise ArgumentError unless name.length > 0
31
- @name = name
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
- # Create a hash of all current router instances.
36
- def X__CLASS_NAME__X.routers
37
- instances = @@node.config_get('X__RESOURCE_NAME__X', 'router')
38
- return {} if instances.nil?
39
- hash = {}
40
- instances.each do |name|
41
- hash[name] = X__CLASS_NAME__X.new(name, false)
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
- def feature_enabled
51
- feat = @@node.config_get('X__RESOURCE_NAME__X', 'feature')
52
- return (!feat.nil? and !feat.empty?)
53
- rescue Cisco::CliError => e
54
- # This cmd will syntax reject if feature is not
55
- # enabled. Just catch the reject and return false.
56
- return false if e.clierror =~ /Syntax error/
57
- raise
58
- end
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
- def feature_enable
61
- @@node.config_set('X__RESOURCE_NAME__X', 'feature', { :state => '' })
62
- end
55
+ def feature_enable
56
+ config_set('X__RESOURCE_NAME__X', 'feature', state: '')
57
+ end
63
58
 
64
- def feature_disable
65
- @@node.config_set('X__RESOURCE_NAME__X', 'feature', { :state => 'no' })
66
- end
59
+ def feature_disable
60
+ config_set('X__RESOURCE_NAME__X', 'feature', state: 'no')
61
+ end
67
62
 
68
- # Enable feature and create router instance
69
- def create
70
- feature_enable unless feature_enabled
71
- X__RESOURCE_NAME__X_router
72
- end
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
- # Destroy a router instance; disable feature on last instance
75
- def destroy
76
- ids = @@node.config_get('X__RESOURCE_NAME__X', 'router')
77
- return if ids.nil?
78
- if ids.size == 1
79
- feature_disable
80
- else
81
- X__RESOURCE_NAME__X_router('no')
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
- def X__RESOURCE_NAME__X_router(state='')
89
- @@node.config_set('X__RESOURCE_NAME__X', 'router', { :name => @name, :state => state })
90
- end
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
- # PROPERTIES
94
- # ----------
87
+ # ----------
88
+ # PROPERTIES
89
+ # ----------
95
90
 
96
- # Property methods for boolean property
97
- def default_X__PROPERTY_BOOL__X
98
- @@node.config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X')
99
- end
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
- def X__PROPERTY_BOOL__X
102
- state = @@node.config_get('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X', { :name => @name })
103
- state ? true : false
104
- end
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
- def X__PROPERTY_BOOL__X=(state)
107
- state = (state ? '' : 'no')
108
- @@node.config_set('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X', { :name => @name, :state => state })
109
- end
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
- # Property methods for integer property
112
- def default_X__PROPERTY_INT__X
113
- @@node.config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X')
114
- end
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
- def X__PROPERTY_INT__X
117
- val = @@node.config_get('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X', { :name => @name })
118
- val.nil? ? default_X__PROPERTY_INT__X : val.first.to_i
119
- end
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
- def X__PROPERTY_INT__X=(val)
122
- @@node.config_set('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X', { :name => @name, :val => val })
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
- require File.expand_path("../ciscotest", __FILE__)
19
- require File.expand_path("../../lib/cisco_node_utils/router___RESOURCE_NAME__", __FILE__)
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/router_X__RESOURCE_NAME__X'
20
17
 
21
- class Test__CLASS_NAME__ < CiscoTestCase
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
- no_feature___RESOURCE_NAME__
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
- no_feature___RESOURCE_NAME__
28
+ no_feature_X__RESOURCE_NAME__X
31
29
  super
32
30
  end
33
31
 
34
- def no_feature___RESOURCE_NAME__
32
+ def no_feature_X__RESOURCE_NAME__X
35
33
  # Turn the feature off for a clean test.
36
- @device.cmd("conf t ; no feature __RESOURCE_NAME__ ; end")
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 = "blue"
45
- rtr = __CLASS_NAME__.new(id)
46
- s = @device.cmd("show runn | i 'router __RESOURCE_NAME__ #{id}'")
47
- assert_match(s, /^router __RESOURCE_NAME__ #{id}$/,
48
- "Error: failed to create router __RESOURCE_NAME__ #{id}")
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
- s = @device.cmd("show runn | i 'router __RESOURCE_NAME__ #{id}'")
52
- refute_match(s, /^router __RESOURCE_NAME__ #{id}$/,
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
- s = @device.cmd("show runn | i 'feature __RESOURCE_NAME__'")
56
- refute_match(s, /^feature __RESOURCE_NAME__$/,
57
- "Error: failed to disable feature __RESOURCE_NAME__")
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 = "blue"
62
- rtr1 = __CLASS_NAME__.new(id1)
63
- id2 = "red"
64
- rtr2 = __CLASS_NAME__.new(id2)
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
- s = @device.cmd("show runn | i 'router __RESOURCE_NAME__'")
67
- assert_match(s, /^router __RESOURCE_NAME__ #{id1}$/)
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
- s = @device.cmd("show runn | i 'router __RESOURCE_NAME__ #{id1}'")
72
- refute_match(s, /^router __RESOURCE_NAME__ #{id1}$/,
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
- s = @device.cmd("show runn | i 'router __RESOURCE_NAME__ #{id2}'")
77
- refute_match(s, /^router __RESOURCE_NAME__ #{id2}$/,
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
- s = @device.cmd("show runn | i 'feature __RESOURCE_NAME__'")
81
- refute_match(s, /^feature __RESOURCE_NAME__$/,
82
- "Error: failed to disable feature __RESOURCE_NAME__")
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 test_router___PROPERTY_INT__
86
- id = "blue"
87
- rtr = __CLASS_NAME__.new(id)
88
- val = 5 # This value depends on property bounds
89
- rtr.__PROPERTY_INT__ = val
90
- assert_equal(rtr.__PROPERTY_INT__, val, "__PROPERTY_INT__ is not #{val}")
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("__RESOURCE_NAME__", "__PROPERTY_INT__")
94
- rtr.__PROPERTY_INT__ = val
95
- assert_equal(rtr.__PROPERTY_INT__, val, "__PROPERTY_INT__ is not #{val}")
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 test_router___PROPERTY_BOOL__
99
- id = "blue"
100
- rtr = __CLASS_NAME__.new(id)
101
- rtr.__PROPERTY_BOOL__ = true
102
- assert(rtr.__PROPERTY_BOOL__, "__PROPERTY_BOOL__ state is not true")
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.__PROPERTY_BOOL__ = false
105
- refute(rtr.__PROPERTY_BOOL__, "__PROPERTY_BOOL__ state is not false")
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
@@ -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
- require "cisco_node_utils/cisco_cmn_utils"
16
- require "cisco_node_utils/command_reference"
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 }