puppet_x_eos_eapi 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +24 -0
- data/LICENSE.txt +202 -0
- data/README.md +87 -0
- data/Rakefile +1 -0
- data/lib/puppet_x/eos/autoload.rb +57 -0
- data/lib/puppet_x/eos/eapi.rb +259 -0
- data/lib/puppet_x/eos/module_base.rb +37 -0
- data/lib/puppet_x/eos/modules/daemon.rb +109 -0
- data/lib/puppet_x/eos/modules/extension.rb +167 -0
- data/lib/puppet_x/eos/modules/interface.rb +180 -0
- data/lib/puppet_x/eos/modules/ipinterface.rb +133 -0
- data/lib/puppet_x/eos/modules/mlag.rb +268 -0
- data/lib/puppet_x/eos/modules/ntp.rb +129 -0
- data/lib/puppet_x/eos/modules/ospf.rb +129 -0
- data/lib/puppet_x/eos/modules/portchannel.rb +277 -0
- data/lib/puppet_x/eos/modules/radius.rb +367 -0
- data/lib/puppet_x/eos/modules/snmp.rb +177 -0
- data/lib/puppet_x/eos/modules/switchport.rb +255 -0
- data/lib/puppet_x/eos/modules/system.rb +138 -0
- data/lib/puppet_x/eos/modules/tacacs.rb +302 -0
- data/lib/puppet_x/eos/modules/vlan.rb +179 -0
- data/lib/puppet_x/eos/modules/vxlan.rb +132 -0
- data/lib/puppet_x/eos/provider.rb +71 -0
- data/lib/puppet_x/eos/version.rb +41 -0
- data/lib/puppet_x/net_dev/eos_api.rb +1011 -0
- data/lib/puppet_x/net_dev/eos_api/common_methods.rb +27 -0
- data/lib/puppet_x/net_dev/eos_api/snmp_methods.rb +647 -0
- data/lib/puppet_x/net_dev/eos_api/version.rb +8 -0
- data/lib/puppet_x_eos_eapi.rb +4 -0
- data/puppet_x_eos_eapi.gemspec +31 -0
- data/spec/fixtures/fixture_all_portchannel_modes.json +8 -0
- data/spec/fixtures/fixture_all_portchannels_detailed.json +15 -0
- data/spec/fixtures/fixture_create_vlan_error.json +17 -0
- data/spec/fixtures/fixture_create_vlan_success.json +12 -0
- data/spec/fixtures/fixture_eapi_conf.yaml +4 -0
- data/spec/fixtures/fixture_enable_configure_vlan_3111_name_foo.json +14 -0
- data/spec/fixtures/fixture_enable_configure_vlan_foo_name_bar.json +19 -0
- data/spec/fixtures/fixture_get_snmp_communities_non_existent_acl.yaml +2 -0
- data/spec/fixtures/fixture_get_snmp_location_westeros.json +5 -0
- data/spec/fixtures/fixture_portchannel_min_links_1.json +8 -0
- data/spec/fixtures/fixture_portchannel_min_links_2.json +8 -0
- data/spec/fixtures/fixture_running_config.yaml +1 -0
- data/spec/fixtures/fixture_running_configuration_radius_configured.yaml +30 -0
- data/spec/fixtures/fixture_running_configuration_radius_default.yaml +29 -0
- data/spec/fixtures/fixture_running_configuration_radius_server_groups.yaml +38 -0
- data/spec/fixtures/fixture_running_configuration_radius_servers.yaml +34 -0
- data/spec/fixtures/fixture_running_configuration_tacacs_configured.yaml +38 -0
- data/spec/fixtures/fixture_running_configuration_tacacs_default.yaml +38 -0
- data/spec/fixtures/fixture_running_configuration_tacacs_groups.yaml +1 -0
- data/spec/fixtures/fixture_running_configuration_tacacs_groups_3.yaml +43 -0
- data/spec/fixtures/fixture_running_configuration_tacacs_servers.yaml +41 -0
- data/spec/fixtures/fixture_s4_show_etherchannel_detailed.json +9 -0
- data/spec/fixtures/fixture_show_flowcontrol_et1.json +5 -0
- data/spec/fixtures/fixture_show_interfaces.json +297 -0
- data/spec/fixtures/fixture_show_interfaces_switchport_format_text.json +9 -0
- data/spec/fixtures/fixture_show_port_channel_summary_2_lags.json +9 -0
- data/spec/fixtures/fixture_show_port_channel_summary_static.json +9 -0
- data/spec/fixtures/fixture_show_snmp_community.yaml +2 -0
- data/spec/fixtures/fixture_show_snmp_contact_empty.json +5 -0
- data/spec/fixtures/fixture_show_snmp_contact_name.json +5 -0
- data/spec/fixtures/fixture_show_snmp_disabled.json +5 -0
- data/spec/fixtures/fixture_show_snmp_enabled.json +5 -0
- data/spec/fixtures/fixture_show_snmp_host.yaml +2 -0
- data/spec/fixtures/fixture_show_snmp_host_duplicates.yaml +2 -0
- data/spec/fixtures/fixture_show_snmp_host_more_duplicates.yaml +2 -0
- data/spec/fixtures/fixture_show_snmp_location_empty.json +5 -0
- data/spec/fixtures/fixture_show_snmp_trap.yaml +2 -0
- data/spec/fixtures/fixture_show_snmp_user.yaml +2 -0
- data/spec/fixtures/fixture_show_snmp_user_raw_text.yaml +1 -0
- data/spec/fixtures/fixture_show_vlan.json +37 -0
- data/spec/fixtures/fixture_show_vlan_3110.json +18 -0
- data/spec/fixtures/fixture_show_vlan_4000.json +18 -0
- data/spec/fixtures/fixture_snmp_host_opts.yaml +11 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/fixtures.rb +104 -0
- data/spec/unit/puppet_x/eos/eapi_spec.rb +182 -0
- data/spec/unit/puppet_x/eos/module_base_spec.rb +26 -0
- data/spec/unit/puppet_x/eos/modules/daemon_spec.rb +110 -0
- data/spec/unit/puppet_x/eos/modules/extension_spec.rb +197 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/daemon_getall.json +3 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/extension_getall.json +28 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/hostname.json +6 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/interface_getall.json +509 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/ipinterface_getall.json +56 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/mlag_get.json +21 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/mlag_get_interfaces.json +18 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/ntp_get.json +5 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/ospf_instance_getall.json +58 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_get.json +54 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_getlacpmode.json +5 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_getmembers.json +5 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_po1.json +7 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/snmp_get.json +14 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/switchport_get.json +5 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/switchport_get_et1.json +7 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/switchport_getall_interfaces.json +230 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/system_domain_list.json +5 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/system_domain_name.json +5 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/system_hostname.json +6 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/system_name_servers.json +5 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/vlan_getall.json +123 -0
- data/spec/unit/puppet_x/eos/modules/fixtures/vxlan_get.json +24 -0
- data/spec/unit/puppet_x/eos/modules/interface_spec.rb +281 -0
- data/spec/unit/puppet_x/eos/modules/ipinterface_spec.rb +143 -0
- data/spec/unit/puppet_x/eos/modules/mlag_spec.rb +349 -0
- data/spec/unit/puppet_x/eos/modules/ntp_spec.rb +136 -0
- data/spec/unit/puppet_x/eos/modules/ospf_spec.rb +143 -0
- data/spec/unit/puppet_x/eos/modules/portchannel_spec.rb +357 -0
- data/spec/unit/puppet_x/eos/modules/radius_spec.rb +509 -0
- data/spec/unit/puppet_x/eos/modules/snmp_spec.rb +202 -0
- data/spec/unit/puppet_x/eos/modules/switchport_get_et1.json +7 -0
- data/spec/unit/puppet_x/eos/modules/switchport_spec.rb +307 -0
- data/spec/unit/puppet_x/eos/modules/system_spec.rb +170 -0
- data/spec/unit/puppet_x/eos/modules/tacacs_spec.rb +448 -0
- data/spec/unit/puppet_x/eos/modules/vlan_spec.rb +244 -0
- data/spec/unit/puppet_x/eos/modules/vxlan_spec.rb +189 -0
- data/spec/unit/puppet_x/eos/provider_spec.rb +35 -0
- data/spec/unit/puppet_x/net_dev/eos_api/common_methods_spec.rb +34 -0
- data/spec/unit/puppet_x/net_dev/eos_api/snmp_methods_spec.rb +842 -0
- data/spec/unit/puppet_x/net_dev/eos_api_spec.rb +1000 -0
- metadata +369 -0
|
@@ -0,0 +1,244 @@
|
|
|
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
|
+
require 'puppet_x/eos/modules/vlan'
|
|
34
|
+
|
|
35
|
+
describe PuppetX::Eos::Vlan do
|
|
36
|
+
let(:eapi) { double }
|
|
37
|
+
let(:instance) { PuppetX::Eos::Vlan.new eapi }
|
|
38
|
+
|
|
39
|
+
context 'when initializing a new Vlan instance' do
|
|
40
|
+
subject { instance }
|
|
41
|
+
it { is_expected.to be_a_kind_of PuppetX::Eos::Vlan }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'with Eapi#enable' do
|
|
45
|
+
before :each do
|
|
46
|
+
allow(eapi).to receive(:enable)
|
|
47
|
+
.with(commands)
|
|
48
|
+
.and_return(api_response)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context '#getall' do
|
|
52
|
+
subject { instance.getall }
|
|
53
|
+
|
|
54
|
+
let(:commands) { ['show vlan', 'show vlan trunk group'] }
|
|
55
|
+
|
|
56
|
+
let :api_response do
|
|
57
|
+
dir = File.dirname(__FILE__)
|
|
58
|
+
file = File.join(dir, 'fixtures/vlan_getall.json')
|
|
59
|
+
JSON.load(File.read(file))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe 'retrieve vlans' do
|
|
63
|
+
it { is_expected.to be_a_kind_of Array }
|
|
64
|
+
|
|
65
|
+
it 'has two entries' do
|
|
66
|
+
expect(subject.size).to eq 2
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'includes vlans' do
|
|
70
|
+
expect(subject[0]).to have_key 'vlans'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'includes trunkGroups' do
|
|
74
|
+
expect(subject[1]).to have_key 'trunkGroups'
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'vlans to have a 1 to 1 mapping to trunkGroups' do
|
|
78
|
+
subject[0].keys do |vid|
|
|
79
|
+
expect(subject[1]['trunkGroups']).to have_key vid
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context 'with Eapi#config' do
|
|
87
|
+
before :each do
|
|
88
|
+
allow(eapi).to receive(:config)
|
|
89
|
+
.with(commands)
|
|
90
|
+
.and_return(api_response)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context '#create' do
|
|
94
|
+
subject { instance.create(vlanid) }
|
|
95
|
+
|
|
96
|
+
let(:commands) { "vlan #{vlanid}" }
|
|
97
|
+
|
|
98
|
+
describe 'vlan 1234 success' do
|
|
99
|
+
let(:vlanid) { '1234' }
|
|
100
|
+
let(:api_response) { [{}] }
|
|
101
|
+
|
|
102
|
+
it { is_expected.to be_truthy }
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
context '#delete' do
|
|
107
|
+
subject { instance.delete(vlanid) }
|
|
108
|
+
|
|
109
|
+
let(:commands) { "no vlan #{vlanid}" }
|
|
110
|
+
|
|
111
|
+
describe 'vlan 1234 success' do
|
|
112
|
+
let(:vlanid) { '1234' }
|
|
113
|
+
let(:api_response) { [{}] }
|
|
114
|
+
|
|
115
|
+
it { is_expected.to be_truthy }
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context '#default' do
|
|
120
|
+
subject { instance.default(vlanid) }
|
|
121
|
+
|
|
122
|
+
let(:commands) { "default vlan #{vlanid}" }
|
|
123
|
+
|
|
124
|
+
describe 'vlan 1234 success' do
|
|
125
|
+
let(:vlanid) { '1234' }
|
|
126
|
+
let(:api_response) { [{}] }
|
|
127
|
+
|
|
128
|
+
it { is_expected.to be_truthy }
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
context '#set_name' do
|
|
133
|
+
subject { instance.set_name(vlanid, opts) }
|
|
134
|
+
|
|
135
|
+
let(:opts) { { value: value, default: default } }
|
|
136
|
+
let(:default) { false }
|
|
137
|
+
let(:value) { nil }
|
|
138
|
+
|
|
139
|
+
%w(10, 100, 1000).each do |vlanid|
|
|
140
|
+
vlan_name = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
|
|
141
|
+
describe "configure name=#{vlan_name} for vlan #{vlanid}" do
|
|
142
|
+
let(:vlanid) { vlanid }
|
|
143
|
+
let(:value) { vlan_name }
|
|
144
|
+
let(:commands) { ["vlan #{vlanid}", "name #{value}"] }
|
|
145
|
+
let(:api_response) { [{}, {}] }
|
|
146
|
+
|
|
147
|
+
it { is_expected.to be_truthy }
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "negate name for vlan #{vlanid}" do
|
|
151
|
+
let(:vlanid) { vlanid }
|
|
152
|
+
let(:commands) { ["vlan #{vlanid}", 'no name'] }
|
|
153
|
+
let(:api_response) { [{}, {}] }
|
|
154
|
+
|
|
155
|
+
it { is_expected.to be_truthy }
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
describe "default name for vlan #{vlanid}" do
|
|
159
|
+
let(:vlanid) { vlanid }
|
|
160
|
+
let(:default) { true }
|
|
161
|
+
let(:commands) { ["vlan #{vlanid}", 'default name'] }
|
|
162
|
+
let(:api_response) { [{}, {}] }
|
|
163
|
+
|
|
164
|
+
it { is_expected.to be_truthy }
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
context '#set_state' do
|
|
170
|
+
subject { instance.set_state(vlanid, opts) }
|
|
171
|
+
|
|
172
|
+
let(:opts) { { value: value, default: default } }
|
|
173
|
+
let(:default) { false }
|
|
174
|
+
let(:value) { nil }
|
|
175
|
+
|
|
176
|
+
%w(10, 100, 1000).each do |vlanid|
|
|
177
|
+
%w(active suspect).each do |value|
|
|
178
|
+
describe "configure state=#{value} for vlan #{vlanid}" do
|
|
179
|
+
let(:vlanid) { vlanid }
|
|
180
|
+
let(:value) { value }
|
|
181
|
+
let(:commands) { ["vlan #{vlanid}", "state #{value}"] }
|
|
182
|
+
let(:api_response) { [{}, {}] }
|
|
183
|
+
|
|
184
|
+
it { is_expected.to be_truthy }
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
describe "negate state for vlan #{vlanid}" do
|
|
189
|
+
let(:vlanid) { vlanid }
|
|
190
|
+
let(:commands) { ["vlan #{vlanid}", 'no state'] }
|
|
191
|
+
let(:api_response) { [{}, {}] }
|
|
192
|
+
|
|
193
|
+
it { is_expected.to be_truthy }
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
describe "default state for vlan #{vlanid}" do
|
|
197
|
+
let(:vlanid) { vlanid }
|
|
198
|
+
let(:default) { true }
|
|
199
|
+
let(:commands) { ["vlan #{vlanid}", 'default state'] }
|
|
200
|
+
let(:api_response) { [{}, {}] }
|
|
201
|
+
|
|
202
|
+
it { is_expected.to be_truthy }
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
context '#set_trunk_group' do
|
|
208
|
+
subject { instance.set_trunk_group(vlanid, opts) }
|
|
209
|
+
|
|
210
|
+
let(:opts) { { value: value, default: default } }
|
|
211
|
+
let(:default) { false }
|
|
212
|
+
let(:value) { nil }
|
|
213
|
+
|
|
214
|
+
%w(10, 100, 1000).each do |vlanid|
|
|
215
|
+
value = (0...10).map { ('a'..'z').to_a[rand(26)] }.join
|
|
216
|
+
describe "configure trunk_group=#{value} for vlan #{vlanid}" do
|
|
217
|
+
let(:vlanid) { vlanid }
|
|
218
|
+
let(:value) { value }
|
|
219
|
+
let(:commands) { ["vlan #{vlanid}", "trunk group #{value}"] }
|
|
220
|
+
let(:api_response) { [{}, {}] }
|
|
221
|
+
|
|
222
|
+
it { is_expected.to be_truthy }
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
describe "negate trunk group for vlan #{vlanid}" do
|
|
226
|
+
let(:vlanid) { vlanid }
|
|
227
|
+
let(:commands) { ["vlan #{vlanid}", 'no trunk group'] }
|
|
228
|
+
let(:api_response) { [{}, {}] }
|
|
229
|
+
|
|
230
|
+
it { is_expected.to be_truthy }
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
describe "default trunk group for vlan #{vlanid}" do
|
|
234
|
+
let(:vlanid) { vlanid }
|
|
235
|
+
let(:default) { true }
|
|
236
|
+
let(:commands) { ["vlan #{vlanid}", 'default trunk group'] }
|
|
237
|
+
let(:api_response) { [{}, {}] }
|
|
238
|
+
|
|
239
|
+
it { is_expected.to be_truthy }
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
@@ -0,0 +1,189 @@
|
|
|
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
|
+
require 'puppet_x/eos/modules/vxlan'
|
|
34
|
+
|
|
35
|
+
describe PuppetX::Eos::Vxlan do
|
|
36
|
+
let(:eapi) { double }
|
|
37
|
+
let(:instance) { PuppetX::Eos::Vxlan.new eapi }
|
|
38
|
+
|
|
39
|
+
context 'when initializing a new Vxlan instance' do
|
|
40
|
+
subject { instance }
|
|
41
|
+
it { is_expected.to be_a_kind_of PuppetX::Eos::Vxlan }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'with Eapi#enable' do
|
|
45
|
+
before :each do
|
|
46
|
+
allow(eapi).to receive(:enable)
|
|
47
|
+
.with(commands)
|
|
48
|
+
.and_return(api_response)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context '#get' do
|
|
52
|
+
subject { instance.get }
|
|
53
|
+
|
|
54
|
+
let(:commands) { 'show interfaces vxlan 1' }
|
|
55
|
+
|
|
56
|
+
let :api_response do
|
|
57
|
+
dir = File.dirname(__FILE__)
|
|
58
|
+
file = File.join(dir, 'fixtures/vxlan_get.json')
|
|
59
|
+
JSON.load(File.read(file))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe 'vxlan interfaces configuration' do
|
|
63
|
+
it { is_expected.to be_a_kind_of Array }
|
|
64
|
+
|
|
65
|
+
it 'has only one entry' do
|
|
66
|
+
expect(subject.size).to eq 1
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'has key interfaces' do
|
|
70
|
+
expect(subject[0]).to have_key 'interfaces'
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context 'with Eapi#config' do
|
|
77
|
+
before :each do
|
|
78
|
+
allow(eapi).to receive(:config)
|
|
79
|
+
.with(commands)
|
|
80
|
+
.and_return(api_response)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
context '#create' do
|
|
84
|
+
subject { instance.create }
|
|
85
|
+
|
|
86
|
+
let(:commands) { 'interface vxlan 1' }
|
|
87
|
+
|
|
88
|
+
describe 'a new instance of vxlan' do
|
|
89
|
+
let(:api_response) { [{}] }
|
|
90
|
+
|
|
91
|
+
it { is_expected.to be_truthy }
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
context '#delete' do
|
|
96
|
+
subject { instance.delete }
|
|
97
|
+
|
|
98
|
+
let(:commands) { 'no interface vxlan 1' }
|
|
99
|
+
|
|
100
|
+
describe 'a configured instance of vxlan' do
|
|
101
|
+
let(:api_response) { [{}] }
|
|
102
|
+
|
|
103
|
+
it { is_expected.to be_truthy }
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context '#default' do
|
|
108
|
+
subject { instance.default }
|
|
109
|
+
|
|
110
|
+
let(:commands) { 'default interface vxlan 1' }
|
|
111
|
+
|
|
112
|
+
describe 'a configured instance of vxlan' do
|
|
113
|
+
let(:api_response) { [{}] }
|
|
114
|
+
|
|
115
|
+
it { is_expected.to be_truthy }
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context '#set_source_interface' do
|
|
120
|
+
subject { instance.set_source_interface(opts) }
|
|
121
|
+
|
|
122
|
+
let(:opts) { { value: value, default: default } }
|
|
123
|
+
let(:default) { false }
|
|
124
|
+
let(:value) { nil }
|
|
125
|
+
|
|
126
|
+
describe 'to interface loopback 0' do
|
|
127
|
+
let(:value) { 'loopback 0' }
|
|
128
|
+
let(:commands) do
|
|
129
|
+
['interface vxlan 1', 'vxlan source-interface loopback 0']
|
|
130
|
+
end
|
|
131
|
+
let(:api_response) { [{}, {}] }
|
|
132
|
+
|
|
133
|
+
it { is_expected.to be_truthy }
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe 'to negate vxlan source-interface' do
|
|
137
|
+
let(:commands) { ['interface vxlan 1', 'no vxlan source-interface'] }
|
|
138
|
+
let(:api_response) { [{}, {}] }
|
|
139
|
+
|
|
140
|
+
it { is_expected.to be_truthy }
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
describe 'default state vxlan source-interface' do
|
|
144
|
+
let(:default) { true }
|
|
145
|
+
let(:commands) do
|
|
146
|
+
['interface vxlan 1', 'default vxlan source-interface']
|
|
147
|
+
end
|
|
148
|
+
let(:api_response) { [{}, {}] }
|
|
149
|
+
|
|
150
|
+
it { is_expected.to be_truthy }
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
context '#set_multicast_group' do
|
|
155
|
+
subject { instance.set_multicast_group(opts) }
|
|
156
|
+
|
|
157
|
+
let(:opts) { { value: value, default: default } }
|
|
158
|
+
let(:default) { false }
|
|
159
|
+
let(:value) { nil }
|
|
160
|
+
|
|
161
|
+
describe 'to mulitcast address 239.10.10.10' do
|
|
162
|
+
let(:value) { '239.10.10.10' }
|
|
163
|
+
let(:commands) do
|
|
164
|
+
['interface vxlan 1', 'vxlan multicast-group 239.10.10.10']
|
|
165
|
+
end
|
|
166
|
+
let(:api_response) { [{}, {}] }
|
|
167
|
+
|
|
168
|
+
it { is_expected.to be_truthy }
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
describe 'to negate vxlan multicast-group' do
|
|
172
|
+
let(:commands) { ['interface vxlan 1', 'no vxlan multicast-group'] }
|
|
173
|
+
let(:api_response) { [{}, {}] }
|
|
174
|
+
|
|
175
|
+
it { is_expected.to be_truthy }
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
describe 'default state vxlan multicast-group' do
|
|
179
|
+
let(:default) { true }
|
|
180
|
+
let(:commands) do
|
|
181
|
+
['interface vxlan 1', 'default vxlan multicast-group']
|
|
182
|
+
end
|
|
183
|
+
let(:api_response) { [{}, {}] }
|
|
184
|
+
|
|
185
|
+
it { is_expected.to be_truthy }
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe 'PuppetX::Eos::EapiProviderMixin' do
|
|
6
|
+
let :provider do
|
|
7
|
+
klass = Class.new do
|
|
8
|
+
include PuppetX::Eos::EapiProviderMixin
|
|
9
|
+
extend PuppetX::Eos::EapiProviderMixin
|
|
10
|
+
end
|
|
11
|
+
klass.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#conf' do
|
|
15
|
+
subject { provider.conf }
|
|
16
|
+
|
|
17
|
+
context 'with a configuration file' do
|
|
18
|
+
before :each do
|
|
19
|
+
file = Pathname.new(File.join(fixture_dir, 'fixture_eapi_conf.yaml'))
|
|
20
|
+
allow(Pathname).to receive(:new).with('/mnt/flash/eapi.conf')
|
|
21
|
+
.and_return(file)
|
|
22
|
+
end
|
|
23
|
+
it { is_expected.to include(hostname: 'localhost') }
|
|
24
|
+
it { is_expected.to include(port: 80) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context 'without a configuration file' do
|
|
28
|
+
before :each do
|
|
29
|
+
allow(Pathname).to receive(:new).with('/mnt/flash/eapi.conf')
|
|
30
|
+
.and_return(Pathname.new('/does/not/exist'))
|
|
31
|
+
end
|
|
32
|
+
it { is_expected.to eq ({}) }
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|