rbeapi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.gitignore +35 -0
  2. data/Gemfile +25 -0
  3. data/Guardfile +15 -0
  4. data/LICENSE +28 -0
  5. data/README.md +218 -0
  6. data/Rakefile +12 -0
  7. data/lib/rbeapi.rb +32 -0
  8. data/lib/rbeapi/api.rb +135 -0
  9. data/lib/rbeapi/api/aaa.rb +410 -0
  10. data/lib/rbeapi/api/dns.rb +198 -0
  11. data/lib/rbeapi/api/interfaces.rb +1193 -0
  12. data/lib/rbeapi/api/ipinterfaces.rb +328 -0
  13. data/lib/rbeapi/api/logging.rb +157 -0
  14. data/lib/rbeapi/api/mlag.rb +519 -0
  15. data/lib/rbeapi/api/ntp.rb +201 -0
  16. data/lib/rbeapi/api/ospf.rb +214 -0
  17. data/lib/rbeapi/api/prefixlists.rb +98 -0
  18. data/lib/rbeapi/api/radius.rb +317 -0
  19. data/lib/rbeapi/api/radius.rb.old +399 -0
  20. data/lib/rbeapi/api/routemaps.rb +100 -0
  21. data/lib/rbeapi/api/snmp.rb +427 -0
  22. data/lib/rbeapi/api/staticroutes.rb +88 -0
  23. data/lib/rbeapi/api/stp.rb +381 -0
  24. data/lib/rbeapi/api/switchports.rb +272 -0
  25. data/lib/rbeapi/api/system.rb +87 -0
  26. data/lib/rbeapi/api/tacacs.rb +236 -0
  27. data/lib/rbeapi/api/varp.rb +181 -0
  28. data/lib/rbeapi/api/vlans.rb +338 -0
  29. data/lib/rbeapi/client.rb +454 -0
  30. data/lib/rbeapi/eapilib.rb +334 -0
  31. data/lib/rbeapi/netdev/snmp.rb +370 -0
  32. data/lib/rbeapi/utils.rb +70 -0
  33. data/lib/rbeapi/version.rb +37 -0
  34. data/rbeapi.gemspec +32 -0
  35. data/spec/fixtures/dut.conf +5 -0
  36. data/spec/spec_helper.rb +22 -0
  37. data/spec/support/fixtures.rb +114 -0
  38. data/spec/support/shared_examples_for_api_modules.rb +124 -0
  39. data/spec/system/api_ospf_interfaces_spec.rb +58 -0
  40. data/spec/system/api_ospf_spec.rb +111 -0
  41. data/spec/system/api_varp_interfaces_spec.rb +60 -0
  42. data/spec/system/api_varp_spec.rb +44 -0
  43. data/spec/system/rbeapi/api/dns_spec.rb +77 -0
  44. data/spec/system/rbeapi/api/interfaces_base_spec.rb +94 -0
  45. data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +135 -0
  46. data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +188 -0
  47. data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +115 -0
  48. data/spec/system/rbeapi/api/ipinterfaces_spec.rb +97 -0
  49. data/spec/system/rbeapi/api/logging_spec.rb +65 -0
  50. data/spec/system/rbeapi/api/mlag_interfaces_spec.rb +80 -0
  51. data/spec/system/rbeapi/api/mlag_spec.rb +94 -0
  52. data/spec/system/rbeapi/api/ntp_spec.rb +76 -0
  53. data/spec/system/rbeapi/api/snmp_spec.rb +68 -0
  54. data/spec/system/rbeapi/api/stp_instances_spec.rb +61 -0
  55. data/spec/system/rbeapi/api/stp_interfaces_spec.rb +71 -0
  56. data/spec/system/rbeapi/api/stp_spec.rb +57 -0
  57. data/spec/system/rbeapi/api/switchports_spec.rb +135 -0
  58. data/spec/system/rbeapi/api/system_spec.rb +38 -0
  59. data/spec/system/rbeapi/api/vlans_spec.rb +121 -0
  60. metadata +274 -0
@@ -0,0 +1,100 @@
1
+ #
2
+ # Copyright (c) 2014, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'rbeapi/api'
33
+
34
+ module Rbeapi
35
+
36
+ module Api
37
+
38
+ class Routemaps < Entity
39
+
40
+ def get(name)
41
+ entries = config.scan(/^route-map\s#{name}\s.+$/)
42
+
43
+ entries.each_with_object([]) do |rm, arry|
44
+ mdata = /route-map\s(.+)\s(.+)\s(\d+)$/.match(rm)
45
+ rules = get_block(rm)
46
+ rule_hsh = { 'action' => mdata[2], 'seqno' => mdata[3],
47
+ 'match_rules' => [], 'set_rules' => [],
48
+ 'continue_rules' => [] }
49
+
50
+ parsed = rules.split("\n").each_with_object({}) do |rule, hsh|
51
+ mdata = /\s{3}(\w+)\s/.match(rule)
52
+ case mdata.nil? ? nil : mdata[1]
53
+ when 'match'
54
+ hsh['match_rules'] = [] unless hsh.include?('match')
55
+ hsh['match_rules'] << rule.strip()
56
+ when 'set'
57
+ hsh['set_rules'] = [] unless hsh.include?('set')
58
+ hsh['set_rules'] << rule.strip()
59
+ when 'continue'
60
+ hsh['continue_rules'] = [] unless hsh.include?('continue')
61
+ hsh['continue_rules'] << rule.strip()
62
+ end
63
+ end
64
+ rule_hsh.update(parsed)
65
+ arry << rule_hsh
66
+ end
67
+ end
68
+
69
+ def getall
70
+ maps = config.scan(/(?<=^route-map\s)[^\s]+/)
71
+ maps.each_with_object({}) do |name, hsh|
72
+ if !hsh.include?(name)
73
+ hsh[name] = get name
74
+ end
75
+ end
76
+ end
77
+
78
+ def create(name)
79
+ configure "route-map #{name}"
80
+ end
81
+
82
+ def delete(name)
83
+ configure "no route-map #{name}"
84
+ end
85
+
86
+ def add_rule(name, action, rule, seqno = nil)
87
+ cmd = "route-map #{name} #{action}"
88
+ cmd << " #{seqno}" if seqno
89
+ cmds = [*cmds]
90
+ cmds << rule
91
+ configure cmds
92
+ end
93
+
94
+ def remove_rule(name, action, seqno)
95
+ configure "no route-map #{name} #{action} #{seqno}"
96
+ end
97
+
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,427 @@
1
+ #
2
+ # Copyright (c) 2014, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'rbeapi/api'
33
+
34
+ module Rbeapi
35
+
36
+ ##
37
+ # Api is module namespace for working with eAPI abstractions
38
+ module Api
39
+
40
+ ##
41
+ # The Snmp class provides a class implementation for working with the
42
+ # nodes SNMP conifguration entity. This class presents an abstraction
43
+ # of the node's snmp configuration from the running config.
44
+ #
45
+ # @eos_version 4.13.7M
46
+ class Snmp < Entity
47
+
48
+ DEFAULT_SNMP_LOCATION = ''
49
+ DEFAULT_SNMP_CONTACT = ''
50
+ DEFAULT_SNMP_CHASSIS_ID = ''
51
+ DEFAULT_SNMP_SOURCE_INTERFACE = ''
52
+ CFG_TO_STATE = { 'default' => 'default', 'no' => 'off', nil => 'on' }
53
+ STATE_TO_CFG = { 'default' => 'default', 'on' => nil, 'off' => 'no' }
54
+
55
+ ##
56
+ # get returns the snmp resource Hash that represents the nodes snmp
57
+ # configuration abstraction from the running config.
58
+ #
59
+ # @example
60
+ # {
61
+ # location: <string>
62
+ # contact: <string>
63
+ # chassis_id: <string>
64
+ # source_interface: <string>
65
+ # }
66
+ #
67
+ # @return[Hash<Symbol, Object>] Returns the snmp resource as a Hash
68
+ def get
69
+ response = {}
70
+ response.merge!(parse_location)
71
+ response.merge!(parse_contact)
72
+ response.merge!(parse_chassis_id)
73
+ response.merge!(parse_source_interface)
74
+ response.merge!(parse_communities)
75
+ response.merge!(parse_notifications)
76
+ response
77
+ end
78
+
79
+ ##
80
+ # parse_location scans the running config from the node and parses
81
+ # the snmp location value if it exists in the configuration. If the
82
+ # snmp location is not configure, then the DEFAULT_SNMP_LOCATION string
83
+ # is returned. The Hash returned by this method is merged into the
84
+ # snmp resource Hash returned by the get method.
85
+ #
86
+ # @api private
87
+ #
88
+ # @return [Hash<Symbol,Object>] resource Hash attribute
89
+ def parse_location
90
+ mdata = /snmp-server location (.+)$/.match(config)
91
+ { location: mdata.nil? ? DEFAULT_SNMP_LOCATION : mdata[1] }
92
+ end
93
+ private :parse_location
94
+
95
+ ##
96
+ # parse_contact scans the running config form the node and parses
97
+ # the snmp contact value if it exists in the configuration. If the
98
+ # snmp contact is not configured, then the DEFAULT_SNMP_CONTACT value
99
+ # is returned. The Hash returned by this method is merged into the
100
+ # snmp resource Hash returned by the get method.
101
+ #
102
+ # @api private
103
+ #
104
+ # @return [Hash<Symbol,Object] resource Hash attribute
105
+ def parse_contact
106
+ mdata = /snmp-server contact (.+)$/.match(config)
107
+ { contact: mdata.nil? ? DEFAULT_SNMP_CONTACT : mdata[1] }
108
+ end
109
+ private :parse_contact
110
+
111
+ ##
112
+ # parse_chassis_id scans the running config from the node and parses
113
+ # the snmp chassis id value if it exists in the configuration. If the
114
+ # snmp chassis id is not configured, then the DEFAULT_SNMP_CHASSIS_ID
115
+ # value is returned. The Hash returned by this method is intended to
116
+ # be merged into the snmp resource Hash
117
+ #
118
+ # @api private
119
+ #
120
+ # @return [Hash<Symbol,Object>] resource Hash attribute
121
+ def parse_chassis_id
122
+ mdata = /snmp-server chassis-id (.+)$/.match(config)
123
+ { chassis_id: mdata.nil? ? DEFAULT_SNMP_CHASSIS_ID : mdata[1] }
124
+ end
125
+ private :parse_chassis_id
126
+
127
+ ##
128
+ # parse_source_interface scans the running config from the node and
129
+ # parses the snmp source interface value if it exists in the
130
+ # configuration. If the snmp source interface is not configured, then
131
+ # the DEFAULT_SNMP_SOURCE_INTERFACE value is returned. The Hash
132
+ # returned by this method is intended to be merged into the snmmp
133
+ # resource Hash
134
+ #
135
+ # @api private
136
+ #
137
+ # @return [Hash<Symbol, Object>] resource Hash attribute
138
+ def parse_source_interface
139
+ mdata = /snmp-server source-interface (.+)$/.match(config)
140
+ { source_interface: mdata.nil? ? '' : mdata[1] }
141
+ end
142
+ private :parse_source_interface
143
+
144
+ ##
145
+ # parse_communities scans the running config from the node and parses all
146
+ # of the configure snmp community strings. If there are no configured
147
+ # snmp community strings, the communitys value is set to an empty array.
148
+ # The returned hash is intended to be merged into the global snmp
149
+ # resource hash
150
+ #
151
+ # @api private
152
+ #
153
+ # @return [Hash<Hash>] resource hash attribute
154
+ def parse_communities
155
+ values = config.scan(/snmp-server community (\w+) (ro|rw)[ ]?(.+)?$/)
156
+ communities = values.each_with_object({}) do |value, hsh|
157
+ name, access, acl = value
158
+ hsh[name] = { access: access, acl: acl }
159
+ end
160
+ { communities: communities }
161
+ end
162
+ private :parse_communities
163
+
164
+ ##
165
+ # parse_notifications scans the running configuration and parses all of
166
+ # the snmp trap notificaitons configuration. It is expected the trap
167
+ # configuration is in the running config. The returned hash is intendd
168
+ # to be merged into the resource hash
169
+ def parse_notifications
170
+ traps = config.scan(/(default|no)?[ ]?snmp-server enable traps (.+)$/)
171
+ all = config.scan(/(default|no)?[ ]?snmp-server enable traps$/).first
172
+
173
+ notifications = traps.map do |trap|
174
+ state, name = trap
175
+ { name: name, state: CFG_TO_STATE[state]}
176
+ end
177
+ notifications << { name: 'all', state: CFG_TO_STATE[all.first] }
178
+ { notifications: notifications }
179
+ end
180
+ private :parse_notifications
181
+
182
+ ##
183
+ # set_notification configures the snmp trap notificaiton for the
184
+ # specified trap. The name option accepts the snmp trap name to
185
+ # configure or the keyword all to globally enable or disable
186
+ # notifications. If the optional state argument is not provided then the
187
+ # default state is default.
188
+ #
189
+ # @eos_version 4.13.7M
190
+ #
191
+ # @commands
192
+ # snmp-server enable traps <name>
193
+ # no snmp-server enable traps <name>
194
+ # default snmp-server enable traps <name>
195
+ #
196
+ # @param [String] :name The name of the trap to configure or the keyword
197
+ # all. If this option is not specified, then the value of 'all' is
198
+ # used as the default.
199
+ #
200
+ # @param [String] :state The state to configure the trap notification.
201
+ # Valid values include 'on', 'off' or 'default'
202
+ def set_notification(opts = {})
203
+ name = opts[:name]
204
+ name = nil if name == 'all'
205
+ state = opts[:state] || 'default'
206
+ state = STATE_TO_CFG[state]
207
+ configure "#{state} snmp-server enable traps #{name}"
208
+ end
209
+
210
+ ##
211
+ # set_location updates the snmp location value in the nodes running
212
+ # configuration. If the value is not provided in the opts Hash then
213
+ # the snmp location value is negated using the no keyword. If the
214
+ # default keyword is set to true, then the snmp location value is
215
+ # defaulted using the default keyword. The default parameter takes
216
+ # precedence over the value keyword.
217
+ #
218
+ # @eos_version 4.13.7M
219
+ #
220
+ # @commands
221
+ # snmp-server location <value>
222
+ # no snmp-server location
223
+ # default snmp-server location
224
+ #
225
+ # @param [Hash] opts The configuration parameters
226
+ #
227
+ # @option opts [string] :value The snmp location value to configure
228
+ #
229
+ # @option opts [Boolean] :default Configure the snmp location value
230
+ # using the default keyword
231
+ #
232
+ # @return [Boolean] returns true if the command completed successfully
233
+ def set_location(opts = {})
234
+ value = opts[:value]
235
+ default = opts[:default] || false
236
+
237
+ case default
238
+ when true
239
+ cmds = ['default snmp-server location']
240
+ when false
241
+ cmds = (value.nil? ? "no snmp-server location" : \
242
+ "snmp-server location #{value}")
243
+ end
244
+ configure(cmds)
245
+ end
246
+
247
+ ##
248
+ # set_contact updates the snmp contact value in the nodes running
249
+ # configuration. If the value is not provided in the opts Hash then
250
+ # the snmp contact value is negated using the no keyword. If the
251
+ # default keyword is set to true, then the snmp contact value is
252
+ # defaulted using the default keyword. The default parameter takes
253
+ # precedence over the value keyword.
254
+ #
255
+ # @eos_version 4.13.7M
256
+ #
257
+ # @commands
258
+ # snmp-server contact <value>
259
+ # no snmp-server contact
260
+ # default snmp-server contact
261
+ #
262
+ # @param [Hash] opts The configuration parameters
263
+ #
264
+ # @option opts [string] :value The snmp contact value to configure
265
+ #
266
+ # @option opts [Boolean] :default Configures the snmp contact value
267
+ # using the default keyword
268
+ #
269
+ # @return [Boolean] returns true if the command completed successfully
270
+ def set_contact(opts = {})
271
+ value = opts[:value]
272
+ default = opts[:default] || false
273
+
274
+ case default
275
+ when true
276
+ cmds = ['default snmp-server contact']
277
+ when false
278
+ cmds = (value.nil? ? "no snmp-server contact" : \
279
+ "snmp-server contact #{value}")
280
+ end
281
+ configure(cmds)
282
+ end
283
+
284
+ ##
285
+ # set_chassis_id updates the snmp chassis id value in the nodes
286
+ # running configuration. If the value is not provided in the opts
287
+ # Hash then the snmp chassis id value is negated using the no
288
+ # keyword. If the default keyword is set to true, then the snmp
289
+ # chassis id value is defaulted using the default keyword. The default
290
+ # keyword takes precedence over the value keyword.
291
+ #
292
+ # @eos_version 4.13.7M
293
+ #
294
+ # @commands
295
+ # snmp-server chassis-id <value>
296
+ # no snmp-server chassis-id
297
+ # default snmp-server chassis-id
298
+ #
299
+ # @param [Hash] opts The configuration parameters
300
+ #
301
+ # @option opts [string] :value The snmp chassis id value to configure
302
+ #
303
+ # @option opts [Boolean] :default Configures the snmp chassis id value
304
+ # using the default keyword
305
+ #
306
+ # @return [Boolean] returns true if the command completed successfully
307
+ def set_chassis_id(opts = {})
308
+ value = opts[:value]
309
+ default = opts[:default] || false
310
+
311
+ case default
312
+ when true
313
+ cmds = 'default snmp-server chassis-id'
314
+ when false
315
+ cmds = (value.nil? ? "no snmp-server chassis-id" : \
316
+ "snmp-server chassis-id #{value}")
317
+ end
318
+ configure(cmds)
319
+ end
320
+
321
+ ##
322
+ # set_source_interface updates the snmp source interface value in the
323
+ # nodes running configuration. If the value is not provided in the opts
324
+ # Hash then the snmp source interface is negated using the no keyword.
325
+ # If the deafult keyword is set to true, then the snmp source interface
326
+ # value is defaulted using the default keyword. The deafult keyword
327
+ # takes precedence over the value keyword.
328
+ #
329
+ # @eos_version 4.13.7M
330
+ #
331
+ # @commands
332
+ # snmp-server source-interface <value>
333
+ # no snmp-server source-interface
334
+ # default snmp-server source-interface
335
+ #
336
+ # @param [Hash] opts The configuration parameters
337
+ #
338
+ # @option opts [string] :value The snmp source interface value to
339
+ # configure. This method will not ensure the interface is present
340
+ # in the configuration
341
+ # @option opts [Boolean] :default Configures the snmp source interface
342
+ # value using the default keyword
343
+ #
344
+ # @return [Boolean] returns true if the command completed successfully
345
+ def set_source_interface(opts = {})
346
+ value = opts[:value]
347
+ default = opts[:default] || false
348
+
349
+ case default
350
+ when true
351
+ cmds = ['default snmp-server source-interface']
352
+ when false
353
+ cmds = (value.nil? ? "no snmp-server source-interface" : \
354
+ "snmp-server source-interface #{value}")
355
+ end
356
+ configure(cmds)
357
+ end
358
+
359
+ ##
360
+ # add_community adds a new snmp community to the nodes running
361
+ # configuration. This function is a convenience function that passes the
362
+ # message to set_community_access.
363
+ #
364
+ # @see set_community_access
365
+ #
366
+ # @param [String] :name The name of the snmp community to add to the
367
+ # nodes running configuration.
368
+ #
369
+ # @param [String] :access Specifies the access level to assign to the
370
+ # new snmp community. Valid values are 'rw' or 'ro'
371
+ #
372
+ # @return [Boolean] returns true if the command completed successfully
373
+ def add_community(name, access = 'ro')
374
+ set_community_access(name, access)
375
+ end
376
+
377
+ ##
378
+ # remove_community removes the specified community from the nodes running
379
+ # configuration. If the specified name is not configured, this method
380
+ # will still return successfully.
381
+ #
382
+ # @eos_version 4.13.7M
383
+ #
384
+ # @commands
385
+ # no snmp-server community <name>
386
+ #
387
+ # @param [String] :name The name of the snmp community to add to the
388
+ # nodes running configuration.
389
+ #
390
+ # @return [Boolean] returns true if the command completed successfully
391
+ def remove_community(name)
392
+ configure "no snmp-server community #{name}"
393
+ end
394
+
395
+ ##
396
+ # set_community_acl configures the acl to apply to the specified
397
+ # community name. If the value option is not specified, the acl is
398
+ # removed from the community name
399
+ #
400
+ # @eos_version 4.13.7M
401
+ #
402
+ # @commands
403
+ # no snmp-server <name> [ro|rw] <value>
404
+ # snmp-server <name> [ro|rw] <value>
405
+ #
406
+ # @param [String] :name The name of the snmp community to add to the
407
+ # nodes running configuration.
408
+ #
409
+ # @option [String] :value The name of the acl to apply to the snmp
410
+ # community in the nodes config
411
+ #
412
+ # @return [Boolean] returns true if the command completed successfully
413
+ def set_community_acl(name, opts = {})
414
+ value = opts[:value]
415
+ communities = parse_communities[:communities]
416
+ access = communities[name][:access] if communities.include?(name)
417
+ cmds = ["no snmp-server community #{name}",
418
+ "snmp-server community #{name} #{access} #{value}"]
419
+ configure cmds
420
+ end
421
+
422
+ def set_community_access(name, access)
423
+ configure "snmp-server community #{name} #{access}"
424
+ end
425
+ end
426
+ end
427
+ end