rbeapi 0.2.0 → 0.3.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.
Files changed (57) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +4 -0
  4. data/README.md +9 -9
  5. data/Rakefile +20 -0
  6. data/lib/rbeapi/api/bgp.rb +770 -0
  7. data/lib/rbeapi/api/dns.rb +32 -31
  8. data/lib/rbeapi/api/interfaces.rb +106 -87
  9. data/lib/rbeapi/api/ipinterfaces.rb +27 -42
  10. data/lib/rbeapi/api/logging.rb +9 -19
  11. data/lib/rbeapi/api/mlag.rb +60 -90
  12. data/lib/rbeapi/api/ntp.rb +12 -17
  13. data/lib/rbeapi/api/ospf.rb +9 -26
  14. data/lib/rbeapi/api/radius.rb +29 -43
  15. data/lib/rbeapi/api/snmp.rb +54 -83
  16. data/lib/rbeapi/api/staticroutes.rb +68 -21
  17. data/lib/rbeapi/api/stp.rb +41 -49
  18. data/lib/rbeapi/api/switchports.rb +41 -68
  19. data/lib/rbeapi/api/system.rb +6 -12
  20. data/lib/rbeapi/api/tacacs.rb +12 -21
  21. data/lib/rbeapi/api/varp.rb +25 -26
  22. data/lib/rbeapi/api/vlans.rb +19 -28
  23. data/lib/rbeapi/api.rb +30 -21
  24. data/lib/rbeapi/client.rb +3 -1
  25. data/lib/rbeapi/version.rb +1 -1
  26. data/rbeapi.spec.tmpl +4 -0
  27. data/spec/spec_helper.rb +8 -0
  28. data/spec/system/api_ospf_interfaces_spec.rb +16 -0
  29. data/spec/system/api_ospf_spec.rb +14 -0
  30. data/spec/system/api_varp_interfaces_spec.rb +16 -0
  31. data/spec/system/rbeapi/api/dns_spec.rb +66 -0
  32. data/spec/system/rbeapi/api/interfaces_base_spec.rb +4 -4
  33. data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +6 -6
  34. data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +6 -6
  35. data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +4 -4
  36. data/spec/system/rbeapi/api/ipinterfaces_spec.rb +44 -0
  37. data/spec/system/rbeapi/api/logging_spec.rb +18 -2
  38. data/spec/system/rbeapi/api/mlag_spec.rb +94 -2
  39. data/spec/system/rbeapi/api/ntp_spec.rb +14 -0
  40. data/spec/system/rbeapi/api/snmp_spec.rb +105 -0
  41. data/spec/system/rbeapi/api/stp_interfaces_spec.rb +43 -6
  42. data/spec/system/rbeapi/api/stp_spec.rb +18 -6
  43. data/spec/system/rbeapi/api/switchports_spec.rb +75 -3
  44. data/spec/system/rbeapi/api/system_spec.rb +16 -0
  45. data/spec/system/rbeapi/api/vlans_spec.rb +28 -0
  46. data/spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb +289 -0
  47. data/spec/unit/rbeapi/api/bgp/bgp_spec.rb +192 -0
  48. data/spec/unit/rbeapi/api/bgp/fixture_bgp.text +101 -0
  49. data/spec/unit/rbeapi/api/interfaces/base_spec.rb +7 -13
  50. data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +3 -3
  51. data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +11 -16
  52. data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +15 -21
  53. data/spec/unit/rbeapi/api/mlag/default_spec.rb +13 -19
  54. data/spec/unit/rbeapi/api/staticroutes/default_spec.rb +138 -0
  55. data/spec/unit/rbeapi/api/staticroutes/fixture_staticroutes.text +5 -0
  56. data/spec/unit/rbeapi/api/vlans/default_spec.rb +4 -4
  57. metadata +15 -4
@@ -0,0 +1,289 @@
1
+ #
2
+ # Copyright (c) 2015, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'spec_helper'
33
+
34
+ require 'rbeapi/api/bgp'
35
+
36
+ include FixtureHelpers
37
+
38
+ describe Rbeapi::Api::BgpNeighbors do
39
+ subject { described_class.new(node) }
40
+
41
+ let(:node) { double('node') }
42
+
43
+ let(:test) do
44
+ { bgp_as: '64600',
45
+ router_id: '192.168.254.1',
46
+ shutdown: false,
47
+ networks: [
48
+ { prefix: '192.168.254.1', masklen: 32, route_map: nil },
49
+ { prefix: '192.168.254.2', masklen: 32, route_map: 'rmap' },
50
+ { prefix: '192.168.254.3', masklen: 32, route_map: nil }
51
+ ],
52
+ neighbors: {
53
+ 'eBGP_GROUP' => {
54
+ peer_group: nil, remote_as: nil, send_community: false,
55
+ shutdown: false, description: nil, next_hop_self: false,
56
+ route_map_in: nil, route_map_out: nil
57
+ },
58
+ '192.168.255.1' => {
59
+ peer_group: 'eBGP_GROUP', remote_as: '65000', send_community: true,
60
+ shutdown: true, description: nil, next_hop_self: true,
61
+ route_map_in: nil, route_map_out: nil
62
+ },
63
+ '192.168.255.3' => {
64
+ peer_group: 'eBGP_GROUP', remote_as: '65001', send_community: true,
65
+ shutdown: true, description: nil, next_hop_self: true,
66
+ route_map_in: nil, route_map_out: nil
67
+ }
68
+ }
69
+ }
70
+ end
71
+ let(:bgp_as) { test[:bgp_as] }
72
+
73
+ def bgp
74
+ bgp = Fixtures[:bgp]
75
+ return bgp if bgp
76
+ fixture('bgp', format: :text, dir: File.dirname(__FILE__))
77
+ end
78
+
79
+ before :each do
80
+ allow(subject.node).to receive(:running_config).and_return(bgp)
81
+ end
82
+
83
+ describe '#get' do
84
+ it 'returns the BGP neighbor resource' do
85
+ expect(subject.get('eBGP_GROUP')).to eq(test[:neighbors]['eBGP_GROUP'])
86
+ end
87
+ end
88
+
89
+ describe '#getall' do
90
+ it 'returns all the neighbors' do
91
+ expect(subject.getall).to eq(test[:neighbors])
92
+ end
93
+
94
+ it 'returns a hash collection' do
95
+ expect(subject.getall).to be_a_kind_of(Hash)
96
+ end
97
+
98
+ it 'has three entries' do
99
+ expect(subject.getall.size).to eq(3)
100
+ end
101
+ end
102
+
103
+ describe '#create' do
104
+ it 'create a new BGP neighbor' do
105
+ expect(node).to receive(:config).with(['router bgp 64600',
106
+ 'neighbor edge shutdown'])
107
+ expect(subject.create('edge')).to be_truthy
108
+ end
109
+ end
110
+
111
+ describe '#delete' do
112
+ it 'delete a BGP resource' do
113
+ expect(node).to receive(:config).with(['router bgp 64600',
114
+ 'neighbor edge shutdown'])
115
+ expect(subject.create('edge')).to be_truthy
116
+ expect(node).to receive(:config).with(['router bgp 64600',
117
+ 'no neighbor edge'])
118
+ expect(subject.delete('edge')).to be_truthy
119
+ end
120
+ end
121
+
122
+ describe '#set_peer_group' do
123
+ it 'set the peer group' do
124
+ expect(node).to receive(:config).with(['router bgp 64600',
125
+ 'neighbor eng peer-group 1.2.3.4'])
126
+ expect(subject.set_peer_group('eng', value: '1.2.3.4')).to be_truthy
127
+ end
128
+
129
+ it 'remove the peer group value' do
130
+ expect(node).to receive(:config).with(['router bgp 64600',
131
+ 'no neighbor eng peer-group'])
132
+ expect(subject.set_peer_group('eng', enable: false))
133
+ .to be_truthy
134
+ end
135
+
136
+ it 'defaults the peer group value' do
137
+ expect(node).to receive(:config).with(['router bgp 64600',
138
+ 'default neighbor eng peer-group'])
139
+ expect(subject.set_peer_group('eng', default: true))
140
+ .to be_truthy
141
+ end
142
+ end
143
+
144
+ describe '#set_remote_as' do
145
+ it 'set the remote AS value' do
146
+ expect(node).to receive(:config).with(['router bgp 64600',
147
+ 'neighbor eng remote-as 10'])
148
+ expect(subject.set_remote_as('eng', value: '10')).to be_truthy
149
+ end
150
+
151
+ it 'remove the remote AS value' do
152
+ expect(node).to receive(:config).with(['router bgp 64600',
153
+ 'no neighbor eng remote-as'])
154
+ expect(subject.set_remote_as('eng', enable: false))
155
+ .to be_truthy
156
+ end
157
+
158
+ it 'defaults the remote AS value' do
159
+ expect(node).to receive(:config).with(['router bgp 64600',
160
+ 'default neighbor eng remote-as'])
161
+ expect(subject.set_remote_as('eng', default: true))
162
+ .to be_truthy
163
+ end
164
+ end
165
+
166
+ describe '#set_shutdown' do
167
+ it 'shutdown neighbor' do
168
+ expect(node).to receive(:config).with(['router bgp 64600',
169
+ 'neighbor eng shutdown'])
170
+ expect(subject.set_shutdown('eng')).to be_truthy
171
+ end
172
+
173
+ it 'negate shutdown neighbor' do
174
+ expect(node).to receive(:config).with(['router bgp 64600',
175
+ 'neighbor eng shutdown'])
176
+ expect(subject.set_shutdown('eng', enable: false)).to be_truthy
177
+ end
178
+
179
+ it 'default shutdown neighbor' do
180
+ expect(node).to receive(:config).with(['router bgp 64600',
181
+ 'default neighbor eng shutdown'])
182
+ expect(subject.set_shutdown('eng', default: true)).to be_truthy
183
+ end
184
+ end
185
+
186
+ describe '#set_send_community' do
187
+ it 'enable neighbor send community' do
188
+ expect(node).to receive(:config).with(['router bgp 64600',
189
+ 'neighbor eng send-community'])
190
+ expect(subject.set_send_community('eng')).to be_truthy
191
+ end
192
+
193
+ it 'negate neighbor send community' do
194
+ expect(node).to receive(:config).with(['router bgp 64600',
195
+ 'no neighbor eng send-community'])
196
+ expect(subject.set_send_community('eng', enable: false)).to be_truthy
197
+ end
198
+
199
+ it 'default neighbor send community' do
200
+ expect(node).to receive(:config)
201
+ .with(['router bgp 64600', 'default neighbor eng send-community'])
202
+ expect(subject.set_send_community('eng', default: true)).to be_truthy
203
+ end
204
+ end
205
+
206
+ describe '#set_next_hop_self' do
207
+ it 'enable neighbor next hop self' do
208
+ expect(node).to receive(:config).with(['router bgp 64600',
209
+ 'neighbor eng next-hop-self'])
210
+ expect(subject.set_next_hop_self('eng')).to be_truthy
211
+ end
212
+
213
+ it 'negate neighbor next hop self' do
214
+ expect(node).to receive(:config).with(['router bgp 64600',
215
+ 'no neighbor eng next-hop-self'])
216
+ expect(subject.set_next_hop_self('eng', enable: false)).to be_truthy
217
+ end
218
+
219
+ it 'default neighbor next hop self' do
220
+ expect(node).to receive(:config)
221
+ .with(['router bgp 64600', 'default neighbor eng next-hop-self'])
222
+ expect(subject.set_next_hop_self('eng', default: true)).to be_truthy
223
+ end
224
+ end
225
+
226
+ describe '#set_route_map_in' do
227
+ it 'set route map in value' do
228
+ expect(node).to receive(:config).with(['router bgp 64600',
229
+ 'neighbor eng route-map edge in'])
230
+ expect(subject.set_route_map_in('eng', value: 'edge')).to be_truthy
231
+ end
232
+
233
+ it 'negate route map in value' do
234
+ expect(node).to receive(:config)
235
+ .with(['router bgp 64600', 'no neighbor eng route-map edge in'])
236
+ expect(subject.set_route_map_in('eng', value: 'edge', enable: false))
237
+ .to be_truthy
238
+ end
239
+
240
+ it 'default route map in value' do
241
+ expect(node).to receive(:config)
242
+ .with(['router bgp 64600', 'default neighbor eng route-map edge in'])
243
+ expect(subject.set_route_map_in('eng', value: 'edge', default: true))
244
+ .to be_truthy
245
+ end
246
+ end
247
+
248
+ describe '#set_route_map_out' do
249
+ it 'set route map out value' do
250
+ expect(node).to receive(:config).with(['router bgp 64600',
251
+ 'neighbor eng route-map edge out'])
252
+ expect(subject.set_route_map_out('eng', value: 'edge')).to be_truthy
253
+ end
254
+
255
+ it 'negate route map out value' do
256
+ expect(node).to receive(:config)
257
+ .with(['router bgp 64600', 'no neighbor eng route-map edge out'])
258
+ expect(subject.set_route_map_out('eng', value: 'edge', enable: false))
259
+ .to be_truthy
260
+ end
261
+
262
+ it 'default route map out value' do
263
+ expect(node).to receive(:config)
264
+ .with(['router bgp 64600', 'default neighbor eng route-map edge out'])
265
+ expect(subject.set_route_map_out('eng', value: 'edge', default: true))
266
+ .to be_truthy
267
+ end
268
+ end
269
+
270
+ describe '#set_description' do
271
+ it 'set the description value' do
272
+ expect(node).to receive(:config).with(['router bgp 64600',
273
+ 'neighbor eng description text'])
274
+ expect(subject.set_description('eng', value: 'text')).to be_truthy
275
+ end
276
+
277
+ it 'negate the description value' do
278
+ expect(node).to receive(:config)
279
+ .with(['router bgp 64600', 'no neighbor eng description'])
280
+ expect(subject.set_description('eng', enable: false)).to be_truthy
281
+ end
282
+
283
+ it 'defaults the description value' do
284
+ expect(node).to receive(:config)
285
+ .with(['router bgp 64600', 'default neighbor eng description'])
286
+ expect(subject.set_description('eng', default: true)).to be_truthy
287
+ end
288
+ end
289
+ end
@@ -0,0 +1,192 @@
1
+ #
2
+ # Copyright (c) 2015, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'spec_helper'
33
+
34
+ require 'rbeapi/api/bgp'
35
+
36
+ include FixtureHelpers
37
+
38
+ describe Rbeapi::Api::Bgp do
39
+ subject { described_class.new(node) }
40
+
41
+ let(:node) { double('node') }
42
+
43
+ let(:test) do
44
+ { bgp_as: '64600',
45
+ router_id: '192.168.254.1',
46
+ shutdown: false,
47
+ networks: [
48
+ { prefix: '192.168.254.1', masklen: 32, route_map: nil },
49
+ { prefix: '192.168.254.2', masklen: 32, route_map: 'rmap' },
50
+ { prefix: '192.168.254.3', masklen: 32, route_map: nil }
51
+ ],
52
+ neighbors: {
53
+ 'eBGP_GROUP' => {
54
+ peer_group: nil, remote_as: nil, send_community: false,
55
+ shutdown: false, description: nil, next_hop_self: false,
56
+ route_map_in: nil, route_map_out: nil
57
+ },
58
+ '192.168.255.1' => {
59
+ peer_group: 'eBGP_GROUP', remote_as: '65000', send_community: true,
60
+ shutdown: true, description: nil, next_hop_self: true,
61
+ route_map_in: nil, route_map_out: nil
62
+ },
63
+ '192.168.255.3' => {
64
+ peer_group: 'eBGP_GROUP', remote_as: '65001', send_community: true,
65
+ shutdown: true, description: nil, next_hop_self: true,
66
+ route_map_in: nil, route_map_out: nil
67
+ }
68
+ }
69
+ }
70
+ end
71
+ let(:bgp_as) { test[:bgp_as] }
72
+
73
+ def bgp
74
+ bgp = Fixtures[:bgp]
75
+ return bgp if bgp
76
+ fixture('bgp', format: :text, dir: File.dirname(__FILE__))
77
+ end
78
+
79
+ before :each do
80
+ allow(subject.node).to receive(:running_config).and_return(bgp)
81
+ end
82
+
83
+ describe '#get' do
84
+ it 'returns the BGP resource' do
85
+ expect(subject.get).to eq(test)
86
+ end
87
+ end
88
+
89
+ describe '#create' do
90
+ it 'create a new BGP resource' do
91
+ expect(node).to receive(:config).with('router bgp 1000')
92
+ expect(subject.create('1000')).to be_truthy
93
+ end
94
+ end
95
+
96
+ describe '#delete' do
97
+ it 'delete a BGP resource' do
98
+ expect(node).to receive(:config).with("no router bgp #{bgp_as}")
99
+ expect(subject.delete).to be_truthy
100
+ end
101
+ end
102
+
103
+ describe '#default' do
104
+ it 'sets router to default value' do
105
+ expect(node).to receive(:config)
106
+ .with('default router bgp 64600')
107
+ expect(subject.default).to be_truthy
108
+ end
109
+ end
110
+
111
+ describe '#set_router_id' do
112
+ it 'set the router id' do
113
+ expect(node).to receive(:config).with(['router bgp 64600',
114
+ 'router-id 1.2.3.4'])
115
+ expect(subject.set_router_id(value: '1.2.3.4')).to be_truthy
116
+ end
117
+
118
+ it 'remove the router-id without a value' do
119
+ expect(node).to receive(:config).with(['router bgp 64600',
120
+ 'no router-id'])
121
+ expect(subject.set_router_id(enable: false)).to be_truthy
122
+ end
123
+
124
+ it 'remove the router-id with a value' do
125
+ expect(node).to receive(:config).with(['router bgp 64600',
126
+ 'no router-id 1.2.3.4'])
127
+ expect(subject.set_router_id(value: '1.2.3.4', enable: false))
128
+ .to be_truthy
129
+ end
130
+
131
+ it 'defaults the router-id without a value' do
132
+ expect(node).to receive(:config).with(['router bgp 64600',
133
+ 'default router-id'])
134
+ expect(subject.set_router_id(default: true)).to be_truthy
135
+ end
136
+
137
+ it 'defaults the router-id with a value' do
138
+ expect(node).to receive(:config).with(['router bgp 64600',
139
+ 'default router-id 1.2.3.4'])
140
+ expect(subject.set_router_id(value: '1.2.3.4', default: true))
141
+ .to be_truthy
142
+ end
143
+ end
144
+
145
+ describe '#set_shutdown' do
146
+ it 'enable BGP routing process' do
147
+ expect(node).to receive(:config).with(['router bgp 64600',
148
+ 'no shutdown'])
149
+ expect(subject.set_shutdown(enable: true)).to be_truthy
150
+ end
151
+
152
+ it 'disable BGP routing process' do
153
+ expect(node).to receive(:config).with(['router bgp 64600',
154
+ 'shutdown'])
155
+ expect(subject.set_shutdown(enable: false)).to be_truthy
156
+ end
157
+
158
+ it 'default BGP routing process state' do
159
+ expect(node).to receive(:config).with(['router bgp 64600',
160
+ 'default shutdown'])
161
+ expect(subject.set_shutdown(default: true)).to be_truthy
162
+ end
163
+ end
164
+
165
+ describe '#add_network' do
166
+ it 'add a BGP network with a route map' do
167
+ expect(node).to receive(:config)
168
+ .with(['router bgp 64600', 'network 1.2.3.0/24 route-map eng'])
169
+ expect(subject.add_network('1.2.3.0', 24, 'eng')).to be_truthy
170
+ end
171
+
172
+ it 'add a BGP network without a route map' do
173
+ expect(node).to receive(:config).with(['router bgp 64600',
174
+ 'network 1.2.3.0/24'])
175
+ expect(subject.add_network('1.2.3.0', 24)).to be_truthy
176
+ end
177
+ end
178
+
179
+ describe '#remove_network' do
180
+ it 'remove a BGP network with a route map' do
181
+ expect(node).to receive(:config)
182
+ .with(['router bgp 64600', 'no network 1.2.3.0/24 route-map eng'])
183
+ expect(subject.remove_network('1.2.3.0', 24, 'eng')).to be_truthy
184
+ end
185
+
186
+ it 'remove a BGP network without a route map' do
187
+ expect(node).to receive(:config).with(['router bgp 64600',
188
+ 'no network 1.2.3.0/24'])
189
+ expect(subject.remove_network('1.2.3.0', 24)).to be_truthy
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,101 @@
1
+ router bgp 64600
2
+ no shutdown
3
+ router-id 192.168.254.1
4
+ bgp convergence time 300
5
+ bgp convergence slow-peer time 90
6
+ no bgp confederation identifier
7
+ no update wait-for-convergence
8
+ no update wait-install
9
+ bgp log-neighbor-changes
10
+ bgp default ipv4-unicast
11
+ no bgp default ipv6-unicast
12
+ timers bgp 60 180
13
+ distance bgp 20 200 200
14
+ graceful-restart stalepath-time 300
15
+ no bgp cluster-id
16
+ bgp client-to-client reflection
17
+ graceful-restart-helper
18
+ bgp peer-mac-resolution-timeout 0
19
+ bgp enforce-first-as
20
+ no default-metric
21
+ no bgp always-compare-med
22
+ no bgp bestpath med missing-as-worst
23
+ no bgp bestpath med confed
24
+ no bgp host-routes fib direct-install
25
+ maximum-paths 32 ecmp 32
26
+ bgp listen limit 1000
27
+ no bgp aspath-cmp-include-nexthop
28
+ no bgp tie-break-on-age
29
+ no bgp tie-break-on-router-id
30
+ no bgp tie-break-on-originator-id
31
+ no bgp tie-break-on-cluster-list-length
32
+ neighbor eBGP_GROUP peer-group
33
+ no neighbor eBGP_GROUP remote-as
34
+ no neighbor eBGP_GROUP import-localpref
35
+ no neighbor eBGP_GROUP export-localpref
36
+ no neighbor eBGP_GROUP description
37
+ no neighbor eBGP_GROUP next-hop-self
38
+ no neighbor eBGP_GROUP next-hop-peer
39
+ no neighbor eBGP_GROUP allowas-in
40
+ no neighbor eBGP_GROUP send-community
41
+ no neighbor eBGP_GROUP shutdown
42
+ no neighbor eBGP_GROUP remove-private-as
43
+ no neighbor eBGP_GROUP out-delay
44
+ no neighbor eBGP_GROUP local-as
45
+ no neighbor eBGP_GROUP weight
46
+ no neighbor eBGP_GROUP transport connection-mode passive
47
+ no neighbor eBGP_GROUP update-source
48
+ no neighbor eBGP_GROUP dont-capability-negotiate
49
+ neighbor eBGP_GROUP fall-over bfd
50
+ no neighbor eBGP_GROUP local-v6-addr
51
+ neighbor eBGP_GROUP soft-reconfiguration inbound
52
+ no neighbor eBGP_GROUP ebgp-multihop
53
+ no neighbor eBGP_GROUP route-reflector-client
54
+ no neighbor eBGP_GROUP timers
55
+ no neighbor eBGP_GROUP route-map in
56
+ neighbor eBGP_GROUP graceful-restart-helper
57
+ no neighbor eBGP_GROUP route-map out
58
+ no neighbor eBGP_GROUP prefix-list in
59
+ no neighbor eBGP_GROUP prefix-list out
60
+ neighbor eBGP_GROUP password 7 6C/HkrwJ53+dsHumQf49Wg==
61
+ no neighbor eBGP_GROUP default-originate
62
+ neighbor eBGP_GROUP enforce-first-as
63
+ no neighbor eBGP_GROUP metric-out
64
+ neighbor eBGP_GROUP maximum-routes 12000
65
+ neighbor 192.168.255.1 peer-group eBGP_GROUP
66
+ neighbor 192.168.255.1 remote-as 65000
67
+ neighbor 192.168.255.3 peer-group eBGP_GROUP
68
+ neighbor 192.168.255.3 remote-as 65001
69
+ network 192.168.254.1/32
70
+ network 192.168.254.2/32 route-map rmap
71
+ network 192.168.254.3/32 rmap
72
+ bgp redistribute-internal
73
+ aggregate-address 192.168.255.0/28 summary-only
74
+ no redistribute connected
75
+ no redistribute ospf match internal
76
+ no redistribute ospf match external
77
+ no redistribute ospf match nssa-external
78
+ no redistribute ospf3 match internal
79
+ no redistribute ospf3 match external
80
+ no redistribute static
81
+ no redistribute rip
82
+ no redistribute aggregate
83
+ address-family ipv4
84
+ default neighbor eBGP_GROUP activate
85
+ no neighbor eBGP_GROUP route-map in
86
+ no neighbor eBGP_GROUP route-map out
87
+ no neighbor eBGP_GROUP default-originate
88
+ default neighbor 192.168.255.1 activate
89
+ default neighbor 192.168.255.3 activate
90
+ !
91
+ address-family ipv6
92
+ default neighbor eBGP_GROUP activate
93
+ no neighbor eBGP_GROUP route-map in
94
+ no neighbor eBGP_GROUP route-map out
95
+ no neighbor eBGP_GROUP prefix-list in
96
+ no neighbor eBGP_GROUP prefix-list out
97
+ no neighbor eBGP_GROUP default-originate
98
+ default neighbor 192.168.255.1 activate
99
+ default neighbor 192.168.255.3 activate
100
+ !
101
+ !
@@ -71,7 +71,7 @@ describe Rbeapi::Api::BaseInterface do
71
71
  it 'negates the interface description' do
72
72
  expect(node).to receive(:config).with(['interface Loopback0',
73
73
  'no description'])
74
- expect(subject.set_description('Loopback0')).to be_truthy
74
+ expect(subject.set_description('Loopback0', enable: false)).to be_truthy
75
75
  end
76
76
 
77
77
  it 'defaults the interface description' do
@@ -80,10 +80,10 @@ describe Rbeapi::Api::BaseInterface do
80
80
  expect(subject.set_description('Loopback0', default: true)).to be_truthy
81
81
  end
82
82
 
83
- it 'default is preferred over value' do
83
+ it 'default is preferred over enable' do
84
84
  expect(node).to receive(:config).with(['interface Loopback0',
85
85
  'default description'])
86
- expect(subject.set_description('Loopback0', value: 'test',
86
+ expect(subject.set_description('Loopback0', enable: false,
87
87
  default: true)).to be_truthy
88
88
  end
89
89
  end
@@ -92,19 +92,13 @@ describe Rbeapi::Api::BaseInterface do
92
92
  it 'enables the interface' do
93
93
  expect(node).to receive(:config).with(['interface Loopback0',
94
94
  'no shutdown'])
95
- expect(subject.set_shutdown('Loopback0', value: false)).to be_truthy
95
+ expect(subject.set_shutdown('Loopback0', enable: true)).to be_truthy
96
96
  end
97
97
 
98
98
  it 'disables the interface' do
99
99
  expect(node).to receive(:config).with(['interface Loopback0',
100
100
  'shutdown'])
101
- expect(subject.set_shutdown('Loopback0', value: true)).to be_truthy
102
- end
103
-
104
- it 'negates the interface description' do
105
- expect(node).to receive(:config).with(['interface Loopback0',
106
- 'no shutdown'])
107
- expect(subject.set_shutdown('Loopback0')).to be_truthy
101
+ expect(subject.set_shutdown('Loopback0', enable: false)).to be_truthy
108
102
  end
109
103
 
110
104
  it 'defaults the interface state' do
@@ -113,10 +107,10 @@ describe Rbeapi::Api::BaseInterface do
113
107
  expect(subject.set_shutdown('Loopback0', default: true)).to be_truthy
114
108
  end
115
109
 
116
- it 'default is preferred over value' do
110
+ it 'default is preferred over enable' do
117
111
  expect(node).to receive(:config).with(['interface Loopback0',
118
112
  'default shutdown'])
119
- expect(subject.set_shutdown('Loopback0', value: 'test',
113
+ expect(subject.set_shutdown('Loopback0', enable: false,
120
114
  default: true)).to be_truthy
121
115
  end
122
116
  end
@@ -70,7 +70,7 @@ describe Rbeapi::Api::EthernetInterface do
70
70
  it 'negates the interface description' do
71
71
  expect(node).to receive(:config).with(['interface Ethernet1',
72
72
  'no description'])
73
- expect(subject.set_description('Ethernet1')).to be_truthy
73
+ expect(subject.set_description('Ethernet1', enable: false)).to be_truthy
74
74
  end
75
75
 
76
76
  it 'defaults the interface description' do
@@ -79,10 +79,10 @@ describe Rbeapi::Api::EthernetInterface do
79
79
  expect(subject.set_description('Ethernet1', default: true)).to be_truthy
80
80
  end
81
81
 
82
- it 'default is preferred over value' do
82
+ it 'default is preferred over enable' do
83
83
  expect(node).to receive(:config).with(['interface Ethernet1',
84
84
  'default description'])
85
- expect(subject.set_description('Ethernet1', value: 'test',
85
+ expect(subject.set_description('Ethernet1', enable: false,
86
86
  default: true)).to be_truthy
87
87
  end
88
88
  end