rbeapi 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +25 -2
- data/Gemfile +13 -7
- data/Rakefile +8 -7
- data/lib/rbeapi/api/alias.rb +160 -0
- data/lib/rbeapi/api/bgp.rb +9 -9
- data/lib/rbeapi/api/dns.rb +3 -1
- data/lib/rbeapi/api/interfaces.rb +194 -32
- data/lib/rbeapi/api/ipinterfaces.rb +5 -3
- data/lib/rbeapi/api/managementdefaults.rb +119 -0
- data/lib/rbeapi/api/mlag.rb +6 -6
- data/lib/rbeapi/api/ntp.rb +1 -1
- data/lib/rbeapi/api/ospf.rb +171 -12
- data/lib/rbeapi/api/prefixlists.rb +19 -9
- data/lib/rbeapi/api/radius.rb +5 -5
- data/lib/rbeapi/api/routemaps.rb +12 -12
- data/lib/rbeapi/api/snmp.rb +6 -4
- data/lib/rbeapi/api/stp.rb +24 -24
- data/lib/rbeapi/api/switchports.rb +15 -9
- data/lib/rbeapi/api/tacacs.rb +1 -1
- data/lib/rbeapi/api/users.rb +4 -4
- data/lib/rbeapi/api/varp.rb +7 -3
- data/lib/rbeapi/api/vlans.rb +2 -2
- data/lib/rbeapi/api/vrrp.rb +61 -61
- data/lib/rbeapi/client.rb +9 -6
- data/lib/rbeapi/eapilib.rb +3 -3
- data/lib/rbeapi/netdev/snmp.rb +8 -6
- data/lib/rbeapi/switchconfig.rb +9 -10
- data/lib/rbeapi/version.rb +1 -1
- data/spec/support/fixtures.rb +4 -4
- data/spec/support/matchers/switch_config_sections.rb +2 -2
- data/spec/system/rbeapi/api/acl_spec.rb +2 -4
- data/spec/system/rbeapi/api/alias_spec.rb +168 -0
- data/spec/system/rbeapi/api/bgp_spec.rb +1 -2
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +7 -8
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +36 -3
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +35 -3
- data/spec/system/rbeapi/api/interfaces_vlan_spec.rb +90 -0
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +3 -4
- data/spec/system/rbeapi/api/managementdefaults_spec.rb +31 -0
- data/spec/system/rbeapi/api/ospf_interfaces_spec.rb +36 -11
- data/spec/system/rbeapi/api/ospf_spec.rb +240 -17
- data/spec/system/rbeapi/api/prefixlists_spec.rb +105 -89
- data/spec/system/rbeapi/api/routemaps_spec.rb +15 -10
- data/spec/system/rbeapi/api/users_spec.rb +4 -5
- data/spec/system/rbeapi/api/vrrp_spec.rb +2 -5
- data/spec/system/rbeapi/client_spec.rb +1 -2
- data/spec/unit/rbeapi/api/acl/default_spec.rb +1 -2
- data/spec/unit/rbeapi/api/alias/default_spec.rb +119 -0
- data/spec/unit/rbeapi/api/alias/fixture_alias.text +3 -0
- data/spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb +1 -2
- data/spec/unit/rbeapi/api/bgp/bgp_spec.rb +1 -2
- data/spec/unit/rbeapi/api/interfaces/base_spec.rb +1 -1
- data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +35 -1
- data/spec/unit/rbeapi/api/interfaces/fixture_interfaces.text +68 -0
- data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +41 -4
- data/spec/unit/rbeapi/api/interfaces/vlan_spec.rb +72 -0
- data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +2 -2
- data/spec/unit/rbeapi/api/managementdefaults/default_spec.rb +50 -0
- data/spec/unit/rbeapi/api/managementdefaults/fixture_managementdefaults.yaml +1 -0
- data/spec/unit/rbeapi/api/prefixlists/default_spec.rb +98 -80
- data/spec/unit/rbeapi/api/prefixlists/fixture_prefixlists.text +9 -4
- data/spec/unit/rbeapi/api/users/default_spec.rb +2 -4
- data/spec/unit/rbeapi/api/vrrp/default_spec.rb +2 -5
- data/spec/unit/rbeapi/client_spec.rb +21 -14
- data/spec/unit/rbeapi/switchconfig_spec.rb +10 -3
- metadata +49 -59
@@ -14,8 +14,8 @@ describe Rbeapi::Api::Interfaces do
|
|
14
14
|
|
15
15
|
describe '#get' do
|
16
16
|
let(:entity) do
|
17
|
-
{ name: 'Ethernet1', type: 'ethernet', description: '',
|
18
|
-
load_interval: '', speed: 'default', sflow: true,
|
17
|
+
{ name: 'Ethernet1', type: 'ethernet', description: '', encapsulation: '',
|
18
|
+
shutdown: false, load_interval: '', speed: 'default', sflow: true,
|
19
19
|
flowcontrol_send: 'off', flowcontrol_receive: 'off',
|
20
20
|
lacp_priority: '32768' }
|
21
21
|
end
|
@@ -45,12 +45,33 @@ describe Rbeapi::Api::Interfaces do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
describe '#create' do
|
49
|
+
before { node.config('no interface Ethernet1.1') }
|
50
|
+
|
51
|
+
it 'creates a new ethernet subinterface' do
|
52
|
+
expect(subject.get('Ethernet1.1')).to be_nil
|
53
|
+
expect(subject.create('Ethernet1.1')).to be_truthy
|
54
|
+
expect(subject.get('Ethernet1.1')).not_to be_nil
|
55
|
+
node.config(['no interface Ethernet1.1'])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
48
59
|
describe '#delete' do
|
49
60
|
it 'raises an error on create' do
|
50
61
|
expect { subject.create('Ethernet1') }.to raise_error(NotImplementedError)
|
51
62
|
end
|
52
63
|
end
|
53
64
|
|
65
|
+
describe '#delete' do
|
66
|
+
before { node.config(['interface Ethernet1.1']) }
|
67
|
+
|
68
|
+
it 'deletes an ethernet subinterface resource' do
|
69
|
+
expect(subject.get('Ethernet1.1')).not_to be_nil
|
70
|
+
expect(subject.delete('Ethernet1.1')).to be_truthy
|
71
|
+
expect(subject.get('Ethernet1.1')).to be_nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
54
75
|
describe '#default' do
|
55
76
|
before { node.config(['interface Ethernet1', :shutdown]) }
|
56
77
|
|
@@ -71,6 +92,17 @@ describe Rbeapi::Api::Interfaces do
|
|
71
92
|
end
|
72
93
|
end
|
73
94
|
|
95
|
+
describe '#set_encapsulation' do
|
96
|
+
it 'sets the encapsulation value on the interface' do
|
97
|
+
node.config(['interface Ethernet1.1', 'no encapsulation dot1q vlan'])
|
98
|
+
expect(subject.get('Ethernet1.1')[:encapsulation]).to be_empty
|
99
|
+
expect(subject.set_encapsulation('Ethernet1.1', value: '10'))
|
100
|
+
.to be_truthy
|
101
|
+
expect(subject.get('Ethernet1.1')[:encapsulation]).to eq('10')
|
102
|
+
node.config(['no interface Ethernet1.1'])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
74
106
|
describe '#set_shutdown' do
|
75
107
|
it 'shutdown the interface' do
|
76
108
|
node.config(['interface Ethernet1', 'no shutdown'])
|
@@ -91,7 +123,8 @@ describe Rbeapi::Api::Interfaces do
|
|
91
123
|
before { node.config(['default interface Ethernet1']) }
|
92
124
|
|
93
125
|
it 'sets enable true' do
|
94
|
-
expect(subject.set_speed('Ethernet1',
|
126
|
+
expect(subject.set_speed('Ethernet1', default: false,
|
127
|
+
enable: true)).to be_falsy
|
95
128
|
end
|
96
129
|
end
|
97
130
|
|
@@ -14,9 +14,9 @@ describe Rbeapi::Api::Interfaces do
|
|
14
14
|
describe '#get' do
|
15
15
|
let(:entity) do
|
16
16
|
{ name: 'Port-Channel1', type: 'portchannel', description: '',
|
17
|
-
shutdown: false, load_interval: '', members: [],
|
18
|
-
minimum_links: '0',
|
19
|
-
|
17
|
+
encapsulation: '', shutdown: false, load_interval: '', members: [],
|
18
|
+
lacp_mode: 'on', minimum_links: '0', lacp_timeout: '90',
|
19
|
+
lacp_fallback: 'disabled' }
|
20
20
|
end
|
21
21
|
|
22
22
|
before do
|
@@ -52,6 +52,17 @@ describe Rbeapi::Api::Interfaces do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
describe '#create' do
|
56
|
+
before { node.config('no interface Port-Channel1.1') }
|
57
|
+
|
58
|
+
it 'creates a new subinterface resource' do
|
59
|
+
expect(subject.get('Port-Channel1.1')).to be_nil
|
60
|
+
expect(subject.create('Port-Channel1.1')).to be_truthy
|
61
|
+
expect(subject.get('Port-Channel1.1')).not_to be_nil
|
62
|
+
node.config(['no interface Port-Channel1.1'])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
55
66
|
describe '#delete' do
|
56
67
|
before { node.config(['interface Port-Channel1']) }
|
57
68
|
|
@@ -62,6 +73,16 @@ describe Rbeapi::Api::Interfaces do
|
|
62
73
|
end
|
63
74
|
end
|
64
75
|
|
76
|
+
describe '#delete' do
|
77
|
+
before { node.config(['interface Port-Channel1.1']) }
|
78
|
+
|
79
|
+
it 'deletes a switchport subinterface resource' do
|
80
|
+
## expect(subject.get('Port-Channel1.1')).not_to be_nil
|
81
|
+
expect(subject.delete('Port-Channel1.1')).to be_truthy
|
82
|
+
expect(subject.get('Port-Channel1.1')).to be_nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
65
86
|
describe '#default' do
|
66
87
|
before { node.config(['interface Port-Channel1', :shutdown]) }
|
67
88
|
|
@@ -82,6 +103,17 @@ describe Rbeapi::Api::Interfaces do
|
|
82
103
|
end
|
83
104
|
end
|
84
105
|
|
106
|
+
describe '#set_encapsulation' do
|
107
|
+
it 'sets the encapsulation value on the interface' do
|
108
|
+
node.config(['interface Port-Channel1.1', 'no encapsulation dot1q vlan'])
|
109
|
+
expect(subject.get('Port-Channel1.1')[:encapsulation]).to be_empty
|
110
|
+
expect(subject.set_encapsulation('Port-Channel1.1', value: '31'))
|
111
|
+
.to be_truthy
|
112
|
+
expect(subject.get('Port-Channel1.1')[:encapsulation]).to eq('31')
|
113
|
+
node.config(['no interface Port-Channel1.1'])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
85
117
|
describe '#set_shutdown' do
|
86
118
|
it 'shutdown the interface' do
|
87
119
|
node.config(['interface Port-Channel1', 'no shutdown'])
|
@@ -0,0 +1,90 @@
|
|
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
|
+
let(:entity) do
|
16
|
+
{ name: 'Vlan1', type: 'vlan', description: '', shutdown: false,
|
17
|
+
autostate: :true, load_interval: '', encapsulation: '' }
|
18
|
+
end
|
19
|
+
|
20
|
+
before { node.config(['no interface Vlan1', 'interface Vlan1']) }
|
21
|
+
|
22
|
+
it 'returns the interface resource' do
|
23
|
+
expect(subject.get('Vlan1')).to eq(entity)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#getall' do
|
28
|
+
before { node.config(['no interface Vlan1', 'interface Vlan1']) }
|
29
|
+
|
30
|
+
it 'returns the interface collection' do
|
31
|
+
expect(subject.getall).to include('Vlan1')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns a hash collection' do
|
35
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#create' do
|
40
|
+
before { node.config('no interface Vlan1') }
|
41
|
+
|
42
|
+
it 'creates a new interface resource' do
|
43
|
+
expect(subject.create('Vlan1')).to be_truthy
|
44
|
+
expect(subject.get('Vlan1')).not_to be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#delete' do
|
49
|
+
before { node.config(['interface Vlan1']) }
|
50
|
+
|
51
|
+
it 'deletes a vlan interface resource' do
|
52
|
+
expect(subject.get('Vlan1')).not_to be_nil
|
53
|
+
expect(subject.delete('Vlan1')).to be_truthy
|
54
|
+
expect(subject.get('Vlan1')).to be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#default' do
|
59
|
+
before { node.config(['interface Vlan1', 'shutdown']) }
|
60
|
+
|
61
|
+
it 'sets Vlan1 to default' do
|
62
|
+
expect(subject.get('Vlan1')[:shutdown]).to be_truthy
|
63
|
+
expect(subject.default('Vlan1')).to be_truthy
|
64
|
+
expect(subject.get('Vlan1')[:shutdown]).to be_falsy
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#set_autostate' do
|
69
|
+
it 'sets the autostate value to true' do
|
70
|
+
node.config(['interface Vlan1', 'no autostate'])
|
71
|
+
expect(subject.get('Vlan1')[:autostate]).to eq(:false)
|
72
|
+
expect(subject.set_autostate('Vlan1', value: :true)).to be_truthy
|
73
|
+
expect(subject.get('Vlan1')[:autostate]).to eq(:true)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'sets the autostate value to false' do
|
77
|
+
node.config(['interface Vlan1', 'autostate'])
|
78
|
+
expect(subject.get('Vlan1')[:autostate]).to be_truthy
|
79
|
+
expect(subject.set_autostate('Vlan1', value: :false)).to be_truthy
|
80
|
+
expect(subject.get('Vlan1')[:autostate]).to eq(:false)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'manages autostate default' do
|
84
|
+
node.config(['interface Vlan1', 'no autostate'])
|
85
|
+
expect(subject.get('Vlan1')[:autostate]).to eq(:false)
|
86
|
+
expect(subject.set_autostate('Vlan1', default: :true)).to be_truthy
|
87
|
+
expect(subject.get('Vlan1')[:autostate]).to eq(:true)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -13,10 +13,9 @@ describe Rbeapi::Api::Interfaces do
|
|
13
13
|
|
14
14
|
describe '#get' do
|
15
15
|
let(:entity) do
|
16
|
-
{ name: 'Vxlan1', type: 'vxlan', description: '',
|
17
|
-
load_interval: '',
|
18
|
-
|
19
|
-
flood_list: [], vlans: {} }
|
16
|
+
{ name: 'Vxlan1', type: 'vxlan', description: '', encapsulation: '',
|
17
|
+
shutdown: false, load_interval: '', source_interface: '',
|
18
|
+
multicast_group: '', udp_port: 4789, flood_list: [], vlans: {} }
|
20
19
|
end
|
21
20
|
|
22
21
|
before { node.config(['no interface Vxlan1', 'interface Vxlan1']) }
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/managementdefaults'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Managementdefaults 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
|
+
before { node.config(['management defaults', 'default secret hash']) }
|
16
|
+
|
17
|
+
it 'contains all required settings' do
|
18
|
+
expect(subject.get).to include(:secret_hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#set_secret_hash' do
|
23
|
+
before { node.config(['management defaults', 'default secret hash']) }
|
24
|
+
|
25
|
+
it 'configures the management defaults secret hash value' do
|
26
|
+
expect(subject.get[:secret_hash]).to eq('md5')
|
27
|
+
expect(subject.set_secret_hash(value: 'sha512')).to be_truthy
|
28
|
+
expect(subject.get[:secret_hash]).to eq('sha512')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -14,11 +14,15 @@ describe Rbeapi::Api::OspfInterfaces do
|
|
14
14
|
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
15
15
|
'no switchport', 'ip address 88.99.99.99/24',
|
16
16
|
'ip ospf network point-to-point',
|
17
|
-
'exit', 'default interface Ethernet2'
|
17
|
+
'exit', 'default interface Ethernet2',
|
18
|
+
'no interface Vlan99', 'interface Vlan99',
|
19
|
+
'ip address 99.9.9.9/24', 'ip ospf network point-to-point',
|
20
|
+
'exit'])
|
18
21
|
end
|
19
22
|
|
20
23
|
it 'returns an ospf interface resource instance' do
|
21
24
|
expect(subject.get('Ethernet1')).not_to be_nil
|
25
|
+
expect(subject.get('Vlan99')).not_to be_nil
|
22
26
|
end
|
23
27
|
|
24
28
|
it 'returns nil for a switchport interface' do
|
@@ -29,16 +33,21 @@ describe Rbeapi::Api::OspfInterfaces do
|
|
29
33
|
describe '#getall' do
|
30
34
|
before do
|
31
35
|
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
32
|
-
'no switchport', 'ip address 88.99.99.99/24',
|
33
|
-
'
|
36
|
+
'no switchport', 'ip address 88.99.99.99/24',
|
37
|
+
'ip ospf network point-to-point',
|
38
|
+
'exit', 'default interface Ethernet2',
|
39
|
+
'no interface Vlan99', 'interface Vlan99',
|
40
|
+
'ip address 99.9.9.9/24', 'ip ospf network point-to-point',
|
41
|
+
'exit'])
|
34
42
|
end
|
35
43
|
|
36
44
|
it 'returns the ospf resource collection' do
|
37
45
|
expect(subject.getall).to be_a_kind_of(Hash)
|
38
46
|
end
|
39
47
|
|
40
|
-
it 'includes an instance of Ethernet1' do
|
48
|
+
it 'includes an instance of Ethernet1 and Vlan99' do
|
41
49
|
expect(subject.getall).to include('Ethernet1')
|
50
|
+
expect(subject.getall).to include('Vlan99')
|
42
51
|
end
|
43
52
|
|
44
53
|
it 'does not include an instance of Ethernet2' do
|
@@ -49,30 +58,46 @@ describe Rbeapi::Api::OspfInterfaces do
|
|
49
58
|
describe '#set_network_type' do
|
50
59
|
before do
|
51
60
|
node.config(['default interface Ethernet1', 'interface Ethernet1',
|
52
|
-
'no switchport', 'ip address 88.99.99.99/24', 'exit'
|
61
|
+
'no switchport', 'ip address 88.99.99.99/24', 'exit',
|
62
|
+
'no interface Vlan99', 'interface Vlan99',
|
63
|
+
'ip address 99.9.9.9/24', 'exit'])
|
53
64
|
end
|
54
65
|
|
55
66
|
it 'configures the ospf interface type to point-to-point' do
|
56
|
-
expect(subject.get('Ethernet1')[
|
67
|
+
expect(subject.get('Ethernet1')[:network_type]).to eq('broadcast')
|
57
68
|
expect(subject.set_network_type('Ethernet1', value: 'point-to-point'))
|
58
69
|
.to be_truthy
|
59
|
-
expect(subject.get('Ethernet1')[
|
70
|
+
expect(subject.get('Ethernet1')[:network_type]).to eq('point-to-point')
|
71
|
+
expect(subject.get('Vlan99')[:network_type]).to eq('broadcast')
|
72
|
+
expect(subject.set_network_type('Vlan99', value: 'point-to-point'))
|
73
|
+
.to be_truthy
|
74
|
+
expect(subject.get('Vlan99')[:network_type]).to eq('point-to-point')
|
60
75
|
end
|
61
76
|
|
62
77
|
it 'negates the ospf interface type' do
|
63
78
|
expect(subject.set_network_type('Ethernet1', value: 'point-to-point'))
|
64
79
|
.to be_truthy
|
65
|
-
expect(subject.get('Ethernet1')[
|
80
|
+
expect(subject.get('Ethernet1')[:network_type]).to eq('point-to-point')
|
66
81
|
expect(subject.set_network_type('Ethernet1', enable: false)).to be_truthy
|
67
|
-
expect(subject.get('Ethernet1')[
|
82
|
+
expect(subject.get('Ethernet1')[:network_type]).to eq('broadcast')
|
83
|
+
expect(subject.set_network_type('Vlan99', value: 'point-to-point'))
|
84
|
+
.to be_truthy
|
85
|
+
expect(subject.get('Vlan99')[:network_type]).to eq('point-to-point')
|
86
|
+
expect(subject.set_network_type('Vlan99', enable: false)).to be_truthy
|
87
|
+
expect(subject.get('Vlan99')[:network_type]).to eq('broadcast')
|
68
88
|
end
|
69
89
|
|
70
90
|
it 'defaults the ospf interface type' do
|
71
91
|
expect(subject.set_network_type('Ethernet1', value: 'point-to-point'))
|
72
92
|
.to be_truthy
|
73
|
-
expect(subject.get('Ethernet1')[
|
93
|
+
expect(subject.get('Ethernet1')[:network_type]).to eq('point-to-point')
|
74
94
|
expect(subject.set_network_type('Ethernet1', default: true)).to be_truthy
|
75
|
-
expect(subject.get('Ethernet1')[
|
95
|
+
expect(subject.get('Ethernet1')[:network_type]).to eq('broadcast')
|
96
|
+
expect(subject.set_network_type('Vlan99', value: 'point-to-point'))
|
97
|
+
.to be_truthy
|
98
|
+
expect(subject.get('Vlan99')[:network_type]).to eq('point-to-point')
|
99
|
+
expect(subject.set_network_type('Vlan99', default: true)).to be_truthy
|
100
|
+
expect(subject.get('Vlan99')[:network_type]).to eq('broadcast')
|
76
101
|
end
|
77
102
|
end
|
78
103
|
end
|
@@ -14,15 +14,25 @@ describe Rbeapi::Api::Ospf do
|
|
14
14
|
node.config(['no router ospf 1',
|
15
15
|
'router ospf 1',
|
16
16
|
'router-id 1.1.1.1',
|
17
|
+
'max-lsa 12000',
|
18
|
+
'maximum-paths 16',
|
19
|
+
'passive-interface default',
|
20
|
+
'no passive-interface Ethernet1',
|
21
|
+
'no passive-interface Ethernet2',
|
17
22
|
'redistribute static route-map word',
|
18
23
|
'network 192.168.10.10/24 area 0.0.0.0',
|
19
24
|
'network 192.168.11.10/24 area 0.0.0.0'])
|
20
25
|
end
|
21
26
|
|
22
27
|
let(:entity) do
|
23
|
-
{
|
24
|
-
|
25
|
-
|
28
|
+
{ router_id: '1.1.1.1',
|
29
|
+
max_lsa: 12_000,
|
30
|
+
maximum_paths: 16,
|
31
|
+
passive_interface_default: true,
|
32
|
+
active_interfaces: %w(Ethernet1 Ethernet2),
|
33
|
+
passive_interfaces: [],
|
34
|
+
areas: { '0.0.0.0' => ['192.168.10.0/24', '192.168.11.0/24'] },
|
35
|
+
redistribute: { 'static' => { route_map: 'word' } } }
|
26
36
|
end
|
27
37
|
|
28
38
|
it 'returns an ospf resource instance' do
|
@@ -39,8 +49,8 @@ describe Rbeapi::Api::Ospf do
|
|
39
49
|
expect(collection).to include('1')
|
40
50
|
end
|
41
51
|
|
42
|
-
it '
|
43
|
-
expect(collection).to include(
|
52
|
+
it 'includes interfaces' do
|
53
|
+
expect(collection).to include(:interfaces)
|
44
54
|
end
|
45
55
|
|
46
56
|
it 'is a kind of hash' do
|
@@ -58,23 +68,203 @@ describe Rbeapi::Api::Ospf do
|
|
58
68
|
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
59
69
|
|
60
70
|
it 'configures the ospf router id to 1.1.1.1' do
|
61
|
-
expect(subject.get('1')[
|
71
|
+
expect(subject.get('1')[:router_id]).to be_empty
|
62
72
|
expect(subject.set_router_id('1', value: '1.1.1.1')).to be_truthy
|
63
|
-
expect(subject.get('1')[
|
73
|
+
expect(subject.get('1')[:router_id]).to eq('1.1.1.1')
|
64
74
|
end
|
65
75
|
|
66
76
|
it 'negates the router id' do
|
67
77
|
expect(subject.set_router_id('1', value: '1.1.1.1')).to be_truthy
|
68
|
-
expect(subject.get('1')[
|
78
|
+
expect(subject.get('1')[:router_id]).to eq('1.1.1.1')
|
69
79
|
expect(subject.set_router_id('1', enable: false)).to be_truthy
|
70
|
-
expect(subject.get('1')[
|
80
|
+
expect(subject.get('1')[:router_id]).to be_empty
|
71
81
|
end
|
72
82
|
|
73
83
|
it 'defaults the router id' do
|
74
84
|
expect(subject.set_router_id('1', value: '1.1.1.1')).to be_truthy
|
75
|
-
expect(subject.get('1')[
|
85
|
+
expect(subject.get('1')[:router_id]).to eq('1.1.1.1')
|
76
86
|
expect(subject.set_router_id('1', default: true)).to be_truthy
|
77
|
-
expect(subject.get('1')[
|
87
|
+
expect(subject.get('1')[:router_id]).to be_empty
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#set_max_lsa' do
|
92
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
93
|
+
|
94
|
+
it 'configures the ospf max-lsa to 24000' do
|
95
|
+
expect(subject.get('1')[:max_lsa]).to eq(12_000)
|
96
|
+
expect(subject.set_max_lsa('1', value: 24_000)).to be_truthy
|
97
|
+
expect(subject.get('1')[:max_lsa]).to eq(24_000)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'negates the max-lsa' do
|
101
|
+
expect(subject.set_max_lsa('1', value: 24_000)).to be_truthy
|
102
|
+
expect(subject.get('1')[:max_lsa]).to eq(24_000)
|
103
|
+
expect(subject.set_max_lsa('1', enable: false)).to be_truthy
|
104
|
+
expect(subject.get('1')[:max_lsa]).to eq(12_000)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'defaults the max-lsa' do
|
108
|
+
expect(subject.set_max_lsa('1', value: 24_000)).to be_truthy
|
109
|
+
expect(subject.get('1')[:max_lsa]).to eq(24_000)
|
110
|
+
expect(subject.set_max_lsa('1', default: true)).to be_truthy
|
111
|
+
expect(subject.get('1')[:max_lsa]).to eq(12_000)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#set_maximum_paths' do
|
116
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
117
|
+
|
118
|
+
it 'configures the ospf maximum-paths to 16' do
|
119
|
+
expect(subject.get('1')[:maximum_paths]).to eq(128)
|
120
|
+
expect(subject.set_maximum_paths('1', value: 16)).to be_truthy
|
121
|
+
expect(subject.get('1')[:maximum_paths]).to eq(16)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'negates the maximum-paths' do
|
125
|
+
expect(subject.set_maximum_paths('1', value: 16)).to be_truthy
|
126
|
+
expect(subject.get('1')[:maximum_paths]).to eq(16)
|
127
|
+
expect(subject.set_maximum_paths('1', enable: false)).to be_truthy
|
128
|
+
expect(subject.get('1')[:maximum_paths]).to eq(128)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'defaults the maximum-paths' do
|
132
|
+
expect(subject.set_maximum_paths('1', value: 16)).to be_truthy
|
133
|
+
expect(subject.get('1')[:maximum_paths]).to eq(16)
|
134
|
+
expect(subject.set_maximum_paths('1', default: true)).to be_truthy
|
135
|
+
expect(subject.get('1')[:maximum_paths]).to eq(128)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#passive_interface_default' do
|
140
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
141
|
+
|
142
|
+
it 'configures the passive-interface default' do
|
143
|
+
expect(subject.get('1')[:passive_interface_default]).to eq(false)
|
144
|
+
expect(subject.set_passive_interface_default('1', value: true))
|
145
|
+
.to be_truthy
|
146
|
+
expect(subject.get('1')[:passive_interface_default]).to eq(true)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'negates the passive-interface default' do
|
150
|
+
expect(subject.set_passive_interface_default('1', value: true))
|
151
|
+
.to be_truthy
|
152
|
+
expect(subject.get('1')[:passive_interface_default]).to eq(true)
|
153
|
+
expect(subject.set_passive_interface_default('1', enable: false))
|
154
|
+
.to be_truthy
|
155
|
+
expect(subject.get('1')[:passive_interface_default]).to eq(false)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'defaults the passive-interface default' do
|
159
|
+
expect(subject.set_passive_interface_default('1', value: true))
|
160
|
+
.to be_truthy
|
161
|
+
expect(subject.get('1')[:passive_interface_default]).to eq(true)
|
162
|
+
expect(subject.set_passive_interface_default('1', default: true))
|
163
|
+
.to be_truthy
|
164
|
+
expect(subject.get('1')[:passive_interface_default]).to eq(false)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe '#set_active_interfaces' do
|
169
|
+
before do
|
170
|
+
node.config(['no router ospf 1', 'router ospf 1',
|
171
|
+
'passive-interface default'])
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'configures the ospf no passive-interface Ethernet1, 2, 3' do
|
175
|
+
expect(subject.get('1')[:active_interfaces]).to be_empty
|
176
|
+
expect(subject.set_active_interfaces('1',
|
177
|
+
value: %w(Ethernet1
|
178
|
+
Ethernet2
|
179
|
+
Ethernet3))).to be_truthy
|
180
|
+
expect(subject.get('1')[:active_interfaces]).to eq(%w(Ethernet1
|
181
|
+
Ethernet2
|
182
|
+
Ethernet3))
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'configures the ospf no passive-interface Ethernet1, 2' do
|
186
|
+
expect(subject.set_active_interfaces('1',
|
187
|
+
value: %w(Ethernet1
|
188
|
+
Ethernet2
|
189
|
+
Ethernet3))).to be_truthy
|
190
|
+
expect(subject.get('1')[:active_interfaces]).to eq(%w(Ethernet1
|
191
|
+
Ethernet2
|
192
|
+
Ethernet3))
|
193
|
+
expect(subject.set_active_interfaces('1',
|
194
|
+
value: %w(Ethernet1
|
195
|
+
Ethernet2))).to be_truthy
|
196
|
+
expect(subject.get('1')[:active_interfaces]).to eq(%w(Ethernet1
|
197
|
+
Ethernet2))
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'negates the no passive-interface' do
|
201
|
+
expect(subject.set_active_interfaces('1',
|
202
|
+
value: %w(Ethernet1
|
203
|
+
Ethernet2))).to be_truthy
|
204
|
+
expect(subject.get('1')[:active_interfaces]).to eq(%w(Ethernet1
|
205
|
+
Ethernet2))
|
206
|
+
expect(subject.set_active_interfaces('1', enable: false)).to be_truthy
|
207
|
+
expect(subject.get('1')[:active_interfaces]).to be_empty
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'defaults the no passive-interface' do
|
211
|
+
expect(subject.set_active_interfaces('1',
|
212
|
+
value: %w(Ethernet1
|
213
|
+
Ethernet2))).to be_truthy
|
214
|
+
expect(subject.get('1')[:active_interfaces]).to eq(%w(Ethernet1
|
215
|
+
Ethernet2))
|
216
|
+
expect(subject.set_active_interfaces('1', default: true)).to be_truthy
|
217
|
+
expect(subject.get('1')[:active_interfaces]).to be_empty
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe '#set_passive_interfaces' do
|
222
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
223
|
+
|
224
|
+
it 'configures the ospf passive-interface Ethernet1, 2, 3' do
|
225
|
+
expect(subject.get('1')[:passive_interfaces]).to be_empty
|
226
|
+
expect(subject.set_passive_interfaces('1',
|
227
|
+
value: %w(Ethernet1
|
228
|
+
Ethernet2
|
229
|
+
Ethernet3))).to be_truthy
|
230
|
+
expect(subject.get('1')[:passive_interfaces]).to eq(%w(Ethernet1
|
231
|
+
Ethernet2
|
232
|
+
Ethernet3))
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'configures the ospf passive-interface Ethernet1, 2' do
|
236
|
+
expect(subject.set_passive_interfaces('1',
|
237
|
+
value: %w(Ethernet1
|
238
|
+
Ethernet2
|
239
|
+
Ethernet3))).to be_truthy
|
240
|
+
expect(subject.get('1')[:passive_interfaces]).to eq(%w(Ethernet1
|
241
|
+
Ethernet2
|
242
|
+
Ethernet3))
|
243
|
+
expect(subject.set_passive_interfaces('1',
|
244
|
+
value: %w(Ethernet1
|
245
|
+
Ethernet2))).to be_truthy
|
246
|
+
expect(subject.get('1')[:passive_interfaces]).to eq(%w(Ethernet1
|
247
|
+
Ethernet2))
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'negates the passive-interface' do
|
251
|
+
expect(subject.set_passive_interfaces('1',
|
252
|
+
value: %w(Ethernet1
|
253
|
+
Ethernet2))).to be_truthy
|
254
|
+
expect(subject.get('1')[:passive_interfaces]).to eq(%w(Ethernet1
|
255
|
+
Ethernet2))
|
256
|
+
expect(subject.set_passive_interfaces('1', enable: false)).to be_truthy
|
257
|
+
expect(subject.get('1')[:passive_interfaces]).to be_empty
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'defaults the passive-interface' do
|
261
|
+
expect(subject.set_passive_interfaces('1',
|
262
|
+
value: %w(Ethernet1
|
263
|
+
Ethernet2))).to be_truthy
|
264
|
+
expect(subject.get('1')[:passive_interfaces]).to eq(%w(Ethernet1
|
265
|
+
Ethernet2))
|
266
|
+
expect(subject.set_passive_interfaces('1', default: true)).to be_truthy
|
267
|
+
expect(subject.get('1')[:passive_interfaces]).to be_empty
|
78
268
|
end
|
79
269
|
end
|
80
270
|
|
@@ -102,10 +292,10 @@ describe Rbeapi::Api::Ospf do
|
|
102
292
|
before { node.config('router ospf 1') }
|
103
293
|
|
104
294
|
it 'adds the network with area to the ospf process' do
|
105
|
-
expect(subject.get('1')[
|
295
|
+
expect(subject.get('1')[:areas]).to be_empty
|
106
296
|
expect(subject.add_network('1', '192.168.10.0/24', '0.0.0.0'))
|
107
297
|
.to be_truthy
|
108
|
-
expect(subject.get('1')[
|
298
|
+
expect(subject.get('1')[:areas]['0.0.0.0']).to include('192.168.10.0/24')
|
109
299
|
end
|
110
300
|
end
|
111
301
|
|
@@ -115,10 +305,10 @@ describe Rbeapi::Api::Ospf do
|
|
115
305
|
end
|
116
306
|
|
117
307
|
it 'removes the network with area to the ospf process' do
|
118
|
-
expect(subject.get('1')[
|
308
|
+
expect(subject.get('1')[:areas]['0.0.0.0']).to include('192.168.10.0/24')
|
119
309
|
expect(subject.remove_network('1', '192.168.10.0/24', '0.0.0.0'))
|
120
310
|
.to be_truthy
|
121
|
-
expect(subject.get('1')[
|
311
|
+
expect(subject.get('1')[:areas]).to be_empty
|
122
312
|
end
|
123
313
|
end
|
124
314
|
|
@@ -126,9 +316,42 @@ describe Rbeapi::Api::Ospf do
|
|
126
316
|
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
127
317
|
|
128
318
|
it 'configures redistribution of static routes' do
|
129
|
-
expect(subject.get('1')[
|
319
|
+
expect(subject.get('1')[:redistribute]).to be_empty
|
320
|
+
expect(subject.set_redistribute('1', 'static')).to be_truthy
|
321
|
+
expect(subject.get('1')[:redistribute])
|
322
|
+
.to eq('static' => { route_map: nil })
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'configures redistribution of static routes with routemap' do
|
130
326
|
expect(subject.set_redistribute('1', 'static')).to be_truthy
|
131
|
-
expect(subject.get('1')[
|
327
|
+
expect(subject.get('1')[:redistribute])
|
328
|
+
.to eq('static' => { route_map: nil })
|
329
|
+
expect(subject.set_redistribute('1', 'static', route_map: 'test'))
|
330
|
+
.to be_truthy
|
331
|
+
expect(subject.get('1')[:redistribute])
|
332
|
+
.to eq('static' => { route_map: 'test' })
|
333
|
+
end
|
334
|
+
|
335
|
+
it 'negates the redistribution' do
|
336
|
+
expect(subject.set_redistribute('1', 'static', route_map: 'test'))
|
337
|
+
.to be_truthy
|
338
|
+
expect(subject.get('1')[:redistribute])
|
339
|
+
.to eq('static' => { route_map: 'test' })
|
340
|
+
expect(subject.set_redistribute('1',
|
341
|
+
'static',
|
342
|
+
enable: false)).to be_truthy
|
343
|
+
expect(subject.get('1')[:redistribute]).to be_empty
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'defaults the redistribution' do
|
347
|
+
expect(subject.set_redistribute('1', 'connected', route_map: 'foo'))
|
348
|
+
.to be_truthy
|
349
|
+
expect(subject.get('1')[:redistribute])
|
350
|
+
.to eq('connected' => { route_map: 'foo' })
|
351
|
+
expect(subject.set_redistribute('1',
|
352
|
+
'connected',
|
353
|
+
default: true)).to be_truthy
|
354
|
+
expect(subject.get('1')[:redistribute]).to be_empty
|
132
355
|
end
|
133
356
|
end
|
134
357
|
end
|