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/tests/test_snmpcommunity.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
15
|
+
require_relative 'ciscotest'
|
16
|
+
require_relative '../lib/cisco_node_utils/snmpcommunity'
|
17
17
|
|
18
18
|
def cleanup_snmp_communities(snmpcommunities)
|
19
|
-
snmpcommunities.
|
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 =
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
100
|
+
SnmpCommunity.new('test', '')
|
107
101
|
end
|
108
102
|
end
|
109
103
|
|
110
104
|
def test_snmpcommunity_create_name_too_long
|
111
|
-
name =
|
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
|
-
|
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 =
|
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
|
-
|
114
|
+
SnmpCommunity.new('test', group)
|
128
115
|
end
|
129
116
|
end
|
130
117
|
|
131
118
|
def test_snmpcommunity_create_group_invalid
|
132
|
-
name =
|
133
|
-
group =
|
119
|
+
name = 'ciscotest'
|
120
|
+
group = 'network-operator-invalid'
|
134
121
|
assert_raises(Cisco::CliError) do
|
135
|
-
|
136
|
-
group)
|
122
|
+
SnmpCommunity.new(name, group)
|
137
123
|
end
|
138
124
|
end
|
139
125
|
|
140
126
|
def test_snmpcommunity_create_valid
|
141
|
-
name =
|
142
|
-
group =
|
127
|
+
name = 'cisco'
|
128
|
+
group = 'network-operator'
|
143
129
|
snmpcommunity = SnmpCommunity.new(name, group)
|
144
|
-
|
145
|
-
|
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 =
|
154
|
-
group =
|
136
|
+
name = 'cisco128lab'
|
137
|
+
group = 'network-operator'
|
155
138
|
snmpcommunity = SnmpCommunity.new(name, group)
|
156
|
-
|
157
|
-
|
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 =
|
166
|
-
group =
|
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 =
|
174
|
-
group =
|
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 =
|
184
|
-
group =
|
163
|
+
name = 'ciscogroupsetcom'
|
164
|
+
group = 'network-operator'
|
185
165
|
snmpcommunity = SnmpCommunity.new(name, group)
|
186
166
|
assert_raises(Cisco::CliError) do
|
187
|
-
snmpcommunity.group=
|
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 =
|
194
|
-
group =
|
173
|
+
name = 'ciscogroupsetcom'
|
174
|
+
group = 'network-operator'
|
195
175
|
snmpcommunity = SnmpCommunity.new(name, group)
|
196
176
|
assert_raises(Cisco::CliError) do
|
197
|
-
snmpcommunity.group=
|
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 =
|
204
|
-
group =
|
183
|
+
name = 'ciscogroupsetcom'
|
184
|
+
group = 'network-operator'
|
205
185
|
snmpcommunity = SnmpCommunity.new(name, group)
|
206
186
|
# new group
|
207
|
-
group =
|
187
|
+
group = 'network-admin'
|
208
188
|
snmpcommunity.group = group
|
209
|
-
|
210
|
-
|
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 =
|
218
|
-
group =
|
195
|
+
name = 'ciscogroupsetcom'
|
196
|
+
group = 'network-operator'
|
219
197
|
snmpcommunity = SnmpCommunity.new(name, group)
|
220
198
|
# new group identity
|
221
|
-
group =
|
199
|
+
group = 'vdc-admin'
|
222
200
|
snmpcommunity.group = group
|
223
|
-
|
224
|
-
|
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
|
-
|
233
|
-
|
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 =
|
243
|
-
group =
|
214
|
+
name = 'ciscotest'
|
215
|
+
group = 'network-operator'
|
244
216
|
snmpcommunity = SnmpCommunity.new(name, group)
|
245
217
|
snmpcommunity.destroy
|
246
|
-
|
247
|
-
|
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 =
|
254
|
-
group =
|
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 =
|
262
|
-
group =
|
231
|
+
name = 'ciscoaclget'
|
232
|
+
group = 'network-operator'
|
263
233
|
snmpcommunity = SnmpCommunity.new(name, group)
|
264
|
-
snmpcommunity.acl=
|
265
|
-
|
266
|
-
|
267
|
-
|
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 =
|
275
|
-
group =
|
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 =
|
285
|
-
group =
|
286
|
-
acl =
|
253
|
+
name = 'ciscoadmin'
|
254
|
+
group = 'network-admin'
|
255
|
+
acl = 'ciscoadminacl'
|
287
256
|
snmpcommunity = SnmpCommunity.new(name, group)
|
288
|
-
snmpcommunity.acl=acl
|
289
|
-
|
290
|
-
|
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 =
|
299
|
-
group =
|
300
|
-
acl =
|
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
|
-
|
305
|
-
|
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
|
-
|
312
|
-
|
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 =
|
320
|
-
group =
|
321
|
-
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
|
-
|
325
|
-
|
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
|
-
|
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
|
-
|
339
|
-
|
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
|