rbeapi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +35 -0
- data/Gemfile +25 -0
- data/Guardfile +15 -0
- data/LICENSE +28 -0
- data/README.md +218 -0
- data/Rakefile +12 -0
- data/lib/rbeapi.rb +32 -0
- data/lib/rbeapi/api.rb +135 -0
- data/lib/rbeapi/api/aaa.rb +410 -0
- data/lib/rbeapi/api/dns.rb +198 -0
- data/lib/rbeapi/api/interfaces.rb +1193 -0
- data/lib/rbeapi/api/ipinterfaces.rb +328 -0
- data/lib/rbeapi/api/logging.rb +157 -0
- data/lib/rbeapi/api/mlag.rb +519 -0
- data/lib/rbeapi/api/ntp.rb +201 -0
- data/lib/rbeapi/api/ospf.rb +214 -0
- data/lib/rbeapi/api/prefixlists.rb +98 -0
- data/lib/rbeapi/api/radius.rb +317 -0
- data/lib/rbeapi/api/radius.rb.old +399 -0
- data/lib/rbeapi/api/routemaps.rb +100 -0
- data/lib/rbeapi/api/snmp.rb +427 -0
- data/lib/rbeapi/api/staticroutes.rb +88 -0
- data/lib/rbeapi/api/stp.rb +381 -0
- data/lib/rbeapi/api/switchports.rb +272 -0
- data/lib/rbeapi/api/system.rb +87 -0
- data/lib/rbeapi/api/tacacs.rb +236 -0
- data/lib/rbeapi/api/varp.rb +181 -0
- data/lib/rbeapi/api/vlans.rb +338 -0
- data/lib/rbeapi/client.rb +454 -0
- data/lib/rbeapi/eapilib.rb +334 -0
- data/lib/rbeapi/netdev/snmp.rb +370 -0
- data/lib/rbeapi/utils.rb +70 -0
- data/lib/rbeapi/version.rb +37 -0
- data/rbeapi.gemspec +32 -0
- data/spec/fixtures/dut.conf +5 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/fixtures.rb +114 -0
- data/spec/support/shared_examples_for_api_modules.rb +124 -0
- data/spec/system/api_ospf_interfaces_spec.rb +58 -0
- data/spec/system/api_ospf_spec.rb +111 -0
- data/spec/system/api_varp_interfaces_spec.rb +60 -0
- data/spec/system/api_varp_spec.rb +44 -0
- data/spec/system/rbeapi/api/dns_spec.rb +77 -0
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +94 -0
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +135 -0
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +188 -0
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +115 -0
- data/spec/system/rbeapi/api/ipinterfaces_spec.rb +97 -0
- data/spec/system/rbeapi/api/logging_spec.rb +65 -0
- data/spec/system/rbeapi/api/mlag_interfaces_spec.rb +80 -0
- data/spec/system/rbeapi/api/mlag_spec.rb +94 -0
- data/spec/system/rbeapi/api/ntp_spec.rb +76 -0
- data/spec/system/rbeapi/api/snmp_spec.rb +68 -0
- data/spec/system/rbeapi/api/stp_instances_spec.rb +61 -0
- data/spec/system/rbeapi/api/stp_interfaces_spec.rb +71 -0
- data/spec/system/rbeapi/api/stp_spec.rb +57 -0
- data/spec/system/rbeapi/api/switchports_spec.rb +135 -0
- data/spec/system/rbeapi/api/system_spec.rb +38 -0
- data/spec/system/rbeapi/api/vlans_spec.rb +121 -0
- metadata +274 -0
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/interfaces'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Interfaces do
|
7
|
+
subject { described_class.new(node) }
|
8
|
+
|
9
|
+
|
10
|
+
let(:node) do
|
11
|
+
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
12
|
+
Rbeapi::Client.connect_to('dut')
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#get' do
|
16
|
+
|
17
|
+
let(:entity) do
|
18
|
+
{ name: 'Port-Channel1', type: 'portchannel', description: '',
|
19
|
+
shutdown: false, members: [], lacp_mode: 'on', minimum_links: '0',
|
20
|
+
lacp_timeout: '90', lacp_fallback: 'disabled' }
|
21
|
+
end
|
22
|
+
|
23
|
+
before { node.config(['no interface Port-Channel1', 'interface Port-Channel1']) }
|
24
|
+
|
25
|
+
it 'returns the interface resource' do
|
26
|
+
expect(subject.get('Port-Channel1')).to eq(entity)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#getall' do
|
31
|
+
before { node.config(['no interface Port-Channel1', 'interface Port-Channel1']) }
|
32
|
+
|
33
|
+
it 'returns the interface collection' do
|
34
|
+
expect(subject.getall).to include('Port-Channel1')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns a hash collection' do
|
38
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#create' do
|
43
|
+
before { node.config('no interface Port-Channel1') }
|
44
|
+
|
45
|
+
it 'creates a new interface resource' do
|
46
|
+
expect(subject.get('Port-Channel1')).to be_nil
|
47
|
+
expect(subject.create('Port-Channel1')).to be_truthy
|
48
|
+
expect(subject.get('Port-Channel1')).not_to be_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#delete' do
|
53
|
+
before { node.config(['interface Port-Channel1']) }
|
54
|
+
|
55
|
+
it 'deletes a switchport resource' do
|
56
|
+
expect(subject.get('Port-Channel1')).not_to be_nil
|
57
|
+
expect(subject.delete('Port-Channel1')).to be_truthy
|
58
|
+
expect(subject.get('Port-Channel1')).to be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#default' do
|
63
|
+
before { node.config(['interface Port-Channel1', :shutdown]) }
|
64
|
+
|
65
|
+
it 'sets Port-Channel1 to default' do
|
66
|
+
expect(subject.get('Port-Channel1')[:shutdown]).to be_truthy
|
67
|
+
expect(subject.default('Port-Channel1')).to be_truthy
|
68
|
+
expect(subject.get('Port-Channel1')[:shutdown]).to be_falsy
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#set_description' do
|
73
|
+
it 'sets the description value on the interface' do
|
74
|
+
node.config(['interface Port-Channel1', 'no description'])
|
75
|
+
expect(subject.get('Port-Channel1')[:description]).to be_empty
|
76
|
+
expect(subject.set_description('Port-Channel1', value: 'foo bar')).to be_truthy
|
77
|
+
expect(subject.get('Port-Channel1')[:description]).to eq('foo bar')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#set_shutdown' do
|
82
|
+
it 'sets the shutdown value to true' do
|
83
|
+
node.config(['interface Port-Channel1', 'no shutdown'])
|
84
|
+
expect(subject.get('Port-Channel1')[:shutdown]).to be_falsy
|
85
|
+
expect(subject.set_shutdown('Port-Channel1', value: true)).to be_truthy
|
86
|
+
expect(subject.get('Port-Channel1')[:shutdown]).to be_truthy
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'sets the shutdown value to false' do
|
90
|
+
node.config(['interface Port-Channel1', :shutdown])
|
91
|
+
expect(subject.get('Port-Channel1')[:shutdown]).to be_truthy
|
92
|
+
expect(subject.set_shutdown('Port-Channel1', value: false)).to be_truthy
|
93
|
+
expect(subject.get('Port-Channel1')[:shutdown]).to be_falsy
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#set_minimum_links' do
|
98
|
+
before { node.config(['interface Port-Channel1',
|
99
|
+
'port-channel min-links 0']) }
|
100
|
+
|
101
|
+
it 'sets the minimum links value on the interface' do
|
102
|
+
expect(subject.get('Port-Channel1')[:minimum_links]).to eq('0')
|
103
|
+
expect(subject.set_minimum_links('Port-Channel1', value: '2')).to be_truthy
|
104
|
+
expect(subject.get('Port-Channel1')[:minimum_links]).to eq('2')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#set_members' do
|
109
|
+
before { node.config(['no interface Port-Channel1',
|
110
|
+
'interface Port-Channel1']) }
|
111
|
+
|
112
|
+
it 'adds new members to the port-channel interface' do
|
113
|
+
node.config(['no interface Port-Channel1', 'interface Port-Channel1'])
|
114
|
+
expect(subject.get('Port-Channel1')[:members]).not_to include('Ethernet1')
|
115
|
+
expect(subject.set_members('Port-Channel1', ['Ethernet1'])).to be_truthy
|
116
|
+
expect(subject.get('Port-Channel1')[:members]).to eq(['Ethernet1'])
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'updates the member interfaces on existing interface' do
|
120
|
+
node.config(['no interface Port-Channel1', 'interface Ethernet1-2',
|
121
|
+
'channel-group 1 mode on'])
|
122
|
+
expect(subject.get('Port-Channel1')[:members]).to eq(['Ethernet1', 'Ethernet2'])
|
123
|
+
expect(subject.set_members('Port-Channel1', ['Ethernet1', 'Ethernet3'])).to be_truthy
|
124
|
+
expect(subject.get('Port-Channel1')[:members]).to eq(['Ethernet1', 'Ethernet3'])
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#set_lacp_mode' do
|
129
|
+
it 'sets the lacp mode on the port-channel to active' do
|
130
|
+
node.config(['no interface Port-Channel1', 'interface Ethernet1-3',
|
131
|
+
'channel-group 1 mode on'])
|
132
|
+
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('on')
|
133
|
+
expect(subject.set_lacp_mode('Port-Channel1', 'active')).to be_truthy
|
134
|
+
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('active')
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'sets the lacp mode on the port-channel to passive' do
|
138
|
+
node.config(['no interface Port-Channel1', 'interface Ethernet1-3',
|
139
|
+
'channel-group 1 mode on'])
|
140
|
+
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('on')
|
141
|
+
expect(subject.set_lacp_mode('Port-Channel1', 'passive')).to be_truthy
|
142
|
+
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('passive')
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'sets the lacp mode on the port-channel to on' do
|
146
|
+
node.config(['no interface Port-Channel1', 'interface Ethernet1-3',
|
147
|
+
'channel-group 1 mode active'])
|
148
|
+
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('active')
|
149
|
+
expect(subject.set_lacp_mode('Port-Channel1', 'on')).to be_truthy
|
150
|
+
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('on')
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#set_lacp_fallback' do
|
155
|
+
it 'sets the lacp fallback on the port-channel to static' do
|
156
|
+
node.config(['interface Port-Channel1', 'no port-channel lacp fallback'])
|
157
|
+
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('disabled')
|
158
|
+
expect(subject.set_lacp_fallback('Port-Channel1', value: 'static')).to be_truthy
|
159
|
+
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('static')
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'sets the lacp fallback on the port-channel to individual' do
|
163
|
+
node.config(['interface Port-Channel1', 'no port-channel lacp fallback'])
|
164
|
+
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('disabled')
|
165
|
+
expect(subject.set_lacp_fallback('Port-Channel1', value: 'individual')).to be_truthy
|
166
|
+
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('individual')
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'sets the lacp fallback on the port-channel to disabled' do
|
170
|
+
node.config(['interface Port-Channel1', 'port-channel lacp fallback static'])
|
171
|
+
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('static')
|
172
|
+
expect(subject.set_lacp_fallback('Port-Channel1', value: 'disabled')).to be_truthy
|
173
|
+
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('disabled')
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe '#set_lacp_timeout' do
|
178
|
+
before { node.config(['interface Port-Channel1',
|
179
|
+
'default port-channel lacp fallback timeout']) }
|
180
|
+
|
181
|
+
it 'sets the lacp fallback timeout value on the interface' do
|
182
|
+
expect(subject.get('Port-Channel1')[:lacp_timeout]).to eq('90')
|
183
|
+
expect(subject.set_lacp_timeout('Port-Channel1', value: '100')).to be_truthy
|
184
|
+
expect(subject.get('Port-Channel1')[:lacp_timeout]).to eq('100')
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/interfaces'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Interfaces do
|
7
|
+
subject { described_class.new(node) }
|
8
|
+
|
9
|
+
let(:node) do
|
10
|
+
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
11
|
+
Rbeapi::Client.connect_to('dut')
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#get' do
|
15
|
+
|
16
|
+
let(:entity) do
|
17
|
+
{ name: 'Vxlan1', type: 'vxlan', description: '', shutdown: false,
|
18
|
+
source_interface: '', multicast_group: ''}
|
19
|
+
end
|
20
|
+
|
21
|
+
before { node.config(['no interface Vxlan1', 'interface Vxlan1']) }
|
22
|
+
|
23
|
+
it 'returns the interface resource' do
|
24
|
+
expect(subject.get('Vxlan1')).to eq(entity)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#getall' do
|
29
|
+
before { node.config(['no interface Vxlan1', 'interface Vxlan1']) }
|
30
|
+
|
31
|
+
it 'returns the interface collection' do
|
32
|
+
expect(subject.getall).to include('Vxlan1')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a hash collection' do
|
36
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#create' do
|
41
|
+
before { node.config('no interface Vxlan1') }
|
42
|
+
|
43
|
+
it 'creates a new interface resource' do
|
44
|
+
expect(subject.get('Vxlan1')).to be_nil
|
45
|
+
expect(subject.create('Vxlan1')).to be_truthy
|
46
|
+
expect(subject.get('Vxlan1')).not_to be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#delete' do
|
51
|
+
before { node.config(['interface Vxlan1']) }
|
52
|
+
|
53
|
+
it 'deletes a vxlan interface resource' do
|
54
|
+
expect(subject.get('Vxlan1')).not_to be_nil
|
55
|
+
expect(subject.delete('Vxlan1')).to be_truthy
|
56
|
+
expect(subject.get('Vxlan1')).to be_nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#default' do
|
61
|
+
before { node.config(['interface Vxlan1', 'shutdown']) }
|
62
|
+
|
63
|
+
it 'sets Vxlan1 to default' do
|
64
|
+
expect(subject.get('Vxlan1')[:shutdown]).to be_truthy
|
65
|
+
expect(subject.default('Vxlan1')).to be_truthy
|
66
|
+
expect(subject.get('Vxlan1')[:shutdown]).to be_falsy
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#set_description' do
|
71
|
+
it 'sets the description value on the interface' do
|
72
|
+
node.config(['interface Vxlan1', 'no description'])
|
73
|
+
expect(subject.get('Vxlan1')[:description]).to be_empty
|
74
|
+
expect(subject.set_description('Vxlan1', value: 'foo bar')).to be_truthy
|
75
|
+
expect(subject.get('Vxlan1')[:description]).to eq('foo bar')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#set_shutdown' do
|
80
|
+
it 'sets the shutdown value to true' do
|
81
|
+
node.config(['interface Vxlan1', 'no shutdown'])
|
82
|
+
expect(subject.get('Vxlan1')[:shutdown]).to be_falsy
|
83
|
+
expect(subject.set_shutdown('Vxlan1', value: true)).to be_truthy
|
84
|
+
expect(subject.get('Vxlan1')[:shutdown]).to be_truthy
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'sets the shutdown value to false' do
|
88
|
+
node.config(['interface Vxlan1', 'shutdown'])
|
89
|
+
expect(subject.get('Vxlan1')[:shutdown]).to be_truthy
|
90
|
+
expect(subject.set_shutdown('Vxlan1', value: false)).to be_truthy
|
91
|
+
expect(subject.get('Vxlan1')[:shutdown]).to be_falsy
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#set_source_interface' do
|
96
|
+
before { node.config(['no interface Vxlan1', 'interface Vxlan1']) }
|
97
|
+
|
98
|
+
it 'sets the source interface value on the interface' do
|
99
|
+
expect(subject.get('Vxlan1')[:source_interface]).to be_empty
|
100
|
+
expect(subject.set_source_interface('Vxlan1', value: 'Loopback0')).to be_truthy
|
101
|
+
expect(subject.get('Vxlan1')[:source_interface]).to eq('Loopback0')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#set_multicast_group' do
|
106
|
+
before { node.config(['no interface Vxlan1', 'interface Vxlan1']) }
|
107
|
+
|
108
|
+
it 'sets the multicast group value on the interface' do
|
109
|
+
expect(subject.get('Vxlan1')[:multicast_group]).to be_empty
|
110
|
+
expect(subject.set_multicast_group('Vxlan1', value: '239.10.10.10')).to be_truthy
|
111
|
+
expect(subject.get('Vxlan1')[:multicast_group]).to eq('239.10.10.10')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/ipinterfaces'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Ipinterfaces do
|
7
|
+
subject { described_class.new(node) }
|
8
|
+
|
9
|
+
let(:node) do
|
10
|
+
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
11
|
+
Rbeapi::Client.connect_to('dut')
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#get' do
|
15
|
+
|
16
|
+
let(:entity) do
|
17
|
+
{ address: '99.99.99.99/24', mtu: '1500', helper_addresses: [] }
|
18
|
+
end
|
19
|
+
|
20
|
+
before { node.config(['default interface Ethernet1', 'interface Ethernet1',
|
21
|
+
'no switchport', 'ip address 99.99.99.99/24']) }
|
22
|
+
|
23
|
+
it 'returns the ipinterface resource' do
|
24
|
+
expect(subject.get('Ethernet1')).to eq(entity)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#getall' do
|
29
|
+
before { node.config(['default interface Ethernet1', 'interface Ethernet1',
|
30
|
+
'no switchport', 'ip address 99.99.99.99/24']) }
|
31
|
+
|
32
|
+
it 'returns the ipinterface collection' do
|
33
|
+
expect(subject.getall).to include('Ethernet1')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns a hash collection' do
|
37
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#create' do
|
42
|
+
before { node.config(['interface Ethernet1', 'switchport']) }
|
43
|
+
|
44
|
+
it 'creates a new ipinterface resource' do
|
45
|
+
expect(subject.get('Ethernet1')).to be_nil
|
46
|
+
expect(subject.create('Ethernet1')).to be_truthy
|
47
|
+
expect(subject.get('Ethernet1')).not_to be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#delete' do
|
52
|
+
before { node.config(['interface Ethernet1', 'no switchport',
|
53
|
+
'ip address 99.99.99.99/24']) }
|
54
|
+
|
55
|
+
it 'deletes a ipinterface resource' do
|
56
|
+
expect(subject.get('Ethernet1')).not_to be_nil
|
57
|
+
expect(subject.delete('Ethernet1')).to be_truthy
|
58
|
+
expect(subject.get('Ethernet1')).to be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#set_address' do
|
63
|
+
before { node.config(['default interface Ethernet1', 'interface Ethernet1',
|
64
|
+
'no switchport']) }
|
65
|
+
|
66
|
+
it 'sets the address value' do
|
67
|
+
expect(subject.get('Ethernet1')[:address]).to be_empty
|
68
|
+
expect(subject.set_address('Ethernet1', value: '99.99.99.99/24')).to be_truthy
|
69
|
+
expect(subject.get('Ethernet1')[:address]).to eq('99.99.99.99/24')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#set_mtu' do
|
74
|
+
before { node.config(['default interface Ethernet1', 'interface Ethernet1',
|
75
|
+
'no switchport']) }
|
76
|
+
|
77
|
+
it 'sets the mtu value on the interface' do
|
78
|
+
expect(subject.get('Ethernet1')[:mtu]).to eq('1500')
|
79
|
+
expect(subject.set_mtu('Ethernet1', value: '2000')).to be_truthy
|
80
|
+
expect(subject.get('Ethernet1')[:mtu]).to eq('2000')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#set_helper_addresses' do
|
85
|
+
before { node.config(['default interface Ethernet1', 'interface Ethernet1',
|
86
|
+
'no switchport', 'ip address 99.99.99.99/24']) }
|
87
|
+
|
88
|
+
let(:helpers) { %w(99.99.99.98 99.99.99.97) }
|
89
|
+
|
90
|
+
it 'sets the helper addresses on the interface' do
|
91
|
+
expect(subject.get('Ethernet1')[:helper_addresses]).to be_empty
|
92
|
+
expect(subject.set_helper_addresses('Ethernet1', value: helpers)).to be_truthy
|
93
|
+
expect(subject.get('Ethernet1')[:helper_addresses].sort).to eq(helpers.sort)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/logging'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Logging do
|
7
|
+
subject { described_class.new(node) }
|
8
|
+
|
9
|
+
let(:node) do
|
10
|
+
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
11
|
+
Rbeapi::Client.connect_to('dut')
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#get' do
|
15
|
+
let(:resource) { subject.get }
|
16
|
+
|
17
|
+
it 'contains the enable key' do
|
18
|
+
expect(resource).to include(:enable)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'contains the host key' do
|
22
|
+
expect(resource).to include(:hosts)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns hosts as an Array' do
|
26
|
+
expect(resource[:hosts]).to be_a_kind_of(Array)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#set_enable' do
|
31
|
+
it 'configures global logging enabled' do
|
32
|
+
node.config('no logging on')
|
33
|
+
expect(subject.get[:enable]).to be_falsy
|
34
|
+
expect(subject.set_enable(value: true)).to be_truthy
|
35
|
+
expect(subject.get[:enable]).to be_truthy
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'configures global logging disabled' do
|
39
|
+
node.config('logging on')
|
40
|
+
expect(subject.get[:enable]).to be_truthy
|
41
|
+
expect(subject.set_enable(value: false)).to be_truthy
|
42
|
+
expect(subject.get[:enable]).to be_falsy
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#add_host' do
|
47
|
+
before { node.config('no logging host foo') }
|
48
|
+
|
49
|
+
it 'adds the host to the list of logging hosts' do
|
50
|
+
expect(subject.get[:hosts]).not_to include('foo')
|
51
|
+
expect(subject.add_host('foo')).to be_truthy
|
52
|
+
expect(subject.get[:hosts]).to include('foo')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#remove_host' do
|
57
|
+
before { node.config('logging host foo') }
|
58
|
+
|
59
|
+
it 'adds the host to the list of logging hosts' do
|
60
|
+
expect(subject.get[:hosts]).to include('foo')
|
61
|
+
expect(subject.remove_host('foo')).to be_truthy
|
62
|
+
expect(subject.get[:hosts]).not_to include('foo')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|