rbeapi 0.2.0 → 0.3.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 (57) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +4 -0
  4. data/README.md +9 -9
  5. data/Rakefile +20 -0
  6. data/lib/rbeapi/api/bgp.rb +770 -0
  7. data/lib/rbeapi/api/dns.rb +32 -31
  8. data/lib/rbeapi/api/interfaces.rb +106 -87
  9. data/lib/rbeapi/api/ipinterfaces.rb +27 -42
  10. data/lib/rbeapi/api/logging.rb +9 -19
  11. data/lib/rbeapi/api/mlag.rb +60 -90
  12. data/lib/rbeapi/api/ntp.rb +12 -17
  13. data/lib/rbeapi/api/ospf.rb +9 -26
  14. data/lib/rbeapi/api/radius.rb +29 -43
  15. data/lib/rbeapi/api/snmp.rb +54 -83
  16. data/lib/rbeapi/api/staticroutes.rb +68 -21
  17. data/lib/rbeapi/api/stp.rb +41 -49
  18. data/lib/rbeapi/api/switchports.rb +41 -68
  19. data/lib/rbeapi/api/system.rb +6 -12
  20. data/lib/rbeapi/api/tacacs.rb +12 -21
  21. data/lib/rbeapi/api/varp.rb +25 -26
  22. data/lib/rbeapi/api/vlans.rb +19 -28
  23. data/lib/rbeapi/api.rb +30 -21
  24. data/lib/rbeapi/client.rb +3 -1
  25. data/lib/rbeapi/version.rb +1 -1
  26. data/rbeapi.spec.tmpl +4 -0
  27. data/spec/spec_helper.rb +8 -0
  28. data/spec/system/api_ospf_interfaces_spec.rb +16 -0
  29. data/spec/system/api_ospf_spec.rb +14 -0
  30. data/spec/system/api_varp_interfaces_spec.rb +16 -0
  31. data/spec/system/rbeapi/api/dns_spec.rb +66 -0
  32. data/spec/system/rbeapi/api/interfaces_base_spec.rb +4 -4
  33. data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +6 -6
  34. data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +6 -6
  35. data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +4 -4
  36. data/spec/system/rbeapi/api/ipinterfaces_spec.rb +44 -0
  37. data/spec/system/rbeapi/api/logging_spec.rb +18 -2
  38. data/spec/system/rbeapi/api/mlag_spec.rb +94 -2
  39. data/spec/system/rbeapi/api/ntp_spec.rb +14 -0
  40. data/spec/system/rbeapi/api/snmp_spec.rb +105 -0
  41. data/spec/system/rbeapi/api/stp_interfaces_spec.rb +43 -6
  42. data/spec/system/rbeapi/api/stp_spec.rb +18 -6
  43. data/spec/system/rbeapi/api/switchports_spec.rb +75 -3
  44. data/spec/system/rbeapi/api/system_spec.rb +16 -0
  45. data/spec/system/rbeapi/api/vlans_spec.rb +28 -0
  46. data/spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb +289 -0
  47. data/spec/unit/rbeapi/api/bgp/bgp_spec.rb +192 -0
  48. data/spec/unit/rbeapi/api/bgp/fixture_bgp.text +101 -0
  49. data/spec/unit/rbeapi/api/interfaces/base_spec.rb +7 -13
  50. data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +3 -3
  51. data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +11 -16
  52. data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +15 -21
  53. data/spec/unit/rbeapi/api/mlag/default_spec.rb +13 -19
  54. data/spec/unit/rbeapi/api/staticroutes/default_spec.rb +138 -0
  55. data/spec/unit/rbeapi/api/staticroutes/fixture_staticroutes.text +5 -0
  56. data/spec/unit/rbeapi/api/vlans/default_spec.rb +4 -4
  57. metadata +15 -4
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2014, Arista Networks, Inc.
2
+ # Copyright (c) 2014,2015, Arista Networks, Inc.
3
3
  # All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without
@@ -98,7 +98,7 @@ module Rbeapi
98
98
  ##
99
99
  # parse_name scans the provided configuration block and parses the
100
100
  # vlan name value. The vlan name should always return a value
101
- # from the running conifguration. The return value is intended to
101
+ # from the running configuration. The return value is intended to
102
102
  # be merged into the resource hash
103
103
  #
104
104
  # @api private
@@ -129,7 +129,7 @@ module Rbeapi
129
129
  # parse_trunk_groups scans the provided configuration block and parses
130
130
  # the trunk groups. If no trunk groups are found in the nodes
131
131
  # running configuration then an empty array is returned as the value.
132
- # The return hash is intedned to be merged into the resource hash.
132
+ # The return hash is intended to be merged into the resource hash.
133
133
  #
134
134
  # @api private
135
135
  #
@@ -199,11 +199,11 @@ module Rbeapi
199
199
 
200
200
  ##
201
201
  # set_name configures the name value for the specified vlan id in the
202
- # nodes running configuration. If the value is not provided in the
202
+ # nodes running configuration. If enable is false in the
203
203
  # opts keyword Hash then the name value is negated using the no
204
204
  # keyword. If the default keyword is set to true, then the name value
205
205
  # is defaulted using the default keyword. The default keyword takes
206
- # precedence over the value keyword
206
+ # precedence over the enable keyword
207
207
  #
208
208
  # @eos_version 4.13.7M
209
209
  #
@@ -211,7 +211,7 @@ module Rbeapi
211
211
  # vlan <id>
212
212
  # name <value>
213
213
  # no name
214
- # defaul name
214
+ # default name
215
215
  #
216
216
  # @param [String, Integer] :id The vlan id to apply the configuration
217
217
  # to. The id value should be in the valid range of 1 to 4094
@@ -222,31 +222,26 @@ module Rbeapi
222
222
  # to in the node configuration. The name parameter accepts a-z, 0-9
223
223
  # and _.
224
224
  #
225
+ # @option :opts [Boolean] :enable If false then the command is
226
+ # negated. Default is true.
227
+ #
225
228
  # @option :opts [Boolean] :default Configure the vlan name value using
226
229
  # the default keyword
227
230
  #
228
231
  # @return [Boolean] returns true if the command completed successfully
229
232
  def set_name(id, opts = {})
230
- value = opts[:value]
231
- default = opts[:default] || false
232
-
233
- cmds = ["vlan #{id}"]
234
- case default
235
- when true
236
- cmds << 'default name'
237
- when false
238
- cmds << (value.nil? ? 'no name' : "name #{value}")
239
- end
233
+ cmd = command_builder('name', opts)
234
+ cmds = ["vlan #{id}", cmd]
240
235
  configure(cmds)
241
236
  end
242
237
 
243
238
  ##
244
239
  # set_state configures the state value for the specified vlan id in
245
- # the nodes running configuration. If the value is not provided in
240
+ # the nodes running configuration. If enable is set to false in
246
241
  # the opts keyword Hash then the state value is negated using the no
247
242
  # keyword. If the default keyword is set to true, then the state
248
243
  # value is defaulted using the default keyword. The default keyword
249
- # takes precedence over the value keyword
244
+ # takes precedence over the enable keyword
250
245
  #
251
246
  # @eos_version 4.13.7M
252
247
  #
@@ -265,7 +260,10 @@ module Rbeapi
265
260
  # to in the node's configuration. Accepted values are 'active' or
266
261
  # 'suspend'
267
262
  #
268
- # @option :opts [Boolean] :deafult Configure the vlan state value using
263
+ # @option :opts [Boolean] :enable If false then the command is
264
+ # negated. Default is true.
265
+ #
266
+ # @option :opts [Boolean] :default Configure the vlan state value using
269
267
  # the default keyword
270
268
  #
271
269
  # @return [Boolean] returns true if the command completed successfully
@@ -274,19 +272,12 @@ module Rbeapi
274
272
  # values
275
273
  def set_state(id, opts = {})
276
274
  value = opts[:value]
277
- default = opts[:default] || false
278
-
279
275
  unless ['active', 'suspend', nil].include?(value)
280
276
  fail ArgumentError, 'state must be active, suspend or nil'
281
277
  end
282
278
 
283
- cmds = ["vlan #{id}"]
284
- case default
285
- when true
286
- cmds << 'default state'
287
- when false
288
- cmds << (value.nil? ? 'no state' : "state #{value}")
289
- end
279
+ cmd = command_builder('state', opts)
280
+ cmds = ["vlan #{id}", cmd]
290
281
  configure(cmds)
291
282
  end
292
283
 
data/lib/rbeapi/api.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2014, Arista Networks, Inc.
2
+ # Copyright (c) 2014,2015, Arista Networks, Inc.
3
3
  # All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without
@@ -39,7 +39,7 @@ module Rbeapi
39
39
  module Api
40
40
  ##
41
41
  # The Entity class provides a base class implementation for building
42
- # API modules. The Entity class is typcially not instantiated directly
42
+ # API modules. The Entity class is typically not instantiated directly
43
43
  # but serves as a super class with convenience methods used to
44
44
  # work with the node.
45
45
  class Entity
@@ -58,7 +58,7 @@ module Rbeapi
58
58
 
59
59
  ##
60
60
  # The Entity class provides a base class implementation for building
61
- # API modules. The Entity class is typcially not instantiated directly
61
+ # API modules. The Entity class is typically not instantiated directly
62
62
  # but serves as a super class with convenience methods used to
63
63
  # work with the node.
64
64
  #
@@ -84,7 +84,7 @@ module Rbeapi
84
84
  # one exists) of the node's connection instance
85
85
  #
86
86
  # @return [Rbeapi::Eapilib::CommandError] An instance of CommandError
87
- # that can be used to futher evaluate the root cause of an error
87
+ # that can be used to further evaluate the root cause of an error
88
88
  def error
89
89
  @node.connection.error
90
90
  end
@@ -133,29 +133,38 @@ module Rbeapi
133
133
  end
134
134
 
135
135
  ##
136
- # command_builder builds the correct version of a command based on the
137
- # configuration options. If the value option is not provided then the
138
- # no keyword is used to build the command. If the default value is
139
- # provided and set to true, then the default keyword is used. If both
140
- # options are provided, then the default option will take precedence.
136
+ # Method called to build the correct version of a command based on
137
+ # the modifier options. If value option is set then it is appended
138
+ # to the command. If the enable option is false then the 'no'
139
+ # keyword is prefixed to the command. If the default value is
140
+ # provided and set to true, then the default keyword is used. If
141
+ # both options are provided, then default option takes precedence.
141
142
  #
142
- # @return [String]
143
+ # @param [String, Array] :commands The commands to send to the node
144
+ # over the API connection to configure the system
145
+ # @param [Hash] :opts the options for the command
146
+ #
147
+ # @option :opts [String] :value Optional value that is
148
+ # appended to the command if set.
149
+ #
150
+ # @option :opts [Boolean] :enable Prefix the command with 'no'.
151
+ # Default is true.
152
+ #
153
+ # @option :opts [Boolean] :default Configure the command using
154
+ # the default keyword. Default is false.
155
+ #
156
+ # @return [String] Returns built command string
143
157
  def command_builder(cmd, opts = {})
144
- value = opts[:value]
158
+ enable = opts.fetch(:enable, true)
145
159
  default = opts.fetch(:default, false)
146
- case default
147
- when true then "default #{cmd}"
148
- when false
149
- case value
150
- when nil, false then "no #{cmd}"
151
- when true then cmd
152
- else "#{cmd} #{value}"
153
- end
154
- end
160
+ cmd << " #{opts[:value]}" if opts[:value]
161
+ return "default #{cmd}" if default
162
+ return "no #{cmd}" unless enable
163
+ cmd
155
164
  end
156
165
 
157
166
  ##
158
- # configure_interface sends the commands over eAPI to the desitnation
167
+ # configure_interface sends the commands over eAPI to the destination
159
168
  # node to configure a specific interface.
160
169
  #
161
170
  # @param [String] :name The interface name to apply the configuration
data/lib/rbeapi/client.rb CHANGED
@@ -156,7 +156,7 @@ module Rbeapi
156
156
  # The Config class holds the loaded configuration file data. It is a
157
157
  # subclass of IniFile.
158
158
  class Config < IniFile
159
- CONFIG_SEARCH_PATH = ['~/.eapi.conf', '/mnt/flash/eapi.conf']
159
+ CONFIG_SEARCH_PATH = ['/mnt/flash/eapi.conf']
160
160
 
161
161
  ##
162
162
  # The Config class will automatically search for a filename to load
@@ -182,6 +182,8 @@ module Rbeapi
182
182
  # search path
183
183
  def autoload(opts = {})
184
184
  search_path = CONFIG_SEARCH_PATH.dup
185
+ # Add the home directory path if the HOME environement var is defined.
186
+ search_path.insert(0, '~/.eapi.conf') if ENV.key?('HOME')
185
187
  search_path.insert(0, ENV['EAPI_CONF']) if ENV.key?('EAPI_CONF')
186
188
 
187
189
  path = opts[:filename] || search_path
@@ -33,5 +33,5 @@
33
33
  # #
34
34
  # Rbeapi toplevel namespace
35
35
  module Rbeapi
36
- VERSION = '0.2.0'
36
+ VERSION = '0.3.0'
37
37
  end
data/rbeapi.spec.tmpl CHANGED
@@ -18,12 +18,16 @@ Requires: pe-rubygems
18
18
  Requires: pe-ruby
19
19
  Requires: pe-rubygem(net-http-unix)
20
20
  Requires: pe-rubygem(inifile)
21
+ Requires: pe-rubygem(netaddr)
21
22
  Provides: pe-rubygem(%{gem_name}) = %{version}
22
23
  Provides: pe-rubygem-%{gem_name} = %{version}
23
24
  %else
24
25
  # Use these settings for all other installs
25
26
  %global gem gem
26
27
  Requires: ruby(abi) = %{rubyabi}
28
+ Requires: ruby(net-http-unix)
29
+ Requires: ruby(inifile)
30
+ Requires: ruby(netaddr)
27
31
  Provides: ruby(%{gem_name}) = %{version}-%{release}
28
32
  %endif
29
33
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'simplecov'
4
+ require 'simplecov-json'
5
+ require 'simplecov-rcov'
6
+ SimpleCov.formatters = [
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ SimpleCov::Formatter::JSONFormatter,
9
+ SimpleCov::Formatter::RcovFormatter
10
+ ]
11
+
4
12
  SimpleCov.start do
5
13
  add_filter '/spec/'
6
14
  add_filter '/.bundle/'
@@ -57,5 +57,21 @@ describe Rbeapi::Api::OspfInterfaces do
57
57
  .to be_truthy
58
58
  expect(subject.get('Ethernet1')['network_type']).to eq('point-to-point')
59
59
  end
60
+
61
+ it 'negates the ospf interface type' do
62
+ expect(subject.set_network_type('Ethernet1', value: 'point-to-point'))
63
+ .to be_truthy
64
+ expect(subject.get('Ethernet1')['network_type']).to eq('point-to-point')
65
+ expect(subject.set_network_type('Ethernet1', enable: false)).to be_truthy
66
+ expect(subject.get('Ethernet1')['network_type']).to eq('broadcast')
67
+ end
68
+
69
+ it 'defaults the ospf interface type' do
70
+ expect(subject.set_network_type('Ethernet1', value: 'point-to-point'))
71
+ .to be_truthy
72
+ expect(subject.get('Ethernet1')['network_type']).to eq('point-to-point')
73
+ expect(subject.set_network_type('Ethernet1', default: true)).to be_truthy
74
+ expect(subject.get('Ethernet1')['network_type']).to eq('broadcast')
75
+ end
60
76
  end
61
77
  end
@@ -53,6 +53,20 @@ describe Rbeapi::Api::Ospf do
53
53
  expect(subject.set_router_id('1', value: '1.1.1.1')).to be_truthy
54
54
  expect(subject.get('1')['router_id']).to eq('1.1.1.1')
55
55
  end
56
+
57
+ it 'negates the router id' do
58
+ expect(subject.set_router_id('1', value: '1.1.1.1')).to be_truthy
59
+ expect(subject.get('1')['router_id']).to eq('1.1.1.1')
60
+ expect(subject.set_router_id('1', enable: false)).to be_truthy
61
+ expect(subject.get('1')['router_id']).to be_empty
62
+ end
63
+
64
+ it 'defaults the router id' do
65
+ expect(subject.set_router_id('1', value: '1.1.1.1')).to be_truthy
66
+ expect(subject.get('1')['router_id']).to eq('1.1.1.1')
67
+ expect(subject.set_router_id('1', default: true)).to be_truthy
68
+ expect(subject.get('1')['router_id']).to be_empty
69
+ end
56
70
  end
57
71
 
58
72
  describe '#create' do
@@ -65,5 +65,21 @@ describe Rbeapi::Api::VarpInterfaces do
65
65
  .to be_truthy
66
66
  expect(subject.get('Vlan100')['addresses']).not_to include('99.99.99.98')
67
67
  end
68
+
69
+ it 'negate the list of addresses' do
70
+ expect(subject.set_addresses('Vlan100', value: ['99.99.99.98']))
71
+ .to be_truthy
72
+ expect(subject.get('Vlan100')['addresses']).to include('99.99.99.98')
73
+ expect(subject.set_addresses('Vlan100', enable: false)).to be_truthy
74
+ expect(subject.get('Vlan100')['addresses']).to be_empty
75
+ end
76
+
77
+ it 'default the list of addresses' do
78
+ expect(subject.set_addresses('Vlan100', value: ['99.99.99.98']))
79
+ .to be_truthy
80
+ expect(subject.get('Vlan100')['addresses']).to include('99.99.99.98')
81
+ expect(subject.set_addresses('Vlan100', default: true)).to be_truthy
82
+ expect(subject.get('Vlan100')['addresses']).to be_empty
83
+ end
68
84
  end
69
85
  end
@@ -27,6 +27,44 @@ describe Rbeapi::Api::Dns do
27
27
  expect(subject.set_domain_name(value: 'arista.com')).to be_truthy
28
28
  expect(subject.get[:domain_name]).to eq('arista.com')
29
29
  end
30
+
31
+ it 'negates the domain name' do
32
+ expect(subject.set_domain_name(value: 'arista.com')).to be_truthy
33
+ expect(subject.get[:domain_name]).to eq('arista.com')
34
+ expect(subject.set_domain_name(enable: false)).to be_truthy
35
+ expect(subject.get[:domain_name]).to be_empty
36
+ end
37
+
38
+ it 'defaults the domain name' do
39
+ expect(subject.set_domain_name(value: 'arista.com')).to be_truthy
40
+ expect(subject.get[:domain_name]).to eq('arista.com')
41
+ expect(subject.set_domain_name(default: true)).to be_truthy
42
+ expect(subject.get[:domain_name]).to be_empty
43
+ end
44
+ end
45
+
46
+ describe '#set_name_servers' do
47
+ let(:servers) { %w(1.2.3.4 5.6.7.8 9.10.11.12) }
48
+
49
+ before { node.config('no ip name-server') }
50
+
51
+ it 'add all the servers to the name servers list' do
52
+ expect(subject.get[:name_servers]).to be_empty
53
+ expect(subject.set_name_servers(value: servers)).to be_truthy
54
+ expect(subject.get[:name_servers]).to eq(servers)
55
+ end
56
+
57
+ it 'negate the name servers list' do
58
+ expect(subject.get[:name_servers]).to be_empty
59
+ expect(subject.set_name_servers(enable: false)).to be_truthy
60
+ expect(subject.get[:name_servers]).to be_empty
61
+ end
62
+
63
+ it 'default the name servers list' do
64
+ expect(subject.get[:name_servers]).to be_empty
65
+ expect(subject.set_name_servers(default: true)).to be_truthy
66
+ expect(subject.get[:name_servers]).to be_empty
67
+ end
30
68
  end
31
69
 
32
70
  describe '#add_name_server' do
@@ -55,6 +93,34 @@ describe Rbeapi::Api::Dns do
55
93
  end
56
94
  end
57
95
 
96
+ describe '#set_domain_list' do
97
+ let(:servers) { %w(foo bar baz) }
98
+
99
+ before do
100
+ node.config(['no ip domain-list foo',
101
+ 'no ip domain-list bar',
102
+ 'no ip domain-list baz'])
103
+ end
104
+
105
+ it 'add all the servers to the name servers list' do
106
+ expect(subject.get[:domain_list]).to be_empty
107
+ expect(subject.set_domain_list(value: servers)).to be_truthy
108
+ expect(subject.get[:domain_list]).to eq(servers)
109
+ end
110
+
111
+ it 'negate the name servers list' do
112
+ expect(subject.get[:domain_list]).to be_empty
113
+ expect(subject.set_domain_list(enable: false)).to be_truthy
114
+ expect(subject.get[:domain_list]).to be_empty
115
+ end
116
+
117
+ it 'default the name servers list' do
118
+ expect(subject.get[:domain_list]).to be_empty
119
+ expect(subject.set_domain_list(default: true)).to be_truthy
120
+ expect(subject.get[:domain_list]).to be_empty
121
+ end
122
+ end
123
+
58
124
  describe '#add_domain_list' do
59
125
  before { node.config(['no ip domain-list arista.net']) }
60
126
 
@@ -76,17 +76,17 @@ describe Rbeapi::Api::Interfaces do
76
76
  end
77
77
 
78
78
  describe '#set_shutdown' do
79
- it 'sets the shutdown value to true' do
79
+ it 'shutdown the interface' do
80
80
  node.config(['interface Loopback0', 'no shutdown'])
81
81
  expect(subject.get('Loopback0')[:shutdown]).to be_falsy
82
- expect(subject.set_shutdown('Loopback0', value: true)).to be_truthy
82
+ expect(subject.set_shutdown('Loopback0', enable: false)).to be_truthy
83
83
  expect(subject.get('Loopback0')[:shutdown]).to be_truthy
84
84
  end
85
85
 
86
- it 'sets the shutdown value to false' do
86
+ it 'enable the interface' do
87
87
  node.config(['interface Loopback0', 'shutdown'])
88
88
  expect(subject.get('Loopback0')[:shutdown]).to be_truthy
89
- expect(subject.set_shutdown('Loopback0', value: false)).to be_truthy
89
+ expect(subject.set_shutdown('Loopback0', enable: true)).to be_truthy
90
90
  expect(subject.get('Loopback0')[:shutdown]).to be_falsy
91
91
  end
92
92
  end
@@ -70,17 +70,17 @@ describe Rbeapi::Api::Interfaces do
70
70
  end
71
71
 
72
72
  describe '#set_shutdown' do
73
- it 'sets the shutdown value to true' do
73
+ it 'shutdown the interface' do
74
74
  node.config(['interface Ethernet1', 'no shutdown'])
75
75
  expect(subject.get('Ethernet1')[:shutdown]).to be_falsy
76
- expect(subject.set_shutdown('Ethernet1', value: true)).to be_truthy
76
+ expect(subject.set_shutdown('Ethernet1', enable: false)).to be_truthy
77
77
  expect(subject.get('Ethernet1')[:shutdown]).to be_truthy
78
78
  end
79
79
 
80
- it 'sets the shutdown value to false' do
80
+ it 'enable the interface' do
81
81
  node.config(['interface Ethernet1', :shutdown])
82
82
  expect(subject.get('Ethernet1')[:shutdown]).to be_truthy
83
- expect(subject.set_shutdown('Ethernet1', value: false)).to be_truthy
83
+ expect(subject.set_shutdown('Ethernet1', enable: true)).to be_truthy
84
84
  expect(subject.get('Ethernet1')[:shutdown]).to be_falsy
85
85
  end
86
86
  end
@@ -89,14 +89,14 @@ describe Rbeapi::Api::Interfaces do
89
89
  it 'sets the sflow value to true' do
90
90
  node.config(['interface Ethernet1', 'no sflow enable'])
91
91
  expect(subject.get('Ethernet1')[:sflow]).to be_falsy
92
- expect(subject.set_sflow('Ethernet1', value: true)).to be_truthy
92
+ expect(subject.set_sflow('Ethernet1', enable: true)).to be_truthy
93
93
  expect(subject.get('Ethernet1')[:sflow]).to be_truthy
94
94
  end
95
95
 
96
96
  it 'sets the sflow value to false' do
97
97
  node.config(['interface Ethernet1', 'sflow enable'])
98
98
  expect(subject.get('Ethernet1')[:sflow]).to be_truthy
99
- expect(subject.set_sflow('Ethernet1', value: false)).to be_truthy
99
+ expect(subject.set_sflow('Ethernet1', enable: false)).to be_truthy
100
100
  expect(subject.get('Ethernet1')[:sflow]).to be_falsy
101
101
  end
102
102
  end
@@ -82,17 +82,17 @@ describe Rbeapi::Api::Interfaces do
82
82
  end
83
83
 
84
84
  describe '#set_shutdown' do
85
- it 'sets the shutdown value to true' do
85
+ it 'shutdown the interface' do
86
86
  node.config(['interface Port-Channel1', 'no shutdown'])
87
87
  expect(subject.get('Port-Channel1')[:shutdown]).to be_falsy
88
- expect(subject.set_shutdown('Port-Channel1', value: true)).to be_truthy
88
+ expect(subject.set_shutdown('Port-Channel1', enable: false)).to be_truthy
89
89
  expect(subject.get('Port-Channel1')[:shutdown]).to be_truthy
90
90
  end
91
91
 
92
- it 'sets the shutdown value to false' do
93
- node.config(['interface Port-Channel1', :shutdown])
92
+ it 'enable the interface' do
93
+ node.config(['interface Port-Channel1', 'shutdown'])
94
94
  expect(subject.get('Port-Channel1')[:shutdown]).to be_truthy
95
- expect(subject.set_shutdown('Port-Channel1', value: false)).to be_truthy
95
+ expect(subject.set_shutdown('Port-Channel1', enable: true)).to be_truthy
96
96
  expect(subject.get('Port-Channel1')[:shutdown]).to be_falsy
97
97
  end
98
98
  end
@@ -183,7 +183,7 @@ describe Rbeapi::Api::Interfaces do
183
183
  node.config(['interface Port-Channel1',
184
184
  'port-channel lacp fallback static'])
185
185
  expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('static')
186
- expect(subject.set_lacp_fallback('Port-Channel1', value: 'disabled'))
186
+ expect(subject.set_lacp_fallback('Port-Channel1', enable: false))
187
187
  .to be_truthy
188
188
  expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('disabled')
189
189
  end
@@ -77,17 +77,17 @@ describe Rbeapi::Api::Interfaces do
77
77
  end
78
78
 
79
79
  describe '#set_shutdown' do
80
- it 'sets the shutdown value to true' do
80
+ it 'shutdown the interface' do
81
81
  node.config(['interface Vxlan1', 'no shutdown'])
82
82
  expect(subject.get('Vxlan1')[:shutdown]).to be_falsy
83
- expect(subject.set_shutdown('Vxlan1', value: true)).to be_truthy
83
+ expect(subject.set_shutdown('Vxlan1', enable: false)).to be_truthy
84
84
  expect(subject.get('Vxlan1')[:shutdown]).to be_truthy
85
85
  end
86
86
 
87
- it 'sets the shutdown value to false' do
87
+ it 'enable the interface' do
88
88
  node.config(['interface Vxlan1', 'shutdown'])
89
89
  expect(subject.get('Vxlan1')[:shutdown]).to be_truthy
90
- expect(subject.set_shutdown('Vxlan1', value: false)).to be_truthy
90
+ expect(subject.set_shutdown('Vxlan1', enable: true)).to be_truthy
91
91
  expect(subject.get('Vxlan1')[:shutdown]).to be_falsy
92
92
  end
93
93
  end
@@ -76,6 +76,22 @@ describe Rbeapi::Api::Ipinterfaces do
76
76
  .to be_truthy
77
77
  expect(subject.get('Ethernet1')[:address]).to eq('77.99.99.99/24')
78
78
  end
79
+
80
+ it 'negates the address value' do
81
+ expect(subject.set_address('Ethernet1', value: '77.99.99.99/24'))
82
+ .to be_truthy
83
+ expect(subject.get('Ethernet1')[:address]).to eq('77.99.99.99/24')
84
+ expect(subject.set_address('Ethernet1', enable: false)).to be_truthy
85
+ expect(subject.get('Ethernet1')[:address]).to be_empty
86
+ end
87
+
88
+ it 'defaults the address value' do
89
+ expect(subject.set_address('Ethernet1', value: '77.99.99.99/24'))
90
+ .to be_truthy
91
+ expect(subject.get('Ethernet1')[:address]).to eq('77.99.99.99/24')
92
+ expect(subject.set_address('Ethernet1', default: true)).to be_truthy
93
+ expect(subject.get('Ethernet1')[:address]).to be_empty
94
+ end
79
95
  end
80
96
 
81
97
  describe '#set_mtu' do
@@ -89,6 +105,20 @@ describe Rbeapi::Api::Ipinterfaces do
89
105
  expect(subject.set_mtu('Ethernet1', value: '2000')).to be_truthy
90
106
  expect(subject.get('Ethernet1')[:mtu]).to eq('2000')
91
107
  end
108
+
109
+ it 'negates the mtu' do
110
+ expect(subject.set_mtu('Ethernet1', value: '2000')).to be_truthy
111
+ expect(subject.get('Ethernet1')[:mtu]).to eq('2000')
112
+ expect(subject.set_mtu('Ethernet1', enable: false)).to be_truthy
113
+ expect(subject.get('Ethernet1')[:mtu]).to eq('1500')
114
+ end
115
+
116
+ it 'defaults the mtu' do
117
+ expect(subject.set_mtu('Ethernet1', value: '2000')).to be_truthy
118
+ expect(subject.get('Ethernet1')[:mtu]).to eq('2000')
119
+ expect(subject.set_mtu('Ethernet1', default: true)).to be_truthy
120
+ expect(subject.get('Ethernet1')[:mtu]).to eq('1500')
121
+ end
92
122
  end
93
123
 
94
124
  describe '#set_helper_addresses' do
@@ -106,5 +136,19 @@ describe Rbeapi::Api::Ipinterfaces do
106
136
  expect(subject.get('Ethernet1')[:helper_addresses].sort)
107
137
  .to eq(helpers.sort)
108
138
  end
139
+
140
+ it 'negates the helper addresses on the interface' do
141
+ expect(subject.get('Ethernet1')[:helper_addresses]).to be_empty
142
+ expect(subject.set_helper_addresses('Ethernet1', enable: false))
143
+ .to be_truthy
144
+ expect(subject.get('Ethernet1')[:helper_addresses].sort).to be_empty
145
+ end
146
+
147
+ it 'default the helper addresses on the interface' do
148
+ expect(subject.get('Ethernet1')[:helper_addresses]).to be_empty
149
+ expect(subject.set_helper_addresses('Ethernet1', default: true))
150
+ .to be_truthy
151
+ expect(subject.get('Ethernet1')[:helper_addresses].sort).to be_empty
152
+ end
109
153
  end
110
154
  end
@@ -31,16 +31,32 @@ describe Rbeapi::Api::Logging do
31
31
  it 'configures global logging enabled' do
32
32
  node.config('no logging on')
33
33
  expect(subject.get[:enable]).to be_falsy
34
- expect(subject.set_enable(value: true)).to be_truthy
34
+ expect(subject.set_enable(enable: true)).to be_truthy
35
35
  expect(subject.get[:enable]).to be_truthy
36
36
  end
37
37
 
38
38
  it 'configures global logging disabled' do
39
39
  node.config('logging on')
40
40
  expect(subject.get[:enable]).to be_truthy
41
- expect(subject.set_enable(value: false)).to be_truthy
41
+ expect(subject.set_enable(enable: false)).to be_truthy
42
42
  expect(subject.get[:enable]).to be_falsy
43
43
  end
44
+
45
+ it 'defaults the global logging' do
46
+ # Default is on
47
+
48
+ # Validate the on case
49
+ node.config('logging on')
50
+ expect(subject.get[:enable]).to be_truthy
51
+ expect(subject.set_enable(default: true)).to be_truthy
52
+ expect(subject.get[:enable]).to be_truthy
53
+
54
+ # Validate the off case
55
+ node.config('no logging on')
56
+ expect(subject.get[:enable]).to be_falsy
57
+ expect(subject.set_enable(default: true)).to be_truthy
58
+ expect(subject.get[:enable]).to be_truthy
59
+ end
44
60
  end
45
61
 
46
62
  describe '#add_host' do