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,410 @@
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
+
35
+ module Rbeapi
36
+ ##
37
+ # Eos is module namesapce for working with the EOS command API
38
+ module Api
39
+
40
+ class Aaa < Entity
41
+
42
+ def get
43
+ response = {}
44
+ response[:groups] = groups.getall
45
+ response
46
+ end
47
+
48
+ def groups
49
+ return @groups if @groups
50
+ @groups = AaaGroups.new node
51
+ @groups
52
+ end
53
+ end
54
+
55
+
56
+ class AaaGroups < Entity
57
+
58
+
59
+ DEFAULT_RADIUS_AUTH_PORT = 1812
60
+ DEFAULT_RADIUS_ACCT_PORT = 1813
61
+
62
+
63
+ # Regular express that parses the radius servers from the aaa group
64
+ # server radius configuration block
65
+ RADIUS_GROUP_SERVER = /\s{3}server
66
+ [ ]([^\s]+)
67
+ [ ]auth-port[ ](\d+)
68
+ [ ]acct-port[ ](\d+)/x
69
+
70
+ # Regular expression that parse the tacacs servers from the aaa group
71
+ # server tacacs+ configuration block
72
+ TACACS_GROUP_SERVER = /\s{3}server
73
+ [ ]([^\s]+)
74
+ (?:[ ]vrf[ ](\w+))?
75
+ (?:[ ]port[ ](\d+))?/x
76
+
77
+
78
+ ##
79
+ # get returns the aaa server group resource hash that describes the
80
+ # current configuration for the specified server group name
81
+ #
82
+ # The resource hash returned contains the following:
83
+ # * type: (String) The server group type. Valid values are either
84
+ # 'tacacs' or 'radius'
85
+ # * servers: (Array) The set of servers associated with the group.
86
+ # Servers are returned as either IP address or host name
87
+ #
88
+ # @param [String] :name The server group name to return f:rom the nodes
89
+ # current running configuration. If the name is not configured a nil
90
+ # object is returned.
91
+ #
92
+ # @return [nil, Hash<Symbol, Object>] returns the resource hash for the
93
+ # specified name. If the name does not exist, a nil object is returned
94
+ def get(name)
95
+ block = get_block("aaa group server ([^\s]+) #{name}")
96
+ return nil unless block
97
+ response = {}
98
+ response.merge!(parse_type(block))
99
+ response.merge!(parse_servers(block, response[:type]))
100
+ response
101
+ end
102
+
103
+ def getall
104
+ cfg = config.scan(/aaa group server (?:radius|tacacs\+) (.+)$/)
105
+ cfg.each_with_object({}) do |name, hsh|
106
+ values = get(name.first)
107
+ hsh[name.first] = values if values
108
+ end
109
+ end
110
+
111
+ ##
112
+ # parse_type scans the specified configuration block and returns the
113
+ # server group type as either 'tacacs' or 'radius' The type value is
114
+ # expected to always be present in the config.
115
+ #
116
+ # @api private
117
+ #
118
+ # @param [String] :config The aaa server group block configuration for the
119
+ # group name to parse
120
+ #
121
+ # @return [Hash<Symbol, Object>] resource hash attribute
122
+ def parse_type(config)
123
+ value = config.scan(/aaa group server ([^\s]+)/).first
124
+ { type: value.first }
125
+ end
126
+ private :parse_type
127
+
128
+ ##
129
+ # parse_servers scans the specified configuraiton block and returns the
130
+ # list of servers configured for the group. If there are no servers
131
+ # configured for the group the servers value will return an empty array.
132
+ #
133
+ # @api private
134
+ #
135
+ # @see parse_radius_server
136
+ # @see parse_tacacs_server
137
+ #
138
+ # @param [String] :config The aaa server group block configuration for the
139
+ # group name to parse
140
+ #
141
+ # @param [String] :type The aaa server block type. Valid values are
142
+ # either radius or tacacs+.
143
+ #
144
+ # @return [Hash<Symbol, Object>] resource hash attribute
145
+ def parse_servers(config, type)
146
+ case type
147
+ when 'radius' then parse_radius_server(config)
148
+ when 'tacacs+' then parse_tacacs_server(config)
149
+ end
150
+ end
151
+ private :parse_servers
152
+
153
+ ##
154
+ # parse_radius_server scans the provide configuration block and returns
155
+ # the list of servers configured. The configuration block is expected to
156
+ # be a radius configuration block. If there are no servers configured
157
+ # for the group the servers value will return an empty array.
158
+ #
159
+ # @api private
160
+ #
161
+ # @param [String] :config The aaa server group block configuration for the
162
+ # group name to parse
163
+ #
164
+ #
165
+ # @return [Hash<Symbol, Object>] resource hash attribute
166
+ def parse_radius_server(config)
167
+ values = config.scan(RADIUS_GROUP_SERVER).map do |(name, auth, acct)|
168
+ {
169
+ name: name,
170
+ auth_port: auth || DEFAULT_RADIUS_AUTH_PORT,
171
+ acct_port: acct || DEFAULT_RADIUS_ACCT_PORT
172
+ }
173
+ end
174
+ { servers: values }
175
+ end
176
+ private :parse_radius_server
177
+
178
+ ##
179
+ # parse_tacacs_server scans the provide configuration block and returns
180
+ # the list of servers configured. The configuration block is expected to
181
+ # be a tacacs configuration block. If there are no servers configured
182
+ # for the group the servers value will return an empty array.
183
+ #
184
+ # @api private
185
+ #
186
+ # @param [String] :config The aaa server group block configuration for the
187
+ # group name to parse
188
+ #
189
+ #
190
+ # @return [Hash<Symbol, Object>] resource hash attribute
191
+ def parse_tacacs_server(config)
192
+ values = config.scan(TACACS_GROUP_SERVER).map do |(name, vrf, port)|
193
+ {
194
+ name: name,
195
+ vrf: vrf,
196
+ port: port
197
+ }
198
+ end
199
+ { servers: values }
200
+ end
201
+ private :parse_radius_server
202
+
203
+
204
+ ##
205
+ # find_type is a utility method to find the type of aaa server group for
206
+ # the specified name. This method will scan the current running
207
+ # configuration on the node and return the server group type as either
208
+ # 'radius' or 'tacacs+'. If the server group is not configured, then nil
209
+ # will be returned.
210
+ #
211
+ # @api private
212
+ #
213
+ # @param [String] :name The aaa server group name to find in the config
214
+ # and return the type value for
215
+ #
216
+ # @return [nil, String] returns either the type name as 'radius' or
217
+ # 'tacacs+' or nil if the server group is not configured.
218
+ def find_type(name)
219
+ mdata = /aaa group server ([^\s]+) #{name}/.match(config)
220
+ return mdata[1] if mdata
221
+ end
222
+ private :find_type
223
+
224
+ ##
225
+ # create adds a new aaa group server to the nodes current configuration.
226
+ # If the specified name and type are already created then this method
227
+ # will return successfully. If the name is configured but the type is
228
+ # different, this method will not return successfully (returns false).
229
+ #
230
+ # @eos_version 4.13.7M
231
+ #
232
+ # @commands
233
+ # aaa group server <type> <name>
234
+ #
235
+ # @param [String] :name The name of the aaa group server to create in the
236
+ # nodes running configuration
237
+ #
238
+ # @param [String] :type The type of aaa group server to create in the
239
+ # nodes running configuration. Valid values include 'radius' or
240
+ # 'tacacs+'
241
+ #
242
+ # @return [Boolean] returns true if the commands complete successfully
243
+ def create(name, type)
244
+ configure ["aaa group server #{type} #{name}", "exit"]
245
+ end
246
+
247
+ ##
248
+ # delete removes a current aaa server group from the nodes current
249
+ # configuration. This method will automatically determine the server
250
+ # group type based on the name. If the name is not configured in the
251
+ # nodes current configuration, this method will return successfully.
252
+ #
253
+ # @eos_version 4.13.7M
254
+ #
255
+ # @commands
256
+ # no aaa group server [radius | tacacs+] <name>
257
+ #
258
+ # @param [String] :name The name of the aaa group server to create in the
259
+ # nodes running configuration
260
+ #
261
+ # @return [Boolean] returns true if the commands complete successfully
262
+ def delete(name)
263
+ type = find_type(name)
264
+ return true unless type
265
+ configure "no aaa group server #{type} #{name}"
266
+ end
267
+
268
+ ##
269
+ # set_servers configures the set of servers for a specified aaa server
270
+ # group. This is an atomic operation that first removes all current
271
+ # servers and then adds the new servers back. If any of the servers
272
+ # failes to be removed or added, this method will return unsuccessfully.
273
+ #
274
+ # @see remove_server
275
+ # @see add_server
276
+ #
277
+ # @param [String] :name The name of the aaa group server to add the new
278
+ # server configuration to.
279
+ #
280
+ # @param [String] :server The IP address or host name of the server to
281
+ # add to the configuration
282
+ #
283
+ # @param [Hash] :opts Optional configuration parameters
284
+ #
285
+ # @return [Boolean] returns true if the commands complete successfully
286
+ def set_servers(name, servers)
287
+ current = get(name)
288
+ current[:servers].each do |srv|
289
+ return false unless remove_server(name, srv)
290
+ end
291
+ servers.each do |srv|
292
+ hostname = srv[:name]
293
+ return false unless add_server(name, hostname, srv)
294
+ end
295
+ return true
296
+ end
297
+
298
+ ##
299
+ # add_server adds a new server to the specified aaa server group. If
300
+ # the server is already configured in the list of servers, this method
301
+ # will still return successfully.
302
+ #
303
+ # @see add_radius_server
304
+ # @see add_tacacs_server
305
+ #
306
+ # @param [String] :name The name of the aaa group server to add the new
307
+ # server configuration to.
308
+ #
309
+ # @param [String] :server The IP address or host name of the server to
310
+ # add to the configuration
311
+ #
312
+ # @param [Hash] :opts Optional configuration parameters
313
+ #
314
+ # @return [Boolean] returns true if the commands complete successfully
315
+ def add_server(name, server, opts = {})
316
+ type = find_type(name)
317
+ return false unless type
318
+ case type
319
+ when 'radius' then add_radius_server(name, server, opts)
320
+ when 'tacacs+' then add_tacacs_server(name, server, opts)
321
+ else return false
322
+ end
323
+ end
324
+
325
+ ##
326
+ # add_radius_server adds a new radius server to the nodes current
327
+ # configuration. If the server already exists in the specified group
328
+ # name this method will still return successfully
329
+ #
330
+ # @eos_version 4.13.7M
331
+ #
332
+ # @commmands
333
+ # aaa group server radius <name>
334
+ # server <server> [acct-port <acct_port>] [auth-port <auth_port>]
335
+ # [vrf <vrf>]
336
+ #
337
+ # @param [String] :name The name of the aaa group server to add the new
338
+ # server configuration to.
339
+ #
340
+ # @param [String] :server The IP address or host name of the server to
341
+ # add to the configuration
342
+ #
343
+ # @param [Hash] :opts Optional configuration parameters
344
+ #
345
+ # @return [Boolean] returns true if the commands complete successfully
346
+ def add_radius_server(name, server, opts = {})
347
+ # order of command options matter here!
348
+ server = "server #{server} "
349
+ server << "auth-port #{opts[:auth_port]} " if opts[:auth_port]
350
+ server << "acct-port #{opts[:acct_port]} " if opts[:acct_port]
351
+ server << "vrf #{opts[:vrf]}" if opts[:vrf]
352
+ configure ["aaa group server radius #{name}", server, "exit"]
353
+ end
354
+
355
+
356
+ ##
357
+ # add_tacacs_server adds a new tacacs server to the nodes current
358
+ # configuration. If the server already exists in the specified group
359
+ # name this method will still return successfully
360
+ #
361
+ # @eos_version 4.13.7M
362
+ #
363
+ # @commmands
364
+ # aaa group server tacacs+ <name>
365
+ # server <server> [acct-port <acct_port>] [auth-port <auth_port>]
366
+ # [vrf <vrf>]
367
+ #
368
+ # @param [String] :name The name of the aaa group server to add the new
369
+ # server configuration to.
370
+ #
371
+ # @param [String] :server The IP address or host name of the server to
372
+ # add to the configuration
373
+ #
374
+ # @param [Hash] :opts Optional configuration parameters
375
+ #
376
+ # @return [Boolean] returns true if the commands complete successfully
377
+ def add_tacacs_server(name, server, opts = {})
378
+ # order of command options matter here!
379
+ server = "server #{server} "
380
+ server << "vrf #{opts[:vrf]} " if opts[:vrf]
381
+ server << "port #{opts[:port]} " if opts[:port]
382
+ configure ["aaa group server tacacs+ #{name}", server, "exit"]
383
+ end
384
+
385
+ ##
386
+ # remove_server deletes an existing server from the specified aaa server
387
+ # group. If the specified server is not configured in the specified
388
+ # server group, this method will still return true.
389
+ #
390
+ # @eos_version 4.13.7M
391
+ #
392
+ # @commands
393
+ # aaa group server [radius | tacacs+] <name>
394
+ # no server <server>
395
+ #
396
+ # @param [String] :name The name of the aaa group server to remove
397
+ #
398
+ # @param [String] :server The IP address or host name of the server
399
+ #
400
+ # @return [Boolean] returns true if the commands complete successfully
401
+ def remove_server(name, server, opts={})
402
+ type = find_type(name)
403
+ return false unless type
404
+ server = "no server #{server} "
405
+ server << "vrf #{opts[:vrf]}" if opts[:vrf]
406
+ configure ["aaa group server #{type} #{name}", server, "exit"]
407
+ end
408
+ end
409
+ end
410
+ end
@@ -0,0 +1,198 @@
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 Dns < Entity
39
+
40
+ ##
41
+ # Returns the DNS resource
42
+ #
43
+ # @example
44
+ # {
45
+ # "domain_name": <string>,
46
+ # "name_servers": array<strings>,
47
+ # "domain_list": array<strings>
48
+ # }
49
+ #
50
+ # @return [Hash] A Ruby hash objec that provides the SNMP settings as
51
+ # key / value pairs.
52
+ def get
53
+ response = {}
54
+ response.merge!(parse_domain_name)
55
+ response.merge!(parse_name_servers)
56
+ response.merge!(parse_domain_list)
57
+ response
58
+ end
59
+
60
+ def parse_domain_name
61
+ mdata = /ip domain-name ([\w.]+)/.match(config)
62
+ { domain_name: mdata.nil? ? '' : mdata[1] }
63
+ end
64
+
65
+ def parse_name_servers
66
+ servers = config.scan(/(?:ip name-server vrf )(?:\w+)\s(.+)/)
67
+ values = servers.each_with_object([]) { |srv, arry| arry << srv.first }
68
+ { name_servers: values }
69
+ end
70
+
71
+ def parse_domain_list
72
+ search = config.scan(/(?<=^ip\sdomain-list\s).+$/)
73
+ { domain_list: search }
74
+ end
75
+
76
+ ##
77
+ # Configure the domain-name value in the running-config
78
+ #
79
+ # @param [Hash] opts The configuration parameters
80
+ # @option opts [string] :value The value to set the domain-name to
81
+ # @option opts [Boolean] :default The value should be set to default
82
+ #
83
+ # @return [Boolean] returns true if the command completed successfully
84
+ def set_domain_name(opts = {})
85
+ value = opts[:value]
86
+ default = opts[:default] || false
87
+
88
+ case default
89
+ when true
90
+ cmds = 'default ip domain-name'
91
+ when false
92
+ cmds = (value ? "ip domain-name #{value}" : 'no ip domain-name')
93
+ end
94
+ configure(cmds)
95
+ end
96
+
97
+ ##
98
+ # set_name_servers configures the set of name servers that eos will use
99
+ # to resolve dns queries. If the value option is not provided, the
100
+ # name-server list will be configured using the no keyword. If the
101
+ # default option is specified, then the name server list will be
102
+ # configured using the default keyword. If both options are provided the
103
+ # keyword option will take precedence
104
+ #
105
+ # @eos_version 4.13.7M
106
+ #
107
+ # @commands
108
+ # ip name-server <value>
109
+ # no ip name-server
110
+ # default ip name-server
111
+ #
112
+ # @option [Array] :value The set of name servers to configure on the
113
+ # node. The list of name servers will be replace in the nodes running
114
+ # configuration by the list provided in value
115
+ #
116
+ # @option [Boolean] :default Configures the ip name-servers using the
117
+ # default keyword argument
118
+ #
119
+ # @return [Boolean] returns true if the commands completed successfuly
120
+ def set_name_servers(opts = {})
121
+ value = opts[:value] || []
122
+ default = opts[:default] || false
123
+
124
+ case default
125
+ when true
126
+ cmds = 'default ip name-server'
127
+ when false
128
+ cmds = []
129
+ parse_name_servers[:name_servers].each do |srv|
130
+ cmds << "no ip name-server #{srv}"
131
+ end
132
+ value.each do |srv|
133
+ cmds << "ip name-server #{srv}"
134
+ end
135
+ end
136
+ configure cmds
137
+ end
138
+
139
+ def add_name_server(server)
140
+ configure "ip name-server #{server}"
141
+ end
142
+
143
+ def remove_name_server(server)
144
+ configure "no ip name-server #{server}"
145
+ end
146
+
147
+ ##
148
+ # set_domain_list configures the set of domain names to search when
149
+ # making dns queries for the FQDN. If the value option is not provided,
150
+ # the domain-list will be configured using the no keyword. If the
151
+ # default option is specified, then the domain list will be configured
152
+ # using the default keyword. If both options are provided the default
153
+ # keyword option will take precedence.
154
+ #
155
+ # @eos_version 4.13.7M
156
+ #
157
+ # @commands
158
+ # ip domain-list <value>
159
+ # no ip domain-list
160
+ # default ip domain-list
161
+ #
162
+ # @option [Array] :value The set of domain names to configure on the
163
+ # node. The list of domain names will be replace in the nodes running
164
+ # configuration by the list provided in value
165
+ #
166
+ # @option [Boolean] :default Configures the ip domain-list using the
167
+ # default keyword argument
168
+ #
169
+ # @return [Boolean] returns true if the commands completed successfuly
170
+ def set_domain_list(opts = {})
171
+ value = opts[:value] || []
172
+ default = opts[:default] || false
173
+
174
+ case default
175
+ when true
176
+ cmds = 'default ip domain-list'
177
+ when false
178
+ cmds = []
179
+ parse_domain_list[:domain_list].each do |name|
180
+ cmds << "no ip domain-list #{name}"
181
+ end
182
+ value.each do |name|
183
+ cmds << "ip domain-list #{name}"
184
+ end
185
+ end
186
+ configure cmds
187
+ end
188
+
189
+ def add_domain_list(name)
190
+ configure "ip domain-list #{name}"
191
+ end
192
+
193
+ def remove_domain_list(name)
194
+ configure "no ip domain-list #{name}"
195
+ end
196
+ end
197
+ end
198
+ end