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
@@ -12,333 +12,289 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require File.expand_path("../ciscotest", __FILE__)
16
- require File.expand_path("../../lib/cisco_node_utils/snmpcommunity", __FILE__)
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/snmpcommunity'
17
17
 
18
18
  def cleanup_snmp_communities(snmpcommunities)
19
- snmpcommunities.each { |name, snmpcommunity|
20
- snmpcommunity.destroy
21
- }
19
+ snmpcommunities.each_value(&:destroy)
22
20
  end
23
21
 
24
22
  def cleanup_snmpcommunity(community)
25
23
  community.destroy
26
24
  end
27
25
 
26
+ # TestSnmpCommunity - Minitest for SnmpCommunity node utility
28
27
  class TestSnmpCommunity < CiscoTestCase
29
28
  SNMP_COMMUNITY_NAME_STR = 128
30
29
  SNMP_GROUP_NAME_STR = 128
31
- DEFAULT_SNMP_COMMUNITY_GROUP = "network-operator"
32
- DEFAULT_SNMP_COMMUNITY_ACL = ""
30
+ DEFAULT_SNMP_COMMUNITY_GROUP = 'network-operator'
31
+ DEFAULT_SNMP_COMMUNITY_ACL = ''
32
+
33
+ def setup
34
+ super
35
+ @default_show_command = 'show run snmp all | no-more'
36
+ end
33
37
 
34
38
  def test_snmpcommunity_collection_empty
35
- # This test requires all the snmp communities removed from device
36
- s = @device.cmd("show run snmp all | no-more")
37
- cmd_prefix = "snmp-server community"
38
- # puts "s : #{s}"
39
- pattern = /#{cmd_prefix}\s\S+\sgroup\s\S+/
40
- until (md = pattern.match(s)).nil?
41
- # puts "md : #{md}"
42
- ret = @device.cmd("configure terminal")
43
- ret = @device.cmd("no #{md}")
44
- ret = @device.cmd("end")
45
- node.cache_flush
46
- s = md.post_match
47
- end
48
- snmpcommunities = SnmpCommunity.communities()
49
- assert_equal(true, snmpcommunities.empty?(),
50
- "SnmpCommunity collection is not empty")
39
+ # This test requires all the snmp communities removed from device
40
+ s = @device.cmd('show run snmp all | no-more')
41
+ cmd_prefix = 'snmp-server community'
42
+ # puts "s : #{s}"
43
+ pattern = /#{cmd_prefix}\s\S+\sgroup\s\S+/
44
+ until (md = pattern.match(s)).nil?
45
+ # puts "md : #{md}"
46
+ config("no #{md}")
47
+ s = md.post_match
48
+ end
49
+ snmpcommunities = SnmpCommunity.communities
50
+ assert_equal(true, snmpcommunities.empty?,
51
+ 'SnmpCommunity collection is not empty')
51
52
  end
52
53
 
53
54
  def test_snmpcommunity_collection_not_empty
54
- # This test require some snmp community exist in device
55
- s = @device.cmd("configure terminal")
56
- s = @device.cmd("snmp-server community com1 group network-admin")
57
- s = @device.cmd("snmp-server community com2")
58
- s = @device.cmd("end")
59
- node.cache_flush
60
- snmpcommunities = SnmpCommunity.communities()
61
- assert_equal(false, snmpcommunities.empty?(),
62
- "SnmpCommunity collection is empty")
63
- cleanup_snmp_communities(snmpcommunities)
55
+ # This test require some snmp community exist in device
56
+ config('snmp-server community com1 group network-admin',
57
+ 'snmp-server community com2')
58
+ snmpcommunities = SnmpCommunity.communities
59
+ assert_equal(false, snmpcommunities.empty?,
60
+ 'SnmpCommunity collection is empty')
61
+ cleanup_snmp_communities(snmpcommunities)
64
62
  end
65
63
 
66
64
  def test_snmpcommunity_collection_valid
67
- # This test require some snmp community exist in device
68
- s = @device.cmd("configure terminal")
69
- s = @device.cmd("snmp-server community com12 group network-operator")
70
- s = @device.cmd("snmp-server community com22 group network-admin")
71
- s = @device.cmd("end")
72
- node.cache_flush
73
- # get collection
74
- snmpcommunities = SnmpCommunity.communities()
75
- s = @device.cmd("show run snmp all | no-more")
76
- cmd = "snmp-server community"
77
- snmpcommunities.each do |name, snmpcommunity|
78
- line = /#{cmd}\s#{name}\sgroup\s#{snmpcommunity.group}/.match(s)
79
- # puts "line: #{line}"
80
- assert_equal(false, line.nil?)
81
- end
82
- cleanup_snmp_communities(snmpcommunities)
83
- snmpcommunities = nil
65
+ # This test require some snmp community exist in device
66
+ config('snmp-server community com12 group network-operator',
67
+ 'snmp-server community com22 group network-admin')
68
+ # get collection
69
+ snmpcommunities = SnmpCommunity.communities
70
+ s = @device.cmd('show run snmp all | no-more')
71
+ cmd = 'snmp-server community'
72
+ snmpcommunities.each do |name, snmpcommunity|
73
+ line = /#{cmd}\s#{name}\sgroup\s#{snmpcommunity.group}/.match(s)
74
+ # puts "line: #{line}"
75
+ assert_equal(false, line.nil?)
76
+ end
77
+ cleanup_snmp_communities(snmpcommunities)
84
78
  end
85
79
 
86
80
  def test_snmpcommunity_create_name_nil
87
81
  assert_raises(TypeError) do
88
- snmpcommunity = SnmpCommunity.new(nil, "network-operator")
82
+ SnmpCommunity.new(nil, 'network-operator')
89
83
  end
90
84
  end
91
85
 
92
86
  def test_snmpcommunity_create_group_nil
93
87
  assert_raises(TypeError) do
94
- snmpcommunity = SnmpCommunity.new("test", nil)
88
+ SnmpCommunity.new('test', nil)
95
89
  end
96
90
  end
97
91
 
98
92
  def test_snmpcommunity_create_name_zero_length
99
93
  assert_raises(Cisco::CliError) do
100
- snmpcommunity = SnmpCommunity.new("", "network-operator")
94
+ SnmpCommunity.new('', 'network-operator')
101
95
  end
102
96
  end
103
97
 
104
98
  def test_snmpcommunity_create_group_zero_length
105
99
  assert_raises(Cisco::CliError) do
106
- snmpcommunity = SnmpCommunity.new("test", "")
100
+ SnmpCommunity.new('test', '')
107
101
  end
108
102
  end
109
103
 
110
104
  def test_snmpcommunity_create_name_too_long
111
- name = "co"
112
- SNMP_COMMUNITY_NAME_STR.times {
113
- name += "c"
114
- }
105
+ name = 'co' + 'c' * SNMP_COMMUNITY_NAME_STR
115
106
  assert_raises(Cisco::CliError) do
116
- snmpcommunity = SnmpCommunity.new(name,
117
- "network-operator")
107
+ SnmpCommunity.new(name, 'network-operator')
118
108
  end
119
109
  end
120
110
 
121
111
  def test_snmpcommunity_create_group_too_long
122
- group = "gr"
123
- SNMP_GROUP_NAME_STR.times {
124
- group += "g"
125
- }
112
+ group = 'gr' + 'g' * SNMP_GROUP_NAME_STR
126
113
  assert_raises(Cisco::CliError) do
127
- snmpcommunity = SnmpCommunity.new("test", group)
114
+ SnmpCommunity.new('test', group)
128
115
  end
129
116
  end
130
117
 
131
118
  def test_snmpcommunity_create_group_invalid
132
- name = "ciscotest"
133
- group = "network-operator-invalid"
119
+ name = 'ciscotest'
120
+ group = 'network-operator-invalid'
134
121
  assert_raises(Cisco::CliError) do
135
- snmpcommunity = SnmpCommunity.new(name,
136
- group)
122
+ SnmpCommunity.new(name, group)
137
123
  end
138
124
  end
139
125
 
140
126
  def test_snmpcommunity_create_valid
141
- name = "cisco"
142
- group = "network-operator"
127
+ name = 'cisco'
128
+ group = 'network-operator'
143
129
  snmpcommunity = SnmpCommunity.new(name, group)
144
- s = @device.cmd("show run snmp all | no-more")
145
- cmd = "snmp-server community"
146
- line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
147
- # puts "line: #{line}"
148
- assert_equal(false, line.nil?)
130
+ assert_show_match(
131
+ pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
149
132
  cleanup_snmpcommunity(snmpcommunity)
150
133
  end
151
134
 
152
135
  def test_snmpcommunity_create_with_name_alphanumeric_char
153
- name = "cisco128lab"
154
- group = "network-operator"
136
+ name = 'cisco128lab'
137
+ group = 'network-operator'
155
138
  snmpcommunity = SnmpCommunity.new(name, group)
156
- s = @device.cmd("show run snmp all | no-more")
157
- cmd = "snmp-server community"
158
- line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
159
- # puts "line: #{line}"
160
- assert_equal(false, line.nil?)
139
+ assert_show_match(
140
+ pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
161
141
  cleanup_snmpcommunity(snmpcommunity)
162
142
  end
163
143
 
164
144
  def test_snmpcommunity_get_group
165
- name = "ciscogetgrp"
166
- group = "network-operator"
145
+ name = 'ciscogetgrp'
146
+ group = 'network-operator'
167
147
  snmpcommunity = SnmpCommunity.new(name, group)
168
148
  assert_equal(snmpcommunity.group, group)
169
149
  cleanup_snmpcommunity(snmpcommunity)
170
150
  end
171
151
 
172
152
  def test_snmpcommunity_group_set_zero_length
173
- name = "ciscogroupsetcom"
174
- group = "network-operator"
153
+ name = 'ciscogroupsetcom'
154
+ group = 'network-operator'
175
155
  snmpcommunity = SnmpCommunity.new(name, group)
176
156
  assert_raises(Cisco::CliError) do
177
- snmpcommunity.group=""
157
+ snmpcommunity.group = ''
178
158
  end
179
159
  cleanup_snmpcommunity(snmpcommunity)
180
160
  end
181
161
 
182
162
  def test_snmpcommunity_group_set_too_long
183
- name = "ciscogroupsetcom"
184
- group = "network-operator"
163
+ name = 'ciscogroupsetcom'
164
+ group = 'network-operator'
185
165
  snmpcommunity = SnmpCommunity.new(name, group)
186
166
  assert_raises(Cisco::CliError) do
187
- snmpcommunity.group="group123456789c123456789c123456789c12345"
167
+ snmpcommunity.group = 'group123456789c123456789c123456789c12345'
188
168
  end
189
169
  cleanup_snmpcommunity(snmpcommunity)
190
170
  end
191
171
 
192
172
  def test_snmpcommunity_group_set_invalid
193
- name = "ciscogroupsetcom"
194
- group = "network-operator"
173
+ name = 'ciscogroupsetcom'
174
+ group = 'network-operator'
195
175
  snmpcommunity = SnmpCommunity.new(name, group)
196
176
  assert_raises(Cisco::CliError) do
197
- snmpcommunity.group="testgroup"
177
+ snmpcommunity.group = 'testgroup'
198
178
  end
199
179
  cleanup_snmpcommunity(snmpcommunity)
200
180
  end
201
181
 
202
182
  def test_snmpcommunity_group_set_valid
203
- name = "ciscogroupsetcom"
204
- group = "network-operator"
183
+ name = 'ciscogroupsetcom'
184
+ group = 'network-operator'
205
185
  snmpcommunity = SnmpCommunity.new(name, group)
206
186
  # new group
207
- group = "network-admin"
187
+ group = 'network-admin'
208
188
  snmpcommunity.group = group
209
- s = @device.cmd("show run snmp all | no-more")
210
- cmd = "snmp-server community"
211
- line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
212
- assert_equal(false, line.nil?)
189
+ assert_show_match(
190
+ pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
213
191
  cleanup_snmpcommunity(snmpcommunity)
214
192
  end
215
193
 
216
194
  def test_snmpcommunity_group_set_default
217
- name = "ciscogroupsetcom"
218
- group = "network-operator"
195
+ name = 'ciscogroupsetcom'
196
+ group = 'network-operator'
219
197
  snmpcommunity = SnmpCommunity.new(name, group)
220
198
  # new group identity
221
- group = "vdc-admin"
199
+ group = 'vdc-admin'
222
200
  snmpcommunity.group = group
223
- s = @device.cmd("show run snmp all | no-more")
224
- cmd = "snmp-server community"
225
- line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
226
- # puts line
227
- assert_equal(false, line.nil?)
201
+ assert_show_match(
202
+ pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
228
203
 
229
204
  # Restore group default
230
- group = SnmpCommunity.default_group()
205
+ group = SnmpCommunity.default_group
231
206
  snmpcommunity.group = group
232
- s = @device.cmd("show run snmp all | no-more")
233
- cmd = "snmp-server community"
234
- line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
235
- # puts line
236
- assert_equal(false, line.nil?)
207
+ assert_show_match(
208
+ pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
237
209
 
238
210
  cleanup_snmpcommunity(snmpcommunity)
239
211
  end
240
212
 
241
213
  def test_snmpcommunity_destroy_valid
242
- name = "ciscotest"
243
- group = "network-operator"
214
+ name = 'ciscotest'
215
+ group = 'network-operator'
244
216
  snmpcommunity = SnmpCommunity.new(name, group)
245
217
  snmpcommunity.destroy
246
- s = @device.cmd("show run snmp all | no-more")
247
- cmd = "snmp-server community"
248
- line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
249
- assert_equal(true, line.nil?)
218
+ refute_show_match(
219
+ pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
250
220
  end
251
221
 
252
222
  def test_snmpcommunity_acl_get_no_acl
253
- name = "cisconoaclget"
254
- group = "network-operator"
223
+ name = 'cisconoaclget'
224
+ group = 'network-operator'
255
225
  snmpcommunity = SnmpCommunity.new(name, group)
256
- assert_equal(snmpcommunity.acl, "")
226
+ assert_equal(snmpcommunity.acl, '')
257
227
  cleanup_snmpcommunity(snmpcommunity)
258
228
  end
259
229
 
260
230
  def test_snmpcommunity_acl_get
261
- name = "ciscoaclget"
262
- group = "network-operator"
231
+ name = 'ciscoaclget'
232
+ group = 'network-operator'
263
233
  snmpcommunity = SnmpCommunity.new(name, group)
264
- snmpcommunity.acl="ciscoacl"
265
- s = @device.cmd("show run snmp all | no-more")
266
- cmd = "snmp-server community"
267
- line = /#{cmd}\s#{name}\suse-acl\s\S+/.match(s)
268
- acl = line.to_s.gsub(/#{cmd}\s#{name}\suse-acl\s/, "").strip
234
+ snmpcommunity.acl = 'ciscoacl'
235
+ line = assert_show_match(
236
+ pattern: /snmp-server community\s#{name}\suse-acl\s\S+/)
237
+ acl = line.to_s.gsub(/snmp-server community\s#{name}\suse-acl\s/, '').strip
269
238
  assert_equal(snmpcommunity.acl, acl)
270
239
  cleanup_snmpcommunity(snmpcommunity)
271
240
  end
272
241
 
273
242
  def test_snmpcommunity_acl_set_nil
274
- name = "cisco"
275
- group = "network-operator"
243
+ name = 'cisco'
244
+ group = 'network-operator'
276
245
  snmpcommunity = SnmpCommunity.new(name, group)
277
246
  assert_raises(TypeError) do
278
- snmpcommunity.acl=nil
247
+ snmpcommunity.acl = nil
279
248
  end
280
249
  cleanup_snmpcommunity(snmpcommunity)
281
250
  end
282
251
 
283
252
  def test_snmpcommunity_acl_set_valid
284
- name = "ciscoadmin"
285
- group = "network-admin"
286
- acl = "ciscoadminacl"
253
+ name = 'ciscoadmin'
254
+ group = 'network-admin'
255
+ acl = 'ciscoadminacl'
287
256
  snmpcommunity = SnmpCommunity.new(name, group)
288
- snmpcommunity.acl=acl
289
- s = @device.cmd("show run snmp all | no-more")
290
- cmd = "snmp-server community"
291
- line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
292
- # puts "line: #{line}"
293
- assert_equal(false, line.nil?)
257
+ snmpcommunity.acl = acl
258
+ assert_show_match(
259
+ pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
294
260
  cleanup_snmpcommunity(snmpcommunity)
295
261
  end
296
262
 
297
263
  def test_snmpcommunity_acl_set_zero_length
298
- name = "ciscooper"
299
- group = "network-operator"
300
- acl = "ciscooperacl"
264
+ name = 'ciscooper'
265
+ group = 'network-operator'
266
+ acl = 'ciscooperacl'
301
267
  snmpcommunity = SnmpCommunity.new(name, group)
302
268
  # puts "set acl #{acl}"
303
- snmpcommunity.acl=acl
304
- s = @device.cmd("show run snmp all | no-more")
305
- cmd = "snmp-server community"
306
- line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
307
- # puts "line: #{line}"
308
- assert_equal(false, line.nil?)
269
+ snmpcommunity.acl = acl
270
+ assert_show_match(
271
+ pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
309
272
  # remove acl
310
- snmpcommunity.acl=""
311
- s = @device.cmd("show run snmp all | no-more")
312
- line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
313
- # puts "line: #{line}"
314
- assert_equal(true, line.nil?)
273
+ snmpcommunity.acl = ''
274
+ refute_show_match(
275
+ pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
315
276
  cleanup_snmpcommunity(snmpcommunity)
316
277
  end
317
278
 
318
279
  def test_snmpcommunity_acl_set_default
319
- name = "cisco"
320
- group = "network-operator"
321
- acl = "cisco_test_acl"
280
+ name = 'cisco'
281
+ group = 'network-operator'
282
+ acl = 'cisco_test_acl'
322
283
  snmpcommunity = SnmpCommunity.new(name, group)
323
284
  snmpcommunity.acl = acl
324
- s = @device.cmd("show run snmp all | no-more")
325
- cmd = "snmp-server community"
326
- line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
327
- # puts "line: #{line}"
328
- assert_equal(false, line.nil?)
285
+ assert_show_match(
286
+ pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
329
287
 
330
288
  # Check default_acl
331
289
  assert_equal(DEFAULT_SNMP_COMMUNITY_ACL,
332
- SnmpCommunity.default_acl(),
333
- "Error: Snmp Community, default ACL not correct value")
290
+ SnmpCommunity.default_acl,
291
+ 'Error: Snmp Community, default ACL not correct value')
334
292
 
335
293
  # Set acl to default
336
- acl = SnmpCommunity.default_acl()
294
+ acl = SnmpCommunity.default_acl
337
295
  snmpcommunity.acl = acl
338
- s = @device.cmd("show run snmp all | no-more")
339
- line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
340
- # puts "line: #{line}"
341
- assert_equal(true, line.nil?)
296
+ refute_show_match(
297
+ pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
342
298
  cleanup_snmpcommunity(snmpcommunity)
343
299
  end
344
300
  end