rbeapi 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -25,7 +25,8 @@ describe Rbeapi::Api::PortchannelInterface do
25
25
  .with(include('show port-channel'), format: 'text')
26
26
  .and_return([{ result:
27
27
  { 'output' => "Port Channel Port-Channel1:\n Active " \
28
- "Ports: Ethernet1 PeerEthernet1 \n\n" } }])
28
+ 'Ports: Ethernet1 PeerEthernet1 ' \
29
+ "Ethernet51/1 \n\n" } }])
29
30
  end
30
31
  let(:resource) { subject.get('Port-Channel1') }
31
32
 
@@ -51,7 +52,7 @@ describe Rbeapi::Api::PortchannelInterface do
51
52
  end
52
53
 
53
54
  it 'returns 1 member' do
54
- expect(resource[:members]).to contain_exactly('Ethernet1')
55
+ expect(resource[:members]).to contain_exactly('Ethernet1', 'Ethernet51/1')
55
56
  end
56
57
  end
57
58
 
@@ -89,7 +90,8 @@ describe Rbeapi::Api::PortchannelInterface do
89
90
  expect(node).to receive(:config)
90
91
  .with(['interface Port-Channel1', 'no description'])
91
92
 
92
- expect(subject.set_description('Port-Channel1')).to be_truthy
93
+ expect(subject.set_description('Port-Channel1',
94
+ enable: false)).to be_truthy
93
95
  end
94
96
 
95
97
  it 'defaults the interface description' do
@@ -100,11 +102,11 @@ describe Rbeapi::Api::PortchannelInterface do
100
102
  .to be_truthy
101
103
  end
102
104
 
103
- it 'default is preferred over value' do
105
+ it 'default is preferred over enable' do
104
106
  expect(node).to receive(:config)
105
107
  .with(['interface Port-Channel1', 'default description'])
106
108
 
107
- opts = { value: 'test', default: true }
109
+ opts = { enable: false, default: true }
108
110
  expect(subject.set_description('Port-Channel1', opts)).to be_truthy
109
111
  end
110
112
  end
@@ -114,21 +116,14 @@ describe Rbeapi::Api::PortchannelInterface do
114
116
  expect(node).to receive(:config)
115
117
  .with(['interface Port-Channel1', 'no shutdown'])
116
118
 
117
- expect(subject.set_shutdown('Port-Channel1', value: false)).to be_truthy
119
+ expect(subject.set_shutdown('Port-Channel1', enable: true)).to be_truthy
118
120
  end
119
121
 
120
122
  it 'disables the interface' do
121
123
  expect(node).to receive(:config)
122
124
  .with(['interface Port-Channel1', 'shutdown'])
123
125
 
124
- expect(subject.set_shutdown('Port-Channel1', value: true)).to be_truthy
125
- end
126
-
127
- it 'negates the interface description' do
128
- expect(node).to receive(:config)
129
- .with(['interface Port-Channel1', 'no shutdown'])
130
-
131
- expect(subject.set_shutdown('Port-Channel1')).to be_truthy
126
+ expect(subject.set_shutdown('Port-Channel1', enable: false)).to be_truthy
132
127
  end
133
128
 
134
129
  it 'defaults the interface state' do
@@ -138,11 +133,11 @@ describe Rbeapi::Api::PortchannelInterface do
138
133
  expect(subject.set_shutdown('Port-Channel1', default: true)).to be_truthy
139
134
  end
140
135
 
141
- it 'default is preferred over value' do
136
+ it 'default is preferred over enable' do
142
137
  expect(node).to receive(:config)
143
138
  .with(['interface Port-Channel1', 'default shutdown'])
144
139
 
145
- opts = { value: 'test', default: true }
140
+ opts = { enable: false, default: true }
146
141
  expect(subject.set_shutdown('Port-Channel1', opts)).to be_truthy
147
142
  end
148
143
  end
@@ -72,7 +72,7 @@ describe Rbeapi::Api::VxlanInterface do
72
72
  it 'negates the vxlan source interface value' do
73
73
  commands = ['interface Vxlan1', 'no vxlan source-interface']
74
74
  expect(node).to receive(:config).with(commands)
75
- expect(subject.set_source_interface('Vxlan1')).to be_truthy
75
+ expect(subject.set_source_interface('Vxlan1', enable: false)).to be_truthy
76
76
  end
77
77
 
78
78
  it 'defaults the source interface setting' do
@@ -82,9 +82,9 @@ describe Rbeapi::Api::VxlanInterface do
82
82
  expect(subject.set_source_interface('Vxlan1', opts)).to be_truthy
83
83
  end
84
84
 
85
- it 'prefers default over value' do
85
+ it 'prefers default over enable' do
86
86
  commands = ['interface Vxlan1', 'default vxlan source-interface']
87
- opts = { default: true, value: 'Looback0' }
87
+ opts = { default: true, enable: false }
88
88
  expect(node).to receive(:config).with(commands)
89
89
  expect(subject.set_source_interface('Vxlan1', opts)).to be_truthy
90
90
  end
@@ -101,7 +101,7 @@ describe Rbeapi::Api::VxlanInterface do
101
101
  it 'negates the vxlan multicast group value' do
102
102
  commands = ['interface Vxlan1', 'no vxlan multicast-group']
103
103
  expect(node).to receive(:config).with(commands)
104
- expect(subject.set_multicast_group('Vxlan1')).to be_truthy
104
+ expect(subject.set_multicast_group('Vxlan1', enable: false)).to be_truthy
105
105
  end
106
106
 
107
107
  it 'defaults the multicast group setting' do
@@ -113,7 +113,7 @@ describe Rbeapi::Api::VxlanInterface do
113
113
 
114
114
  it 'prefers default over value' do
115
115
  commands = ['interface Vxlan1', 'default vxlan multicast-group']
116
- opts = { default: true, value: '239.10.10.10' }
116
+ opts = { default: true, enable: false }
117
117
  expect(node).to receive(:config).with(commands)
118
118
  expect(subject.set_multicast_group('Vxlan1', opts)).to be_truthy
119
119
  end
@@ -130,7 +130,7 @@ describe Rbeapi::Api::VxlanInterface do
130
130
  it 'negates the vxlan udp-port value' do
131
131
  commands = ['interface Vxlan1', 'no vxlan udp-port']
132
132
  expect(node).to receive(:config).with(commands)
133
- expect(subject.set_udp_port('Vxlan1')).to be_truthy
133
+ expect(subject.set_udp_port('Vxlan1', enable: false)).to be_truthy
134
134
  end
135
135
 
136
136
  it 'defaults the vxlan udp-port setting' do
@@ -140,9 +140,9 @@ describe Rbeapi::Api::VxlanInterface do
140
140
  expect(subject.set_udp_port('Vxlan1', opts)).to be_truthy
141
141
  end
142
142
 
143
- it 'prefers default over value' do
143
+ it 'prefers default over enable' do
144
144
  commands = ['interface Vxlan1', 'default vxlan udp-port']
145
- opts = { default: true, value: '1024' }
145
+ opts = { default: true, enable: false }
146
146
  expect(node).to receive(:config).with(commands)
147
147
  expect(subject.set_udp_port('Vxlan1', opts)).to be_truthy
148
148
  end
@@ -191,7 +191,7 @@ describe Rbeapi::Api::VxlanInterface do
191
191
  it 'negates the interface description' do
192
192
  expect(node).to receive(:config).with(['interface Vxlan1',
193
193
  'no description'])
194
- expect(subject.set_description('Vxlan1')).to be_truthy
194
+ expect(subject.set_description('Vxlan1', enable: false)).to be_truthy
195
195
  end
196
196
 
197
197
  it 'defaults the interface description' do
@@ -200,10 +200,10 @@ describe Rbeapi::Api::VxlanInterface do
200
200
  expect(subject.set_description('Vxlan1', default: true)).to be_truthy
201
201
  end
202
202
 
203
- it 'default is preferred over value' do
203
+ it 'default is preferred over enable' do
204
204
  expect(node).to receive(:config).with(['interface Vxlan1',
205
205
  'default description'])
206
- expect(subject.set_description('Vxlan1', value: 'test',
206
+ expect(subject.set_description('Vxlan1', enable: false,
207
207
  default: true)).to be_truthy
208
208
  end
209
209
  end
@@ -212,19 +212,13 @@ describe Rbeapi::Api::VxlanInterface do
212
212
  it 'enables the interface' do
213
213
  expect(node).to receive(:config).with(['interface Vxlan1',
214
214
  'no shutdown'])
215
- expect(subject.set_shutdown('Vxlan1', value: false)).to be_truthy
215
+ expect(subject.set_shutdown('Vxlan1', enable: true)).to be_truthy
216
216
  end
217
217
 
218
218
  it 'disables the interface' do
219
219
  expect(node).to receive(:config).with(['interface Vxlan1',
220
220
  'shutdown'])
221
- expect(subject.set_shutdown('Vxlan1', value: true)).to be_truthy
222
- end
223
-
224
- it 'negates the interface description' do
225
- expect(node).to receive(:config).with(['interface Vxlan1',
226
- 'no shutdown'])
227
- expect(subject.set_shutdown('Vxlan1')).to be_truthy
221
+ expect(subject.set_shutdown('Vxlan1', enable: false)).to be_truthy
228
222
  end
229
223
 
230
224
  it 'defaults the interface state' do
@@ -233,10 +227,10 @@ describe Rbeapi::Api::VxlanInterface do
233
227
  expect(subject.set_shutdown('Vxlan1', default: true)).to be_truthy
234
228
  end
235
229
 
236
- it 'default is preferred over value' do
230
+ it 'default is preferred over enable' do
237
231
  expect(node).to receive(:config).with(['interface Vxlan1',
238
232
  'default shutdown'])
239
- expect(subject.set_shutdown('Vxlan1', value: 'test', default: true))
233
+ expect(subject.set_shutdown('Vxlan1', enable: false, default: true))
240
234
  .to be_truthy
241
235
  end
242
236
  end
@@ -60,7 +60,7 @@ describe Rbeapi::Api::Mlag do
60
60
  it 'negates the domain_id' do
61
61
  expect(node).to receive(:config).with(['mlag configuration',
62
62
  'no domain-id'])
63
- expect(subject.set_domain_id).to be_truthy
63
+ expect(subject.set_domain_id(enable: false)).to be_truthy
64
64
  end
65
65
 
66
66
  it 'defaults the domain_id' do
@@ -72,7 +72,7 @@ describe Rbeapi::Api::Mlag do
72
72
  it 'default option takes precedence' do
73
73
  expect(node).to receive(:config).with(['mlag configuration',
74
74
  'default domain-id'])
75
- expect(subject.set_domain_id(value: 'foo', default: true)).to be_truthy
75
+ expect(subject.set_domain_id(enable: false, default: true)).to be_truthy
76
76
  end
77
77
  end
78
78
 
@@ -86,7 +86,7 @@ describe Rbeapi::Api::Mlag do
86
86
  it 'negates the local_interface' do
87
87
  expect(node).to receive(:config).with(['mlag configuration',
88
88
  'no local-interface'])
89
- expect(subject.set_local_interface).to be_truthy
89
+ expect(subject.set_local_interface(enable: false)).to be_truthy
90
90
  end
91
91
 
92
92
  it 'defaults the local_interface' do
@@ -98,7 +98,7 @@ describe Rbeapi::Api::Mlag do
98
98
  it 'default option takes precedence' do
99
99
  expect(node).to receive(:config).with(['mlag configuration',
100
100
  'default local-interface'])
101
- expect(subject.set_local_interface(value: 'Port-Channel1',
101
+ expect(subject.set_local_interface(enable: false,
102
102
  default: true)).to be_truthy
103
103
  end
104
104
  end
@@ -113,7 +113,7 @@ describe Rbeapi::Api::Mlag do
113
113
  it 'negates the peer_address' do
114
114
  expect(node).to receive(:config).with(['mlag configuration',
115
115
  'no peer-address'])
116
- expect(subject.set_peer_address).to be_truthy
116
+ expect(subject.set_peer_address(enable: false)).to be_truthy
117
117
  end
118
118
 
119
119
  it 'defaults the peer_address' do
@@ -125,7 +125,7 @@ describe Rbeapi::Api::Mlag do
125
125
  it 'default option takes precedence' do
126
126
  expect(node).to receive(:config).with(['mlag configuration',
127
127
  'default peer-address'])
128
- expect(subject.set_peer_address(value: '1.1.1.1',
128
+ expect(subject.set_peer_address(enable: false,
129
129
  default: true)).to be_truthy
130
130
  end
131
131
  end
@@ -140,7 +140,7 @@ describe Rbeapi::Api::Mlag do
140
140
  it 'negates the peer_link' do
141
141
  expect(node).to receive(:config).with(['mlag configuration',
142
142
  'no peer-link'])
143
- expect(subject.set_peer_link).to be_truthy
143
+ expect(subject.set_peer_link(enable: false)).to be_truthy
144
144
  end
145
145
 
146
146
  it 'defaults the peer_link' do
@@ -152,7 +152,7 @@ describe Rbeapi::Api::Mlag do
152
152
  it 'default option takes precedence' do
153
153
  expect(node).to receive(:config).with(['mlag configuration',
154
154
  'default peer-link'])
155
- expect(subject.set_peer_link(value: 'Vlan4094', default: true))
155
+ expect(subject.set_peer_link(enable: false, default: true))
156
156
  .to be_truthy
157
157
  end
158
158
  end
@@ -167,7 +167,7 @@ describe Rbeapi::Api::Mlag do
167
167
  it 'negates the mlag_id' do
168
168
  expect(node).to receive(:config).with(['interface Port-Channel1',
169
169
  'no mlag'])
170
- expect(subject.set_mlag_id('Port-Channel1')).to be_truthy
170
+ expect(subject.set_mlag_id('Port-Channel1', enable: false)).to be_truthy
171
171
  end
172
172
 
173
173
  it 'defaults the mlag_id' do
@@ -179,7 +179,7 @@ describe Rbeapi::Api::Mlag do
179
179
  it 'default option takes precedence' do
180
180
  expect(node).to receive(:config).with(['interface Port-Channel1',
181
181
  'default mlag'])
182
- expect(subject.set_mlag_id('Port-Channel1', value: 'Vlan4094',
182
+ expect(subject.set_mlag_id('Port-Channel1', enable: false,
183
183
  default: true)).to be_truthy
184
184
  end
185
185
  end
@@ -188,19 +188,13 @@ describe Rbeapi::Api::Mlag do
188
188
  it 'disables the mlag configuration' do
189
189
  expect(node).to receive(:config).with(['mlag configuration',
190
190
  'shutdown'])
191
- expect(subject.set_shutdown(value: true)).to be_truthy
191
+ expect(subject.set_shutdown(enable: false)).to be_truthy
192
192
  end
193
193
 
194
194
  it 'enables the mlag configuration' do
195
195
  expect(node).to receive(:config).with(['mlag configuration',
196
196
  'no shutdown'])
197
- expect(subject.set_shutdown(value: false)).to be_truthy
198
- end
199
-
200
- it 'negates the shutdown value' do
201
- expect(node).to receive(:config).with(['mlag configuration',
202
- 'no shutdown'])
203
- expect(subject.set_shutdown).to be_truthy
197
+ expect(subject.set_shutdown(enable: true)).to be_truthy
204
198
  end
205
199
 
206
200
  it 'defaults the shutdown value' do
@@ -212,7 +206,7 @@ describe Rbeapi::Api::Mlag do
212
206
  it 'default option takes precedence' do
213
207
  expect(node).to receive(:config).with(['mlag configuration',
214
208
  'default shutdown'])
215
- expect(subject.set_shutdown(value: true, default: true)).to be_truthy
209
+ expect(subject.set_shutdown(enable: false, default: true)).to be_truthy
216
210
  end
217
211
  end
218
212
  end
@@ -0,0 +1,138 @@
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/staticroutes'
35
+
36
+ include FixtureHelpers
37
+
38
+ describe Rbeapi::Api::Staticroutes do
39
+ subject { described_class.new(node) }
40
+
41
+ let(:node) { double('node') }
42
+
43
+ def staticroutes
44
+ staticroutes = Fixtures[:staticroutes]
45
+ return staticroutes if staticroutes
46
+ fixture('staticroutes', format: :text, dir: File.dirname(__FILE__))
47
+ end
48
+
49
+ before :each do
50
+ allow(subject.node).to receive(:running_config).and_return(staticroutes)
51
+ end
52
+
53
+ describe '#getall' do
54
+ it 'returns the staticroute collection' do
55
+ expect(subject.getall).to include(destination: '1.2.3.4/32',
56
+ nexthop: 'Ethernet7',
57
+ distance: '4',
58
+ tag: '3',
59
+ name: 'frank')
60
+ expect(subject.getall).to include(destination: '1.2.3.4/32',
61
+ nexthop: 'Null0',
62
+ distance: '32',
63
+ tag: '3',
64
+ name: 'fred')
65
+ expect(subject.getall).to include(destination: '192.0.2.0/24',
66
+ nexthop: 'Ethernet7',
67
+ distance: '3',
68
+ tag: '0',
69
+ name: 'dummy1')
70
+ expect(subject.getall).to include(destination: '192.0.3.0/24',
71
+ nexthop: '192.0.3.1',
72
+ distance: '1',
73
+ tag: '0',
74
+ name: 'dummy2')
75
+ end
76
+
77
+ it 'returns a hash collection' do
78
+ expect(subject.getall).to be_a_kind_of(Array)
79
+ end
80
+
81
+ it 'has four entries' do
82
+ expect(subject.getall.size).to eq(4)
83
+ end
84
+ end
85
+
86
+ describe '#create' do
87
+ context 'creates a new staticroute resoure' do
88
+ it 'with minimum input' do
89
+ expect(node).to receive(:config)
90
+ .with('ip route 192.0.2.0/24 Ethernet1')
91
+ expect(subject.create('192.0.2.0/24', 'Ethernet1')).to be_truthy
92
+ end
93
+
94
+ it 'with a router_ip' do
95
+ expect(node).to receive(:config)
96
+ .with('ip route 192.0.2.0/24 Ethernet1 192.168.1.1')
97
+ expect(subject.create('192.0.2.0/24', 'Ethernet1',
98
+ router_ip: '192.168.1.1')).to be_truthy
99
+ end
100
+
101
+ it 'with distance (metric)' do
102
+ expect(node).to receive(:config)
103
+ .with('ip route 192.0.2.0/24 Ethernet1 254')
104
+ expect(subject.create('192.0.2.0/24', 'Ethernet1', distance: 254))
105
+ .to be_truthy
106
+ end
107
+
108
+ it 'with a tag' do
109
+ expect(node).to receive(:config)
110
+ .with('ip route 192.0.2.0/24 Ethernet1 tag 3')
111
+ expect(subject.create('192.0.2.0/24', 'Ethernet1', tag: 3))
112
+ .to be_truthy
113
+ end
114
+
115
+ it 'with a name' do
116
+ expect(node).to receive(:config)
117
+ .with('ip route 192.0.2.0/24 Ethernet1 name my_route')
118
+ expect(subject.create('192.0.2.0/24', 'Ethernet1', name: 'my_route'))
119
+ .to be_truthy
120
+ end
121
+ end
122
+ end
123
+
124
+ describe '#delete' do
125
+ context 'deletes a staticroute resource' do
126
+ it 'given only a destination network' do
127
+ expect(node).to receive(:config).with('no ip route 192.0.2.0/24')
128
+ expect(subject.delete('192.0.2.0/24')).to be_truthy
129
+ end
130
+
131
+ it 'given a destination and nexthop' do
132
+ expect(node).to receive(:config)
133
+ .with('no ip route 192.0.2.0/24 Ethernet1')
134
+ expect(subject.delete('192.0.2.0/24', 'Ethernet1')).to be_truthy
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,5 @@
1
+ ip route 1.2.3.4/32 Ethernet7 4 tag 3 name frank
2
+ ip route 1.2.3.4/32 Null0 32 tag 3 name fred
3
+ ip route 192.0.2.0/24 Ethernet7 3 tag 0 name dummy1
4
+ ip route 192.0.3.0/24 192.0.3.1 1 tag 0 name dummy2
5
+ !
@@ -72,7 +72,7 @@ describe Rbeapi::Api::Vlans do
72
72
 
73
73
  it 'negates vlan name' do
74
74
  expect(node).to receive(:config).with(['vlan 1', 'no name'])
75
- expect(subject.set_name('1')).to be_truthy
75
+ expect(subject.set_name('1', enable: false)).to be_truthy
76
76
  end
77
77
 
78
78
  it 'defaults the vlan name' do
@@ -82,7 +82,7 @@ describe Rbeapi::Api::Vlans do
82
82
 
83
83
  it 'default option takes precedence' do
84
84
  expect(node).to receive(:config).with(['vlan 1', 'default name'])
85
- expect(subject.set_name('1', value: 'foo', default: true)).to be_truthy
85
+ expect(subject.set_name('1', enable: false, default: true)).to be_truthy
86
86
  end
87
87
  end
88
88
 
@@ -99,7 +99,7 @@ describe Rbeapi::Api::Vlans do
99
99
 
100
100
  it 'negates the state' do
101
101
  expect(node).to receive(:config).with(['vlan 1', 'no state'])
102
- expect(subject.set_state('1')).to be_truthy
102
+ expect(subject.set_state('1', enable: false)).to be_truthy
103
103
  end
104
104
 
105
105
  it 'defaults the state' do
@@ -109,7 +109,7 @@ describe Rbeapi::Api::Vlans do
109
109
 
110
110
  it 'default option take precedence' do
111
111
  expect(node).to receive(:config).with(['vlan 1', 'default state'])
112
- expect(subject.set_state('1', value: 'active', default: true)).to \
112
+ expect(subject.set_state('1', enable: false, default: true)).to \
113
113
  be_truthy
114
114
  end
115
115
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbeapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-09 00:00:00.000000000 Z
12
+ date: 2015-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: inifile
@@ -215,6 +215,7 @@ files:
215
215
  - lib/rbeapi/api.rb
216
216
  - lib/rbeapi/api/aaa.rb
217
217
  - lib/rbeapi/api/acl.rb
218
+ - lib/rbeapi/api/bgp.rb
218
219
  - lib/rbeapi/api/dns.rb
219
220
  - lib/rbeapi/api/interfaces.rb
220
221
  - lib/rbeapi/api/ipinterfaces.rb
@@ -268,6 +269,9 @@ files:
268
269
  - spec/system/rbeapi/api/vlans_spec.rb
269
270
  - spec/unit/rbeapi/api/acl/default_spec.rb
270
271
  - spec/unit/rbeapi/api/acl/fixture_acl_standard.text
272
+ - spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb
273
+ - spec/unit/rbeapi/api/bgp/bgp_spec.rb
274
+ - spec/unit/rbeapi/api/bgp/fixture_bgp.text
271
275
  - spec/unit/rbeapi/api/interfaces/base_spec.rb
272
276
  - spec/unit/rbeapi/api/interfaces/ethernet_spec.rb
273
277
  - spec/unit/rbeapi/api/interfaces/fixture_interfaces.text
@@ -275,6 +279,8 @@ files:
275
279
  - spec/unit/rbeapi/api/interfaces/vxlan_spec.rb
276
280
  - spec/unit/rbeapi/api/mlag/default_spec.rb
277
281
  - spec/unit/rbeapi/api/mlag/fixture_mlag.text
282
+ - spec/unit/rbeapi/api/staticroutes/default_spec.rb
283
+ - spec/unit/rbeapi/api/staticroutes/fixture_staticroutes.text
278
284
  - spec/unit/rbeapi/api/vlans/default_spec.rb
279
285
  - spec/unit/rbeapi/api/vlans/fixture_vlans.text
280
286
  homepage: https://github.com/arista-eosplus/rbeapi
@@ -292,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
292
298
  version: '0'
293
299
  segments:
294
300
  - 0
295
- hash: 1144077190260473885
301
+ hash: -1143951047580431806
296
302
  required_rubygems_version: !ruby/object:Gem::Requirement
297
303
  none: false
298
304
  requirements:
@@ -301,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
307
  version: '0'
302
308
  segments:
303
309
  - 0
304
- hash: 1144077190260473885
310
+ hash: -1143951047580431806
305
311
  requirements: []
306
312
  rubyforge_project:
307
313
  rubygems_version: 1.8.23
@@ -337,6 +343,9 @@ test_files:
337
343
  - spec/system/rbeapi/api/vlans_spec.rb
338
344
  - spec/unit/rbeapi/api/acl/default_spec.rb
339
345
  - spec/unit/rbeapi/api/acl/fixture_acl_standard.text
346
+ - spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb
347
+ - spec/unit/rbeapi/api/bgp/bgp_spec.rb
348
+ - spec/unit/rbeapi/api/bgp/fixture_bgp.text
340
349
  - spec/unit/rbeapi/api/interfaces/base_spec.rb
341
350
  - spec/unit/rbeapi/api/interfaces/ethernet_spec.rb
342
351
  - spec/unit/rbeapi/api/interfaces/fixture_interfaces.text
@@ -344,6 +353,8 @@ test_files:
344
353
  - spec/unit/rbeapi/api/interfaces/vxlan_spec.rb
345
354
  - spec/unit/rbeapi/api/mlag/default_spec.rb
346
355
  - spec/unit/rbeapi/api/mlag/fixture_mlag.text
356
+ - spec/unit/rbeapi/api/staticroutes/default_spec.rb
357
+ - spec/unit/rbeapi/api/staticroutes/fixture_staticroutes.text
347
358
  - spec/unit/rbeapi/api/vlans/default_spec.rb
348
359
  - spec/unit/rbeapi/api/vlans/fixture_vlans.text
349
360
  has_rdoc: