arista-eos 1.1.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 +41 -0
- data/.rubocop.yml +21 -0
- data/Gemfile +57 -0
- data/Guardfile +21 -0
- data/LICENSE +28 -0
- data/README.md +178 -0
- data/Rakefile +46 -0
- data/eos.gemspec +36 -0
- data/guide/.gitignore +2 -0
- data/guide/Makefile +177 -0
- data/guide/_static/arista_logo_jpg-11.jpg +0 -0
- data/guide/_static/favicon.ico +0 -0
- data/guide/conf.py +282 -0
- data/guide/cookbook.rst +135 -0
- data/guide/developing.rst +55 -0
- data/guide/faq.rst +30 -0
- data/guide/index.rst +25 -0
- data/guide/installation.rst +174 -0
- data/guide/license.rst +5 -0
- data/guide/overview.rst +35 -0
- data/guide/quickstart.rst +184 -0
- data/guide/release-notes-1.0.rst +37 -0
- data/guide/release-notes-1.1.rst +25 -0
- data/guide/release-notes.rst +10 -0
- data/guide/testing.rst +8 -0
- data/guide/troubleshooting.rst +26 -0
- data/guide/typedoc.rst +928 -0
- data/guide/types.rst +44 -0
- data/lib/eos.rb +8 -0
- data/lib/eos/version.rb +5 -0
- data/lib/puppet/provider/eos_acl_entry/default.rb +122 -0
- data/lib/puppet/provider/eos_command/default.rb +61 -0
- data/lib/puppet/provider/eos_ethernet/default.rb +96 -0
- data/lib/puppet/provider/eos_interface/default.rb +89 -0
- data/lib/puppet/provider/eos_ipinterface/default.rb +89 -0
- data/lib/puppet/provider/eos_mlag/default.rb +86 -0
- data/lib/puppet/provider/eos_mlag_interface/default.rb +90 -0
- data/lib/puppet/provider/eos_ntp_config/default.rb +68 -0
- data/lib/puppet/provider/eos_ntp_server/default.rb +69 -0
- data/lib/puppet/provider/eos_portchannel/default.rb +117 -0
- data/lib/puppet/provider/eos_snmp/default.rb +77 -0
- data/lib/puppet/provider/eos_stp_interface/default.rb +73 -0
- data/lib/puppet/provider/eos_switchport/default.rb +100 -0
- data/lib/puppet/provider/eos_system/default.rb +63 -0
- data/lib/puppet/provider/eos_vlan/default.rb +93 -0
- data/lib/puppet/provider/eos_vxlan/default.rb +104 -0
- data/lib/puppet/provider/eos_vxlan_vlan/default.rb +89 -0
- data/lib/puppet/provider/eos_vxlan_vtep/default.rb +70 -0
- data/lib/puppet/type/eos_acl_entry.rb +126 -0
- data/lib/puppet/type/eos_command.rb +75 -0
- data/lib/puppet/type/eos_ethernet.rb +101 -0
- data/lib/puppet/type/eos_interface.rb +79 -0
- data/lib/puppet/type/eos_ipinterface.rb +116 -0
- data/lib/puppet/type/eos_mlag.rb +133 -0
- data/lib/puppet/type/eos_mlag_interface.rb +85 -0
- data/lib/puppet/type/eos_ntp_config.rb +70 -0
- data/lib/puppet/type/eos_ntp_server.rb +52 -0
- data/lib/puppet/type/eos_portchannel.rb +189 -0
- data/lib/puppet/type/eos_snmp.rb +127 -0
- data/lib/puppet/type/eos_stp_interface.rb +94 -0
- data/lib/puppet/type/eos_switchport.rb +150 -0
- data/lib/puppet/type/eos_system.rb +69 -0
- data/lib/puppet/type/eos_vlan.rb +130 -0
- data/lib/puppet/type/eos_vxlan.rb +150 -0
- data/lib/puppet/type/eos_vxlan_vlan.rb +78 -0
- data/lib/puppet/type/eos_vxlan_vtep.rb +62 -0
- data/lib/puppet_x/eos/provider.rb +86 -0
- data/lib/puppet_x/eos/utils/helpers.rb +34 -0
- data/metadata.json +20 -0
- data/spec/fixtures/README +61 -0
- data/spec/fixtures/ethernet.json +9 -0
- data/spec/fixtures/fixture_stp.yaml +11 -0
- data/spec/fixtures/fixture_vxlan_get.yaml +11 -0
- data/spec/fixtures/ospf.json +13 -0
- data/spec/fixtures/snmp.json +6 -0
- data/spec/fixtures/varp.json +11 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/fixtures.rb +74 -0
- data/spec/support/shared_examples_for_providers.rb +7 -0
- data/spec/support/shared_examples_for_types.rb +451 -0
- data/spec/unit/puppet/provider/eos_acl_entry/default_spec.rb +226 -0
- data/spec/unit/puppet/provider/eos_acl_entry/fixture_acl_entry.yaml +20 -0
- data/spec/unit/puppet/provider/eos_ethernet/default_spec.rb +226 -0
- data/spec/unit/puppet/provider/eos_ethernet/fixture_ethernet.yaml +8 -0
- data/spec/unit/puppet/provider/eos_interface/default_spec.rb +176 -0
- data/spec/unit/puppet/provider/eos_interface/fixture_interfaces.yaml +5 -0
- data/spec/unit/puppet/provider/eos_ipinterface/default_spec.rb +223 -0
- data/spec/unit/puppet/provider/eos_ipinterface/fixture_ipinterfaces.yaml +5 -0
- data/spec/unit/puppet/provider/eos_mlag/default_spec.rb +203 -0
- data/spec/unit/puppet/provider/eos_mlag/fixture_mlag.yaml +11 -0
- data/spec/unit/puppet/provider/eos_mlag_interface/default_spec.rb +177 -0
- data/spec/unit/puppet/provider/eos_mlag_interface/fixture_mlag.yaml +11 -0
- data/spec/unit/puppet/provider/eos_ntp_config/default_spec.rb +150 -0
- data/spec/unit/puppet/provider/eos_ntp_config/fixture_ntp.yaml +3 -0
- data/spec/unit/puppet/provider/eos_ntp_server/default_spec.rb +152 -0
- data/spec/unit/puppet/provider/eos_ntp_server/fixture_ntp.yaml +3 -0
- data/spec/unit/puppet/provider/eos_portchannel/default_spec.rb +271 -0
- data/spec/unit/puppet/provider/eos_portchannel/fixture_portchannels.yaml +10 -0
- data/spec/unit/puppet/provider/eos_snmp/default_spec.rb +193 -0
- data/spec/unit/puppet/provider/eos_snmp/fixture_snmp.yaml +6 -0
- data/spec/unit/puppet/provider/eos_stp_interface/default_spec.rb +138 -0
- data/spec/unit/puppet/provider/eos_switchport/default_spec.rb +250 -0
- data/spec/unit/puppet/provider/eos_switchport/fixture_switchports.yaml +7 -0
- data/spec/unit/puppet/provider/eos_system/default_spec.rb +129 -0
- data/spec/unit/puppet/provider/eos_system/fixture_system.yaml +2 -0
- data/spec/unit/puppet/provider/eos_vlan/default_spec.rb +228 -0
- data/spec/unit/puppet/provider/eos_vlan/fixture_vlans.yaml +6 -0
- data/spec/unit/puppet/provider/eos_vxlan/default_spec.rb +229 -0
- data/spec/unit/puppet/provider/eos_vxlan/fixture_vxlan.yaml +9 -0
- data/spec/unit/puppet/provider/eos_vxlan_vlan/default_spec.rb +148 -0
- data/spec/unit/puppet/provider/eos_vxlan_vtep/default_spec.rb +140 -0
- data/spec/unit/puppet/type/eos_acl_entry_spec.rb +103 -0
- data/spec/unit/puppet/type/eos_command_spec.rb +67 -0
- data/spec/unit/puppet/type/eos_ethernet_spec.rb +87 -0
- data/spec/unit/puppet/type/eos_interface_spec.rb +67 -0
- data/spec/unit/puppet/type/eos_ipinterface_spec.rb +84 -0
- data/spec/unit/puppet/type/eos_mlag_interface_spec.rb +62 -0
- data/spec/unit/puppet/type/eos_mlag_spec.rb +98 -0
- data/spec/unit/puppet/type/eos_ntp_config_spec.rb +58 -0
- data/spec/unit/puppet/type/eos_ntp_server_spec.rb +51 -0
- data/spec/unit/puppet/type/eos_portchannel_spec.rb +99 -0
- data/spec/unit/puppet/type/eos_snmp_spec.rb +87 -0
- data/spec/unit/puppet/type/eos_stp_interface_spec.rb +77 -0
- data/spec/unit/puppet/type/eos_switchport_spec.rb +88 -0
- data/spec/unit/puppet/type/eos_system_spec.rb +57 -0
- data/spec/unit/puppet/type/eos_vlan_spec.rb +86 -0
- data/spec/unit/puppet/type/eos_vxlan_spec.rb +100 -0
- data/spec/unit/puppet/type/eos_vxlan_vlan_spec.rb +73 -0
- data/spec/unit/puppet/type/eos_vxlan_vtep_spec.rb +52 -0
- data/tests/init.pp +12 -0
- metadata +437 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2014, 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
|
+
include FixtureHelpers
|
|
35
|
+
|
|
36
|
+
describe Puppet::Type.type(:eos_interface).provider(:eos) do
|
|
37
|
+
# Puppet RAL memoized methods
|
|
38
|
+
let(:resource) do
|
|
39
|
+
resource_hash = {
|
|
40
|
+
name: 'Loopback0',
|
|
41
|
+
description: 'test interface',
|
|
42
|
+
enable: :true,
|
|
43
|
+
provider: described_class.name
|
|
44
|
+
}
|
|
45
|
+
Puppet::Type.type(:eos_interface).new(resource_hash)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
let(:provider) { resource.provider }
|
|
49
|
+
|
|
50
|
+
let(:api) { double('interfaces') }
|
|
51
|
+
|
|
52
|
+
def interfaces
|
|
53
|
+
interfaces = Fixtures[:interfaces]
|
|
54
|
+
return interfaces if interfaces
|
|
55
|
+
fixture('interfaces', dir: File.dirname(__FILE__))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
before :each do
|
|
59
|
+
allow(described_class.node).to receive(:api).with('interfaces')
|
|
60
|
+
.and_return(api)
|
|
61
|
+
allow(provider.node).to receive(:api).with('interfaces').and_return(api)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'class methods' do
|
|
65
|
+
before { allow(api).to receive(:getall).and_return(interfaces) }
|
|
66
|
+
|
|
67
|
+
describe '.instances' do
|
|
68
|
+
subject { described_class.instances }
|
|
69
|
+
|
|
70
|
+
it { is_expected.to be_an Array }
|
|
71
|
+
|
|
72
|
+
it 'has one entry' do
|
|
73
|
+
expect(subject.size).to eq(1)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'has an instance for interface Loopback0' do
|
|
77
|
+
instance = subject.find { |p| p.name == 'Loopback0' }
|
|
78
|
+
expect(instance).to be_a described_class
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context 'eos_interface { Loopback0: }' do
|
|
82
|
+
subject { described_class.instances.find { |p| p.name == 'Loopback0' } }
|
|
83
|
+
|
|
84
|
+
include_examples 'provider resource methods',
|
|
85
|
+
name: 'Loopback0',
|
|
86
|
+
description: 'test interface',
|
|
87
|
+
enable: :true
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe '.prefetch' do
|
|
92
|
+
let :resources do
|
|
93
|
+
{
|
|
94
|
+
'Loopback0' => Puppet::Type.type(:eos_interface)
|
|
95
|
+
.new(name: 'Loopback0'),
|
|
96
|
+
'Loopback2' => Puppet::Type.type(:eos_interface)
|
|
97
|
+
.new(name: 'Loopback2')
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
subject { described_class.prefetch(resources) }
|
|
101
|
+
|
|
102
|
+
it 'resource providers are absent prior to calling .prefetch' do
|
|
103
|
+
resources.values.each do |rsrc|
|
|
104
|
+
expect(rsrc.provider.description).to eq(:absent)
|
|
105
|
+
expect(rsrc.provider.enable).to eq(:absent)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'sets the provider instance of the managed resource' do
|
|
110
|
+
subject
|
|
111
|
+
expect(resources['Loopback0'].provider.description).to \
|
|
112
|
+
eq('test interface')
|
|
113
|
+
expect(resources['Loopback0'].provider.enable).to eq :true
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'does not set the provider instance of the unmanaged resource' do
|
|
117
|
+
subject
|
|
118
|
+
expect(resources['Loopback2'].provider.description).to eq :absent
|
|
119
|
+
expect(resources['Loopback2'].provider.enable).to eq :absent
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
context 'resource (instance) methods' do
|
|
125
|
+
describe '#create' do
|
|
126
|
+
let(:name) { 'Loopback0' }
|
|
127
|
+
|
|
128
|
+
before do
|
|
129
|
+
expect(api).to receive(:create).with(resource[:name])
|
|
130
|
+
allow(api).to receive_messages(
|
|
131
|
+
set_shutdown: true,
|
|
132
|
+
set_description: true
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'sets enable on the resource' do
|
|
137
|
+
provider.create
|
|
138
|
+
expect(provider.enable).to be_truthy
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it 'sets description on the resource' do
|
|
142
|
+
provider.create
|
|
143
|
+
expect(provider.description).to eq('test interface')
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe '#destroy' do
|
|
148
|
+
it 'sets ensure to :absent' do
|
|
149
|
+
expect(api).to receive(:delete).with(resource[:name])
|
|
150
|
+
provider.destroy
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe '#description=(value)' do
|
|
155
|
+
it 'updates description in the provider' do
|
|
156
|
+
expect(api).to receive(:set_description)
|
|
157
|
+
.with(resource[:name], value: 'foo')
|
|
158
|
+
provider.description = 'foo'
|
|
159
|
+
expect(provider.description).to eq('foo')
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
describe '#enable=(value)' do
|
|
164
|
+
%w(true false).each do |val|
|
|
165
|
+
let(:value) { !val }
|
|
166
|
+
let(:name) { 'Loopback0' }
|
|
167
|
+
|
|
168
|
+
it 'updates enable in the provider' do
|
|
169
|
+
expect(api).to receive(:set_shutdown).with(name, value: !val)
|
|
170
|
+
provider.enable = val
|
|
171
|
+
expect(provider.enable).to eq(val)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2014, 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
|
+
include FixtureHelpers
|
|
35
|
+
|
|
36
|
+
describe Puppet::Type.type(:eos_ipinterface).provider(:eos) do
|
|
37
|
+
# Puppet RAL memoized methods
|
|
38
|
+
let(:resource) do
|
|
39
|
+
resource_hash = {
|
|
40
|
+
ensure: :present,
|
|
41
|
+
name: 'Ethernet1',
|
|
42
|
+
address: '1.2.3.4/5',
|
|
43
|
+
helper_addresses: %w(5.6.7.8 9.10.11.12),
|
|
44
|
+
mtu: '9000',
|
|
45
|
+
provider: described_class.name
|
|
46
|
+
}
|
|
47
|
+
Puppet::Type.type(:eos_ipinterface).new(resource_hash)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
let(:provider) { resource.provider }
|
|
51
|
+
|
|
52
|
+
let(:api) { double('ipinterfaces') }
|
|
53
|
+
|
|
54
|
+
def ipinterfaces
|
|
55
|
+
ipinterfaces = Fixtures[:ipinterfaces]
|
|
56
|
+
return ipinterfaces if ipinterfaces
|
|
57
|
+
fixture('ipinterfaces', dir: File.dirname(__FILE__))
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
before :each do
|
|
61
|
+
allow(described_class.node).to receive(:api).with('ipinterfaces')
|
|
62
|
+
.and_return(api)
|
|
63
|
+
allow(provider.node).to receive(:api).with('ipinterfaces').and_return(api)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context 'class methods' do
|
|
67
|
+
before { allow(api).to receive(:getall).and_return(ipinterfaces) }
|
|
68
|
+
|
|
69
|
+
describe '.instances' do
|
|
70
|
+
subject { described_class.instances }
|
|
71
|
+
|
|
72
|
+
it { is_expected.to be_an Array }
|
|
73
|
+
|
|
74
|
+
it 'has one entry' do
|
|
75
|
+
expect(subject.size).to eq 1
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'has an instance for Ethernet1' do
|
|
79
|
+
instance = subject.find { |p| p.name == 'Ethernet1' }
|
|
80
|
+
expect(instance).to be_a described_class
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
context "eos_ipinterface { 'Ethernet1': }" do
|
|
84
|
+
subject { described_class.instances.find { |p| p.name == 'Ethernet1' } }
|
|
85
|
+
|
|
86
|
+
include_examples 'provider resource methods',
|
|
87
|
+
ensure: :present,
|
|
88
|
+
name: 'Ethernet1',
|
|
89
|
+
address: '1.2.3.4/5',
|
|
90
|
+
helper_addresses: %w(5.6.7.8 9.10.11.12),
|
|
91
|
+
mtu: '1500',
|
|
92
|
+
exists?: true
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe '.prefetch' do
|
|
97
|
+
let :resources do
|
|
98
|
+
{
|
|
99
|
+
'Ethernet1' => Puppet::Type.type(:eos_ipinterface)
|
|
100
|
+
.new(name: 'Ethernet1'),
|
|
101
|
+
'Ethernet2' => Puppet::Type.type(:eos_ipinterface)
|
|
102
|
+
.new(name: 'Ethernet2')
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
subject { described_class.prefetch(resources) }
|
|
107
|
+
|
|
108
|
+
it 'resource providers are absent prior to calling .prefetch' do
|
|
109
|
+
resources.values.each do |rsrc|
|
|
110
|
+
expect(rsrc.provider.address).to eq(:absent)
|
|
111
|
+
expect(rsrc.provider.mtu).to eq(:absent)
|
|
112
|
+
expect(rsrc.provider.helper_addresses).to eq(:absent)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'sets the provider instance of the managed resource' do
|
|
117
|
+
subject
|
|
118
|
+
expect(resources['Ethernet1'].provider.name).to eq 'Ethernet1'
|
|
119
|
+
expect(resources['Ethernet1'].provider.address).to eq '1.2.3.4/5'
|
|
120
|
+
expect(resources['Ethernet1'].provider.mtu).to eq '1500'
|
|
121
|
+
expect(resources['Ethernet1'].provider.helper_addresses).to \
|
|
122
|
+
eq %w(5.6.7.8 9.10.11.12)
|
|
123
|
+
expect(resources['Ethernet1'].provider.exists?).to be_truthy
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'does not set the provider instance of the unmanaged resource' do
|
|
127
|
+
subject
|
|
128
|
+
expect(resources['Ethernet2'].provider.name).to eq('Ethernet2')
|
|
129
|
+
expect(resources['Ethernet2'].provider.address).to eq(:absent)
|
|
130
|
+
expect(resources['Ethernet2'].provider.mtu).to eq(:absent)
|
|
131
|
+
expect(resources['Ethernet2'].provider.helper_addresses).to eq(:absent)
|
|
132
|
+
expect(resources['Ethernet2'].provider.exists?).to be_falsey
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
context 'resource (instance) methods' do
|
|
138
|
+
describe '#exists?' do
|
|
139
|
+
subject { provider.exists? }
|
|
140
|
+
|
|
141
|
+
context 'when the resource does not exist on the system' do
|
|
142
|
+
it { is_expected.to be_falsey }
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
context 'when the resource exists on the system' do
|
|
146
|
+
let(:provider) do
|
|
147
|
+
allow(api).to receive(:getall).and_return(ipinterfaces)
|
|
148
|
+
described_class.instances.first
|
|
149
|
+
end
|
|
150
|
+
it { is_expected.to be_truthy }
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe '#create' do
|
|
155
|
+
let(:name) { resource[:name] }
|
|
156
|
+
|
|
157
|
+
before do
|
|
158
|
+
expect(api).to receive(:create).with(name)
|
|
159
|
+
allow(api).to receive_messages(
|
|
160
|
+
set_address: true,
|
|
161
|
+
set_mtu: true,
|
|
162
|
+
set_helper_addresses: true
|
|
163
|
+
)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'sets ensure to :present' do
|
|
167
|
+
provider.create
|
|
168
|
+
expect(provider.ensure).to eq(:present)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'sets address to the resource value' do
|
|
172
|
+
provider.create
|
|
173
|
+
expect(provider.address).to eq(provider.resource[:address])
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it 'sets mtu to the resource value' do
|
|
177
|
+
provider.create
|
|
178
|
+
expect(provider.mtu).to eq(provider.resource[:mtu])
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it 'sets helper_addresses to the resource value' do
|
|
182
|
+
provider.create
|
|
183
|
+
expect(provider.helper_addresses).to eq(resource[:helper_addresses])
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
describe '#destroy' do
|
|
188
|
+
it 'sets ensure to :absent' do
|
|
189
|
+
expect(api).to receive(:delete).with(resource[:name])
|
|
190
|
+
provider.destroy
|
|
191
|
+
expect(provider.ensure).to eq(:absent)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
describe '#address=(val)' do
|
|
196
|
+
it 'updates address on the provider' do
|
|
197
|
+
expect(api).to receive(:set_address)
|
|
198
|
+
.with(resource[:name], value: '1.2.3.4/5')
|
|
199
|
+
provider.address = '1.2.3.4/5'
|
|
200
|
+
expect(provider.address).to eq('1.2.3.4/5')
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
describe '#mtu=(val)' do
|
|
205
|
+
it 'updates mtu on the provider' do
|
|
206
|
+
expect(api).to receive(:set_mtu).with(resource[:name], value: 1600)
|
|
207
|
+
provider.mtu = 1600
|
|
208
|
+
expect(provider.mtu).to eq(1600)
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
describe '#helper_addresses=(val)' do
|
|
213
|
+
let(:value) { %w(5.6.7.8 9.10.11.12) }
|
|
214
|
+
|
|
215
|
+
it 'updates helper_addresses on the provider' do
|
|
216
|
+
expect(api).to receive(:set_helper_addresses)
|
|
217
|
+
.with(resource[:name], value: value)
|
|
218
|
+
provider.helper_addresses = value
|
|
219
|
+
expect(provider.helper_addresses).to eq(value)
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2014, 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
|
+
include FixtureHelpers
|
|
35
|
+
|
|
36
|
+
describe Puppet::Type.type(:eos_mlag).provider(:eos) do
|
|
37
|
+
# Puppet RAL memoized methods
|
|
38
|
+
let(:resource) do
|
|
39
|
+
resource_hash = {
|
|
40
|
+
name: 'settings',
|
|
41
|
+
domain_id: 'MLAG-Domain',
|
|
42
|
+
local_interface: 'Vlan4094',
|
|
43
|
+
peer_address: '10.1.1.1',
|
|
44
|
+
peer_link: 'Port-Channel1',
|
|
45
|
+
enable: :true,
|
|
46
|
+
provider: described_class.name
|
|
47
|
+
}
|
|
48
|
+
Puppet::Type.type(:eos_mlag).new(resource_hash)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
let(:provider) { resource.provider }
|
|
52
|
+
|
|
53
|
+
let(:api) { double('mlag') }
|
|
54
|
+
|
|
55
|
+
def mlag
|
|
56
|
+
mlag = Fixtures[:mlag]
|
|
57
|
+
return mlag if mlag
|
|
58
|
+
fixture('mlag', dir: File.dirname(__FILE__))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
before :each do
|
|
62
|
+
allow(described_class.node).to receive(:api).with('mlag').and_return(api)
|
|
63
|
+
allow(provider.node).to receive(:api).with('mlag').and_return(api)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context 'class methods' do
|
|
67
|
+
before { allow(api).to receive(:get).and_return(mlag) }
|
|
68
|
+
|
|
69
|
+
describe '.instances' do
|
|
70
|
+
subject { described_class.instances }
|
|
71
|
+
|
|
72
|
+
it { is_expected.to be_an Array }
|
|
73
|
+
|
|
74
|
+
it 'has only one entry' do
|
|
75
|
+
expect(subject.size).to eq 1
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'has an instance for settings' do
|
|
79
|
+
instance = subject.find { |p| p.name == 'settings' }
|
|
80
|
+
expect(instance).to be_a described_class
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
context "eos_mlag { 'settings': }" do
|
|
84
|
+
subject { described_class.instances.find { |p| p.name == 'settings' } }
|
|
85
|
+
|
|
86
|
+
include_examples 'provider resource methods',
|
|
87
|
+
name: 'settings',
|
|
88
|
+
domain_id: 'MLAG-Domain',
|
|
89
|
+
local_interface: 'Vlan4094',
|
|
90
|
+
peer_address: '1.1.1.1',
|
|
91
|
+
peer_link: 'Port-Channel1',
|
|
92
|
+
enable: :true
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe '.prefetch' do
|
|
97
|
+
let :resources do
|
|
98
|
+
{
|
|
99
|
+
'settings' => Puppet::Type.type(:eos_mlag).new(name: 'settings'),
|
|
100
|
+
'alternative' => Puppet::Type.type(:eos_mlag).new(name: 'alternative')
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
subject { described_class.prefetch(resources) }
|
|
105
|
+
|
|
106
|
+
it 'resource providers are absent prior to calling .prefetch' do
|
|
107
|
+
resources.values.each do |rsrc|
|
|
108
|
+
expect(rsrc.provider.domain_id).to eq(:absent)
|
|
109
|
+
expect(rsrc.provider.local_interface).to eq(:absent)
|
|
110
|
+
expect(rsrc.provider.peer_address).to eq(:absent)
|
|
111
|
+
expect(rsrc.provider.peer_link).to eq(:absent)
|
|
112
|
+
expect(rsrc.provider.enable).to eq(:absent)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'sets the provider instance of the managed resource' do
|
|
117
|
+
subject
|
|
118
|
+
expect(resources['settings'].provider.name).to eq 'settings'
|
|
119
|
+
expect(resources['settings'].provider.exists?).to be_truthy
|
|
120
|
+
expect(resources['settings'].provider.domain_id).to eq 'MLAG-Domain'
|
|
121
|
+
expect(resources['settings'].provider.local_interface).to eq 'Vlan4094'
|
|
122
|
+
expect(resources['settings'].provider.peer_address).to eq '1.1.1.1'
|
|
123
|
+
expect(resources['settings'].provider.peer_link).to eq 'Port-Channel1'
|
|
124
|
+
expect(resources['settings'].provider.enable).to eq :true
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'does not set the provider instance of the unmanaged resource' do
|
|
128
|
+
subject
|
|
129
|
+
expect(resources['alternative'].provider.name).to eq 'alternative'
|
|
130
|
+
expect(resources['alternative'].provider.exists?).to be_falsy
|
|
131
|
+
expect(resources['alternative'].provider.domain_id).to eq :absent
|
|
132
|
+
expect(resources['alternative'].provider.local_interface).to eq :absent
|
|
133
|
+
expect(resources['alternative'].provider.peer_address).to eq :absent
|
|
134
|
+
expect(resources['alternative'].provider.peer_link).to eq :absent
|
|
135
|
+
expect(resources['alternative'].provider.enable).to eq :absent
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'resource (instance) methods' do
|
|
141
|
+
describe '#exists?' do
|
|
142
|
+
subject { provider.exists? }
|
|
143
|
+
|
|
144
|
+
context 'when the resource does not exist on the system' do
|
|
145
|
+
it { is_expected.to be_falsey }
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
context 'when the resource exists on the system' do
|
|
149
|
+
let(:provider) do
|
|
150
|
+
allow(api).to receive(:get).and_return(mlag)
|
|
151
|
+
described_class.instances.first
|
|
152
|
+
end
|
|
153
|
+
it { is_expected.to be_truthy }
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe '#local_interface=(val)' do
|
|
158
|
+
it 'updates the local_interface with Loopback1' do
|
|
159
|
+
expect(api).to receive(:set_local_interface).with(value: 'Loopback1')
|
|
160
|
+
provider.local_interface = 'Loopback1'
|
|
161
|
+
expect(provider.local_interface).to eq('Loopback1')
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
describe '#domain_id=(val)' do
|
|
166
|
+
it 'updates the domain_id with value "foo"' do
|
|
167
|
+
expect(api).to receive(:set_domain_id).with(value: 'foo')
|
|
168
|
+
provider.domain_id = 'foo'
|
|
169
|
+
expect(provider.domain_id).to eq('foo')
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
describe '#peer_address=(val)' do
|
|
174
|
+
it 'updates the peer_address with value "2.2.2.2"' do
|
|
175
|
+
expect(api).to receive(:set_peer_address).with(value: '2.2.2.2')
|
|
176
|
+
provider.peer_address = '2.2.2.2'
|
|
177
|
+
expect(provider.peer_address).to eq('2.2.2.2')
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
describe '#peer_link=(val)' do
|
|
182
|
+
it 'updates the peer_link with value "Vlan1234"' do
|
|
183
|
+
expect(api).to receive(:set_peer_link).with(value: 'Vlan1234')
|
|
184
|
+
provider.peer_link = 'Vlan1234'
|
|
185
|
+
expect(provider.peer_link).to eq('Vlan1234')
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
describe '#enable=(val)' do
|
|
190
|
+
it 'updates enable with value :true' do
|
|
191
|
+
expect(api).to receive(:set_shutdown).with(value: false)
|
|
192
|
+
provider.enable = :true
|
|
193
|
+
expect(provider.enable).to eq(:true)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it 'updates enable with the value :false' do
|
|
197
|
+
expect(api).to receive(:set_shutdown).with(value: true)
|
|
198
|
+
provider.enable = :false
|
|
199
|
+
expect(provider.enable).to eq(:false)
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|