rbeapi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +35 -0
- data/Gemfile +25 -0
- data/Guardfile +15 -0
- data/LICENSE +28 -0
- data/README.md +218 -0
- data/Rakefile +12 -0
- data/lib/rbeapi.rb +32 -0
- data/lib/rbeapi/api.rb +135 -0
- data/lib/rbeapi/api/aaa.rb +410 -0
- data/lib/rbeapi/api/dns.rb +198 -0
- data/lib/rbeapi/api/interfaces.rb +1193 -0
- data/lib/rbeapi/api/ipinterfaces.rb +328 -0
- data/lib/rbeapi/api/logging.rb +157 -0
- data/lib/rbeapi/api/mlag.rb +519 -0
- data/lib/rbeapi/api/ntp.rb +201 -0
- data/lib/rbeapi/api/ospf.rb +214 -0
- data/lib/rbeapi/api/prefixlists.rb +98 -0
- data/lib/rbeapi/api/radius.rb +317 -0
- data/lib/rbeapi/api/radius.rb.old +399 -0
- data/lib/rbeapi/api/routemaps.rb +100 -0
- data/lib/rbeapi/api/snmp.rb +427 -0
- data/lib/rbeapi/api/staticroutes.rb +88 -0
- data/lib/rbeapi/api/stp.rb +381 -0
- data/lib/rbeapi/api/switchports.rb +272 -0
- data/lib/rbeapi/api/system.rb +87 -0
- data/lib/rbeapi/api/tacacs.rb +236 -0
- data/lib/rbeapi/api/varp.rb +181 -0
- data/lib/rbeapi/api/vlans.rb +338 -0
- data/lib/rbeapi/client.rb +454 -0
- data/lib/rbeapi/eapilib.rb +334 -0
- data/lib/rbeapi/netdev/snmp.rb +370 -0
- data/lib/rbeapi/utils.rb +70 -0
- data/lib/rbeapi/version.rb +37 -0
- data/rbeapi.gemspec +32 -0
- data/spec/fixtures/dut.conf +5 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/fixtures.rb +114 -0
- data/spec/support/shared_examples_for_api_modules.rb +124 -0
- data/spec/system/api_ospf_interfaces_spec.rb +58 -0
- data/spec/system/api_ospf_spec.rb +111 -0
- data/spec/system/api_varp_interfaces_spec.rb +60 -0
- data/spec/system/api_varp_spec.rb +44 -0
- data/spec/system/rbeapi/api/dns_spec.rb +77 -0
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +94 -0
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +135 -0
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +188 -0
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +115 -0
- data/spec/system/rbeapi/api/ipinterfaces_spec.rb +97 -0
- data/spec/system/rbeapi/api/logging_spec.rb +65 -0
- data/spec/system/rbeapi/api/mlag_interfaces_spec.rb +80 -0
- data/spec/system/rbeapi/api/mlag_spec.rb +94 -0
- data/spec/system/rbeapi/api/ntp_spec.rb +76 -0
- data/spec/system/rbeapi/api/snmp_spec.rb +68 -0
- data/spec/system/rbeapi/api/stp_instances_spec.rb +61 -0
- data/spec/system/rbeapi/api/stp_interfaces_spec.rb +71 -0
- data/spec/system/rbeapi/api/stp_spec.rb +57 -0
- data/spec/system/rbeapi/api/switchports_spec.rb +135 -0
- data/spec/system/rbeapi/api/system_spec.rb +38 -0
- data/spec/system/rbeapi/api/vlans_spec.rb +121 -0
- metadata +274 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/ospf'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Ospf do
|
7
|
+
subject { described_class.new(node) }
|
8
|
+
|
9
|
+
let(:config) { Rbeapi::Client::Config.new(filename: get_fixture('dut.conf')) }
|
10
|
+
let(:node) { Rbeapi::Client.connect_to('veos02') }
|
11
|
+
|
12
|
+
describe '#get' do
|
13
|
+
|
14
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
15
|
+
|
16
|
+
let(:entity) do
|
17
|
+
{ 'router_id' => '', 'areas' => {}, 'redistribute' => {} }
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns an ospf resource instance' do
|
21
|
+
expect(subject.get('1')).to eq(entity)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#getall' do
|
26
|
+
|
27
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
28
|
+
|
29
|
+
let(:collection) { subject.getall }
|
30
|
+
|
31
|
+
it 'includes ospf process id 1' do
|
32
|
+
expect(collection).to include('1')
|
33
|
+
end
|
34
|
+
|
35
|
+
it ' includes interfaces' do
|
36
|
+
expect(collection).to include('interfaces')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'is a kind of hash' do
|
40
|
+
expect(collection).to be_a_kind_of(Hash)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#interfaces' do
|
46
|
+
it 'is a kind of StpInterfaces' do
|
47
|
+
expect(subject.interfaces).to be_a_kind_of(Rbeapi::Api::OspfInterfaces)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#set_router_id' do
|
52
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
53
|
+
|
54
|
+
it 'configures the ospf router id to 1.1.1.1' do
|
55
|
+
expect(subject.get('1')['router_id']).to be_empty
|
56
|
+
expect(subject.set_router_id('1', value: '1.1.1.1')).to be_truthy
|
57
|
+
expect(subject.get('1')['router_id']).to eq('1.1.1.1')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#create' do
|
62
|
+
before { node.config('no router ospf 1') }
|
63
|
+
|
64
|
+
it 'configures router ospf with process id 1' do
|
65
|
+
expect(subject.get('1')).to be_nil
|
66
|
+
expect(subject.create('1')).to be_truthy
|
67
|
+
expect(subject.get('1')).not_to be_nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#delete' do
|
72
|
+
before { node.config('router ospf 1') }
|
73
|
+
|
74
|
+
it 'configures router ospf with process id 1' do
|
75
|
+
expect(subject.get('1')).not_to be_nil
|
76
|
+
expect(subject.delete('1')).to be_truthy
|
77
|
+
expect(subject.get('1')).to be_nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#add_network' do
|
82
|
+
before { node.config('router ospf 1') }
|
83
|
+
|
84
|
+
it 'adds the network with area to the ospf process' do
|
85
|
+
expect(subject.get('1')['areas']).to be_empty
|
86
|
+
expect(subject.add_network('1', '192.168.10.0/24', '0.0.0.0')).to be_truthy
|
87
|
+
expect(subject.get('1')['areas']['0.0.0.0']).to include('192.168.10.0/24')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#remove_network' do
|
92
|
+
before { node.config(['router ospf 1', 'network 192.168.10.10/24 area 0.0.0.0']) }
|
93
|
+
|
94
|
+
it 'removes the network with area to the ospf process' do
|
95
|
+
expect(subject.get('1')['areas']['0.0.0.0']).to include('192.168.10.0/24')
|
96
|
+
expect(subject.remove_network('1', '192.168.10.0/24', '0.0.0.0')).to be_truthy
|
97
|
+
expect(subject.get('1')['areas']).to be_empty
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#set_redistribute' do
|
102
|
+
before { node.config(['no router ospf 1', 'router ospf 1']) }
|
103
|
+
|
104
|
+
it 'configures redistribution of static routes' do
|
105
|
+
expect(subject.get('1')['redistribute']).not_to include('static')
|
106
|
+
expect(subject.set_redistribute('1', 'static')).to be_truthy
|
107
|
+
expect(subject.get('1')['redistribute']).to include('static')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/varp'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::VarpInterfaces do
|
7
|
+
subject { described_class.new(node) }
|
8
|
+
|
9
|
+
let(:config) { Rbeapi::Client::Config.new(filename: get_fixture('dut.conf')) }
|
10
|
+
let(:node) { Rbeapi::Client.connect_to('veos02') }
|
11
|
+
|
12
|
+
describe '#get' do
|
13
|
+
before { node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
14
|
+
'interface vlan 100', 'ip address 99.99.99.99/24',
|
15
|
+
'ip virtual-router address 99.99.99.98']) }
|
16
|
+
|
17
|
+
it 'returns an instance for vlan 100' do
|
18
|
+
expect(subject.get('Vlan100')).not_to be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not return an instance for vlan 101' do
|
22
|
+
expect(subject.get('Vlan101')).to be_nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#getall' do
|
27
|
+
before { node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
28
|
+
'interface vlan 100', 'ip address 99.99.99.99/24',
|
29
|
+
'ip virtual-router address 99.99.99.98']) }
|
30
|
+
|
31
|
+
it 'returns a collection that includes vlan 100' do
|
32
|
+
expect(subject.getall).to include('Vlan100')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a collection as a Hash' do
|
36
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#set_addresses' do
|
41
|
+
before { node.config(['ip virtual-router mac-address aabb.ccdd.eeff',
|
42
|
+
'no interface vlan 100', 'interface vlan 100',
|
43
|
+
'ip address 99.99.99.99/24']) }
|
44
|
+
|
45
|
+
it 'adds new address to the list of addresses' do
|
46
|
+
expect(subject.get('Vlan100')['addresses']).not_to include('99.99.99.98')
|
47
|
+
expect(subject.set_addresses('Vlan100', value: ['99.99.99.98'])).to be_truthy
|
48
|
+
expect(subject.get('Vlan100')['addresses']).to include('99.99.99.98')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'removes address to the list of addresses' do
|
52
|
+
node.config(['interface vlan 100', 'ip address 99.99.99.99/24',
|
53
|
+
'ip virtual-router address 99.99.99.98'])
|
54
|
+
expect(subject.get('Vlan100')['addresses']).to include('99.99.99.98')
|
55
|
+
expect(subject.set_addresses('Vlan100', value: ['99.99.99.97'])).to be_truthy
|
56
|
+
expect(subject.get('Vlan100')['addresses']).not_to include('99.99.99.98')
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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(:config) { Rbeapi::Client::Config.new(filename: get_fixture('dut.conf')) }
|
10
|
+
let(:node) { Rbeapi::Client.connect_to('veos02') }
|
11
|
+
|
12
|
+
describe '#get' do
|
13
|
+
|
14
|
+
it 'returns a varp resource instance' do
|
15
|
+
expect(subject.get).to be_a_kind_of(Hash)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'has a key for mac_address' do
|
19
|
+
expect(subject.get).to include('mac_address')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has a key for interfaces' do
|
23
|
+
expect(subject.get).to include('interfaces')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#interfaces' do
|
28
|
+
it 'is a kind of VarpInterfaces' do
|
29
|
+
expect(subject.interfaces).to be_a_kind_of(Rbeapi::Api::VarpInterfaces)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#set_router_id' do
|
34
|
+
before { node.config('no ip virtual-router mac-address') }
|
35
|
+
|
36
|
+
it 'configures the ip varp mac-address' do
|
37
|
+
expect(subject.get['mac_address']).to be_empty
|
38
|
+
expect(subject.set_mac_address(value: 'aa:bb:cc:dd:ee:ff')).to be_truthy
|
39
|
+
expect(subject.get['mac_address']).to eq('aa:bb:cc:dd:ee:ff')
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rbeapi/client'
|
4
|
+
require 'rbeapi/api/dns'
|
5
|
+
|
6
|
+
describe Rbeapi::Api::Dns 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
|
+
[:domain_name, :domain_list, :name_servers].each do |key|
|
16
|
+
it 'returns the dns resource with key' do
|
17
|
+
expect(subject.get).to include(key)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#set_domain_name' do
|
23
|
+
before { node.config(['no ip domain-name']) }
|
24
|
+
|
25
|
+
it 'configure the ip domain-name value' do
|
26
|
+
expect(subject.get[:domain_name]).to be_empty
|
27
|
+
expect(subject.set_domain_name(value: 'arista.com')).to be_truthy
|
28
|
+
expect(subject.get[:domain_name]).to eq('arista.com')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#add_name_server' do
|
33
|
+
before do
|
34
|
+
begin
|
35
|
+
node.config('no ip name-server 1.2.3.4')
|
36
|
+
rescue Rbeapi::Eapilib::CommandError
|
37
|
+
next
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'adds the name-server to the list' do
|
42
|
+
expect(subject.get[:name_servers]).not_to include('1.2.3.4')
|
43
|
+
expect(subject.add_name_server('1.2.3.4')).to be_truthy
|
44
|
+
expect(subject.get[:name_servers]).to include('1.2.3.4')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#remove_name_server' do
|
49
|
+
before { node.config(['ip name-server 1.2.3.4']) }
|
50
|
+
|
51
|
+
it 'removes the name-server from the list' do
|
52
|
+
expect(subject.get[:name_servers]).to include('1.2.3.4')
|
53
|
+
expect(subject.remove_name_server('1.2.3.4')).to be_truthy
|
54
|
+
expect(subject.get[:name_servers]).not_to include('1.2.3.4')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#add_domain_list' do
|
59
|
+
before { node.config(['no ip domain-list arista.net']) }
|
60
|
+
|
61
|
+
it 'adds the domain to the list' do
|
62
|
+
expect(subject.get[:domain_list]).not_to include('arista.net')
|
63
|
+
expect(subject.add_domain_list('arista.net')).to be_truthy
|
64
|
+
expect(subject.get[:domain_list]).to include('arista.net')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#remove_name_server' do
|
69
|
+
before { node.config(['ip domain-list arista.net']) }
|
70
|
+
|
71
|
+
it 'adds the name-server to the list' do
|
72
|
+
expect(subject.get[:domain_list]).to include('arista.net')
|
73
|
+
expect(subject.remove_domain_list('arista.net')).to be_truthy
|
74
|
+
expect(subject.get[:domain_list]).not_to include('arista.net')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,94 @@
|
|
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
|
+
|
16
|
+
let(:entity) do
|
17
|
+
{ name: 'Loopback0', type: 'generic', description: '', shutdown: false }
|
18
|
+
end
|
19
|
+
|
20
|
+
before { node.config(['no interface Loopback0', 'interface Loopback0']) }
|
21
|
+
|
22
|
+
it 'returns the interface resource' do
|
23
|
+
expect(subject.get('Loopback0')).to eq(entity)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#getall' do
|
28
|
+
before { node.config(['no interface Loopback0', 'interface Loopback0']) }
|
29
|
+
|
30
|
+
it 'returns the interface collection' do
|
31
|
+
expect(subject.getall).to include('Loopback0')
|
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 Loopback0') }
|
41
|
+
|
42
|
+
it 'creates a new interface resource' do
|
43
|
+
expect(subject.get('Loopback0')).to be_nil
|
44
|
+
expect(subject.create('Loopback0')).to be_truthy
|
45
|
+
expect(subject.get('Loopback0')).not_to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#delete' do
|
50
|
+
before { node.config(['interface Loopback0']) }
|
51
|
+
|
52
|
+
it 'deletes a switchport resource' do
|
53
|
+
expect(subject.get('Loopback0')).not_to be_nil
|
54
|
+
expect(subject.delete('Loopback0')).to be_truthy
|
55
|
+
expect(subject.get('Loopback0')).to be_nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#default' do
|
60
|
+
before { node.config(['interface Loopback0', 'shutdown']) }
|
61
|
+
|
62
|
+
it 'sets Loopback0 to default' do
|
63
|
+
expect(subject.get('Loopback0')[:shutdown]).to be_truthy
|
64
|
+
expect(subject.default('Loopback0')).to be_truthy
|
65
|
+
expect(subject.get('Loopback0')[:shutdown]).to be_falsy
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#set_description' do
|
70
|
+
it 'sets the description value on the interface' do
|
71
|
+
node.config(['interface Loopback0', 'no description'])
|
72
|
+
expect(subject.get('Loopback0')[:description]).to be_empty
|
73
|
+
expect(subject.set_description('Loopback0', value: 'foo bar')).to be_truthy
|
74
|
+
expect(subject.get('Loopback0')[:description]).to eq('foo bar')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#set_shutdown' do
|
79
|
+
it 'sets the shutdown value to true' do
|
80
|
+
node.config(['interface Loopback0', 'no shutdown'])
|
81
|
+
expect(subject.get('Loopback0')[:shutdown]).to be_falsy
|
82
|
+
expect(subject.set_shutdown('Loopback0', value: true)).to be_truthy
|
83
|
+
expect(subject.get('Loopback0')[:shutdown]).to be_truthy
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'sets the shutdown value to false' do
|
87
|
+
node.config(['interface Loopback0', 'shutdown'])
|
88
|
+
expect(subject.get('Loopback0')[:shutdown]).to be_truthy
|
89
|
+
expect(subject.set_shutdown('Loopback0', value: false)).to be_truthy
|
90
|
+
expect(subject.get('Loopback0')[:shutdown]).to be_falsy
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
@@ -0,0 +1,135 @@
|
|
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
|
+
|
16
|
+
let(:entity) do
|
17
|
+
{ name: 'Ethernet1', type: 'ethernet', description: '', shutdown: false,
|
18
|
+
sflow: true, flowcontrol_send: 'off', flowcontrol_receive: 'off' }
|
19
|
+
end
|
20
|
+
|
21
|
+
before { node.config(['default interface Ethernet1']) }
|
22
|
+
|
23
|
+
it 'returns the interface resource' do
|
24
|
+
expect(subject.get('Ethernet1')).to eq(entity)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#getall' do
|
29
|
+
before { node.config(['default interface Ethernet1']) }
|
30
|
+
|
31
|
+
it 'returns the interface collection' do
|
32
|
+
expect(subject.getall).to include('Ethernet1')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a hash collection' do
|
36
|
+
expect(subject.getall).to be_a_kind_of(Hash)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#create' do
|
41
|
+
it 'raises an error on create' do
|
42
|
+
expect { subject.create('Ethernet1') }.to raise_error(NotImplementedError)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#delete' do
|
47
|
+
it 'raises an error on create' do
|
48
|
+
expect { subject.create('Ethernet1') }.to raise_error(NotImplementedError)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#default' do
|
53
|
+
before { node.config(['interface Ethernet1', :shutdown]) }
|
54
|
+
|
55
|
+
it 'sets Ethernet1 to default' do
|
56
|
+
expect(subject.get('Ethernet1')[:shutdown]).to be_truthy
|
57
|
+
expect(subject.default('Ethernet1')).to be_truthy
|
58
|
+
expect(subject.get('Ethernet1')[:shutdown]).to be_falsy
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#set_description' do
|
63
|
+
it 'sets the description value on the interface' do
|
64
|
+
node.config(['interface Ethernet1', 'no description'])
|
65
|
+
expect(subject.get('Ethernet1')[:description]).to be_empty
|
66
|
+
expect(subject.set_description('Ethernet1', value: 'foo bar')).to be_truthy
|
67
|
+
expect(subject.get('Ethernet1')[:description]).to eq('foo bar')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#set_shutdown' do
|
72
|
+
it 'sets the shutdown value to true' do
|
73
|
+
node.config(['interface Ethernet1', 'no shutdown'])
|
74
|
+
expect(subject.get('Ethernet1')[:shutdown]).to be_falsy
|
75
|
+
expect(subject.set_shutdown('Ethernet1', value: true)).to be_truthy
|
76
|
+
expect(subject.get('Ethernet1')[:shutdown]).to be_truthy
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'sets the shutdown value to false' do
|
80
|
+
node.config(['interface Ethernet1', :shutdown])
|
81
|
+
expect(subject.get('Ethernet1')[:shutdown]).to be_truthy
|
82
|
+
expect(subject.set_shutdown('Ethernet1', value: false)).to be_truthy
|
83
|
+
expect(subject.get('Ethernet1')[:shutdown]).to be_falsy
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#set_sflow' do
|
88
|
+
it 'sets the sflow value to true' do
|
89
|
+
node.config(['interface Ethernet1', 'no sflow enable'])
|
90
|
+
expect(subject.get('Ethernet1')[:sflow]).to be_falsy
|
91
|
+
expect(subject.set_sflow('Ethernet1', value: true)).to be_truthy
|
92
|
+
expect(subject.get('Ethernet1')[:sflow]).to be_truthy
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'sets the sflow value to false' do
|
96
|
+
node.config(['interface Ethernet1', 'sflow enable'])
|
97
|
+
expect(subject.get('Ethernet1')[:sflow]).to be_truthy
|
98
|
+
expect(subject.set_sflow('Ethernet1', value: false)).to be_truthy
|
99
|
+
expect(subject.get('Ethernet1')[:sflow]).to be_falsy
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#set_flowcontrol_send' do
|
104
|
+
it 'sets the flowcontrol send value to on' do
|
105
|
+
node.config(['interface Ethernet1', 'flowcontrol send off'])
|
106
|
+
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('off')
|
107
|
+
expect(subject.set_flowcontrol_send('Ethernet1', value: 'on')).to be_truthy
|
108
|
+
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('on')
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'sets the flowcontrol send value to off' do
|
112
|
+
node.config(['interface Ethernet1', 'flowcontrol send on'])
|
113
|
+
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('on')
|
114
|
+
expect(subject.set_flowcontrol_send('Ethernet1', value: 'off')).to be_truthy
|
115
|
+
expect(subject.get('Ethernet1')[:flowcontrol_send]).to eq('off')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#set_flowcontrol_receive' do
|
120
|
+
it 'sets the flowcontrol receive value to on' do
|
121
|
+
node.config(['interface Ethernet1', 'flowcontrol receive off '])
|
122
|
+
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('off')
|
123
|
+
expect(subject.set_flowcontrol_receive('Ethernet1', value: 'on')).to be_truthy
|
124
|
+
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('on')
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'sets the flowcontrol receive value to off' do
|
128
|
+
node.config(['interface Ethernet1', 'flowcontrol receive on'])
|
129
|
+
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('on')
|
130
|
+
expect(subject.set_flowcontrol_receive('Ethernet1', value: 'off')).to be_truthy
|
131
|
+
expect(subject.get('Ethernet1')[:flowcontrol_receive]).to eq('off')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|