puppet_x_eos_eapi 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +24 -0
  4. data/LICENSE.txt +202 -0
  5. data/README.md +87 -0
  6. data/Rakefile +1 -0
  7. data/lib/puppet_x/eos/autoload.rb +57 -0
  8. data/lib/puppet_x/eos/eapi.rb +259 -0
  9. data/lib/puppet_x/eos/module_base.rb +37 -0
  10. data/lib/puppet_x/eos/modules/daemon.rb +109 -0
  11. data/lib/puppet_x/eos/modules/extension.rb +167 -0
  12. data/lib/puppet_x/eos/modules/interface.rb +180 -0
  13. data/lib/puppet_x/eos/modules/ipinterface.rb +133 -0
  14. data/lib/puppet_x/eos/modules/mlag.rb +268 -0
  15. data/lib/puppet_x/eos/modules/ntp.rb +129 -0
  16. data/lib/puppet_x/eos/modules/ospf.rb +129 -0
  17. data/lib/puppet_x/eos/modules/portchannel.rb +277 -0
  18. data/lib/puppet_x/eos/modules/radius.rb +367 -0
  19. data/lib/puppet_x/eos/modules/snmp.rb +177 -0
  20. data/lib/puppet_x/eos/modules/switchport.rb +255 -0
  21. data/lib/puppet_x/eos/modules/system.rb +138 -0
  22. data/lib/puppet_x/eos/modules/tacacs.rb +302 -0
  23. data/lib/puppet_x/eos/modules/vlan.rb +179 -0
  24. data/lib/puppet_x/eos/modules/vxlan.rb +132 -0
  25. data/lib/puppet_x/eos/provider.rb +71 -0
  26. data/lib/puppet_x/eos/version.rb +41 -0
  27. data/lib/puppet_x/net_dev/eos_api.rb +1011 -0
  28. data/lib/puppet_x/net_dev/eos_api/common_methods.rb +27 -0
  29. data/lib/puppet_x/net_dev/eos_api/snmp_methods.rb +647 -0
  30. data/lib/puppet_x/net_dev/eos_api/version.rb +8 -0
  31. data/lib/puppet_x_eos_eapi.rb +4 -0
  32. data/puppet_x_eos_eapi.gemspec +31 -0
  33. data/spec/fixtures/fixture_all_portchannel_modes.json +8 -0
  34. data/spec/fixtures/fixture_all_portchannels_detailed.json +15 -0
  35. data/spec/fixtures/fixture_create_vlan_error.json +17 -0
  36. data/spec/fixtures/fixture_create_vlan_success.json +12 -0
  37. data/spec/fixtures/fixture_eapi_conf.yaml +4 -0
  38. data/spec/fixtures/fixture_enable_configure_vlan_3111_name_foo.json +14 -0
  39. data/spec/fixtures/fixture_enable_configure_vlan_foo_name_bar.json +19 -0
  40. data/spec/fixtures/fixture_get_snmp_communities_non_existent_acl.yaml +2 -0
  41. data/spec/fixtures/fixture_get_snmp_location_westeros.json +5 -0
  42. data/spec/fixtures/fixture_portchannel_min_links_1.json +8 -0
  43. data/spec/fixtures/fixture_portchannel_min_links_2.json +8 -0
  44. data/spec/fixtures/fixture_running_config.yaml +1 -0
  45. data/spec/fixtures/fixture_running_configuration_radius_configured.yaml +30 -0
  46. data/spec/fixtures/fixture_running_configuration_radius_default.yaml +29 -0
  47. data/spec/fixtures/fixture_running_configuration_radius_server_groups.yaml +38 -0
  48. data/spec/fixtures/fixture_running_configuration_radius_servers.yaml +34 -0
  49. data/spec/fixtures/fixture_running_configuration_tacacs_configured.yaml +38 -0
  50. data/spec/fixtures/fixture_running_configuration_tacacs_default.yaml +38 -0
  51. data/spec/fixtures/fixture_running_configuration_tacacs_groups.yaml +1 -0
  52. data/spec/fixtures/fixture_running_configuration_tacacs_groups_3.yaml +43 -0
  53. data/spec/fixtures/fixture_running_configuration_tacacs_servers.yaml +41 -0
  54. data/spec/fixtures/fixture_s4_show_etherchannel_detailed.json +9 -0
  55. data/spec/fixtures/fixture_show_flowcontrol_et1.json +5 -0
  56. data/spec/fixtures/fixture_show_interfaces.json +297 -0
  57. data/spec/fixtures/fixture_show_interfaces_switchport_format_text.json +9 -0
  58. data/spec/fixtures/fixture_show_port_channel_summary_2_lags.json +9 -0
  59. data/spec/fixtures/fixture_show_port_channel_summary_static.json +9 -0
  60. data/spec/fixtures/fixture_show_snmp_community.yaml +2 -0
  61. data/spec/fixtures/fixture_show_snmp_contact_empty.json +5 -0
  62. data/spec/fixtures/fixture_show_snmp_contact_name.json +5 -0
  63. data/spec/fixtures/fixture_show_snmp_disabled.json +5 -0
  64. data/spec/fixtures/fixture_show_snmp_enabled.json +5 -0
  65. data/spec/fixtures/fixture_show_snmp_host.yaml +2 -0
  66. data/spec/fixtures/fixture_show_snmp_host_duplicates.yaml +2 -0
  67. data/spec/fixtures/fixture_show_snmp_host_more_duplicates.yaml +2 -0
  68. data/spec/fixtures/fixture_show_snmp_location_empty.json +5 -0
  69. data/spec/fixtures/fixture_show_snmp_trap.yaml +2 -0
  70. data/spec/fixtures/fixture_show_snmp_user.yaml +2 -0
  71. data/spec/fixtures/fixture_show_snmp_user_raw_text.yaml +1 -0
  72. data/spec/fixtures/fixture_show_vlan.json +37 -0
  73. data/spec/fixtures/fixture_show_vlan_3110.json +18 -0
  74. data/spec/fixtures/fixture_show_vlan_4000.json +18 -0
  75. data/spec/fixtures/fixture_snmp_host_opts.yaml +11 -0
  76. data/spec/spec_helper.rb +21 -0
  77. data/spec/support/fixtures.rb +104 -0
  78. data/spec/unit/puppet_x/eos/eapi_spec.rb +182 -0
  79. data/spec/unit/puppet_x/eos/module_base_spec.rb +26 -0
  80. data/spec/unit/puppet_x/eos/modules/daemon_spec.rb +110 -0
  81. data/spec/unit/puppet_x/eos/modules/extension_spec.rb +197 -0
  82. data/spec/unit/puppet_x/eos/modules/fixtures/daemon_getall.json +3 -0
  83. data/spec/unit/puppet_x/eos/modules/fixtures/extension_getall.json +28 -0
  84. data/spec/unit/puppet_x/eos/modules/fixtures/hostname.json +6 -0
  85. data/spec/unit/puppet_x/eos/modules/fixtures/interface_getall.json +509 -0
  86. data/spec/unit/puppet_x/eos/modules/fixtures/ipinterface_getall.json +56 -0
  87. data/spec/unit/puppet_x/eos/modules/fixtures/mlag_get.json +21 -0
  88. data/spec/unit/puppet_x/eos/modules/fixtures/mlag_get_interfaces.json +18 -0
  89. data/spec/unit/puppet_x/eos/modules/fixtures/ntp_get.json +5 -0
  90. data/spec/unit/puppet_x/eos/modules/fixtures/ospf_instance_getall.json +58 -0
  91. data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_get.json +54 -0
  92. data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_getlacpmode.json +5 -0
  93. data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_getmembers.json +5 -0
  94. data/spec/unit/puppet_x/eos/modules/fixtures/portchannel_po1.json +7 -0
  95. data/spec/unit/puppet_x/eos/modules/fixtures/snmp_get.json +14 -0
  96. data/spec/unit/puppet_x/eos/modules/fixtures/switchport_get.json +5 -0
  97. data/spec/unit/puppet_x/eos/modules/fixtures/switchport_get_et1.json +7 -0
  98. data/spec/unit/puppet_x/eos/modules/fixtures/switchport_getall_interfaces.json +230 -0
  99. data/spec/unit/puppet_x/eos/modules/fixtures/system_domain_list.json +5 -0
  100. data/spec/unit/puppet_x/eos/modules/fixtures/system_domain_name.json +5 -0
  101. data/spec/unit/puppet_x/eos/modules/fixtures/system_hostname.json +6 -0
  102. data/spec/unit/puppet_x/eos/modules/fixtures/system_name_servers.json +5 -0
  103. data/spec/unit/puppet_x/eos/modules/fixtures/vlan_getall.json +123 -0
  104. data/spec/unit/puppet_x/eos/modules/fixtures/vxlan_get.json +24 -0
  105. data/spec/unit/puppet_x/eos/modules/interface_spec.rb +281 -0
  106. data/spec/unit/puppet_x/eos/modules/ipinterface_spec.rb +143 -0
  107. data/spec/unit/puppet_x/eos/modules/mlag_spec.rb +349 -0
  108. data/spec/unit/puppet_x/eos/modules/ntp_spec.rb +136 -0
  109. data/spec/unit/puppet_x/eos/modules/ospf_spec.rb +143 -0
  110. data/spec/unit/puppet_x/eos/modules/portchannel_spec.rb +357 -0
  111. data/spec/unit/puppet_x/eos/modules/radius_spec.rb +509 -0
  112. data/spec/unit/puppet_x/eos/modules/snmp_spec.rb +202 -0
  113. data/spec/unit/puppet_x/eos/modules/switchport_get_et1.json +7 -0
  114. data/spec/unit/puppet_x/eos/modules/switchport_spec.rb +307 -0
  115. data/spec/unit/puppet_x/eos/modules/system_spec.rb +170 -0
  116. data/spec/unit/puppet_x/eos/modules/tacacs_spec.rb +448 -0
  117. data/spec/unit/puppet_x/eos/modules/vlan_spec.rb +244 -0
  118. data/spec/unit/puppet_x/eos/modules/vxlan_spec.rb +189 -0
  119. data/spec/unit/puppet_x/eos/provider_spec.rb +35 -0
  120. data/spec/unit/puppet_x/net_dev/eos_api/common_methods_spec.rb +34 -0
  121. data/spec/unit/puppet_x/net_dev/eos_api/snmp_methods_spec.rb +842 -0
  122. data/spec/unit/puppet_x/net_dev/eos_api_spec.rb +1000 -0
  123. metadata +369 -0
@@ -0,0 +1,143 @@
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/ipinterface'
34
+
35
+ describe PuppetX::Eos::Ipinterface do
36
+ let(:eapi) { double }
37
+ let(:instance) { PuppetX::Eos::Ipinterface.new eapi }
38
+
39
+ context 'when initializing a new Ipinterface instance' do
40
+ subject { instance }
41
+ it { is_expected.to be_a_kind_of PuppetX::Eos::Ipinterface }
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 ip interface' }
55
+
56
+ let :api_response do
57
+ dir = File.dirname(__FILE__)
58
+ file = File.join(dir, 'fixtures/ipinterface_getall.json')
59
+ JSON.load(File.read(file))
60
+ end
61
+
62
+ describe 'retrieve ip interfaces' do
63
+ it { is_expected.to be_a_kind_of Array }
64
+
65
+ it 'has one entry' do
66
+ expect(subject.size).to eq 1
67
+ end
68
+
69
+ it 'includes 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(name) }
85
+
86
+ let(:commands) { ["interface #{name}", 'no switchport'] }
87
+
88
+ describe 'logical ip interface' do
89
+ let(:name) { 'Ethernet1' }
90
+ let(:api_response) { [{}, {}] }
91
+
92
+ it { is_expected.to be_truthy }
93
+ end
94
+ end
95
+
96
+ context '#delete' do
97
+ subject { instance.delete(name) }
98
+
99
+ let(:commands) { ["interface #{name}", 'no ip address'] }
100
+
101
+ describe 'logical ip address' do
102
+ let(:name) { 'Ethernet1' }
103
+ let(:api_response) { [{}, {}] }
104
+
105
+ it { is_expected.to be_truthy }
106
+ end
107
+ end
108
+
109
+ context '#set_address' do
110
+ subject { instance.set_address(name, opts) }
111
+
112
+ let(:opts) { { value: value, default: default } }
113
+ let(:default) { false }
114
+ let(:value) { nil }
115
+
116
+ describe 'with valid address and mask' do
117
+ let(:name) { 'Ethernet1' }
118
+ let(:value) { '10.10.10.10/24' }
119
+ let(:commands) { ["interface #{name}", "ip address #{value}"] }
120
+ let(:api_response) { [{}, {}] }
121
+
122
+ it { is_expected.to be_truthy }
123
+ end
124
+
125
+ describe 'negate address for interface' do
126
+ let(:name) { 'Ethernet1' }
127
+ let(:commands) { ["interface #{name}", 'no ip address'] }
128
+ let(:api_response) { [{}, {}] }
129
+
130
+ it { is_expected.to be_truthy }
131
+ end
132
+
133
+ describe 'default address for interface' do
134
+ let(:name) { 'Ethernet1' }
135
+ let(:default) { true }
136
+ let(:commands) { ["interface #{name}", 'default ip address'] }
137
+ let(:api_response) { [{}, {}] }
138
+
139
+ it { is_expected.to be_truthy }
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,349 @@
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/mlag'
34
+
35
+ describe PuppetX::Eos::Mlag do
36
+ let(:eapi) { double }
37
+ let(:instance) { PuppetX::Eos::Mlag.new eapi }
38
+
39
+ context 'when initializing a new Mlag instance' do
40
+ subject { instance }
41
+ it { is_expected.to be_a_kind_of PuppetX::Eos::Mlag }
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 mlag' }
55
+
56
+ let :api_response do
57
+ dir = File.dirname(__FILE__)
58
+ file = File.join(dir, 'fixtures/mlag_get.json')
59
+ JSON.load(File.read(file))
60
+ end
61
+
62
+ describe 'mlag configuration' do
63
+ it { is_expected.to be_a_kind_of Hash }
64
+ end
65
+ end
66
+
67
+ context '#get_interfaces' do
68
+ subject { instance.get_interfaces }
69
+
70
+ let(:commands) { 'show mlag interfaces' }
71
+
72
+ let :api_response do
73
+ dir = File.dirname(__FILE__)
74
+ file = File.join(dir, 'fixtures/mlag_get_interfaces.json')
75
+ JSON.load(File.read(file))
76
+ end
77
+
78
+ it { is_expected.to be_a_kind_of Array }
79
+
80
+ it 'has only one entry' do
81
+ expect(subject.size).to eq 1
82
+ end
83
+
84
+ it 'has includes key interfaces' do
85
+ expect(subject[0]).to have_key 'interfaces'
86
+ end
87
+ end
88
+ end
89
+
90
+ context 'with Eapi#config' do
91
+ before :each do
92
+ allow(eapi).to receive(:config)
93
+ .with(commands)
94
+ .and_return(api_response)
95
+ end
96
+
97
+ context '#create' do
98
+ subject { instance.create(name) }
99
+
100
+ let(:name) { 'mlag-domain' }
101
+ let(:commands) { ['mlag configuration', "domain-id #{name}"] }
102
+
103
+ describe 'create mlag instance with domain-id' do
104
+ let(:api_response) { [{}, {}] }
105
+ it { is_expected.to be_truthy }
106
+ end
107
+ end
108
+
109
+ context '#delete' do
110
+ subject { instance.delete }
111
+
112
+ let(:commands) { 'no mlag configuration' }
113
+
114
+ describe 'remove mlag configuration' do
115
+ let(:api_response) { [{}] }
116
+ it { is_expected.to be_truthy }
117
+ end
118
+ end
119
+
120
+ context '#default' do
121
+ subject { instance.default }
122
+
123
+ let(:commands) { 'default mlag configuration' }
124
+
125
+ describe 'default mlag configuration' do
126
+ let(:api_response) { [{}] }
127
+ it { is_expected.to be_truthy }
128
+ end
129
+ end
130
+
131
+ context '#add_interface' do
132
+ subject { instance.add_interface(name, mlag_id) }
133
+
134
+ let(:name) { 'Port-Channel1' }
135
+ let(:mlag_id) { 1 }
136
+ let(:commands) { ["interface #{name}", "mlag #{mlag_id}"] }
137
+
138
+ describe 'using mlag id 1' do
139
+ let(:api_response) { [{}, {}] }
140
+
141
+ it { is_expected.to be_truthy }
142
+ end
143
+ end
144
+
145
+ context '#remove_interface' do
146
+ subject { instance.remove_interface(name) }
147
+
148
+ let(:name) { 'Port-Channel1' }
149
+ let(:commands) { ["interface #{name}", 'no mlag'] }
150
+
151
+ describe 'delete from mlag' do
152
+ let(:api_response) { [{}, {}] }
153
+
154
+ it { is_expected.to be_truthy }
155
+ end
156
+ end
157
+
158
+ context '#set_domain_id' do
159
+ subject { instance.set_domain_id(opts) }
160
+
161
+ let(:opts) { { value: value, default: default } }
162
+ let(:default) { false }
163
+ let(:value) { nil }
164
+
165
+ describe 'to foo' do
166
+ let(:value) { 'foo' }
167
+ let(:commands) { ['mlag configuration', 'domain-id foo'] }
168
+ let(:api_response) { [{}, {}] }
169
+
170
+ it { is_expected.to be_truthy }
171
+ end
172
+
173
+ describe 'to negate mlag domain-id' do
174
+ let(:commands) { ['mlag configuration', 'no domain-id'] }
175
+ let(:api_response) { [{}, {}] }
176
+
177
+ it { is_expected.to be_truthy }
178
+ end
179
+
180
+ describe 'default mlag domain-id' do
181
+ let(:default) { true }
182
+ let(:commands) { ['mlag configuration', 'default domain-id'] }
183
+ let(:api_response) { [{}, {}] }
184
+
185
+ it { is_expected.to be_truthy }
186
+ end
187
+ end
188
+
189
+ context '#set_local_interface' do
190
+ subject { instance.set_local_interface(opts) }
191
+
192
+ let(:opts) { { value: value, default: default } }
193
+ let(:default) { false }
194
+ let(:value) { nil }
195
+
196
+ describe 'to value vlan 4094' do
197
+ let(:value) { 'Vlan 4094' }
198
+ let(:commands) { ['mlag configuration', 'local-interface Vlan 4094'] }
199
+ let(:api_response) { [{}, {}] }
200
+
201
+ it { is_expected.to be_truthy }
202
+ end
203
+
204
+ describe 'to negate mlag local-interface' do
205
+ let(:commands) { ['mlag configuration', 'no local-interface'] }
206
+ let(:api_response) { [{}, {}] }
207
+
208
+ it { is_expected.to be_truthy }
209
+ end
210
+
211
+ describe 'default mlag local-interface' do
212
+ let(:default) { true }
213
+ let(:commands) { ['mlag configuration', 'default local-interface'] }
214
+ let(:api_response) { [{}, {}] }
215
+
216
+ it { is_expected.to be_truthy }
217
+ end
218
+ end
219
+
220
+ context '#set_peer_address' do
221
+ subject { instance.set_peer_address(opts) }
222
+
223
+ let(:opts) { { value: value, default: default } }
224
+ let(:default) { false }
225
+ let(:value) { nil }
226
+
227
+ describe 'to value 10.10.10.10' do
228
+ let(:value) { '10.10.10.10' }
229
+ let(:commands) { ['mlag configuration', 'peer-address 10.10.10.10'] }
230
+ let(:api_response) { [{}, {}] }
231
+
232
+ it { is_expected.to be_truthy }
233
+ end
234
+
235
+ describe 'to negate mlag peer-address' do
236
+ let(:commands) { ['mlag configuration', 'no peer-address'] }
237
+ let(:api_response) { [{}, {}] }
238
+
239
+ it { is_expected.to be_truthy }
240
+ end
241
+
242
+ describe 'default mlag peer-address' do
243
+ let(:default) { true }
244
+ let(:commands) { ['mlag configuration', 'default peer-address'] }
245
+ let(:api_response) { [{}, {}] }
246
+
247
+ it { is_expected.to be_truthy }
248
+ end
249
+ end
250
+
251
+ context '#set_peer_link' do
252
+ subject { instance.set_peer_link(opts) }
253
+
254
+ let(:opts) { { value: value, default: default } }
255
+ let(:default) { false }
256
+ let(:value) { nil }
257
+
258
+ describe 'to value Port-Channel 100' do
259
+ let(:value) { 'Port-Channel 100' }
260
+ let(:commands) { ['mlag configuration', 'peer-link Port-Channel 100'] }
261
+ let(:api_response) { [{}, {}] }
262
+
263
+ it { is_expected.to be_truthy }
264
+ end
265
+
266
+ describe 'to negate mlag peer-link' do
267
+ let(:commands) { ['mlag configuration', 'no peer-link'] }
268
+ let(:api_response) { [{}, {}] }
269
+
270
+ it { is_expected.to be_truthy }
271
+ end
272
+
273
+ describe 'default mlag peer-link' do
274
+ let(:default) { true }
275
+ let(:commands) { ['mlag configuration', 'default peer-link'] }
276
+ let(:api_response) { [{}, {}] }
277
+
278
+ it { is_expected.to be_truthy }
279
+ end
280
+ end
281
+
282
+ context '#set_mlag_id' do
283
+ subject { instance.set_mlag_id(name, opts) }
284
+
285
+ let(:name) { 'Port-Channel1' }
286
+ let(:opts) { { value: value, default: default } }
287
+ let(:default) { false }
288
+ let(:value) { nil }
289
+
290
+ describe 'to value 100' do
291
+ let(:value) { '100' }
292
+ let(:commands) { ["interface #{name}", "mlag #{value}"] }
293
+ let(:api_response) { [{}, {}] }
294
+
295
+ it { is_expected.to be_truthy }
296
+ end
297
+
298
+ describe 'to negate mlag peer-link' do
299
+ let(:commands) { ["interface #{name}", 'no mlag'] }
300
+ let(:api_response) { [{}, {}] }
301
+
302
+ it { is_expected.to be_truthy }
303
+ end
304
+
305
+ describe 'default mlag peer-link' do
306
+ let(:default) { true }
307
+ let(:commands) { ["interface #{name}", 'default mlag'] }
308
+ let(:api_response) { [{}, {}] }
309
+
310
+ it { is_expected.to be_truthy }
311
+ end
312
+ end
313
+
314
+ context '#set_shutdown' do
315
+ subject { instance.set_shutdown(opts) }
316
+
317
+ let(:opts) { { value: value, default: default } }
318
+ let(:default) { false }
319
+ let(:value) { nil }
320
+
321
+ describe 'configure shutdown=false' do
322
+ let(:value) { false }
323
+ let(:commands) { ['mlag configuration', 'no shutdown'] }
324
+ let(:api_response) { [{}, {}] }
325
+ it { is_expected.to be_truthy }
326
+ end
327
+
328
+ describe 'configure shutdown=true' do
329
+ let(:value) { true }
330
+ let(:commands) { ['mlag configuration', 'shutdown'] }
331
+ let(:api_response) { [{}, {}] }
332
+ it { is_expected.to be_truthy }
333
+ end
334
+
335
+ describe 'configure default interface shutdown' do
336
+ let(:default) { true }
337
+ let(:commands) { ['mlag configuration', 'default shutdown'] }
338
+ let(:api_response) { [{}, {}] }
339
+ it { is_expected.to be_truthy }
340
+ end
341
+
342
+ describe 'negate interface shutdown' do
343
+ let(:commands) { ['mlag configuration', 'no shutdown'] }
344
+ let(:api_response) { [{}, {}] }
345
+ it { is_expected.to be_truthy }
346
+ end
347
+ end
348
+ end
349
+ end