rbeapi 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +16 -0
- data/Gemfile +3 -1
- data/Guardfile +2 -2
- data/README.md +35 -24
- data/Rakefile +48 -18
- data/gems/inifile/inifile.spec.tmpl +50 -14
- data/gems/net_http_unix/net_http_unix.spec.tmpl +48 -15
- data/gems/netaddr/netaddr.spec.tmpl +47 -14
- data/lib/rbeapi/api/bgp.rb +100 -4
- data/lib/rbeapi/api/interfaces.rb +4 -5
- data/lib/rbeapi/api/radius.rb +1 -1
- data/lib/rbeapi/api/routemaps.rb +405 -37
- data/lib/rbeapi/api/system.rb +21 -0
- data/lib/rbeapi/api/users.rb +361 -0
- data/lib/rbeapi/api/varp.rb +50 -22
- data/lib/rbeapi/api/vrrp.rb +1072 -0
- data/lib/rbeapi/client.rb +12 -4
- data/lib/rbeapi/eapilib.rb +1 -1
- data/lib/rbeapi/version.rb +1 -1
- data/rbeapi.spec.tmpl +57 -25
- data/spec/system/rbeapi/api/dns_spec.rb +2 -2
- data/spec/system/rbeapi/api/routemaps_spec.rb +344 -0
- data/spec/system/rbeapi/api/switchports_spec.rb +1 -1
- data/spec/system/rbeapi/api/system_spec.rb +44 -4
- data/spec/system/{api_varp_interfaces_spec.rb → rbeapi/api/varp_interfaces_spec.rb} +25 -16
- data/spec/system/rbeapi/api/varp_spec.rb +76 -0
- data/spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb +2 -0
- data/spec/unit/rbeapi/api/bgp/bgp_spec.rb +54 -1
- data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +1 -1
- data/spec/unit/rbeapi/api/routemaps/default_spec.rb +370 -0
- data/spec/unit/rbeapi/api/routemaps/fixture_routemaps.text +27 -0
- data/spec/unit/rbeapi/api/system/default_spec.rb +102 -0
- data/spec/unit/rbeapi/api/system/fixture_system.text +2 -0
- data/spec/unit/rbeapi/api/users/default_spec.rb +280 -0
- data/spec/unit/rbeapi/api/users/fixture_users.text +4 -0
- data/spec/unit/rbeapi/api/vrrp/default_spec.rb +582 -0
- data/spec/unit/rbeapi/api/vrrp/fixture_vrrp.text +186 -0
- metadata +28 -8
- data/spec/system/api_varp_spec.rb +0 -41
@@ -6,18 +6,21 @@ require 'rbeapi/api/varp'
|
|
6
6
|
describe Rbeapi::Api::VarpInterfaces do
|
7
7
|
subject { described_class.new(node) }
|
8
8
|
|
9
|
-
let(:
|
10
|
-
|
9
|
+
let(:node) do
|
10
|
+
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
11
|
+
Rbeapi::Client.connect_to('dut')
|
12
|
+
end
|
11
13
|
|
12
14
|
describe '#get' do
|
13
15
|
before do
|
14
16
|
node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
15
|
-
'
|
17
|
+
'no interface Vlan99', 'no interface Vlan100',
|
18
|
+
'default interface Vlan100', 'interface Vlan100',
|
16
19
|
'ip address 99.99.99.99/24',
|
17
20
|
'ip virtual-router address 99.99.99.98', 'exit'])
|
18
21
|
end
|
19
22
|
|
20
|
-
it 'returns an instance for
|
23
|
+
it 'returns an instance for Vlan100' do
|
21
24
|
expect(subject.get('Vlan100')).not_to be_nil
|
22
25
|
end
|
23
26
|
|
@@ -29,12 +32,13 @@ describe Rbeapi::Api::VarpInterfaces do
|
|
29
32
|
describe '#getall' do
|
30
33
|
before do
|
31
34
|
node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
32
|
-
'
|
35
|
+
'no interface Vlan99', 'no interface Vlan100',
|
36
|
+
'default interface Vlan100', 'interface Vlan100',
|
33
37
|
'ip address 99.99.99.99/24',
|
34
38
|
'ip virtual-router address 99.99.99.98', 'exit'])
|
35
39
|
end
|
36
40
|
|
37
|
-
it 'returns a collection that includes
|
41
|
+
it 'returns a collection that includes Vlan100' do
|
38
42
|
expect(subject.getall).to include('Vlan100')
|
39
43
|
end
|
40
44
|
|
@@ -46,40 +50,45 @@ describe Rbeapi::Api::VarpInterfaces do
|
|
46
50
|
describe '#set_addresses' do
|
47
51
|
before do
|
48
52
|
node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
49
|
-
'
|
53
|
+
'no interface Vlan99', 'no interface Vlan100',
|
54
|
+
'default interface Vlan100', 'interface Vlan100',
|
50
55
|
'ip address 99.99.99.99/24', 'exit'])
|
51
56
|
end
|
52
57
|
|
53
58
|
it 'adds new address to the list of addresses' do
|
54
|
-
expect(subject.get('Vlan100')[
|
59
|
+
expect(subject.get('Vlan100')[:addresses]).not_to include('99.99.99.98')
|
55
60
|
expect(subject.set_addresses('Vlan100', value: ['99.99.99.98']))
|
56
61
|
.to be_truthy
|
57
|
-
expect(subject.get('Vlan100')[
|
62
|
+
expect(subject.get('Vlan100')[:addresses]).to include('99.99.99.98')
|
58
63
|
end
|
59
64
|
|
60
|
-
it 'removes address
|
65
|
+
it 'removes address from the list of addresses' do
|
61
66
|
node.config(['interface vlan 100', 'ip address 99.99.99.99/24',
|
62
67
|
'ip virtual-router address 99.99.99.98'])
|
63
|
-
expect(subject.get('Vlan100')[
|
68
|
+
expect(subject.get('Vlan100')[:addresses]).to include('99.99.99.98')
|
64
69
|
expect(subject.set_addresses('Vlan100', value: ['99.99.99.97']))
|
65
70
|
.to be_truthy
|
66
|
-
expect(subject.get('Vlan100')[
|
71
|
+
expect(subject.get('Vlan100')[:addresses]).not_to include('99.99.99.98')
|
67
72
|
end
|
68
73
|
|
69
74
|
it 'negate the list of addresses' do
|
70
75
|
expect(subject.set_addresses('Vlan100', value: ['99.99.99.98']))
|
71
76
|
.to be_truthy
|
72
|
-
expect(subject.get('Vlan100')[
|
77
|
+
expect(subject.get('Vlan100')[:addresses]).to include('99.99.99.98')
|
73
78
|
expect(subject.set_addresses('Vlan100', enable: false)).to be_truthy
|
74
|
-
expect(subject.get('Vlan100')[
|
79
|
+
expect(subject.get('Vlan100')[:addresses]).to be_empty
|
75
80
|
end
|
76
81
|
|
77
82
|
it 'default the list of addresses' do
|
78
83
|
expect(subject.set_addresses('Vlan100', value: ['99.99.99.98']))
|
79
84
|
.to be_truthy
|
80
|
-
expect(subject.get('Vlan100')[
|
85
|
+
expect(subject.get('Vlan100')[:addresses]).to include('99.99.99.98')
|
81
86
|
expect(subject.set_addresses('Vlan100', default: true)).to be_truthy
|
82
|
-
expect(subject.get('Vlan100')[
|
87
|
+
expect(subject.get('Vlan100')[:addresses]).to be_empty
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'can not evaluate without addresses' do
|
91
|
+
expect { subject.set_addresses('Vlan100') }.to raise_error ArgumentError
|
83
92
|
end
|
84
93
|
end
|
85
94
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/varp'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Varp do
|
7
|
+
subject { described_class.new(node) }
|
8
|
+
|
9
|
+
let(:node) do
|
10
|
+
Rbeapi::Client.config.read(fixture_file('dut.conf'))
|
11
|
+
Rbeapi::Client.connect_to('dut')
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#get' do
|
15
|
+
let(:resource) { subject.get }
|
16
|
+
|
17
|
+
before do
|
18
|
+
node.config(['no ip virtual-router mac-address',
|
19
|
+
'no interface Vlan99', 'no interface Vlan100',
|
20
|
+
'ip virtual-router mac-address aa:bb:cc:dd:ee:ff',
|
21
|
+
'interface Vlan99', 'interface Vlan100'])
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns a varp resource instance' do
|
25
|
+
expect(subject.get).to be_a_kind_of(Hash)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'has a key for mac_address' do
|
29
|
+
expect(subject.get).to include(:mac_address)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has a key for interfaces' do
|
33
|
+
expect(subject.get).to include(:interfaces)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#interfaces' do
|
38
|
+
it 'is a kind of VarpInterfaces' do
|
39
|
+
expect(subject.interfaces).to be_a_kind_of(Rbeapi::Api::VarpInterfaces)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#set_mac_address' do
|
44
|
+
before { node.config('no ip virtual-router mac-address') }
|
45
|
+
|
46
|
+
it 'set mac-address to aa:bb:cc:dd:ee:ff' do
|
47
|
+
expect(subject.get[:mac_address]).to be_empty
|
48
|
+
expect(subject.set_mac_address(value: 'aa:bb:cc:dd:ee:ff')).to be_truthy
|
49
|
+
expect(subject.get[:mac_address]).to eq('aa:bb:cc:dd:ee:ff')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'set mac-address to ff-ff-ff-ff-ff-ff' do
|
53
|
+
expect(subject.get[:mac_address]).to be_empty
|
54
|
+
expect(subject.set_mac_address(value: 'ff-ff-ff-ff-ff-ff')).to be_truthy
|
55
|
+
expect(subject.get[:mac_address]).to eq('ff:ff:ff:ff:ff:ff')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'set mac-address to ffff.ffff.ffff' do
|
59
|
+
expect(subject.get[:mac_address]).to be_empty
|
60
|
+
expect(subject.set_mac_address(value: 'ffff.ffff.ffff')).to be_truthy
|
61
|
+
expect(subject.get[:mac_address]).to eq('ff:ff:ff:ff:ff:ff')
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'set mac-address to ffff:ffff:ffff fails' do
|
65
|
+
expect(subject.get[:mac_address]).to be_empty
|
66
|
+
expect(subject.set_mac_address(value: 'ffff:ffff:ffff')).to be_falsey
|
67
|
+
expect(subject.get[:mac_address]).to eq('')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'set mac-address to ff.ff.ff.ff.ff.ff fails' do
|
71
|
+
expect(subject.get[:mac_address]).to be_empty
|
72
|
+
expect(subject.set_mac_address(value: 'ff.ff.ff.ff.ff.ff')).to be_falsey
|
73
|
+
expect(subject.get[:mac_address]).to eq('')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -44,6 +44,8 @@ describe Rbeapi::Api::BgpNeighbors do
|
|
44
44
|
{ bgp_as: '64600',
|
45
45
|
router_id: '192.168.254.1',
|
46
46
|
shutdown: false,
|
47
|
+
maximum_paths: 32,
|
48
|
+
maximum_ecmp_paths: 32,
|
47
49
|
networks: [
|
48
50
|
{ prefix: '192.168.254.1', masklen: 32, route_map: nil },
|
49
51
|
{ prefix: '192.168.254.2', masklen: 32, route_map: 'rmap' },
|
@@ -44,6 +44,8 @@ describe Rbeapi::Api::Bgp do
|
|
44
44
|
{ bgp_as: '64600',
|
45
45
|
router_id: '192.168.254.1',
|
46
46
|
shutdown: false,
|
47
|
+
maximum_paths: 32,
|
48
|
+
maximum_ecmp_paths: 32,
|
47
49
|
networks: [
|
48
50
|
{ prefix: '192.168.254.1', masklen: 32, route_map: nil },
|
49
51
|
{ prefix: '192.168.254.2', masklen: 32, route_map: 'rmap' },
|
@@ -88,9 +90,40 @@ describe Rbeapi::Api::Bgp do
|
|
88
90
|
|
89
91
|
describe '#create' do
|
90
92
|
it 'create a new BGP resource' do
|
91
|
-
expect(node).to receive(:config).with('router bgp 1000')
|
93
|
+
expect(node).to receive(:config).with(['router bgp 1000'])
|
92
94
|
expect(subject.create('1000')).to be_truthy
|
93
95
|
end
|
96
|
+
it 'create with enable' do
|
97
|
+
expect(node).to receive(:config).with(['router bgp 1000', 'no shutdown'])
|
98
|
+
expect(subject.create('1000', enable: true)).to be_truthy
|
99
|
+
end
|
100
|
+
it 'create with router_id' do
|
101
|
+
expect(node).to receive(:config).with(['router bgp 1000', 'router-id 1'])
|
102
|
+
expect(subject.create('1000', router_id: 1)).to be_truthy
|
103
|
+
end
|
104
|
+
it 'create with maximum paths' do
|
105
|
+
expect(node).to receive(:config).with(['router bgp 1000',
|
106
|
+
'maximum-paths 1'])
|
107
|
+
expect(subject.create('1000', maximum_paths: 1)).to be_truthy
|
108
|
+
end
|
109
|
+
it 'create with maximum paths and ecmp paths' do
|
110
|
+
expect(node).to receive(:config).with(['router bgp 1000',
|
111
|
+
'maximum-paths 13 ecmp 13'])
|
112
|
+
expect(subject.create('1000', maximum_paths: 13,
|
113
|
+
maximum_ecmp_paths: 13)).to be_truthy
|
114
|
+
end
|
115
|
+
it 'raises ArgumentError for create with ecmp paths only' do
|
116
|
+
expect { subject.create('1000', maximum_ecmp_paths: 13) }.to \
|
117
|
+
raise_error ArgumentError
|
118
|
+
end
|
119
|
+
it 'create with all options set' do
|
120
|
+
expect(node).to receive(:config).with(['router bgp 1000', 'no shutdown',
|
121
|
+
'router-id 1',
|
122
|
+
'maximum-paths 13 ecmp 13'])
|
123
|
+
expect(subject.create('1000', enable: true, router_id: 1,
|
124
|
+
maximum_paths: 13,
|
125
|
+
maximum_ecmp_paths: 13)).to be_truthy
|
126
|
+
end
|
94
127
|
end
|
95
128
|
|
96
129
|
describe '#delete' do
|
@@ -162,6 +195,26 @@ describe Rbeapi::Api::Bgp do
|
|
162
195
|
end
|
163
196
|
end
|
164
197
|
|
198
|
+
describe '#set_maximum_paths' do
|
199
|
+
it 'set the maximum paths and ecmp paths' do
|
200
|
+
expect(node).to receive(:config).with(['router bgp 64600',
|
201
|
+
'maximum-paths 13 ecmp 200'])
|
202
|
+
expect(subject.set_maximum_paths(13, 200)).to be_truthy
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'remove the maximum paths' do
|
206
|
+
expect(node).to receive(:config).with(['router bgp 64600',
|
207
|
+
'no maximum-paths'])
|
208
|
+
expect(subject.set_maximum_paths(0, 0, enable: false)).to be_truthy
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'defaults the maximum paths' do
|
212
|
+
expect(node).to receive(:config).with(['router bgp 64600',
|
213
|
+
'default maximum-paths'])
|
214
|
+
expect(subject.set_maximum_paths(0, 0, default: true)).to be_truthy
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
165
218
|
describe '#add_network' do
|
166
219
|
it 'add a BGP network with a route map' do
|
167
220
|
expect(node).to receive(:config)
|
@@ -22,7 +22,7 @@ describe Rbeapi::Api::PortchannelInterface do
|
|
22
22
|
describe '#get' do
|
23
23
|
before :each do
|
24
24
|
allow(subject.node).to receive(:enable)
|
25
|
-
.with(include('show port-channel'),
|
25
|
+
.with(include('show port-channel'), encoding: 'text')
|
26
26
|
.and_return([{ result:
|
27
27
|
{ 'output' => "Port Channel Port-Channel1:\n Active " \
|
28
28
|
'Ports: Ethernet1 PeerEthernet1 ' \
|
@@ -0,0 +1,370 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2015, 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/routemaps'
|
35
|
+
|
36
|
+
include FixtureHelpers
|
37
|
+
|
38
|
+
describe Rbeapi::Api::Routemaps do
|
39
|
+
subject { described_class.new(node) }
|
40
|
+
|
41
|
+
let(:node) { double('node') }
|
42
|
+
|
43
|
+
let(:test) do
|
44
|
+
{
|
45
|
+
'permit' => {
|
46
|
+
10 => {
|
47
|
+
match: ['interface Loopback0',
|
48
|
+
'ip address prefix-list MYLOOPBACK'],
|
49
|
+
set: ['community internet 5555:5555'],
|
50
|
+
description: 'description',
|
51
|
+
continue: 99
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
end
|
56
|
+
let(:name) { 'test1' }
|
57
|
+
|
58
|
+
def routemaps
|
59
|
+
routemaps = Fixtures[:routemaps]
|
60
|
+
return routemaps if routemaps
|
61
|
+
fixture('routemaps', format: :text, dir: File.dirname(__FILE__))
|
62
|
+
end
|
63
|
+
|
64
|
+
before :each do
|
65
|
+
allow(subject.node).to receive(:running_config).and_return(routemaps)
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#getall' do
|
69
|
+
let(:test1_entries) do
|
70
|
+
{
|
71
|
+
'test1' => {
|
72
|
+
'permit' => {
|
73
|
+
10 => {
|
74
|
+
match: ['interface Loopback0',
|
75
|
+
'ip address prefix-list MYLOOPBACK'],
|
76
|
+
set: ['community internet 5555:5555'],
|
77
|
+
description: 'description',
|
78
|
+
continue: 99
|
79
|
+
}
|
80
|
+
}
|
81
|
+
},
|
82
|
+
'test' => {
|
83
|
+
'permit' => {
|
84
|
+
10 => {
|
85
|
+
match: ['interface Vlan100'],
|
86
|
+
description: 'description',
|
87
|
+
continue: 99
|
88
|
+
},
|
89
|
+
20 => {
|
90
|
+
continue: 99,
|
91
|
+
description: 'description',
|
92
|
+
set: ['community internet 5555:5555']
|
93
|
+
}
|
94
|
+
},
|
95
|
+
'deny' => {
|
96
|
+
10 => {
|
97
|
+
match: ['interface Vlan100'],
|
98
|
+
description: 'description',
|
99
|
+
continue: 99
|
100
|
+
},
|
101
|
+
20 => {
|
102
|
+
continue: 99,
|
103
|
+
description: 'description',
|
104
|
+
set: ['community internet 5555:5555']
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'returns the routemap collection' do
|
112
|
+
expect(subject.getall).to include(test1_entries)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'returns a hash collection' do
|
116
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'has two entries' do
|
120
|
+
expect(subject.getall.size).to eq(2)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#get' do
|
125
|
+
it 'returns the routemap resource for given name' do
|
126
|
+
expect(subject.get(name)).to eq(test)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'returns a hash' do
|
130
|
+
expect(subject.get(name)).to be_a_kind_of(Hash)
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'has two entries' do
|
134
|
+
expect(subject.get(name).size).to eq(1)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#create' do
|
139
|
+
it 'create an existing routemap test1 permit 10' do
|
140
|
+
expect(node).to receive(:config).with(['route-map test1 permit 10'])
|
141
|
+
expect(subject.create('test1', 'permit', 10)).to be_truthy
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'create an existing routemap test deny 20' do
|
145
|
+
expect(node).to receive(:config).with(['route-map test deny 20'])
|
146
|
+
expect(subject.create('test', 'deny', 20)).to be_truthy
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'create a new routemap test4 permit 20' do
|
150
|
+
expect(node).to receive(:config).with(['route-map test4 permit 20'])
|
151
|
+
expect(subject.create('test4', 'permit', 20)).to be_truthy
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'create a new routemap test4 permit 20 with enable false' do
|
155
|
+
expect(node).to receive(:config).with(['no route-map test4 permit 20'])
|
156
|
+
expect(subject.create('test4', 'permit', 20, enable: false)).to be_truthy
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'create a new routemap test4 permit 20 with enable true' do
|
160
|
+
expect(node).to receive(:config).with(['route-map test4 permit 20'])
|
161
|
+
expect(subject.create('test4', 'permit', 20, enable: true)).to be_truthy
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'add description to routemap test1 permit 10 with create' do
|
165
|
+
expect(node).to receive(:config)
|
166
|
+
.with(['route-map test1 permit 10', 'no description',
|
167
|
+
'description description'])
|
168
|
+
expect(subject.create('test1', 'permit', 10,
|
169
|
+
description: 'description')).to be_truthy
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'add description to routemap test deny 20 with create' do
|
173
|
+
expect(node).to receive(:config)
|
174
|
+
.with(['route-map test deny 20', 'no description',
|
175
|
+
'description description'])
|
176
|
+
expect(subject.create('test', 'deny', 20,
|
177
|
+
description: 'description')).to be_truthy
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'add match statements to routemap test1 permit 10 with create' do
|
181
|
+
expect(node).to receive(:config)
|
182
|
+
.with(['route-map test1 permit 10',
|
183
|
+
'no match interface Loopback0',
|
184
|
+
'no match ip address prefix-list MYLOOPBACK',
|
185
|
+
'match ip address prefix-list MYLOOPBACK',
|
186
|
+
'match interface Loopback0'])
|
187
|
+
expect(subject.create('test1', 'permit', 10,
|
188
|
+
match: ['ip address prefix-list MYLOOPBACK',
|
189
|
+
'interface Loopback0'])).to be_truthy
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'add match statements to routemap test deny 20 with create' do
|
193
|
+
expect(node).to receive(:config)
|
194
|
+
.with(['route-map test deny 20',
|
195
|
+
'match ip address prefix-list MYLOOPBACK',
|
196
|
+
'match interface Loopback0'])
|
197
|
+
expect(subject.create('test', 'deny', 20,
|
198
|
+
match: ['ip address prefix-list MYLOOPBACK',
|
199
|
+
'interface Loopback0'])).to be_truthy
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'add set statements to routemap test1 permit 10 with create' do
|
203
|
+
expect(node).to receive(:config)
|
204
|
+
.with(['route-map test1 permit 10',
|
205
|
+
'no set community internet 5555:5555',
|
206
|
+
'set community internet 5555:5555'])
|
207
|
+
expect(subject.create('test1', 'permit', 10,
|
208
|
+
set: ['community internet 5555:5555'])).to be_truthy
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'add set statements to routemap test deny 20 with create' do
|
212
|
+
expect(node).to receive(:config)
|
213
|
+
.with(['route-map test deny 20',
|
214
|
+
'no set community internet 5555:5555',
|
215
|
+
'set community internet 5555:5555'])
|
216
|
+
expect(subject.create('test', 'deny', 20,
|
217
|
+
set: ['community internet 5555:5555'])).to be_truthy
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'add continue to routemap test1 permit 10 with create' do
|
221
|
+
expect(node).to receive(:config)
|
222
|
+
.with(['route-map test1 permit 10', 'no continue', 'continue 99'])
|
223
|
+
expect(subject.create('test1', 'permit', 10,
|
224
|
+
continue: 99)).to be_truthy
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'add continue to routemap test deny 20 with create' do
|
228
|
+
expect(node).to receive(:config)
|
229
|
+
.with(['route-map test deny 20', 'no continue', 'continue 99'])
|
230
|
+
expect(subject.create('test', 'deny', 20,
|
231
|
+
continue: 99)).to be_truthy
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'default routemap test permit 10 with create' do
|
235
|
+
expect(node).to receive(:config)
|
236
|
+
.with(['default route-map test1 permit 10'])
|
237
|
+
expect(subject.create('test1', 'permit', 10,
|
238
|
+
default: true)).to be_truthy
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'default routemap test deny 20 with create' do
|
242
|
+
expect(node).to receive(:config)
|
243
|
+
.with(['default route-map test deny 20'])
|
244
|
+
expect(subject.create('test', 'deny', 20,
|
245
|
+
default: true)).to be_truthy
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe '#delete' do
|
250
|
+
it 'delete test1 permit 10 routemap resource' do
|
251
|
+
expect(node).to receive(:config).with(['no route-map test1 permit 10'])
|
252
|
+
expect(subject.delete('test1', 'permit', 10)).to be_truthy
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'delete test deny 20 routemap resource' do
|
256
|
+
expect(node).to receive(:config).with(['no route-map test deny 20'])
|
257
|
+
expect(subject.delete('test', 'deny', 20)).to be_truthy
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'delete non existent routemap' do
|
261
|
+
expect(node).to receive(:config).with(['no route-map blah deny 30'])
|
262
|
+
expect(subject.delete('blah', 'deny', 30)).to be_truthy
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
describe '#default' do
|
267
|
+
it 'default test1 permit 10 routemap resource' do
|
268
|
+
expect(node).to receive(:config)
|
269
|
+
.with(['default route-map test1 permit 10'])
|
270
|
+
expect(subject.default('test1', 'permit', 10)).to be_truthy
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
describe '#set_match_statements' do
|
275
|
+
it 'set the match statements on exsiting routemap' do
|
276
|
+
expect(node).to receive(:config)
|
277
|
+
.with(['route-map test1 permit 10',
|
278
|
+
'no match interface Loopback0',
|
279
|
+
'no match ip address prefix-list MYLOOPBACK',
|
280
|
+
'match ip address prefix-list MYLOOPBACK',
|
281
|
+
'match interface Loopback0'])
|
282
|
+
expect(
|
283
|
+
subject
|
284
|
+
.set_match_statements('test1', 'permit', 10,
|
285
|
+
['ip address prefix-list MYLOOPBACK',
|
286
|
+
'interface Loopback0'])
|
287
|
+
).to be_truthy
|
288
|
+
expect(subject.get('test1').assoc('permit')[1].assoc(10)[1][:match])
|
289
|
+
.to include('ip address prefix-list MYLOOPBACK',
|
290
|
+
'interface Loopback0')
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'set the match statements on a new routemap' do
|
294
|
+
expect(node).to receive(:config)
|
295
|
+
.with(['route-map test4 permit 20',
|
296
|
+
'match ip address prefix-list MYLOOPBACK',
|
297
|
+
'match interface Loopback0'])
|
298
|
+
expect(
|
299
|
+
subject
|
300
|
+
.set_match_statements('test4', 'permit', 20,
|
301
|
+
['ip address prefix-list MYLOOPBACK',
|
302
|
+
'interface Loopback0'])
|
303
|
+
).to be_truthy
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe '#set_set_statements' do
|
308
|
+
it 'set the set statements on existing routemap' do
|
309
|
+
expect(node).to receive(:config)
|
310
|
+
.with(['route-map test1 permit 10',
|
311
|
+
'no set community internet 5555:5555',
|
312
|
+
'set community internet 5555:5555'])
|
313
|
+
expect(
|
314
|
+
subject.set_set_statements('test1', 'permit', 10,
|
315
|
+
['community internet 5555:5555'])
|
316
|
+
).to be_truthy
|
317
|
+
expect(subject.get('test1').assoc('permit')[1].assoc(10)[1][:set])
|
318
|
+
.to include('community internet 5555:5555')
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'set the set statements on new routemap' do
|
322
|
+
expect(node).to receive(:config)
|
323
|
+
.with(['route-map test4 permit 20',
|
324
|
+
'set community internet 5555:5555'])
|
325
|
+
expect(
|
326
|
+
subject.set_set_statements('test4', 'permit', 20,
|
327
|
+
['community internet 5555:5555'])
|
328
|
+
).to be_truthy
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
describe '#set_continue' do
|
333
|
+
it 'set the continue statement on existing routemap' do
|
334
|
+
expect(node).to receive(:config).with(['route-map test1 permit 10',
|
335
|
+
'no continue',
|
336
|
+
'continue 99'])
|
337
|
+
expect(subject.set_continue('test1', 'permit', 10, 99)).to be_truthy
|
338
|
+
expect(subject.get('test1').assoc('permit')[1]
|
339
|
+
.assoc(10)[1][:continue]).to eq(99)
|
340
|
+
end
|
341
|
+
|
342
|
+
it 'set the continue statement on new routemap' do
|
343
|
+
expect(node).to receive(:config).with(['route-map test4 permit 10',
|
344
|
+
'no continue',
|
345
|
+
'continue 99'])
|
346
|
+
expect(subject.set_continue('test4', 'permit', 10, 99)).to be_truthy
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
describe '#set_description' do
|
351
|
+
it 'set the description statement on existing routemap' do
|
352
|
+
expect(node).to receive(:config).with(['route-map test1 permit 10',
|
353
|
+
'no description',
|
354
|
+
'description description'])
|
355
|
+
expect(subject.set_description('test1', 'permit', 10,
|
356
|
+
'description')).to be_truthy
|
357
|
+
expect(subject.get('test1')
|
358
|
+
.assoc('permit')[1].assoc(10)[1][:description])
|
359
|
+
.to eq('description')
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'set the description statement on new routemap' do
|
363
|
+
expect(node).to receive(:config).with(['route-map test4 permit 20',
|
364
|
+
'no description',
|
365
|
+
'description description'])
|
366
|
+
expect(subject.set_description('test4', 'permit', 20,
|
367
|
+
'description')).to be_truthy
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
route-map test1 permit 10
|
2
|
+
description description
|
3
|
+
match interface Loopback0
|
4
|
+
match ip address prefix-list MYLOOPBACK
|
5
|
+
continue 99
|
6
|
+
set community internet 5555:5555
|
7
|
+
!
|
8
|
+
route-map test permit 10
|
9
|
+
description description
|
10
|
+
match interface Vlan100
|
11
|
+
continue 99
|
12
|
+
!
|
13
|
+
route-map test permit 20
|
14
|
+
description description
|
15
|
+
continue 99
|
16
|
+
set community internet 5555:5555
|
17
|
+
!
|
18
|
+
route-map test deny 10
|
19
|
+
description description
|
20
|
+
match interface Vlan100
|
21
|
+
continue 99
|
22
|
+
!
|
23
|
+
route-map test deny 20
|
24
|
+
description description
|
25
|
+
continue 99
|
26
|
+
set community internet 5555:5555
|
27
|
+
!
|