rbeapi 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +1 -1
- data/README.md +11 -11
- data/Rakefile +19 -0
- data/guide/Makefile +177 -0
- data/guide/_static/arista_logo_11-trans-w.png +0 -0
- data/guide/_static/arista_logo_jpg-11.jpg +0 -0
- data/guide/_static/favicon.ico +0 -0
- data/guide/conf.py +279 -0
- data/guide/cookbook.rst +4 -0
- data/guide/developing.rst +4 -0
- data/guide/faq.rst +4 -0
- data/guide/index.rst +23 -0
- data/guide/installation.rst +4 -0
- data/guide/license.rst +5 -0
- data/guide/overview.rst +20 -0
- data/guide/quickstart.rst +4 -0
- data/guide/release-notes-0.5.0.rst +60 -0
- data/guide/release-notes.rst +6 -0
- data/guide/testing.rst +4 -0
- data/guide/troubleshooting.rst +1 -0
- data/lib/rbeapi/api/aaa.rb +54 -18
- data/lib/rbeapi/api/acl.rb +60 -2
- data/lib/rbeapi/api/bgp.rb +81 -0
- data/lib/rbeapi/api/dns.rb +48 -2
- data/lib/rbeapi/api/interfaces.rb +97 -32
- data/lib/rbeapi/api/ipinterfaces.rb +13 -2
- data/lib/rbeapi/api/logging.rb +11 -2
- data/lib/rbeapi/api/mlag.rb +20 -10
- data/lib/rbeapi/api/ntp.rb +4 -3
- data/lib/rbeapi/api/ospf.rb +102 -10
- data/lib/rbeapi/api/prefixlists.rb +47 -4
- data/lib/rbeapi/api/radius.rb +9 -9
- data/lib/rbeapi/api/routemaps.rb +7 -5
- data/lib/rbeapi/api/snmp.rb +13 -4
- data/lib/rbeapi/api/staticroutes.rb +1 -1
- data/lib/rbeapi/api/stp.rb +39 -14
- data/lib/rbeapi/api/switchports.rb +126 -2
- data/lib/rbeapi/api/system.rb +24 -3
- data/lib/rbeapi/api/tacacs.rb +9 -10
- data/lib/rbeapi/api/users.rb +12 -3
- data/lib/rbeapi/api/varp.rb +40 -8
- data/lib/rbeapi/api/vlans.rb +15 -5
- data/lib/rbeapi/client.rb +19 -11
- data/lib/rbeapi/eapilib.rb +8 -0
- data/lib/rbeapi/utils.rb +10 -0
- data/lib/rbeapi/version.rb +1 -1
- data/spec/fixtures/eapi.conf.yaml +6 -0
- data/spec/fixtures/empty.conf +0 -0
- data/spec/fixtures/env_path.conf +5 -0
- data/spec/fixtures/test.conf +39 -0
- data/spec/fixtures/wildcard.conf +43 -0
- data/spec/system/rbeapi/api/aaa_groups_spec.rb +122 -0
- data/spec/system/rbeapi/api/aaa_spec.rb +90 -0
- data/spec/system/{api_acl_spec.rb → rbeapi/api/acl_spec.rb} +0 -0
- data/spec/system/rbeapi/api/bgp_neighbors_spec.rb +354 -0
- data/spec/system/rbeapi/api/bgp_spec.rb +275 -0
- data/spec/system/rbeapi/api/dns_spec.rb +17 -1
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +46 -5
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +14 -0
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +68 -0
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +0 -1
- data/spec/system/{api_ospf_interfaces_spec.rb → rbeapi/api/ospf_interfaces_spec.rb} +3 -2
- data/spec/system/{api_ospf_spec.rb → rbeapi/api/ospf_spec.rb} +11 -2
- data/spec/system/rbeapi/api/routemaps_spec.rb +3 -4
- data/spec/system/rbeapi/api/snmp_spec.rb +65 -0
- data/spec/system/rbeapi/api/staticroutes_spec.rb +177 -0
- data/spec/system/rbeapi/api/stp_instances_spec.rb +20 -0
- data/spec/system/rbeapi/api/stp_interfaces_spec.rb +7 -0
- data/spec/system/rbeapi/api/switchports_spec.rb +86 -16
- data/spec/system/rbeapi/api/users_spec.rb +324 -0
- data/spec/system/rbeapi/api/varp_interfaces_spec.rb +34 -0
- data/spec/system/rbeapi/api/vrrp_spec.rb +707 -0
- data/spec/system/rbeapi/client_spec.rb +367 -0
- data/spec/unit/rbeapi/api/aaa/aaa_groups_spec.rb +111 -0
- data/spec/unit/rbeapi/api/aaa/aaa_spec.rb +77 -0
- data/spec/unit/rbeapi/api/aaa/fixture_aaa.text +3 -0
- data/spec/unit/rbeapi/api/switchports/default_spec.rb +249 -0
- data/spec/unit/rbeapi/api/switchports/fixture_switchports.text +284 -0
- data/spec/unit/rbeapi/api/users/default_spec.rb +1 -1
- data/spec/unit/rbeapi/client_spec.rb +211 -0
- metadata +65 -10
@@ -91,4 +91,38 @@ describe Rbeapi::Api::VarpInterfaces do
|
|
91
91
|
expect { subject.set_addresses('Vlan100') }.to raise_error ArgumentError
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
95
|
+
describe '#add_address' do
|
96
|
+
before do
|
97
|
+
node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
98
|
+
'no interface Vlan99', 'no interface Vlan100',
|
99
|
+
'default interface Vlan100', 'interface Vlan100',
|
100
|
+
'ip address 99.99.99.99/24', 'exit'])
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'adds a new address to the list of addresses' do
|
104
|
+
expect(subject.get('Vlan100')[:addresses]).not_to include('99.99.99.98')
|
105
|
+
expect(subject.add_address('Vlan100', '99.99.99.98'))
|
106
|
+
.to be_truthy
|
107
|
+
expect(subject.get('Vlan100')[:addresses]).to include('99.99.99.98')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#remove_address' do
|
112
|
+
before do
|
113
|
+
node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
114
|
+
'no interface Vlan99', 'no interface Vlan100',
|
115
|
+
'default interface Vlan100', 'interface Vlan100',
|
116
|
+
'ip address 99.99.99.99/24', 'exit'])
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'removes the address from the list of addresses' do
|
120
|
+
expect(subject.add_address('Vlan100', '99.99.99.98'))
|
121
|
+
.to be_truthy
|
122
|
+
expect(subject.get('Vlan100')[:addresses]).to include('99.99.99.98')
|
123
|
+
expect(subject.remove_address('Vlan100', '99.99.99.98'))
|
124
|
+
.to be_truthy
|
125
|
+
expect(subject.get('Vlan100')[:addresses]).to eq([])
|
126
|
+
end
|
127
|
+
end
|
94
128
|
end
|
@@ -0,0 +1,707 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/vrrp'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Vrrp 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
|
+
before :all do
|
15
|
+
@sec_ips = ['1.2.3.1', '1.2.3.2', '1.2.3.3', '1.2.3.4']
|
16
|
+
@tracks = [{ name: 'Ethernet3', action: 'decrement', amount: 33 },
|
17
|
+
{ name: 'Ethernet2', action: 'decrement', amount: 22 },
|
18
|
+
{ name: 'Ethernet2', action: 'shutdown' }]
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#get' do
|
22
|
+
before do
|
23
|
+
node.config(['no interface Vlan150',
|
24
|
+
'no interface Vlan100',
|
25
|
+
'interface Vlan100',
|
26
|
+
'interface Vlan150',
|
27
|
+
'ip address 40.10.5.8/24',
|
28
|
+
'vrrp 30 priority 100',
|
29
|
+
'vrrp 30 timers advertise 1',
|
30
|
+
'vrrp 30 mac-address advertisement-interval 30',
|
31
|
+
'no vrrp 30 preempt',
|
32
|
+
'vrrp 30 preempt delay reload 0',
|
33
|
+
'vrrp 30 delay reload 0',
|
34
|
+
'vrrp 30 ip 40.10.5.31',
|
35
|
+
'vrrp 30 description The description',
|
36
|
+
'vrrp 30 shutdown',
|
37
|
+
'vrrp 30 track Ethernet1 decrement 5',
|
38
|
+
'vrrp 30 ip version 2',
|
39
|
+
'vrrp 40 priority 200',
|
40
|
+
'vrrp 40 timers advertise 1',
|
41
|
+
'vrrp 40 mac-address advertisement-interval 30',
|
42
|
+
'vrrp 40 preempt',
|
43
|
+
'vrrp 40 preempt delay reload 0',
|
44
|
+
'vrrp 40 delay reload 0',
|
45
|
+
'vrrp 40 ip 40.10.5.32',
|
46
|
+
'vrrp 40 track Ethernet3 decrement 33',
|
47
|
+
'vrrp 40 track Ethernet2 decrement 22',
|
48
|
+
'vrrp 40 track Ethernet2 shutdown',
|
49
|
+
'vrrp 40 ip version 2'])
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:entity) do
|
53
|
+
{ 30 => { primary_ip: '40.10.5.31', delay_reload: 0,
|
54
|
+
description: 'The description', enable: false, ip_version: 2,
|
55
|
+
mac_addr_adv_interval: 30, preempt: false, preempt_delay_min: 0,
|
56
|
+
preempt_delay_reload: 0, priority: 100, secondary_ip: [],
|
57
|
+
timers_advertise: 1,
|
58
|
+
track: [
|
59
|
+
{ name: 'Ethernet1', action: 'decrement', amount: 5 }
|
60
|
+
]
|
61
|
+
},
|
62
|
+
40 => { primary_ip: '40.10.5.32', delay_reload: 0, description: nil,
|
63
|
+
enable: true, ip_version: 2, mac_addr_adv_interval: 30,
|
64
|
+
preempt: true, preempt_delay_min: 0, preempt_delay_reload: 0,
|
65
|
+
priority: 200, secondary_ip: [], timers_advertise: 1,
|
66
|
+
track: @tracks
|
67
|
+
}
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns the virtual router resource' do
|
72
|
+
expect(subject.get('Vlan150')).to eq(entity)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#getall' do
|
77
|
+
it 'returns a hash collection' do
|
78
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'returns the virtual router collection' do
|
82
|
+
expect(subject.getall).to include('Vlan100')
|
83
|
+
expect(subject.getall).to include('Vlan150')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#create' do
|
88
|
+
before do
|
89
|
+
node.config(['no interface Vlan100'])
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'creates a new virtual router with enable true' do
|
93
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
94
|
+
expect(subject.create('Vlan100', 9, enable: true)).to be_truthy
|
95
|
+
expect(subject.get('Vlan100')).to eq({})
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'creates a new virtual router with enable false' do
|
99
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
100
|
+
expect(subject.create('Vlan100', 9, enable: false)).to be_truthy
|
101
|
+
expect(subject.get('Vlan100')).to include(9)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'creates a new virtual router with primary ip' do
|
105
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
106
|
+
expect(subject.create('Vlan100', 9, primary_ip: '1.2.3.4')).to be_truthy
|
107
|
+
expect(subject.get('Vlan100')[9][:primary_ip]).to eq('1.2.3.4')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'creates a new virtual router with priority' do
|
111
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
112
|
+
expect(subject.create('Vlan100', 9, primary_ip: '1.2.3.4',
|
113
|
+
priority: 100)).to be_truthy
|
114
|
+
expect(subject.get('Vlan100')[9][:priority]).to eq(100)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'creates a new virtual router with description' do
|
118
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
119
|
+
expect(subject.create('Vlan100', 9, description: 'Desc')).to be_truthy
|
120
|
+
expect(subject.get('Vlan100')[9][:description]).to eq('Desc')
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'creates a new virtual router with secondary ips' do
|
124
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
125
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
126
|
+
.to be_truthy
|
127
|
+
expect(subject.create('Vlan100', 9,
|
128
|
+
secondary_ip: ['100.99.98.71',
|
129
|
+
'100.99.98.70'])).to be_truthy
|
130
|
+
expect(subject.get('Vlan100')[9][:secondary_ip]).to eq(['100.99.98.70',
|
131
|
+
'100.99.98.71'])
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'creates a new virtual router with ip version 2' do
|
135
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
136
|
+
expect(subject.create('Vlan100',
|
137
|
+
9,
|
138
|
+
primary_ip: '100.99.98.100',
|
139
|
+
ip_version: 2)).to be_truthy
|
140
|
+
expect(subject.get('Vlan100')[9][:ip_version]).to eq(2)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'creates a new virtual router with timers advertise' do
|
144
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
145
|
+
expect(subject.create('Vlan100', 9, timers_advertise: 77)).to be_truthy
|
146
|
+
expect(subject.get('Vlan100')[9][:timers_advertise]).to eq(77)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'creates a new virtual router with mac addr adv interval' do
|
150
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
151
|
+
expect(subject.create('Vlan100', 9, mac_addr_adv_interval: 77))
|
152
|
+
.to be_truthy
|
153
|
+
expect(subject.get('Vlan100')[9][:mac_addr_adv_interval]).to eq(77)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'creates a new virtual router with preemt true' do
|
157
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
158
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
159
|
+
.to be_truthy
|
160
|
+
expect(subject.create('Vlan100', 9, preempt: true)).to be_truthy
|
161
|
+
expect(subject.get('Vlan100')[9][:preempt]).to eq(true)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'creates a new virtual router with preemt false' do
|
165
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
166
|
+
expect(subject.create('Vlan100', 9, preempt: false)).to be_truthy
|
167
|
+
expect(subject.get('Vlan100')[9][:preempt]).to eq(false)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'creates a new virtual router with preempt delay min' do
|
171
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
172
|
+
expect(subject.create('Vlan100', 9, preempt_delay_min: 100))
|
173
|
+
.to be_truthy
|
174
|
+
expect(subject.get('Vlan100')[9][:preempt_delay_min]).to eq(100)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'creates a new virtual router with preempt delay reload' do
|
178
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
179
|
+
expect(subject.create('Vlan100', 9, preempt_delay_reload: 100))
|
180
|
+
.to be_truthy
|
181
|
+
expect(subject.get('Vlan100')[9][:preempt_delay_reload]).to eq(100)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'creates a new virtual router with preempt delay reload' do
|
185
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
186
|
+
expect(subject.create('Vlan100', 9, delay_reload: 100)).to be_truthy
|
187
|
+
expect(subject.get('Vlan100')[9][:delay_reload]).to eq(100)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'creates a new virtual router with track values' do
|
191
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
192
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
193
|
+
.to be_truthy
|
194
|
+
expect(subject.create('Vlan100',
|
195
|
+
9,
|
196
|
+
track: [{ name: 'Ethernet3',
|
197
|
+
action: 'decrement',
|
198
|
+
amount: 33 },
|
199
|
+
{ name: 'Ethernet2',
|
200
|
+
action: 'decrement',
|
201
|
+
amount: 22 },
|
202
|
+
{ name: 'Ethernet2',
|
203
|
+
action: 'shutdown' }])).to be_truthy
|
204
|
+
expect(subject.get('Vlan100')[9][:track]).to eq(@tracks)
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'creates a new virtual router resource with enable and primary ip' do
|
208
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
209
|
+
expect(subject.create('Vlan100', 9, enable: true, primary_ip: '1.2.3.4'))
|
210
|
+
.to be_truthy
|
211
|
+
expect(subject.get('Vlan100')[9][:primary_ip]).to eq('1.2.3.4')
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'creates a new virtual router resource with enable and priority' do
|
215
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
216
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
217
|
+
.to be_truthy
|
218
|
+
expect(subject.create('Vlan100', 9, enable: true, priority: 100))
|
219
|
+
.to be_truthy
|
220
|
+
expect(subject.get('Vlan100')[9][:priority]).to eq(100)
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'creates a new virtual router resource with enable and description' do
|
224
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
225
|
+
expect(subject.create('Vlan100', 9, enable: true, description: 'Desc'))
|
226
|
+
.to be_truthy
|
227
|
+
expect(subject.get('Vlan100')[9][:description]).to eq('Desc')
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'creates a new virtual router resource with enable and secondary_ip' do
|
231
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
232
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
233
|
+
.to be_truthy
|
234
|
+
expect(subject.create('Vlan100',
|
235
|
+
9,
|
236
|
+
enable: true,
|
237
|
+
secondary_ip: ['1.2.3.1',
|
238
|
+
'1.2.3.2',
|
239
|
+
'1.2.3.3', '1.2.3.4'])).to be_truthy
|
240
|
+
expect(subject.get('Vlan100')[9][:secondary_ip]).to eq(@sec_ips)
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'creates a new virtual router resource with all options set' do
|
244
|
+
expect(subject.get('Vlan100')).to eq(nil)
|
245
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
246
|
+
.to be_truthy
|
247
|
+
expect(subject.create('Vlan100',
|
248
|
+
9,
|
249
|
+
enable: true,
|
250
|
+
priority: 100,
|
251
|
+
description: 'Desc',
|
252
|
+
secondary_ip: ['100.99.98.71',
|
253
|
+
'100.99.98.70'],
|
254
|
+
ip_version: 2,
|
255
|
+
timers_advertise: 77,
|
256
|
+
mac_addr_adv_interval: 77,
|
257
|
+
preempt: true,
|
258
|
+
preempt_delay_min: 100,
|
259
|
+
preempt_delay_reload: 100,
|
260
|
+
delay_reload: 100,
|
261
|
+
track: [{ name: 'Ethernet3',
|
262
|
+
action: 'decrement',
|
263
|
+
amount: 33 },
|
264
|
+
{ name: 'Ethernet2',
|
265
|
+
action: 'decrement',
|
266
|
+
amount: 22 },
|
267
|
+
{ name: 'Ethernet2',
|
268
|
+
action: 'shutdown' }])).to be_truthy
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'raises ArgumentError for create without options' do
|
272
|
+
expect { subject.create('Vlan100', 9) }.to \
|
273
|
+
raise_error ArgumentError
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe '#delete' do
|
278
|
+
before do
|
279
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
280
|
+
'vrrp 9 priority 100'])
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'deletes a virtual router resource' do
|
284
|
+
expect(subject.delete('Vlan100', 9)).to be_truthy
|
285
|
+
expect(subject.get('Vlan100')).to eq({})
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
describe '#default' do
|
290
|
+
before do
|
291
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
292
|
+
'vrrp 9 priority 100'])
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'sets virtual router resource to default' do
|
296
|
+
expect(subject.default('Vlan100', 9)).to be_truthy
|
297
|
+
expect(subject.get('Vlan100')).to eq({})
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
describe '#set_shutdown' do
|
302
|
+
before do
|
303
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
304
|
+
'vrrp 9 priority 100'])
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'enable Vlan100 vrid 9' do
|
308
|
+
expect(subject.set_shutdown('Vlan100', 9)).to be_truthy
|
309
|
+
expect(subject.get('Vlan100')).to eq({})
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'disable Vlan100 vrid 9' do
|
313
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
314
|
+
.to be_truthy
|
315
|
+
expect(subject.set_shutdown('Vlan100', 9, enable: false)).to be_truthy
|
316
|
+
expect(subject.get('Vlan100')[9][:enable]).to eq(false)
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'defaults Vlan100 vrid 9' do
|
320
|
+
expect(subject.set_shutdown('Vlan100', 9, default: true)).to be_truthy
|
321
|
+
expect(subject.get('Vlan100')).to eq({})
|
322
|
+
end
|
323
|
+
|
324
|
+
it 'default option takes precedence' do
|
325
|
+
expect(subject.set_shutdown('Vlan100', 9, enable: false,
|
326
|
+
default: true)).to be_truthy
|
327
|
+
expect(subject.get('Vlan100')).to eq({})
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe '#set_primary_ip' do
|
332
|
+
before do
|
333
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
334
|
+
'vrrp 9 priority 100'])
|
335
|
+
end
|
336
|
+
|
337
|
+
it 'set primary IP address' do
|
338
|
+
expect(subject.set_primary_ip('Vlan100', 9,
|
339
|
+
value: '1.2.3.4')).to be_truthy
|
340
|
+
expect(subject.get('Vlan100')[9][:primary_ip]).to eq('1.2.3.4')
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'disable primary IP address' do
|
344
|
+
expect(subject.set_primary_ip('Vlan100', 9, value: '1.2.3.4',
|
345
|
+
enable: false)).to be_truthy
|
346
|
+
expect(subject.get('Vlan100')).to eq({})
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'defaults primary IP address' do
|
350
|
+
expect(subject.set_primary_ip('Vlan100', 9, value: '1.2.3.4',
|
351
|
+
default: true)).to be_truthy
|
352
|
+
expect(subject.get('Vlan100')).to eq({})
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'default option takes precedence' do
|
356
|
+
expect(subject.set_primary_ip('Vlan100', 9, enable: false,
|
357
|
+
value: '1.2.3.4',
|
358
|
+
default: true)).to be_truthy
|
359
|
+
expect(subject.get('Vlan100')).to eq({})
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
describe '#set_priority' do
|
364
|
+
before do
|
365
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
366
|
+
'vrrp 9 priority 100'])
|
367
|
+
end
|
368
|
+
|
369
|
+
it 'set priority' do
|
370
|
+
expect(subject.set_priority('Vlan100', 9, value: 13)).to be_truthy
|
371
|
+
expect(subject.get('Vlan100')[9][:priority]).to eq(13)
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'disable priority' do
|
375
|
+
expect(subject.set_priority('Vlan100', 9, enable: false)).to be_truthy
|
376
|
+
expect(subject.get('Vlan100')).to eq({})
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'defaults priority' do
|
380
|
+
expect(subject.set_priority('Vlan100', 9, default: true)).to be_truthy
|
381
|
+
expect(subject.get('Vlan100')).to eq({})
|
382
|
+
end
|
383
|
+
|
384
|
+
it 'default option takes precedence' do
|
385
|
+
expect(subject.set_priority('Vlan100', 9, enable: false,
|
386
|
+
default: true)).to be_truthy
|
387
|
+
expect(subject.get('Vlan100')).to eq({})
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
describe '#set_description' do
|
392
|
+
before do
|
393
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
394
|
+
'vrrp 9 priority 100'])
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'set description' do
|
398
|
+
expect(subject.set_description('Vlan100', 9,
|
399
|
+
value: 'Howdy')).to be_truthy
|
400
|
+
expect(subject.get('Vlan100')[9][:description]).to eq('Howdy')
|
401
|
+
end
|
402
|
+
|
403
|
+
it 'disable description' do
|
404
|
+
expect(subject.set_description('Vlan100', 9, enable: false)).to be_truthy
|
405
|
+
expect(subject.get('Vlan100')).to eq({})
|
406
|
+
end
|
407
|
+
|
408
|
+
it 'defaults description' do
|
409
|
+
expect(subject.set_description('Vlan100', 9, default: true)).to be_truthy
|
410
|
+
expect(subject.get('Vlan100')).to eq({})
|
411
|
+
end
|
412
|
+
|
413
|
+
it 'default option takes precedence' do
|
414
|
+
expect(subject.set_description('Vlan100', 9, enable: false,
|
415
|
+
default: true)).to be_truthy
|
416
|
+
expect(subject.get('Vlan100')).to eq({})
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
describe '#set_secondary_ip' do
|
421
|
+
before do
|
422
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
423
|
+
'vrrp 9 priority 100'])
|
424
|
+
end
|
425
|
+
|
426
|
+
it 'set secondary IP addresses' do
|
427
|
+
# Set current IP addresses
|
428
|
+
expect(subject.set_secondary_ip('Vlan100', 9, @sec_ips)).to be_truthy
|
429
|
+
expect(subject.get('Vlan100')[9][:secondary_ip]).to eq(@sec_ips)
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'remove all secondary IP addresses' do
|
433
|
+
# Set current IP addresses
|
434
|
+
expect(subject.set_secondary_ip('Vlan100', 9, @sec_ips)).to be_truthy
|
435
|
+
# Delete all IP addresses
|
436
|
+
expect(subject.set_secondary_ip('Vlan100', 9, [])).to be_truthy
|
437
|
+
expect(subject.get('Vlan100')).to eq({})
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
describe '#set_ip_version' do
|
442
|
+
before do
|
443
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
444
|
+
'vrrp 9 priority 100'])
|
445
|
+
end
|
446
|
+
|
447
|
+
it 'set VRRP version' do
|
448
|
+
expect(subject.set_ip_version('Vlan100', 9, value: 3)).to be_truthy
|
449
|
+
expect(subject.get('Vlan100')[9][:ip_version]).to eq(3)
|
450
|
+
end
|
451
|
+
|
452
|
+
it 'disable VRRP version' do
|
453
|
+
expect(subject.set_ip_version('Vlan100', 9, enable: false)).to be_truthy
|
454
|
+
expect(subject.get('Vlan100')).to eq({})
|
455
|
+
end
|
456
|
+
|
457
|
+
it 'defaults VRRP version' do
|
458
|
+
expect(subject.set_ip_version('Vlan100', 9, default: true)).to be_truthy
|
459
|
+
expect(subject.get('Vlan100')).to eq({})
|
460
|
+
end
|
461
|
+
|
462
|
+
it 'default option takes precedence' do
|
463
|
+
expect(subject.set_ip_version('Vlan100', 9, enable: false,
|
464
|
+
default: true)).to be_truthy
|
465
|
+
expect(subject.get('Vlan100')).to eq({})
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
describe '#set_timers_advertise' do
|
470
|
+
before do
|
471
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
472
|
+
'vrrp 9 priority 100'])
|
473
|
+
end
|
474
|
+
|
475
|
+
it 'set advertise timer' do
|
476
|
+
expect(subject.set_timers_advertise('Vlan100', 9, value: 7)).to be_truthy
|
477
|
+
expect(subject.get('Vlan100')[9][:timers_advertise]).to eq(7)
|
478
|
+
end
|
479
|
+
|
480
|
+
it 'disable advertise timer' do
|
481
|
+
expect(subject.set_timers_advertise('Vlan100', 9,
|
482
|
+
enable: false)).to be_truthy
|
483
|
+
expect(subject.get('Vlan100')).to eq({})
|
484
|
+
end
|
485
|
+
|
486
|
+
it 'defaults advertise timer' do
|
487
|
+
expect(subject.set_timers_advertise('Vlan100', 9,
|
488
|
+
default: true)).to be_truthy
|
489
|
+
expect(subject.get('Vlan100')).to eq({})
|
490
|
+
end
|
491
|
+
|
492
|
+
it 'default option takes precedence' do
|
493
|
+
expect(subject.set_timers_advertise('Vlan100', 9,
|
494
|
+
enable: false,
|
495
|
+
default: true)).to be_truthy
|
496
|
+
expect(subject.get('Vlan100')).to eq({})
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
describe '#set_mac_addr_adv_interval' do
|
501
|
+
before do
|
502
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
503
|
+
'vrrp 9 priority 100'])
|
504
|
+
end
|
505
|
+
|
506
|
+
it 'set mac address advertisement interval' do
|
507
|
+
expect(subject.set_mac_addr_adv_interval('Vlan100', 9,
|
508
|
+
value: 12)).to be_truthy
|
509
|
+
expect(subject.get('Vlan100')[9][:mac_addr_adv_interval]).to eq(12)
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'disable mac address advertisement interval' do
|
513
|
+
expect(subject.set_mac_addr_adv_interval('Vlan100', 9,
|
514
|
+
enable: false)).to be_truthy
|
515
|
+
expect(subject.get('Vlan100')).to eq({})
|
516
|
+
end
|
517
|
+
|
518
|
+
it 'defaults mac address advertisement interval' do
|
519
|
+
expect(subject.set_mac_addr_adv_interval('Vlan100', 9,
|
520
|
+
default: true)).to be_truthy
|
521
|
+
expect(subject.get('Vlan100')).to eq({})
|
522
|
+
end
|
523
|
+
|
524
|
+
it 'default option takes precedence' do
|
525
|
+
expect(subject.set_mac_addr_adv_interval('Vlan100', 9,
|
526
|
+
enable: false,
|
527
|
+
default: true)).to be_truthy
|
528
|
+
expect(subject.get('Vlan100')).to eq({})
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
describe '#set_preempt' do
|
533
|
+
before do
|
534
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
535
|
+
'vrrp 9 priority 100'])
|
536
|
+
end
|
537
|
+
|
538
|
+
it 'enable preempt mode' do
|
539
|
+
expect(subject.create('Vlan100', 9, primary_ip: '100.99.98.100'))
|
540
|
+
.to be_truthy
|
541
|
+
expect(subject.set_preempt('Vlan100', 9)).to be_truthy
|
542
|
+
expect(subject.get('Vlan100')[9][:preempt]).to eq(true)
|
543
|
+
end
|
544
|
+
|
545
|
+
it 'disable preempt mode' do
|
546
|
+
expect(subject.set_preempt('Vlan100', 9, enable: false)).to be_truthy
|
547
|
+
expect(subject.get('Vlan100')[9][:preempt]).to eq(false)
|
548
|
+
end
|
549
|
+
|
550
|
+
it 'defaults preempt mode' do
|
551
|
+
expect(subject.set_preempt('Vlan100', 9, default: true)).to be_truthy
|
552
|
+
expect(subject.get('Vlan100')[9][:preempt]).to eq(false)
|
553
|
+
end
|
554
|
+
|
555
|
+
it 'default option takes precedence' do
|
556
|
+
expect(subject.set_preempt('Vlan100', 9, enable: false,
|
557
|
+
default: true)).to be_truthy
|
558
|
+
expect(subject.get('Vlan100')[9][:preempt]).to eq(false)
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
describe '#set_preempt_delay_min' do
|
563
|
+
before do
|
564
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
565
|
+
'vrrp 9 priority 100'])
|
566
|
+
end
|
567
|
+
|
568
|
+
it 'enable preempt mode' do
|
569
|
+
expect(subject.set_preempt_delay_min('Vlan100', 9, value: 8)).to be_truthy
|
570
|
+
expect(subject.get('Vlan100')[9][:preempt_delay_min]).to eq(8)
|
571
|
+
end
|
572
|
+
|
573
|
+
it 'disable preempt mode' do
|
574
|
+
expect(subject.set_preempt_delay_min('Vlan100', 9,
|
575
|
+
enable: false)).to be_truthy
|
576
|
+
expect(subject.get('Vlan100')).to eq({})
|
577
|
+
end
|
578
|
+
|
579
|
+
it 'defaults preempt mode' do
|
580
|
+
expect(subject.set_preempt_delay_min('Vlan100', 9,
|
581
|
+
default: true)).to be_truthy
|
582
|
+
expect(subject.get('Vlan100')).to eq({})
|
583
|
+
end
|
584
|
+
|
585
|
+
it 'default option takes precedence' do
|
586
|
+
expect(subject.set_preempt_delay_min('Vlan100', 9,
|
587
|
+
enable: false,
|
588
|
+
default: true)).to be_truthy
|
589
|
+
expect(subject.get('Vlan100')).to eq({})
|
590
|
+
end
|
591
|
+
end
|
592
|
+
|
593
|
+
describe '#set_preempt_delay_reload' do
|
594
|
+
before do
|
595
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
596
|
+
'vrrp 9 priority 100'])
|
597
|
+
end
|
598
|
+
|
599
|
+
it 'enable preempt delay reload' do
|
600
|
+
expect(subject.set_preempt_delay_reload('Vlan100', 9,
|
601
|
+
value: 8)).to be_truthy
|
602
|
+
expect(subject.get('Vlan100')[9][:preempt_delay_reload]).to eq(8)
|
603
|
+
end
|
604
|
+
|
605
|
+
it 'disable preempt delay reload' do
|
606
|
+
expect(subject.set_preempt_delay_reload('Vlan100', 9,
|
607
|
+
enable: false)).to be_truthy
|
608
|
+
expect(subject.get('Vlan100')).to eq({})
|
609
|
+
end
|
610
|
+
|
611
|
+
it 'defaults preempt delay reload' do
|
612
|
+
expect(subject.set_preempt_delay_reload('Vlan100', 9,
|
613
|
+
default: true)).to be_truthy
|
614
|
+
expect(subject.get('Vlan100')).to eq({})
|
615
|
+
end
|
616
|
+
|
617
|
+
it 'default option takes precedence' do
|
618
|
+
expect(subject.set_preempt_delay_reload('Vlan100', 9,
|
619
|
+
enable: false,
|
620
|
+
default: true)).to be_truthy
|
621
|
+
expect(subject.get('Vlan100')).to eq({})
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
625
|
+
describe '#set_delay_reload' do
|
626
|
+
before do
|
627
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
628
|
+
'vrrp 9 priority 100'])
|
629
|
+
end
|
630
|
+
|
631
|
+
it 'enable delay reload' do
|
632
|
+
expect(subject.set_delay_reload('Vlan100', 9, value: 8)).to be_truthy
|
633
|
+
expect(subject.get('Vlan100')[9][:delay_reload]).to eq(8)
|
634
|
+
end
|
635
|
+
|
636
|
+
it 'disable delay reload' do
|
637
|
+
expect(subject.set_delay_reload('Vlan100', 9, enable: false)).to be_truthy
|
638
|
+
expect(subject.get('Vlan100')).to eq({})
|
639
|
+
end
|
640
|
+
|
641
|
+
it 'defaults delay reload' do
|
642
|
+
expect(subject.set_delay_reload('Vlan100', 9, default: true)).to be_truthy
|
643
|
+
expect(subject.get('Vlan100')).to eq({})
|
644
|
+
end
|
645
|
+
|
646
|
+
it 'default option takes precedence' do
|
647
|
+
expect(subject.set_delay_reload('Vlan100', 9,
|
648
|
+
enable: false,
|
649
|
+
default: true)).to be_truthy
|
650
|
+
expect(subject.get('Vlan100')).to eq({})
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
654
|
+
describe '#set_tracks' do
|
655
|
+
before do
|
656
|
+
node.config(['no interface Vlan100', 'interface Vlan100',
|
657
|
+
'vrrp 9 priority 100'])
|
658
|
+
end
|
659
|
+
|
660
|
+
before :all do
|
661
|
+
@bad_key = [{ nombre: 'Ethernet3', action: 'decrement', amount: 33 }]
|
662
|
+
@miss_key = [{ action: 'decrement', amount: 33 }]
|
663
|
+
@bad_action = [{ name: 'Ethernet3', action: 'dec', amount: 33 }]
|
664
|
+
@sem_key = [{ name: 'Ethernet3', action: 'shutdown', amount: 33 }]
|
665
|
+
@bad_amount = [{ name: 'Ethernet3', action: 'decrement', amount: -1 }]
|
666
|
+
end
|
667
|
+
|
668
|
+
it 'set tracks' do
|
669
|
+
# Set current IP addresses
|
670
|
+
expect(subject.set_tracks('Vlan100', 9, @tracks)).to be_truthy
|
671
|
+
expect(subject.get('Vlan100')[9][:track]).to eq(@tracks)
|
672
|
+
end
|
673
|
+
|
674
|
+
it 'remove all tracks' do
|
675
|
+
# Set current IP addresses
|
676
|
+
expect(subject.set_tracks('Vlan100', 9, @tracks)).to be_truthy
|
677
|
+
# Delete all IP addresses
|
678
|
+
expect(subject.set_tracks('Vlan100', 9, [])).to be_truthy
|
679
|
+
expect(subject.get('Vlan100')).to eq({})
|
680
|
+
end
|
681
|
+
|
682
|
+
it 'raises ArgumentError for track hash with a bad key' do
|
683
|
+
expect { subject.set_tracks('Vlan100', 9, @bad_key) }.to \
|
684
|
+
raise_error ArgumentError
|
685
|
+
end
|
686
|
+
|
687
|
+
it 'raises ArgumentError for track hash with missing required key' do
|
688
|
+
expect { subject.set_tracks('Vlan100', 9, @miss_key) }.to \
|
689
|
+
raise_error ArgumentError
|
690
|
+
end
|
691
|
+
|
692
|
+
it 'raises ArgumentError for track hash with invalid action' do
|
693
|
+
expect { subject.set_tracks('Vlan100', 9, @bad_action) }.to \
|
694
|
+
raise_error ArgumentError
|
695
|
+
end
|
696
|
+
|
697
|
+
it 'raises ArgumentError for track hash with shutdown and amount' do
|
698
|
+
expect { subject.set_tracks('Vlan100', 9, @sem_key) }.to \
|
699
|
+
raise_error ArgumentError
|
700
|
+
end
|
701
|
+
|
702
|
+
it 'raises ArgumentError for track hash with negative amount' do
|
703
|
+
expect { subject.set_tracks('Vlan100', 9, @bad_amount) }.to \
|
704
|
+
raise_error ArgumentError
|
705
|
+
end
|
706
|
+
end
|
707
|
+
end
|