rbeapi 1.1 → 1.2
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +33 -24
- data/README.md +49 -47
- data/Rakefile +2 -0
- data/lib/rbeapi/api/iphosts.rb +157 -0
- data/lib/rbeapi/api/ntp.rb +235 -10
- data/lib/rbeapi/api/snmp.rb +1 -1
- data/lib/rbeapi/api/system.rb +35 -0
- data/lib/rbeapi/version.rb +1 -1
- data/spec/fixtures/dut.conf +6 -3
- data/spec/support/fixtures.rb +1 -1
- data/spec/system/rbeapi/api/iphost_spec.rb +142 -0
- data/spec/system/rbeapi/api/managementdefaults_spec.rb +1 -0
- data/spec/system/rbeapi/api/ntp_spec.rb +161 -11
- data/spec/system/rbeapi/api/staticroutes_spec.rb +2 -1
- data/spec/system/rbeapi/api/system_spec.rb +22 -2
- data/spec/system/rbeapi/api/users_spec.rb +1 -1
- data/spec/system/rbeapi/api/varp_spec.rb +12 -9
- data/spec/system/rbeapi/client_spec.rb +5 -5
- data/spec/unit/rbeapi/api/iphost/default_spec.rb +125 -0
- data/spec/unit/rbeapi/api/iphost/fixture_iphosts.text +3 -0
- data/spec/unit/rbeapi/api/system/default_spec.rb +13 -4
- data/spec/unit/rbeapi/api/system/fixture_system.text +1 -0
- metadata +10 -2
@@ -4,20 +4,42 @@ require 'rbeapi/client'
|
|
4
4
|
require 'rbeapi/api/ntp'
|
5
5
|
|
6
6
|
describe Rbeapi::Api::Ntp do
|
7
|
-
subject { described_class.new(node) }
|
7
|
+
subject { described_class.new(@node) }
|
8
8
|
|
9
|
-
|
9
|
+
before(:all) do
|
10
10
|
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
11
|
-
Rbeapi::Client.connect_to('dut')
|
11
|
+
@node = Rbeapi::Client.connect_to('dut')
|
12
|
+
|
13
|
+
@node.config(['no ntp authenticate',
|
14
|
+
'default ntp trusted-key',
|
15
|
+
'no ntp server foo',
|
16
|
+
'no ntp server vrf rspec bar',
|
17
|
+
'vrf definition rspec'])
|
12
18
|
end
|
13
19
|
|
14
20
|
describe '#get' do
|
15
21
|
let(:resource) { subject.get }
|
16
22
|
|
23
|
+
it 'contains the auth_keys key' do
|
24
|
+
expect(resource).to include(:auth_keys)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns servers as an Hash' do
|
28
|
+
expect(resource[:auth_keys]).to be_a_kind_of(Hash)
|
29
|
+
end
|
30
|
+
|
17
31
|
it 'contains the source_interface key' do
|
18
32
|
expect(resource).to include(:source_interface)
|
19
33
|
end
|
20
34
|
|
35
|
+
it 'contains the authenticate key' do
|
36
|
+
expect(resource).to include(:authenticate)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns authenticate as Boolean' do
|
40
|
+
expect(resource[:auth_keys]).to be_a_kind_of(Hash)
|
41
|
+
end
|
42
|
+
|
21
43
|
it 'contains the servers key' do
|
22
44
|
expect(resource).to include(:servers)
|
23
45
|
end
|
@@ -27,8 +49,29 @@ describe Rbeapi::Api::Ntp do
|
|
27
49
|
end
|
28
50
|
end
|
29
51
|
|
52
|
+
describe '#set_ntp_authenticate' do
|
53
|
+
it 'sets ntp authenticate value' do
|
54
|
+
expect(subject.get[:authenticate]).to be_falsy
|
55
|
+
expect(subject.set_authenticate(enable: true)).to be_truthy
|
56
|
+
expect(subject.get[:authenticate]).to be_truthy
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'negates ntp authenticate' do
|
60
|
+
expect(subject.get[:authenticate]).to be_truthy
|
61
|
+
expect(subject.set_authenticate(enable: false)).to be_truthy
|
62
|
+
expect(subject.get[:authenticate]).to be_falsy
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'defaults ntp authenticate' do
|
66
|
+
@node.config('ntp authenticate')
|
67
|
+
expect(subject.get[:authenticate]).to be_truthy
|
68
|
+
expect(subject.set_authenticate(default: true)).to be_truthy
|
69
|
+
expect(subject.get[:authenticate]).to be_falsy
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
30
73
|
describe '#set_source_interface' do
|
31
|
-
before { node.config('no ntp source') }
|
74
|
+
before { @node.config('no ntp source') }
|
32
75
|
|
33
76
|
it 'sets the ntp source interface value' do
|
34
77
|
expect(subject.get[:source_interface]).to be_empty
|
@@ -51,8 +94,8 @@ describe Rbeapi::Api::Ntp do
|
|
51
94
|
end
|
52
95
|
end
|
53
96
|
|
54
|
-
describe '#
|
55
|
-
before { node.config('no ntp server foo') }
|
97
|
+
describe '#add_basic_server' do
|
98
|
+
before { @node.config('no ntp server foo') }
|
56
99
|
|
57
100
|
it 'adds the host to the list of servers' do
|
58
101
|
expect(subject.get[:servers]).not_to include('foo')
|
@@ -61,10 +104,10 @@ describe Rbeapi::Api::Ntp do
|
|
61
104
|
end
|
62
105
|
end
|
63
106
|
|
64
|
-
describe '#
|
65
|
-
before { node.config('ntp server foo') }
|
107
|
+
describe '#remove_basic_server' do
|
108
|
+
before { @node.config('ntp server foo') }
|
66
109
|
|
67
|
-
it '
|
110
|
+
it 'removes the server from the list of ntp servers' do
|
68
111
|
expect(subject.get[:servers]).to include('foo')
|
69
112
|
expect(subject.remove_server('foo')).to be_truthy
|
70
113
|
expect(subject.get[:servers]).not_to include('foo')
|
@@ -73,7 +116,7 @@ describe Rbeapi::Api::Ntp do
|
|
73
116
|
|
74
117
|
describe '#set_prefer' do
|
75
118
|
it 'configures the ntp server with the prefer keyword' do
|
76
|
-
node.config('no ntp server foo')
|
119
|
+
@node.config('no ntp server foo')
|
77
120
|
expect(subject.get[:servers]).not_to include('foo')
|
78
121
|
expect(subject.set_prefer('foo', true)).to be_truthy
|
79
122
|
expect(subject.get[:servers]).to include('foo')
|
@@ -81,10 +124,117 @@ describe Rbeapi::Api::Ntp do
|
|
81
124
|
end
|
82
125
|
|
83
126
|
it 'unconfigures the prefer value' do
|
84
|
-
node.config('ntp server foo prefer')
|
127
|
+
@node.config('ntp server foo prefer')
|
85
128
|
expect(subject.get[:servers]['foo'][:prefer]).to be_truthy
|
86
129
|
expect(subject.set_prefer('foo', false)).to be_truthy
|
87
130
|
expect(subject.get[:servers]['foo'][:prefer]).to be_falsy
|
88
131
|
end
|
89
132
|
end
|
133
|
+
|
134
|
+
describe '#add_nondefault_server' do
|
135
|
+
before { @node.config('no ntp server foo') }
|
136
|
+
|
137
|
+
let(:opts) do
|
138
|
+
{ vrf: 'rspec',
|
139
|
+
prefer: true,
|
140
|
+
minpoll: 5,
|
141
|
+
maxpoll: 12,
|
142
|
+
source_interface: 'Loopback0',
|
143
|
+
key: 1 }
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'adds the host to the list of servers' do
|
147
|
+
expect(subject.get[:servers]).not_to include('bar')
|
148
|
+
expect(subject.add_server('bar', false, opts)).to be_truthy
|
149
|
+
expect(subject.get[:servers]).to include('bar')
|
150
|
+
expect(subject.get[:servers]['bar']).to eq(opts)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#remove_nondefault_server' do
|
155
|
+
it 'removes the server from the list of ntp servers' do
|
156
|
+
expect(subject.get[:servers]).to include('bar')
|
157
|
+
expect(subject.remove_server('bar', 'rspec')).to be_truthy
|
158
|
+
expect(subject.get[:servers]).not_to include('bar')
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#set_ntp_trusted_keys' do
|
163
|
+
it 'adds key to the list of trusted-keys' do
|
164
|
+
expect(subject.set_trusted_key(value: 1)).to be_truthy
|
165
|
+
expect(subject.get[:trusted_key]).to eq('1')
|
166
|
+
expect(subject.set_trusted_key(value: 5)).to be_truthy
|
167
|
+
expect(subject.get[:trusted_key]).to eq('5')
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'changes key in the list of trusted-keys' do
|
171
|
+
expect(subject.set_trusted_key(value: 5)).to be_truthy
|
172
|
+
expect(subject.get[:trusted_key]).to eq('5')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe '#remove_ntp_trusted_keys' do
|
177
|
+
it 'removes key in the list of trusted-keys' do
|
178
|
+
expect(subject.set_trusted_key(enable: false, value: 5)).to be_truthy
|
179
|
+
expect(subject.get[:trusted_key]).to eq('')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#set_ntp_authentication_key' do
|
184
|
+
let(:opts) do
|
185
|
+
{ algorithm: 'md5',
|
186
|
+
key: 1,
|
187
|
+
mode: 7,
|
188
|
+
password: '06120A3258' }
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'adds authentication-key key' do
|
192
|
+
expect(subject.set_authentication_key(opts)).to be_truthy
|
193
|
+
expect(subject.get[:auth_keys]).to include('1')
|
194
|
+
expect(subject.get[:auth_keys]['1'][:algorithm]).to eq('md5')
|
195
|
+
expect(subject.get[:auth_keys]['1'][:mode]).to eq('7')
|
196
|
+
expect(subject.get[:auth_keys]['1'][:password]).to eq('06120A3258')
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe '#remove_ntp_authentication_key' do
|
201
|
+
let(:opts) do
|
202
|
+
{ algorithm: 'md5',
|
203
|
+
key: 1,
|
204
|
+
mode: 7,
|
205
|
+
password: '06120A3258' }
|
206
|
+
end
|
207
|
+
|
208
|
+
let(:disable) do
|
209
|
+
{ key: 1,
|
210
|
+
enable: false }
|
211
|
+
end
|
212
|
+
|
213
|
+
let(:default) do
|
214
|
+
{ key: 1,
|
215
|
+
default: true }
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'remove authentication-key key via enable' do
|
219
|
+
expect(subject.set_authentication_key(opts)).to be_truthy
|
220
|
+
expect(subject.get[:auth_keys]).to include('1')
|
221
|
+
expect(subject.set_authentication_key(disable)).to be_truthy
|
222
|
+
expect(subject.get[:auth_keys]).not_to include('1')
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'remove authentication-key key via default' do
|
226
|
+
expect(subject.set_authentication_key(opts)).to be_truthy
|
227
|
+
expect(subject.get[:auth_keys]).to include('1')
|
228
|
+
expect(subject.set_authentication_key(default)).to be_truthy
|
229
|
+
expect(subject.get[:auth_keys]).not_to include('1')
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
after(:all) do
|
234
|
+
@node.config(['no ntp authenticate',
|
235
|
+
'default ntp trusted-key',
|
236
|
+
'no ntp server foo',
|
237
|
+
'no ntp server vrf rspec bar',
|
238
|
+
'vrf definition rspec'])
|
239
|
+
end
|
90
240
|
end
|
@@ -46,7 +46,8 @@ describe Rbeapi::Api::Staticroutes do
|
|
46
46
|
let(:resource) { subject.getall }
|
47
47
|
|
48
48
|
before do
|
49
|
-
node.config(['no ip route
|
49
|
+
node.config(['no ip route 0.0.0.0/0',
|
50
|
+
'no ip route 1.2.3.4/32',
|
50
51
|
'no ip route 192.0.2.0/24',
|
51
52
|
'no ip route 192.0.3.0/24',
|
52
53
|
'ip route 1.2.3.4/32 Ethernet7 4 tag 3 name frank',
|
@@ -14,12 +14,12 @@ describe Rbeapi::Api::System do
|
|
14
14
|
describe '#get' do
|
15
15
|
let(:entity) do
|
16
16
|
{ hostname: 'localhost', iprouting: true, banner_motd: '',
|
17
|
-
banner_login: '' }
|
17
|
+
banner_login: '', timezone: 'UTC' }
|
18
18
|
end
|
19
19
|
|
20
20
|
before do
|
21
21
|
node.config(['hostname localhost', 'ip routing', 'no banner motd',
|
22
|
-
'no banner login'])
|
22
|
+
'no banner login', 'no clock timezone'])
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns the snmp resource' do
|
@@ -132,4 +132,24 @@ describe Rbeapi::Api::System do
|
|
132
132
|
expect(subject.get[:banner_motd]).to eq('')
|
133
133
|
end
|
134
134
|
end
|
135
|
+
|
136
|
+
describe '#set_timezone' do
|
137
|
+
before { node.config(['no clock timezone']) }
|
138
|
+
|
139
|
+
it 'configures the system timezone value' do
|
140
|
+
expect(subject.get[:timezone]).to eq('UTC')
|
141
|
+
expect(subject.set_timezone(value: 'Europe/London')).to be_truthy
|
142
|
+
expect(subject.get[:timezone]).to eq('Europe/London')
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'negates the timezone' do
|
146
|
+
expect(subject.set_timezone(enable: false)).to be_truthy
|
147
|
+
expect(subject.get[:timezone]).to eq('UTC')
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'defaults the timezone' do
|
151
|
+
expect(subject.set_timezone(default: true)).to be_truthy
|
152
|
+
expect(subject.get[:timezone]).to eq('UTC')
|
153
|
+
end
|
154
|
+
end
|
135
155
|
end
|
@@ -90,7 +90,7 @@ describe Rbeapi::Api::Users do
|
|
90
90
|
'username admin privilege 1 role network-admin nopassword',
|
91
91
|
"username rbeapi privilege 1 secret 5 #{md5_secret}",
|
92
92
|
"username rbeapi sshkey #{sshkey}",
|
93
|
-
'management defaults', '
|
93
|
+
'management defaults', 'secret hash md5'])
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'returns the username collection' do
|
@@ -15,7 +15,7 @@ describe Rbeapi::Api::Varp do
|
|
15
15
|
let(:resource) { subject.get }
|
16
16
|
|
17
17
|
before do
|
18
|
-
node.config(['no ip virtual-router mac-address',
|
18
|
+
node.config(['no ip virtual-router mac-address aa:bb:cc:dd:ee:ff',
|
19
19
|
'no interface Vlan99', 'no interface Vlan100',
|
20
20
|
'ip virtual-router mac-address aa:bb:cc:dd:ee:ff',
|
21
21
|
'interface Vlan99', 'interface Vlan100'])
|
@@ -41,36 +41,39 @@ describe Rbeapi::Api::Varp do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#set_mac_address' do
|
44
|
-
before
|
44
|
+
before do
|
45
|
+
orig_mac = subject.get[:mac_address]
|
46
|
+
node.config("no ip virtual-router mac-address #{orig_mac}")
|
47
|
+
end
|
45
48
|
|
46
49
|
it 'set mac-address to aa:bb:cc:dd:ee:ff' do
|
47
|
-
expect(subject.get[:mac_address]).to
|
50
|
+
expect(subject.get[:mac_address]).to eq('00:00:00:00:00:00')
|
48
51
|
expect(subject.set_mac_address(value: 'aa:bb:cc:dd:ee:ff')).to be_truthy
|
49
52
|
expect(subject.get[:mac_address]).to eq('aa:bb:cc:dd:ee:ff')
|
50
53
|
end
|
51
54
|
|
52
55
|
it 'set mac-address to ff-ff-ff-ff-ff-ff' do
|
53
|
-
expect(subject.get[:mac_address]).to
|
56
|
+
expect(subject.get[:mac_address]).to eq('00:00:00:00:00:00')
|
54
57
|
expect(subject.set_mac_address(value: 'ff-ff-ff-ff-ff-ff')).to be_truthy
|
55
58
|
expect(subject.get[:mac_address]).to eq('ff:ff:ff:ff:ff:ff')
|
56
59
|
end
|
57
60
|
|
58
61
|
it 'set mac-address to ffff.ffff.ffff' do
|
59
|
-
expect(subject.get[:mac_address]).to
|
62
|
+
expect(subject.get[:mac_address]).to eq('00:00:00:00:00:00')
|
60
63
|
expect(subject.set_mac_address(value: 'ffff.ffff.ffff')).to be_truthy
|
61
64
|
expect(subject.get[:mac_address]).to eq('ff:ff:ff:ff:ff:ff')
|
62
65
|
end
|
63
66
|
|
64
67
|
it 'set mac-address to ffff:ffff:ffff fails' do
|
65
|
-
expect(subject.get[:mac_address]).to
|
68
|
+
expect(subject.get[:mac_address]).to eq('00:00:00:00:00:00')
|
66
69
|
expect(subject.set_mac_address(value: 'ffff:ffff:ffff')).to be_falsey
|
67
|
-
expect(subject.get[:mac_address]).to eq('')
|
70
|
+
expect(subject.get[:mac_address]).to eq('00:00:00:00:00:00')
|
68
71
|
end
|
69
72
|
|
70
73
|
it 'set mac-address to ff.ff.ff.ff.ff.ff fails' do
|
71
|
-
expect(subject.get[:mac_address]).to
|
74
|
+
expect(subject.get[:mac_address]).to eq('00:00:00:00:00:00')
|
72
75
|
expect(subject.set_mac_address(value: 'ff.ff.ff.ff.ff.ff')).to be_falsey
|
73
|
-
expect(subject.get[:mac_address]).to eq('')
|
76
|
+
expect(subject.get[:mac_address]).to eq('00:00:00:00:00:00')
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
@@ -209,17 +209,17 @@ describe Rbeapi::Client do
|
|
209
209
|
|
210
210
|
describe '#config' do
|
211
211
|
it 'puts switch into config mode' do
|
212
|
-
expect(node.config(['
|
212
|
+
expect(node.config(['ip host test 192.0.2.9']))
|
213
213
|
.to be_truthy
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'expects config to return array' do
|
217
|
-
expect(node.config(['no ip
|
217
|
+
expect(node.config(['no ip host test 192.0.2.9']))
|
218
218
|
.to be_kind_of(Array)
|
219
219
|
end
|
220
220
|
|
221
221
|
it 'puts switch into config mode with options and returns array' do
|
222
|
-
expect(node.config(['no ip
|
222
|
+
expect(node.config(['no ip host test 192.0.2.9'],
|
223
223
|
encoding: 'json',
|
224
224
|
open_timeout: 27.00,
|
225
225
|
read_timeout: 27.00))
|
@@ -234,13 +234,13 @@ describe Rbeapi::Client do
|
|
234
234
|
end
|
235
235
|
|
236
236
|
it 'expects config to do dry run' do
|
237
|
-
expect(node.config(['no ip
|
237
|
+
expect(node.config(['no ip host test 192.0.2.1']))
|
238
238
|
.to eq(nil)
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
242
|
it 'returns error if invalid command' do
|
243
|
-
expect { node.config(['no ip
|
243
|
+
expect { node.config(['no ip hosts']) }
|
244
244
|
.to raise_error Rbeapi::Eapilib::CommandError
|
245
245
|
end
|
246
246
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2017, 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 'spec_helper'
|
33
|
+
|
34
|
+
require 'rbeapi/api/iphosts'
|
35
|
+
|
36
|
+
include FixtureHelpers
|
37
|
+
|
38
|
+
describe Rbeapi::Api::Iphosts do
|
39
|
+
subject { described_class.new(node) }
|
40
|
+
|
41
|
+
let(:node) { double('node') }
|
42
|
+
|
43
|
+
let(:test) do
|
44
|
+
{
|
45
|
+
name: 'test1',
|
46
|
+
ipaddress: ['192.168.0.1']
|
47
|
+
}
|
48
|
+
end
|
49
|
+
let(:name) { test[:name] }
|
50
|
+
|
51
|
+
def iphosts
|
52
|
+
iphosts = Fixtures[:iphosts]
|
53
|
+
return iphosts if iphosts
|
54
|
+
fixture('iphosts', format: :text, dir: File.dirname(__FILE__))
|
55
|
+
end
|
56
|
+
|
57
|
+
before :each do
|
58
|
+
allow(subject.node).to receive(:running_config).and_return(iphosts)
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#getall' do
|
62
|
+
let(:test1_entries) do
|
63
|
+
{
|
64
|
+
'test1' => { name: 'test1', ipaddress: ['192.168.0.1'] },
|
65
|
+
'test2' => { name: 'test2', ipaddress: ['10.0.0.1', '10.0.1.1'] },
|
66
|
+
'test3.domain' => { name: 'test3.domain', ipaddress: ['172.16.0.1'] }
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns the ip host collection' do
|
71
|
+
expect(subject.getall).to include(test1_entries)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns a hash collection' do
|
75
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'has three entries' do
|
79
|
+
expect(subject.getall.size).to eq(3)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#get' do
|
84
|
+
it 'returns the ip host resource for given name' do
|
85
|
+
expect(subject.get(name)).to eq(test)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'returns a hash' do
|
89
|
+
expect(subject.get(name)).to be_a_kind_of(Hash)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'has two entries' do
|
93
|
+
expect(subject.get(name).size).to eq(2)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#create' do
|
98
|
+
it 'create a new ip host entry' do
|
99
|
+
expect(node).to receive(:config).with('ip host test 172.16.10.1')
|
100
|
+
expect(subject.create('test', ipaddress: ['172.16.10.1'])).to be_truthy
|
101
|
+
end
|
102
|
+
it 'raises ArgumentError for create without required args ' do
|
103
|
+
expect { subject.create('rbeapi') }.to \
|
104
|
+
raise_error ArgumentError
|
105
|
+
end
|
106
|
+
it 'raises ArgumentError for invalid ipaddress value' do
|
107
|
+
expect { subject.create('name', ipaddress: 'bogus') }.to \
|
108
|
+
raise_error ArgumentError
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#delete' do
|
113
|
+
it 'delete a ip host resource' do
|
114
|
+
expect(node).to receive(:config).with('no ip host test12')
|
115
|
+
expect(subject.delete('test12')).to be_truthy
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#set_ipaddress' do
|
120
|
+
it 'set the ipaddress' do
|
121
|
+
expect(node).to receive(:config).with('ip host test 172.16.10.1')
|
122
|
+
expect(subject.create('test', ipaddress: ['172.16.10.1'])).to be_truthy
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -43,7 +43,8 @@ describe Rbeapi::Api::System do
|
|
43
43
|
let(:test) do
|
44
44
|
{ hostname: 'localhost', iprouting: true,
|
45
45
|
banner_motd: "MOTD Banner\nSecond Line\nEOF \n*\\v1?",
|
46
|
-
banner_login: "Login Banner\nSecond Line\n123456\n EOF"
|
46
|
+
banner_login: "Login Banner\nSecond Line\n123456\n EOF",
|
47
|
+
timezone: 'Europe/Berlin' }
|
47
48
|
end
|
48
49
|
|
49
50
|
def system
|
@@ -65,12 +66,12 @@ describe Rbeapi::Api::System do
|
|
65
66
|
expect(subject.get).to be_a_kind_of(Hash)
|
66
67
|
end
|
67
68
|
|
68
|
-
it 'has
|
69
|
-
expect(subject.get.size).to eq(
|
69
|
+
it 'has five entries' do
|
70
|
+
expect(subject.get.size).to eq(5)
|
70
71
|
end
|
71
72
|
|
72
73
|
it 'retrieves only global ip routing' do
|
73
|
-
expect(subject.get.size).to eq(
|
74
|
+
expect(subject.get.size).to eq(5)
|
74
75
|
expect(subject.get[:iprouting]).to eq(true)
|
75
76
|
end
|
76
77
|
end
|
@@ -140,4 +141,12 @@ describe Rbeapi::Api::System do
|
|
140
141
|
expect(subject.set_banner('motd', default: true)).to be_truthy
|
141
142
|
end
|
142
143
|
end
|
144
|
+
|
145
|
+
describe '#set_timezone' do
|
146
|
+
it 'sets the timezone' do
|
147
|
+
expect(node).to receive(:config).with('clock timezone Europe/Berlin')
|
148
|
+
expect(subject.set_timezone(value: 'Europe/Berlin')).to be_truthy
|
149
|
+
expect(subject.get[:timezone]).to eq('Europe/Berlin')
|
150
|
+
end
|
151
|
+
end
|
143
152
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbeapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Sprygada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/rbeapi/api/bgp.rb
|
214
214
|
- lib/rbeapi/api/dns.rb
|
215
215
|
- lib/rbeapi/api/interfaces.rb
|
216
|
+
- lib/rbeapi/api/iphosts.rb
|
216
217
|
- lib/rbeapi/api/ipinterfaces.rb
|
217
218
|
- lib/rbeapi/api/logging.rb
|
218
219
|
- lib/rbeapi/api/managementdefaults.rb
|
@@ -263,6 +264,7 @@ files:
|
|
263
264
|
- spec/system/rbeapi/api/interfaces_portchannel_spec.rb
|
264
265
|
- spec/system/rbeapi/api/interfaces_vlan_spec.rb
|
265
266
|
- spec/system/rbeapi/api/interfaces_vxlan_spec.rb
|
267
|
+
- spec/system/rbeapi/api/iphost_spec.rb
|
266
268
|
- spec/system/rbeapi/api/ipinterfaces_spec.rb
|
267
269
|
- spec/system/rbeapi/api/logging_spec.rb
|
268
270
|
- spec/system/rbeapi/api/managementdefaults_spec.rb
|
@@ -302,6 +304,8 @@ files:
|
|
302
304
|
- spec/unit/rbeapi/api/interfaces/portchannel_spec.rb
|
303
305
|
- spec/unit/rbeapi/api/interfaces/vlan_spec.rb
|
304
306
|
- spec/unit/rbeapi/api/interfaces/vxlan_spec.rb
|
307
|
+
- spec/unit/rbeapi/api/iphost/default_spec.rb
|
308
|
+
- spec/unit/rbeapi/api/iphost/fixture_iphosts.text
|
305
309
|
- spec/unit/rbeapi/api/managementdefaults/default_spec.rb
|
306
310
|
- spec/unit/rbeapi/api/managementdefaults/fixture_managementdefaults.yaml
|
307
311
|
- spec/unit/rbeapi/api/mlag/default_spec.rb
|
@@ -374,6 +378,7 @@ test_files:
|
|
374
378
|
- spec/system/rbeapi/api/interfaces_portchannel_spec.rb
|
375
379
|
- spec/system/rbeapi/api/interfaces_vlan_spec.rb
|
376
380
|
- spec/system/rbeapi/api/interfaces_vxlan_spec.rb
|
381
|
+
- spec/system/rbeapi/api/iphost_spec.rb
|
377
382
|
- spec/system/rbeapi/api/ipinterfaces_spec.rb
|
378
383
|
- spec/system/rbeapi/api/logging_spec.rb
|
379
384
|
- spec/system/rbeapi/api/managementdefaults_spec.rb
|
@@ -413,6 +418,8 @@ test_files:
|
|
413
418
|
- spec/unit/rbeapi/api/interfaces/portchannel_spec.rb
|
414
419
|
- spec/unit/rbeapi/api/interfaces/vlan_spec.rb
|
415
420
|
- spec/unit/rbeapi/api/interfaces/vxlan_spec.rb
|
421
|
+
- spec/unit/rbeapi/api/iphost/default_spec.rb
|
422
|
+
- spec/unit/rbeapi/api/iphost/fixture_iphosts.text
|
416
423
|
- spec/unit/rbeapi/api/managementdefaults/default_spec.rb
|
417
424
|
- spec/unit/rbeapi/api/managementdefaults/fixture_managementdefaults.yaml
|
418
425
|
- spec/unit/rbeapi/api/mlag/default_spec.rb
|
@@ -437,3 +444,4 @@ test_files:
|
|
437
444
|
- spec/unit/rbeapi/switchconfig2_spec.rb
|
438
445
|
- spec/unit/rbeapi/switchconfig3_spec.rb
|
439
446
|
- spec/unit/rbeapi/switchconfig_spec.rb
|
447
|
+
has_rdoc:
|