rbeapi 0.1.0 → 0.2.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 +5 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile +3 -1
- data/Guardfile +3 -3
- data/README.md +92 -17
- data/Rakefile +99 -4
- data/gems/README.rst +4 -0
- data/gems/inifile/.gitignore +2 -0
- data/gems/inifile/README.rst +5 -0
- data/gems/inifile/inifile.spec.tmpl +84 -0
- data/gems/net_http_unix/.gitignore +2 -0
- data/gems/net_http_unix/README.rst +5 -0
- data/gems/net_http_unix/net_http_unix.spec.tmpl +54 -0
- data/gems/netaddr/README.rst +5 -0
- data/gems/netaddr/netaddr.spec.tmpl +50 -0
- data/lib/rbeapi/api/aaa.rb +14 -17
- data/lib/rbeapi/api/acl.rb +276 -0
- data/lib/rbeapi/api/dns.rb +7 -4
- data/lib/rbeapi/api/interfaces.rb +239 -239
- data/lib/rbeapi/api/ipinterfaces.rb +5 -3
- data/lib/rbeapi/api/logging.rb +8 -5
- data/lib/rbeapi/api/mlag.rb +45 -127
- data/lib/rbeapi/api/ntp.rb +1 -4
- data/lib/rbeapi/api/ospf.rb +16 -13
- data/lib/rbeapi/api/prefixlists.rb +4 -4
- data/lib/rbeapi/api/radius.rb +34 -25
- data/lib/rbeapi/api/routemaps.rb +16 -10
- data/lib/rbeapi/api/snmp.rb +26 -13
- data/lib/rbeapi/api/staticroutes.rb +6 -5
- data/lib/rbeapi/api/stp.rb +77 -18
- data/lib/rbeapi/api/switchports.rb +20 -12
- data/lib/rbeapi/api/system.rb +6 -6
- data/lib/rbeapi/api/tacacs.rb +9 -6
- data/lib/rbeapi/api/varp.rb +15 -10
- data/lib/rbeapi/api/vlans.rb +5 -6
- data/lib/rbeapi/api.rb +56 -16
- data/lib/rbeapi/client.rb +85 -50
- data/lib/rbeapi/eapilib.rb +95 -56
- data/lib/rbeapi/netdev/snmp.rb +7 -16
- data/lib/rbeapi/utils.rb +3 -5
- data/lib/rbeapi/version.rb +1 -1
- data/rbeapi.gemspec +4 -2
- data/rbeapi.spec.tmpl +72 -0
- data/spec/support/fixtures.rb +6 -4
- data/spec/support/shared_examples_for_api_modules.rb +3 -18
- data/spec/system/api_acl_spec.rb +128 -0
- data/spec/system/api_ospf_interfaces_spec.rb +17 -14
- data/spec/system/api_ospf_spec.rb +8 -8
- data/spec/system/api_varp_interfaces_spec.rb +22 -13
- data/spec/system/api_varp_spec.rb +1 -4
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +3 -4
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +13 -9
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +43 -26
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +7 -6
- data/spec/system/rbeapi/api/ipinterfaces_spec.rb +34 -21
- data/spec/system/rbeapi/api/mlag_interfaces_spec.rb +15 -38
- data/spec/system/rbeapi/api/mlag_spec.rb +26 -30
- data/spec/system/rbeapi/api/snmp_spec.rb +0 -3
- data/spec/system/rbeapi/api/stp_instances_spec.rb +20 -12
- data/spec/system/rbeapi/api/stp_interfaces_spec.rb +1 -3
- data/spec/system/rbeapi/api/switchports_spec.rb +14 -12
- data/spec/system/rbeapi/api/system_spec.rb +0 -3
- data/spec/system/rbeapi/api/vlans_spec.rb +19 -9
- data/spec/unit/rbeapi/api/acl/default_spec.rb +158 -0
- data/spec/unit/rbeapi/api/acl/fixture_acl_standard.text +22 -0
- data/spec/unit/rbeapi/api/interfaces/base_spec.rb +123 -0
- data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +89 -0
- data/spec/unit/rbeapi/api/interfaces/fixture_interfaces.text +219 -0
- data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +149 -0
- data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +243 -0
- data/spec/unit/rbeapi/api/mlag/default_spec.rb +218 -0
- data/spec/unit/rbeapi/api/mlag/fixture_mlag.text +238 -0
- data/spec/unit/rbeapi/api/vlans/default_spec.rb +135 -0
- data/spec/unit/rbeapi/api/vlans/fixture_vlans.text +5 -0
- metadata +79 -4
- data/lib/rbeapi/api/radius.rb.old +0 -399
@@ -12,10 +12,10 @@ describe Rbeapi::Api::Interfaces do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#get' do
|
15
|
-
|
16
15
|
let(:entity) do
|
17
16
|
{ name: 'Ethernet1', type: 'ethernet', description: '', shutdown: false,
|
18
|
-
sflow: true, flowcontrol_send: 'off',
|
17
|
+
speed: 'auto', forced: false, sflow: true, flowcontrol_send: 'off',
|
18
|
+
flowcontrol_receive: 'off' }
|
19
19
|
end
|
20
20
|
|
21
21
|
before { node.config(['default interface Ethernet1']) }
|
@@ -35,7 +35,7 @@ describe Rbeapi::Api::Interfaces do
|
|
35
35
|
it 'returns a hash collection' do
|
36
36
|
expect(subject.getall).to be_a_kind_of(Hash)
|
37
37
|
end
|
38
|
-
|
38
|
+
end
|
39
39
|
|
40
40
|
describe '#create' do
|
41
41
|
it 'raises an error on create' do
|
@@ -63,7 +63,8 @@ describe Rbeapi::Api::Interfaces do
|
|
63
63
|
it 'sets the description value on the interface' do
|
64
64
|
node.config(['interface Ethernet1', 'no description'])
|
65
65
|
expect(subject.get('Ethernet1')[:description]).to be_empty
|
66
|
-
expect(subject.set_description('Ethernet1', value: 'foo bar'))
|
66
|
+
expect(subject.set_description('Ethernet1', value: 'foo bar'))
|
67
|
+
.to be_truthy
|
67
68
|
expect(subject.get('Ethernet1')[:description]).to eq('foo bar')
|
68
69
|
end
|
69
70
|
end
|
@@ -104,14 +105,16 @@ describe Rbeapi::Api::Interfaces do
|
|
104
105
|
it 'sets the flowcontrol send value to on' do
|
105
106
|
node.config(['interface Ethernet1', 'flowcontrol send off'])
|
106
107
|
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('off')
|
107
|
-
expect(subject.set_flowcontrol_send('Ethernet1', value: 'on'))
|
108
|
+
expect(subject.set_flowcontrol_send('Ethernet1', value: 'on'))
|
109
|
+
.to be_truthy
|
108
110
|
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('on')
|
109
111
|
end
|
110
112
|
|
111
113
|
it 'sets the flowcontrol send value to off' do
|
112
114
|
node.config(['interface Ethernet1', 'flowcontrol send on'])
|
113
115
|
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('on')
|
114
|
-
expect(subject.set_flowcontrol_send('Ethernet1', value: 'off'))
|
116
|
+
expect(subject.set_flowcontrol_send('Ethernet1', value: 'off'))
|
117
|
+
.to be_truthy
|
115
118
|
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('off')
|
116
119
|
end
|
117
120
|
end
|
@@ -120,16 +123,17 @@ describe Rbeapi::Api::Interfaces do
|
|
120
123
|
it 'sets the flowcontrol receive value to on' do
|
121
124
|
node.config(['interface Ethernet1', 'flowcontrol receive off '])
|
122
125
|
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('off')
|
123
|
-
expect(subject.set_flowcontrol_receive('Ethernet1', value: 'on'))
|
126
|
+
expect(subject.set_flowcontrol_receive('Ethernet1', value: 'on'))
|
127
|
+
.to be_truthy
|
124
128
|
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('on')
|
125
129
|
end
|
126
130
|
|
127
131
|
it 'sets the flowcontrol receive value to off' do
|
128
132
|
node.config(['interface Ethernet1', 'flowcontrol receive on'])
|
129
133
|
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('on')
|
130
|
-
expect(subject.set_flowcontrol_receive('Ethernet1', value: 'off'))
|
134
|
+
expect(subject.set_flowcontrol_receive('Ethernet1', value: 'off'))
|
135
|
+
.to be_truthy
|
131
136
|
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('off')
|
132
137
|
end
|
133
138
|
end
|
134
139
|
end
|
135
|
-
|
@@ -6,21 +6,21 @@ require 'rbeapi/api/interfaces'
|
|
6
6
|
describe Rbeapi::Api::Interfaces do
|
7
7
|
subject { described_class.new(node) }
|
8
8
|
|
9
|
-
|
10
9
|
let(:node) do
|
11
10
|
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
12
11
|
Rbeapi::Client.connect_to('dut')
|
13
12
|
end
|
14
13
|
|
15
14
|
describe '#get' do
|
16
|
-
|
17
15
|
let(:entity) do
|
18
16
|
{ name: 'Port-Channel1', type: 'portchannel', description: '',
|
19
17
|
shutdown: false, members: [], lacp_mode: 'on', minimum_links: '0',
|
20
18
|
lacp_timeout: '90', lacp_fallback: 'disabled' }
|
21
19
|
end
|
22
20
|
|
23
|
-
before
|
21
|
+
before do
|
22
|
+
node.config(['no interface Port-Channel1', 'interface Port-Channel1'])
|
23
|
+
end
|
24
24
|
|
25
25
|
it 'returns the interface resource' do
|
26
26
|
expect(subject.get('Port-Channel1')).to eq(entity)
|
@@ -28,7 +28,9 @@ describe Rbeapi::Api::Interfaces do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#getall' do
|
31
|
-
before
|
31
|
+
before do
|
32
|
+
node.config(['no interface Port-Channel1', 'interface Port-Channel1'])
|
33
|
+
end
|
32
34
|
|
33
35
|
it 'returns the interface collection' do
|
34
36
|
expect(subject.getall).to include('Port-Channel1')
|
@@ -37,7 +39,7 @@ describe Rbeapi::Api::Interfaces do
|
|
37
39
|
it 'returns a hash collection' do
|
38
40
|
expect(subject.getall).to be_a_kind_of(Hash)
|
39
41
|
end
|
40
|
-
|
42
|
+
end
|
41
43
|
|
42
44
|
describe '#create' do
|
43
45
|
before { node.config('no interface Port-Channel1') }
|
@@ -73,7 +75,8 @@ describe Rbeapi::Api::Interfaces do
|
|
73
75
|
it 'sets the description value on the interface' do
|
74
76
|
node.config(['interface Port-Channel1', 'no description'])
|
75
77
|
expect(subject.get('Port-Channel1')[:description]).to be_empty
|
76
|
-
expect(subject.set_description('Port-Channel1', value: 'foo bar'))
|
78
|
+
expect(subject.set_description('Port-Channel1', value: 'foo bar'))
|
79
|
+
.to be_truthy
|
77
80
|
expect(subject.get('Port-Channel1')[:description]).to eq('foo bar')
|
78
81
|
end
|
79
82
|
end
|
@@ -95,19 +98,24 @@ describe Rbeapi::Api::Interfaces do
|
|
95
98
|
end
|
96
99
|
|
97
100
|
describe '#set_minimum_links' do
|
98
|
-
before
|
99
|
-
|
101
|
+
before do
|
102
|
+
node.config(['interface Port-Channel1',
|
103
|
+
'port-channel min-links 0'])
|
104
|
+
end
|
100
105
|
|
101
106
|
it 'sets the minimum links value on the interface' do
|
102
107
|
expect(subject.get('Port-Channel1')[:minimum_links]).to eq('0')
|
103
|
-
expect(subject.set_minimum_links('Port-Channel1', value: '2'))
|
108
|
+
expect(subject.set_minimum_links('Port-Channel1', value: '2'))
|
109
|
+
.to be_truthy
|
104
110
|
expect(subject.get('Port-Channel1')[:minimum_links]).to eq('2')
|
105
111
|
end
|
106
112
|
end
|
107
113
|
|
108
114
|
describe '#set_members' do
|
109
|
-
before
|
110
|
-
|
115
|
+
before do
|
116
|
+
node.config(['no interface Port-Channel1',
|
117
|
+
'interface Port-Channel1'])
|
118
|
+
end
|
111
119
|
|
112
120
|
it 'adds new members to the port-channel interface' do
|
113
121
|
node.config(['no interface Port-Channel1', 'interface Port-Channel1'])
|
@@ -118,17 +126,20 @@ describe Rbeapi::Api::Interfaces do
|
|
118
126
|
|
119
127
|
it 'updates the member interfaces on existing interface' do
|
120
128
|
node.config(['no interface Port-Channel1', 'interface Ethernet1-2',
|
121
|
-
|
122
|
-
expect(subject.get('Port-Channel1')[:members]).to eq(
|
123
|
-
|
124
|
-
expect(subject.
|
129
|
+
'channel-group 1 mode on'])
|
130
|
+
expect(subject.get('Port-Channel1')[:members]).to eq(%w(Ethernet1
|
131
|
+
Ethernet2))
|
132
|
+
expect(subject.set_members('Port-Channel1',
|
133
|
+
%w(Ethernet1 Ethernet3))).to be_truthy
|
134
|
+
expect(subject.get('Port-Channel1')[:members]).to eq(%w(Ethernet1
|
135
|
+
Ethernet3))
|
125
136
|
end
|
126
137
|
end
|
127
138
|
|
128
139
|
describe '#set_lacp_mode' do
|
129
140
|
it 'sets the lacp mode on the port-channel to active' do
|
130
141
|
node.config(['no interface Port-Channel1', 'interface Ethernet1-3',
|
131
|
-
|
142
|
+
'channel-group 1 mode on'])
|
132
143
|
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('on')
|
133
144
|
expect(subject.set_lacp_mode('Port-Channel1', 'active')).to be_truthy
|
134
145
|
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('active')
|
@@ -136,7 +147,7 @@ describe Rbeapi::Api::Interfaces do
|
|
136
147
|
|
137
148
|
it 'sets the lacp mode on the port-channel to passive' do
|
138
149
|
node.config(['no interface Port-Channel1', 'interface Ethernet1-3',
|
139
|
-
|
150
|
+
'channel-group 1 mode on'])
|
140
151
|
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('on')
|
141
152
|
expect(subject.set_lacp_mode('Port-Channel1', 'passive')).to be_truthy
|
142
153
|
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('passive')
|
@@ -144,7 +155,7 @@ describe Rbeapi::Api::Interfaces do
|
|
144
155
|
|
145
156
|
it 'sets the lacp mode on the port-channel to on' do
|
146
157
|
node.config(['no interface Port-Channel1', 'interface Ethernet1-3',
|
147
|
-
|
158
|
+
'channel-group 1 mode active'])
|
148
159
|
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('active')
|
149
160
|
expect(subject.set_lacp_mode('Port-Channel1', 'on')).to be_truthy
|
150
161
|
expect(subject.get('Port-Channel1')[:lacp_mode]).to eq('on')
|
@@ -155,34 +166,40 @@ describe Rbeapi::Api::Interfaces do
|
|
155
166
|
it 'sets the lacp fallback on the port-channel to static' do
|
156
167
|
node.config(['interface Port-Channel1', 'no port-channel lacp fallback'])
|
157
168
|
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('disabled')
|
158
|
-
expect(subject.set_lacp_fallback('Port-Channel1', value: 'static'))
|
169
|
+
expect(subject.set_lacp_fallback('Port-Channel1', value: 'static'))
|
170
|
+
.to be_truthy
|
159
171
|
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('static')
|
160
172
|
end
|
161
173
|
|
162
174
|
it 'sets the lacp fallback on the port-channel to individual' do
|
163
175
|
node.config(['interface Port-Channel1', 'no port-channel lacp fallback'])
|
164
176
|
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('disabled')
|
165
|
-
expect(subject.set_lacp_fallback('Port-Channel1', value: 'individual'))
|
177
|
+
expect(subject.set_lacp_fallback('Port-Channel1', value: 'individual'))
|
178
|
+
.to be_truthy
|
166
179
|
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('individual')
|
167
180
|
end
|
168
181
|
|
169
182
|
it 'sets the lacp fallback on the port-channel to disabled' do
|
170
|
-
node.config(['interface Port-Channel1',
|
183
|
+
node.config(['interface Port-Channel1',
|
184
|
+
'port-channel lacp fallback static'])
|
171
185
|
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('static')
|
172
|
-
expect(subject.set_lacp_fallback('Port-Channel1', value: 'disabled'))
|
186
|
+
expect(subject.set_lacp_fallback('Port-Channel1', value: 'disabled'))
|
187
|
+
.to be_truthy
|
173
188
|
expect(subject.get('Port-Channel1')[:lacp_fallback]).to eq('disabled')
|
174
189
|
end
|
175
190
|
end
|
176
191
|
|
177
192
|
describe '#set_lacp_timeout' do
|
178
|
-
before
|
179
|
-
|
193
|
+
before do
|
194
|
+
node.config(['interface Port-Channel1',
|
195
|
+
'default port-channel lacp fallback timeout'])
|
196
|
+
end
|
180
197
|
|
181
198
|
it 'sets the lacp fallback timeout value on the interface' do
|
182
199
|
expect(subject.get('Port-Channel1')[:lacp_timeout]).to eq('90')
|
183
|
-
expect(subject.set_lacp_timeout('Port-Channel1', value: '100'))
|
200
|
+
expect(subject.set_lacp_timeout('Port-Channel1', value: '100'))
|
201
|
+
.to be_truthy
|
184
202
|
expect(subject.get('Port-Channel1')[:lacp_timeout]).to eq('100')
|
185
203
|
end
|
186
204
|
end
|
187
205
|
end
|
188
|
-
|
@@ -12,10 +12,10 @@ describe Rbeapi::Api::Interfaces do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#get' do
|
15
|
-
|
16
15
|
let(:entity) do
|
17
16
|
{ name: 'Vxlan1', type: 'vxlan', description: '', shutdown: false,
|
18
|
-
source_interface: '', multicast_group: ''
|
17
|
+
source_interface: '', multicast_group: '', udp_port: 4789,
|
18
|
+
flood_list: [], vlans: {} }
|
19
19
|
end
|
20
20
|
|
21
21
|
before { node.config(['no interface Vxlan1', 'interface Vxlan1']) }
|
@@ -35,7 +35,7 @@ describe Rbeapi::Api::Interfaces do
|
|
35
35
|
it 'returns a hash collection' do
|
36
36
|
expect(subject.getall).to be_a_kind_of(Hash)
|
37
37
|
end
|
38
|
-
|
38
|
+
end
|
39
39
|
|
40
40
|
describe '#create' do
|
41
41
|
before { node.config('no interface Vxlan1') }
|
@@ -97,7 +97,8 @@ describe Rbeapi::Api::Interfaces do
|
|
97
97
|
|
98
98
|
it 'sets the source interface value on the interface' do
|
99
99
|
expect(subject.get('Vxlan1')[:source_interface]).to be_empty
|
100
|
-
expect(subject.set_source_interface('Vxlan1', value: 'Loopback0'))
|
100
|
+
expect(subject.set_source_interface('Vxlan1', value: 'Loopback0'))
|
101
|
+
.to be_truthy
|
101
102
|
expect(subject.get('Vxlan1')[:source_interface]).to eq('Loopback0')
|
102
103
|
end
|
103
104
|
end
|
@@ -107,9 +108,9 @@ describe Rbeapi::Api::Interfaces do
|
|
107
108
|
|
108
109
|
it 'sets the multicast group value on the interface' do
|
109
110
|
expect(subject.get('Vxlan1')[:multicast_group]).to be_empty
|
110
|
-
expect(subject.set_multicast_group('Vxlan1', value: '239.10.10.10'))
|
111
|
+
expect(subject.set_multicast_group('Vxlan1', value: '239.10.10.10'))
|
112
|
+
.to be_truthy
|
111
113
|
expect(subject.get('Vxlan1')[:multicast_group]).to eq('239.10.10.10')
|
112
114
|
end
|
113
115
|
end
|
114
116
|
end
|
115
|
-
|
@@ -12,13 +12,14 @@ describe Rbeapi::Api::Ipinterfaces do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#get' do
|
15
|
-
|
16
15
|
let(:entity) do
|
17
|
-
{ address: '
|
16
|
+
{ address: '77.99.99.99/24', mtu: '1500', helper_addresses: [] }
|
18
17
|
end
|
19
18
|
|
20
|
-
before
|
21
|
-
|
19
|
+
before do
|
20
|
+
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
21
|
+
'no switchport', 'ip address 77.99.99.99/24'])
|
22
|
+
end
|
22
23
|
|
23
24
|
it 'returns the ipinterface resource' do
|
24
25
|
expect(subject.get('Ethernet1')).to eq(entity)
|
@@ -26,8 +27,10 @@ describe Rbeapi::Api::Ipinterfaces do
|
|
26
27
|
end
|
27
28
|
|
28
29
|
describe '#getall' do
|
29
|
-
before
|
30
|
-
|
30
|
+
before do
|
31
|
+
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
32
|
+
'no switchport', 'ip address 77.99.99.99/24'])
|
33
|
+
end
|
31
34
|
|
32
35
|
it 'returns the ipinterface collection' do
|
33
36
|
expect(subject.getall).to include('Ethernet1')
|
@@ -36,7 +39,7 @@ describe Rbeapi::Api::Ipinterfaces do
|
|
36
39
|
it 'returns a hash collection' do
|
37
40
|
expect(subject.getall).to be_a_kind_of(Hash)
|
38
41
|
end
|
39
|
-
|
42
|
+
end
|
40
43
|
|
41
44
|
describe '#create' do
|
42
45
|
before { node.config(['interface Ethernet1', 'switchport']) }
|
@@ -49,8 +52,10 @@ describe Rbeapi::Api::Ipinterfaces do
|
|
49
52
|
end
|
50
53
|
|
51
54
|
describe '#delete' do
|
52
|
-
before
|
53
|
-
|
55
|
+
before do
|
56
|
+
node.config(['interface Ethernet1', 'no switchport',
|
57
|
+
'ip address 77.99.99.99/24'])
|
58
|
+
end
|
54
59
|
|
55
60
|
it 'deletes a ipinterface resource' do
|
56
61
|
expect(subject.get('Ethernet1')).not_to be_nil
|
@@ -60,19 +65,24 @@ describe Rbeapi::Api::Ipinterfaces do
|
|
60
65
|
end
|
61
66
|
|
62
67
|
describe '#set_address' do
|
63
|
-
before
|
64
|
-
|
68
|
+
before do
|
69
|
+
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
70
|
+
'no switchport'])
|
71
|
+
end
|
65
72
|
|
66
73
|
it 'sets the address value' do
|
67
74
|
expect(subject.get('Ethernet1')[:address]).to be_empty
|
68
|
-
expect(subject.set_address('Ethernet1', value: '
|
69
|
-
|
75
|
+
expect(subject.set_address('Ethernet1', value: '77.99.99.99/24'))
|
76
|
+
.to be_truthy
|
77
|
+
expect(subject.get('Ethernet1')[:address]).to eq('77.99.99.99/24')
|
70
78
|
end
|
71
79
|
end
|
72
80
|
|
73
81
|
describe '#set_mtu' do
|
74
|
-
before
|
75
|
-
|
82
|
+
before do
|
83
|
+
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
84
|
+
'no switchport'])
|
85
|
+
end
|
76
86
|
|
77
87
|
it 'sets the mtu value on the interface' do
|
78
88
|
expect(subject.get('Ethernet1')[:mtu]).to eq('1500')
|
@@ -82,16 +92,19 @@ describe Rbeapi::Api::Ipinterfaces do
|
|
82
92
|
end
|
83
93
|
|
84
94
|
describe '#set_helper_addresses' do
|
85
|
-
before
|
86
|
-
|
95
|
+
before do
|
96
|
+
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
97
|
+
'no switchport', 'ip address 77.99.99.99/24'])
|
98
|
+
end
|
87
99
|
|
88
|
-
let(:helpers) { %w(
|
100
|
+
let(:helpers) { %w(77.99.99.98 77.99.99.97) }
|
89
101
|
|
90
102
|
it 'sets the helper addresses on the interface' do
|
91
103
|
expect(subject.get('Ethernet1')[:helper_addresses]).to be_empty
|
92
|
-
expect(subject.set_helper_addresses('Ethernet1', value: helpers))
|
93
|
-
|
104
|
+
expect(subject.set_helper_addresses('Ethernet1', value: helpers))
|
105
|
+
.to be_truthy
|
106
|
+
expect(subject.get('Ethernet1')[:helper_addresses].sort)
|
107
|
+
.to eq(helpers.sort)
|
94
108
|
end
|
95
109
|
end
|
96
110
|
end
|
97
|
-
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
require 'rbeapi/client'
|
4
4
|
require 'rbeapi/api/mlag'
|
5
5
|
|
6
|
-
describe Rbeapi::Api::
|
6
|
+
describe Rbeapi::Api::Mlag do
|
7
7
|
subject { described_class.new(node) }
|
8
8
|
|
9
9
|
let(:node) do
|
@@ -12,15 +12,14 @@ describe Rbeapi::Api::MlagInterfaces do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#get' do
|
15
|
-
|
16
15
|
let(:entity) do
|
17
|
-
{ mlag_id:
|
16
|
+
{ mlag_id: 1 }
|
18
17
|
end
|
19
18
|
|
20
19
|
before { node.config(['interface Port-Channel1', 'mlag 1']) }
|
21
20
|
|
22
21
|
it 'returns the mlag interface resource' do
|
23
|
-
expect(subject.get
|
22
|
+
expect(subject.get[:interfaces]['Port-Channel1']).to eq(entity)
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
@@ -28,53 +27,31 @@ describe Rbeapi::Api::MlagInterfaces do
|
|
28
27
|
before { node.config(['interface Port-Channel1', 'mlag 1']) }
|
29
28
|
|
30
29
|
it 'returns the interface collection' do
|
31
|
-
expect(subject.
|
30
|
+
expect(subject.get[:interfaces]).to include('Port-Channel1')
|
32
31
|
end
|
33
32
|
|
34
33
|
it 'returns a hash collection' do
|
35
|
-
expect(subject.
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#create' do
|
40
|
-
before { node.config(['interface Port-Channel1', 'no mlag']) }
|
41
|
-
|
42
|
-
it 'creates a new mlag interface resource' do
|
43
|
-
expect(subject.get('Port-Channel1')).to be_nil
|
44
|
-
expect(subject.create('Port-Channel1', '1')).to be_truthy
|
45
|
-
expect(subject.get('Port-Channel1')).not_to be_nil
|
34
|
+
expect(subject.get[:interfaces]).to be_a_kind_of(Hash)
|
46
35
|
end
|
47
36
|
end
|
48
37
|
|
49
|
-
describe '#
|
50
|
-
before { node.config(['interface Port-Channel1', 'mlag
|
38
|
+
describe '#set_mlag_id' do
|
39
|
+
before { node.config(['interface Port-Channel1', 'no mlag']) }
|
51
40
|
|
52
|
-
it '
|
53
|
-
expect(subject.get
|
54
|
-
expect(subject.
|
55
|
-
expect(subject.get
|
41
|
+
it 'sets mlag_id on Port-Channel1' do
|
42
|
+
expect(subject.get[:interfaces]['Port-Channel1']).to be_nil
|
43
|
+
expect(subject.set_mlag_id('Port-Channel1', value: '1')).to be_truthy
|
44
|
+
expect(subject.get[:interfaces]['Port-Channel1'][:mlag_id]).to eq(1)
|
56
45
|
end
|
57
46
|
end
|
58
47
|
|
59
|
-
describe '#default' do
|
48
|
+
describe '#set_mlag_id default' do
|
60
49
|
before { node.config(['interface Port-Channel1', 'mlag 1']) }
|
61
50
|
|
62
51
|
it 'sets Port-Channel1 to default' do
|
63
|
-
expect(subject.get
|
64
|
-
expect(subject.
|
65
|
-
expect(subject.get
|
52
|
+
expect(subject.get[:interfaces]['Port-Channel1']).not_to be_nil
|
53
|
+
expect(subject.set_mlag_id('Port-Channel1', default: true)).to be_truthy
|
54
|
+
expect(subject.get[:interfaces]['Port-Channel1']).to be_nil
|
66
55
|
end
|
67
56
|
end
|
68
|
-
|
69
|
-
describe '#set_mlag_id' do
|
70
|
-
before { node.config(['interface Port-Channel1', 'no mlag']) }
|
71
|
-
|
72
|
-
it 'sets Port-Channel1 to default' do
|
73
|
-
expect(subject.get('Port-Channel1')).to be_nil
|
74
|
-
expect(subject.set_mlag_id('Port-Channel1', value: '1')).to be_truthy
|
75
|
-
expect(subject.get('Port-Channel1')[:mlag_id]).to eq('1')
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
57
|
end
|
80
|
-
|
@@ -12,18 +12,17 @@ describe Rbeapi::Api::Mlag do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#get' do
|
15
|
-
|
16
|
-
|
17
|
-
[ :domain_id, :local_interface, :peer_address, :peer_link, :shutdown,
|
18
|
-
:interfaces ]
|
15
|
+
let(:global_keys) do
|
16
|
+
[:domain_id, :local_interface, :peer_address, :peer_link, :shutdown]
|
19
17
|
end
|
20
18
|
|
21
19
|
before { node.config('default mlag configuration') }
|
22
20
|
|
23
|
-
it 'contains all required keys' do
|
24
|
-
|
25
|
-
expect(subject.get).to include(key)
|
21
|
+
it 'contains all required global keys' do
|
22
|
+
global_keys.each do |key|
|
23
|
+
expect(subject.get[:global]).to include(key)
|
26
24
|
end
|
25
|
+
expect(subject.get).to include(:interfaces)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
@@ -31,9 +30,9 @@ describe Rbeapi::Api::Mlag do
|
|
31
30
|
before { node.config('default mlag configuration') }
|
32
31
|
|
33
32
|
it 'configures the mlag domain-id value' do
|
34
|
-
expect(subject.get[:domain_id]).to be_empty
|
33
|
+
expect(subject.get[:global][:domain_id]).to be_empty
|
35
34
|
expect(subject.set_domain_id(value: 'foo')).to be_truthy
|
36
|
-
expect(subject.get[:domain_id]).to eq('foo')
|
35
|
+
expect(subject.get[:global][:domain_id]).to eq('foo')
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -41,54 +40,51 @@ describe Rbeapi::Api::Mlag do
|
|
41
40
|
before { node.config(['default mlag configuration', 'interface vlan4094']) }
|
42
41
|
|
43
42
|
it 'configures the mlag local interface value' do
|
44
|
-
expect(subject.get[:local_interface]).to be_empty
|
43
|
+
expect(subject.get[:global][:local_interface]).to be_empty
|
45
44
|
expect(subject.set_local_interface(value: 'Vlan4094')).to be_truthy
|
46
|
-
expect(subject.get[:local_interface]).to eq('Vlan4094')
|
45
|
+
expect(subject.get[:global][:local_interface]).to eq('Vlan4094')
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
49
|
describe '#set_peer_link' do
|
51
|
-
before
|
52
|
-
|
50
|
+
before do
|
51
|
+
node.config(['default mlag configuration',
|
52
|
+
'default interface Ethernet1'])
|
53
|
+
end
|
53
54
|
|
54
55
|
it 'configures the mlag peer link value' do
|
55
|
-
expect(subject.get[:peer_link]).to be_empty
|
56
|
+
expect(subject.get[:global][:peer_link]).to be_empty
|
56
57
|
expect(subject.set_peer_link(value: 'Ethernet1')).to be_truthy
|
57
|
-
expect(subject.get[:peer_link]).to eq('Ethernet1')
|
58
|
+
expect(subject.get[:global][:peer_link]).to eq('Ethernet1')
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
62
|
describe '#set_peer_address' do
|
62
|
-
before
|
63
|
-
|
63
|
+
before do
|
64
|
+
node.config(['default mlag configuration',
|
65
|
+
'default interface Ethernet1'])
|
66
|
+
end
|
64
67
|
|
65
68
|
it 'configures the mlag peer address value' do
|
66
|
-
expect(subject.get[:peer_address]).to be_empty
|
69
|
+
expect(subject.get[:global][:peer_address]).to be_empty
|
67
70
|
expect(subject.set_peer_address(value: '1.1.1.1')).to be_truthy
|
68
|
-
expect(subject.get[:peer_address]).to eq('1.1.1.1')
|
71
|
+
expect(subject.get[:global][:peer_address]).to eq('1.1.1.1')
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
75
|
describe '#set_shutdown' do
|
73
76
|
it 'configures mlag to be enabled' do
|
74
77
|
node.config(['mlag configuration', 'shutdown'])
|
75
|
-
expect(subject.get[:shutdown]).to be_truthy
|
78
|
+
expect(subject.get[:global][:shutdown]).to be_truthy
|
76
79
|
expect(subject.set_shutdown(value: false)).to be_truthy
|
77
|
-
expect(subject.get[:shutdown]).to be_falsy
|
80
|
+
expect(subject.get[:global][:shutdown]).to be_falsy
|
78
81
|
end
|
79
82
|
|
80
83
|
it 'configures mlag to be disabled' do
|
81
84
|
node.config(['mlag configuration', 'no shutdown'])
|
82
|
-
expect(subject.get[:shutdown]).to be_falsy
|
85
|
+
expect(subject.get[:global][:shutdown]).to be_falsy
|
83
86
|
expect(subject.set_shutdown(value: true)).to be_truthy
|
84
|
-
expect(subject.get[:shutdown]).to be_truthy
|
87
|
+
expect(subject.get[:global][:shutdown]).to be_truthy
|
85
88
|
end
|
86
89
|
end
|
87
|
-
|
88
|
-
describe '#interfaces' do
|
89
|
-
it 'is a kind of MlagInterfaces' do
|
90
|
-
expect(subject.interfaces).to be_a_kind_of(Rbeapi::Api::MlagInterfaces)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
90
|
end
|