rbeapi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.gitignore +5 -0
  2. data/.rubocop.yml +21 -0
  3. data/CHANGELOG.md +24 -0
  4. data/Gemfile +3 -1
  5. data/Guardfile +3 -3
  6. data/README.md +92 -17
  7. data/Rakefile +99 -4
  8. data/gems/README.rst +4 -0
  9. data/gems/inifile/.gitignore +2 -0
  10. data/gems/inifile/README.rst +5 -0
  11. data/gems/inifile/inifile.spec.tmpl +84 -0
  12. data/gems/net_http_unix/.gitignore +2 -0
  13. data/gems/net_http_unix/README.rst +5 -0
  14. data/gems/net_http_unix/net_http_unix.spec.tmpl +54 -0
  15. data/gems/netaddr/README.rst +5 -0
  16. data/gems/netaddr/netaddr.spec.tmpl +50 -0
  17. data/lib/rbeapi/api/aaa.rb +14 -17
  18. data/lib/rbeapi/api/acl.rb +276 -0
  19. data/lib/rbeapi/api/dns.rb +7 -4
  20. data/lib/rbeapi/api/interfaces.rb +239 -239
  21. data/lib/rbeapi/api/ipinterfaces.rb +5 -3
  22. data/lib/rbeapi/api/logging.rb +8 -5
  23. data/lib/rbeapi/api/mlag.rb +45 -127
  24. data/lib/rbeapi/api/ntp.rb +1 -4
  25. data/lib/rbeapi/api/ospf.rb +16 -13
  26. data/lib/rbeapi/api/prefixlists.rb +4 -4
  27. data/lib/rbeapi/api/radius.rb +34 -25
  28. data/lib/rbeapi/api/routemaps.rb +16 -10
  29. data/lib/rbeapi/api/snmp.rb +26 -13
  30. data/lib/rbeapi/api/staticroutes.rb +6 -5
  31. data/lib/rbeapi/api/stp.rb +77 -18
  32. data/lib/rbeapi/api/switchports.rb +20 -12
  33. data/lib/rbeapi/api/system.rb +6 -6
  34. data/lib/rbeapi/api/tacacs.rb +9 -6
  35. data/lib/rbeapi/api/varp.rb +15 -10
  36. data/lib/rbeapi/api/vlans.rb +5 -6
  37. data/lib/rbeapi/api.rb +56 -16
  38. data/lib/rbeapi/client.rb +85 -50
  39. data/lib/rbeapi/eapilib.rb +95 -56
  40. data/lib/rbeapi/netdev/snmp.rb +7 -16
  41. data/lib/rbeapi/utils.rb +3 -5
  42. data/lib/rbeapi/version.rb +1 -1
  43. data/rbeapi.gemspec +4 -2
  44. data/rbeapi.spec.tmpl +72 -0
  45. data/spec/support/fixtures.rb +6 -4
  46. data/spec/support/shared_examples_for_api_modules.rb +3 -18
  47. data/spec/system/api_acl_spec.rb +128 -0
  48. data/spec/system/api_ospf_interfaces_spec.rb +17 -14
  49. data/spec/system/api_ospf_spec.rb +8 -8
  50. data/spec/system/api_varp_interfaces_spec.rb +22 -13
  51. data/spec/system/api_varp_spec.rb +1 -4
  52. data/spec/system/rbeapi/api/interfaces_base_spec.rb +3 -4
  53. data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +13 -9
  54. data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +43 -26
  55. data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +7 -6
  56. data/spec/system/rbeapi/api/ipinterfaces_spec.rb +34 -21
  57. data/spec/system/rbeapi/api/mlag_interfaces_spec.rb +15 -38
  58. data/spec/system/rbeapi/api/mlag_spec.rb +26 -30
  59. data/spec/system/rbeapi/api/snmp_spec.rb +0 -3
  60. data/spec/system/rbeapi/api/stp_instances_spec.rb +20 -12
  61. data/spec/system/rbeapi/api/stp_interfaces_spec.rb +1 -3
  62. data/spec/system/rbeapi/api/switchports_spec.rb +14 -12
  63. data/spec/system/rbeapi/api/system_spec.rb +0 -3
  64. data/spec/system/rbeapi/api/vlans_spec.rb +19 -9
  65. data/spec/unit/rbeapi/api/acl/default_spec.rb +158 -0
  66. data/spec/unit/rbeapi/api/acl/fixture_acl_standard.text +22 -0
  67. data/spec/unit/rbeapi/api/interfaces/base_spec.rb +123 -0
  68. data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +89 -0
  69. data/spec/unit/rbeapi/api/interfaces/fixture_interfaces.text +219 -0
  70. data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +149 -0
  71. data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +243 -0
  72. data/spec/unit/rbeapi/api/mlag/default_spec.rb +218 -0
  73. data/spec/unit/rbeapi/api/mlag/fixture_mlag.text +238 -0
  74. data/spec/unit/rbeapi/api/vlans/default_spec.rb +135 -0
  75. data/spec/unit/rbeapi/api/vlans/fixture_vlans.text +5 -0
  76. metadata +79 -4
  77. data/lib/rbeapi/api/radius.rb.old +0 -399
@@ -0,0 +1,219 @@
1
+ interface Loopback0
2
+ no description
3
+ no shutdown
4
+ default load-interval
5
+ mtu 1500
6
+ logging event link-status use-global
7
+ snmp trap link-status
8
+ no ip proxy-arp
9
+ no ip local-proxy-arp
10
+ no ip address
11
+ no ip verify unicast
12
+ default arp timeout 14400
13
+ default ipv6 nd cache expire 14400
14
+ bfd interval 300 min_rx 300 multiplier 3
15
+ no bfd echo
16
+ no ipv6 enable
17
+ no ipv6 address
18
+ no ipv6 verify unicast
19
+ no ipv6 nd ra suppress
20
+ ipv6 nd ra interval msec 200000
21
+ ipv6 nd ra lifetime 1800
22
+ no ipv6 nd ra mtu suppress
23
+ no ipv6 nd managed-config-flag
24
+ no ipv6 nd other-config-flag
25
+ ipv6 nd reachable-time 0
26
+ ipv6 nd router-preference medium
27
+ ipv6 nd ra dns-servers lifetime 300
28
+ ipv6 nd ra dns-suffixes lifetime 300
29
+ ipv6 nd ra hop-limit 64
30
+ default ntp serve
31
+ !
32
+ interface Ethernet1
33
+ no description
34
+ no shutdown
35
+ default load-interval
36
+ logging event link-status use-global
37
+ no dcbx mode
38
+ no mac-address
39
+ no link-debounce
40
+ no flowcontrol send
41
+ no flowcontrol receive
42
+ no mac timestamp
43
+ no speed
44
+ no l2 mtu
45
+ default logging event congestion-drops
46
+ default unidirectional
47
+ switchport access vlan 1
48
+ switchport trunk native vlan 1
49
+ switchport trunk allowed vlan 1-4094
50
+ switchport mode access
51
+ switchport mac address learning
52
+ no switchport private-vlan mapping
53
+ switchport
54
+ default encapsulation dot1q vlan
55
+ no l2-protocol encapsulation dot1q vlan 0
56
+ snmp trap link-status
57
+ no channel-group
58
+ lacp rate normal
59
+ lacp port-priority 32768
60
+ lldp transmit
61
+ lldp receive
62
+ no msrp
63
+ no mvrp
64
+ no switchport port-security
65
+ switchport port-security maximum 1
66
+ default qos trust
67
+ qos cos 5
68
+ qos dscp 2
69
+ no shape rate
70
+ mc-tx-queue 0
71
+ priority strict
72
+ no bandwidth percent
73
+ no shape rate
74
+ no bandwidth guaranteed
75
+ !
76
+ mc-tx-queue 1
77
+ priority strict
78
+ no bandwidth percent
79
+ no shape rate
80
+ no bandwidth guaranteed
81
+ !
82
+ mc-tx-queue 2
83
+ priority strict
84
+ no bandwidth percent
85
+ no shape rate
86
+ no bandwidth guaranteed
87
+ !
88
+ mc-tx-queue 3
89
+ priority strict
90
+ no bandwidth percent
91
+ no shape rate
92
+ no bandwidth guaranteed
93
+ !
94
+ uc-tx-queue 0
95
+ priority strict
96
+ no bandwidth percent
97
+ no shape rate
98
+ no bandwidth guaranteed
99
+ !
100
+ uc-tx-queue 1
101
+ priority strict
102
+ no bandwidth percent
103
+ no shape rate
104
+ no bandwidth guaranteed
105
+ !
106
+ uc-tx-queue 2
107
+ priority strict
108
+ no bandwidth percent
109
+ no shape rate
110
+ no bandwidth guaranteed
111
+ !
112
+ uc-tx-queue 3
113
+ priority strict
114
+ no bandwidth percent
115
+ no shape rate
116
+ no bandwidth guaranteed
117
+ !
118
+ uc-tx-queue 4
119
+ priority strict
120
+ no bandwidth percent
121
+ no shape rate
122
+ no bandwidth guaranteed
123
+ !
124
+ uc-tx-queue 5
125
+ priority strict
126
+ no bandwidth percent
127
+ no shape rate
128
+ no bandwidth guaranteed
129
+ !
130
+ uc-tx-queue 6
131
+ priority strict
132
+ no bandwidth percent
133
+ no shape rate
134
+ no bandwidth guaranteed
135
+ !
136
+ uc-tx-queue 7
137
+ priority strict
138
+ no bandwidth percent
139
+ no shape rate
140
+ no bandwidth guaranteed
141
+ sflow enable
142
+ no spanning-tree portfast
143
+ spanning-tree portfast auto
144
+ no spanning-tree link-type
145
+ no spanning-tree bpduguard
146
+ no spanning-tree bpdufilter
147
+ no spanning-tree cost
148
+ spanning-tree port-priority 128
149
+ no spanning-tree guard
150
+ no spanning-tree bpduguard rate-limit
151
+ logging event spanning-tree use-global
152
+ switchport tap native vlan 1
153
+ no switchport tap identity
154
+ switchport tap allowed vlan 1-4094
155
+ switchport tool allowed vlan 1-4094
156
+ no switchport tool identity
157
+ no switchport tap truncation
158
+ no switchport tool truncation
159
+ no switchport tap default group
160
+ no switchport tool group
161
+ no switchport tool dot1q remove outer
162
+ !
163
+ interface Vxlan1
164
+ no description
165
+ no shutdown
166
+ default load-interval
167
+ logging event link-status use-global
168
+ switchport access vlan 1
169
+ switchport trunk native vlan 1
170
+ switchport trunk allowed vlan 1-4094
171
+ switchport mode access
172
+ switchport mac address learning
173
+ no switchport private-vlan mapping
174
+ switchport
175
+ default encapsulation dot1q vlan
176
+ no l2-protocol encapsulation dot1q vlan 0
177
+ snmp trap link-status
178
+ no switchport port-security
179
+ switchport port-security maximum 1
180
+ sflow enable
181
+ no spanning-tree portfast
182
+ spanning-tree portfast auto
183
+ no spanning-tree link-type
184
+ no spanning-tree bpduguard
185
+ no spanning-tree bpdufilter
186
+ no spanning-tree cost
187
+ spanning-tree port-priority 128
188
+ no spanning-tree guard
189
+ no spanning-tree bpduguard rate-limit
190
+ logging event spanning-tree use-global
191
+ switchport tap native vlan 1
192
+ no switchport tap identity
193
+ switchport tap allowed vlan 1-4094
194
+ switchport tool allowed vlan 1-4094
195
+ no switchport tool identity
196
+ no switchport tap truncation
197
+ no switchport tool truncation
198
+ no switchport tap default group
199
+ no switchport tool group
200
+ no switchport tool dot1q remove outer
201
+ no vxlan multicast-group
202
+ no vxlan source-interface
203
+ no vxlan controller-client
204
+ vxlan udp-port 4789
205
+ vxlan vlan 10 vni 10
206
+ no vxlan flood vtep
207
+ no vxlan vlan flood vtep
208
+ no vxlan learn-restrict vtep
209
+ no vxlan vlan learn-restrict vtep
210
+ !
211
+ interface Port-Channel1
212
+ description mlag port-channel
213
+ switchport trunk allowed vlan 500-502
214
+ switchport mode trunk
215
+ port-channel lacp fallback static
216
+ port-channel lacp fallback timeout 30
217
+ mlag 1
218
+ spanning-tree portfast
219
+ !
@@ -0,0 +1,149 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rbeapi/api/interfaces'
4
+
5
+ include FixtureHelpers
6
+
7
+ describe Rbeapi::Api::PortchannelInterface do
8
+ subject { described_class.new(node) }
9
+
10
+ let(:node) { double('node') }
11
+
12
+ def interfaces
13
+ interfaces = Fixtures[:interfaces]
14
+ return interfaces if interfaces
15
+ fixture('interfaces', format: :text, dir: File.dirname(__FILE__))
16
+ end
17
+
18
+ before :each do
19
+ allow(subject.node).to receive(:running_config).and_return(interfaces)
20
+ end
21
+
22
+ describe '#get' do
23
+ before :each do
24
+ allow(subject.node).to receive(:enable)
25
+ .with(include('show port-channel'), format: 'text')
26
+ .and_return([{ result:
27
+ { 'output' => "Port Channel Port-Channel1:\n Active " \
28
+ "Ports: Ethernet1 PeerEthernet1 \n\n" } }])
29
+ end
30
+ let(:resource) { subject.get('Port-Channel1') }
31
+
32
+ let(:keys) do
33
+ [:type, :shutdown, :description, :name, :members, :lacp_mode,
34
+ :minimum_links, :lacp_timeout, :lacp_fallback]
35
+ end
36
+
37
+ it 'returns an ethernet resource as a hash' do
38
+ expect(resource).to be_a_kind_of(Hash)
39
+ end
40
+
41
+ it 'returns an interface type of portchannel' do
42
+ expect(resource[:type]).to eq('portchannel')
43
+ end
44
+
45
+ it 'has all keys' do
46
+ expect(resource.keys).to match_array(keys)
47
+ end
48
+
49
+ it 'does not return PeerEthernet members' do
50
+ expect(resource[:members]).to_not include 'PeerEthernet'
51
+ end
52
+
53
+ it 'returns 1 member' do
54
+ expect(resource[:members]).to contain_exactly('Ethernet1')
55
+ end
56
+ end
57
+
58
+ describe '#create' do
59
+ it 'creates the interface in the config' do
60
+ expect(node).to receive(:config).with('interface Port-Channel1')
61
+ expect(subject.create('Port-Channel1')).to be_truthy
62
+ end
63
+ end
64
+
65
+ describe '#delete' do
66
+ it 'deletes the interface in the config' do
67
+ expect(node).to receive(:config).with('no interface Port-Channel1')
68
+ expect(subject.delete('Port-Channel1')).to be_truthy
69
+ end
70
+ end
71
+
72
+ describe '#default' do
73
+ it 'defaults the interface config' do
74
+ expect(node).to receive(:config).with('default interface Port-Channel1')
75
+ expect(subject.default('Port-Channel1')).to be_truthy
76
+ end
77
+ end
78
+
79
+ describe '#set_description' do
80
+ it 'sets the interface description' do
81
+ expect(node).to receive(:config)
82
+ .with(['interface Port-Channel1', 'description test string'])
83
+
84
+ expect(subject.set_description('Port-Channel1', value: 'test string'))
85
+ .to be_truthy
86
+ end
87
+
88
+ it 'negates the interface description' do
89
+ expect(node).to receive(:config)
90
+ .with(['interface Port-Channel1', 'no description'])
91
+
92
+ expect(subject.set_description('Port-Channel1')).to be_truthy
93
+ end
94
+
95
+ it 'defaults the interface description' do
96
+ expect(node).to receive(:config)
97
+ .with(['interface Port-Channel1', 'default description'])
98
+
99
+ expect(subject.set_description('Port-Channel1', default: true))
100
+ .to be_truthy
101
+ end
102
+
103
+ it 'default is preferred over value' do
104
+ expect(node).to receive(:config)
105
+ .with(['interface Port-Channel1', 'default description'])
106
+
107
+ opts = { value: 'test', default: true }
108
+ expect(subject.set_description('Port-Channel1', opts)).to be_truthy
109
+ end
110
+ end
111
+
112
+ describe '#set_shutdown' do
113
+ it 'enables the interface' do
114
+ expect(node).to receive(:config)
115
+ .with(['interface Port-Channel1', 'no shutdown'])
116
+
117
+ expect(subject.set_shutdown('Port-Channel1', value: false)).to be_truthy
118
+ end
119
+
120
+ it 'disables the interface' do
121
+ expect(node).to receive(:config)
122
+ .with(['interface Port-Channel1', 'shutdown'])
123
+
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
132
+ end
133
+
134
+ it 'defaults the interface state' do
135
+ expect(node).to receive(:config)
136
+ .with(['interface Port-Channel1', 'default shutdown'])
137
+
138
+ expect(subject.set_shutdown('Port-Channel1', default: true)).to be_truthy
139
+ end
140
+
141
+ it 'default is preferred over value' do
142
+ expect(node).to receive(:config)
143
+ .with(['interface Port-Channel1', 'default shutdown'])
144
+
145
+ opts = { value: 'test', default: true }
146
+ expect(subject.set_shutdown('Port-Channel1', opts)).to be_truthy
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,243 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rbeapi/api/interfaces'
4
+
5
+ include FixtureHelpers
6
+
7
+ describe Rbeapi::Api::VxlanInterface do
8
+ subject { described_class.new(node) }
9
+
10
+ let(:node) { double('node') }
11
+
12
+ def interfaces
13
+ interfaces = Fixtures[:interfaces]
14
+ return interfaces if interfaces
15
+ fixture('interfaces', format: :text, dir: File.dirname(__FILE__))
16
+ end
17
+
18
+ before :each do
19
+ allow(subject.node).to receive(:running_config).and_return(interfaces)
20
+ end
21
+
22
+ describe '#get' do
23
+ let(:resource) { subject.get('Vxlan1') }
24
+
25
+ let(:keys) do
26
+ [:type, :shutdown, :description, :name, :source_interface,
27
+ :multicast_group, :udp_port, :flood_list, :vlans]
28
+ end
29
+
30
+ it 'returns the resource as a hash' do
31
+ expect(resource).to be_a_kind_of(Hash)
32
+ end
33
+
34
+ it 'returns an interface type of vxlan' do
35
+ expect(resource[:type]).to eq('vxlan')
36
+ end
37
+
38
+ it 'has all keys' do
39
+ expect(resource.keys).to match_array(keys)
40
+ end
41
+ end
42
+
43
+ describe '#create' do
44
+ it 'creates the interface in the config' do
45
+ expect(node).to receive(:config).with('interface Vxlan1')
46
+ expect(subject.create('Vxlan1')).to be_truthy
47
+ end
48
+ end
49
+
50
+ describe '#delete' do
51
+ it 'deletes the interface in the config' do
52
+ expect(node).to receive(:config).with('no interface Vxlan1')
53
+ expect(subject.delete('Vxlan1')).to be_truthy
54
+ end
55
+ end
56
+
57
+ describe '#default' do
58
+ it 'defaults the interface config' do
59
+ expect(node).to receive(:config).with('default interface Vxlan1')
60
+ expect(subject.default('Vxlan1')).to be_truthy
61
+ end
62
+ end
63
+
64
+ describe '#set_source_interface' do
65
+ it 'sets the vxlan source interface' do
66
+ commands = ['interface Vxlan1', 'vxlan source-interface Loopback0']
67
+ opts = { value: 'Loopback0' }
68
+ expect(node).to receive(:config).with(commands)
69
+ expect(subject.set_source_interface('Vxlan1', opts)).to be_truthy
70
+ end
71
+
72
+ it 'negates the vxlan source interface value' do
73
+ commands = ['interface Vxlan1', 'no vxlan source-interface']
74
+ expect(node).to receive(:config).with(commands)
75
+ expect(subject.set_source_interface('Vxlan1')).to be_truthy
76
+ end
77
+
78
+ it 'defaults the source interface setting' do
79
+ commands = ['interface Vxlan1', 'default vxlan source-interface']
80
+ opts = { default: true }
81
+ expect(node).to receive(:config).with(commands)
82
+ expect(subject.set_source_interface('Vxlan1', opts)).to be_truthy
83
+ end
84
+
85
+ it 'prefers default over value' do
86
+ commands = ['interface Vxlan1', 'default vxlan source-interface']
87
+ opts = { default: true, value: 'Looback0' }
88
+ expect(node).to receive(:config).with(commands)
89
+ expect(subject.set_source_interface('Vxlan1', opts)).to be_truthy
90
+ end
91
+ end
92
+
93
+ describe '#set_multicast_group' do
94
+ it 'sets the vxlan multicast group' do
95
+ commands = ['interface Vxlan1', 'vxlan multicast-group 239.10.10.10']
96
+ opts = { value: '239.10.10.10' }
97
+ expect(node).to receive(:config).with(commands)
98
+ expect(subject.set_multicast_group('Vxlan1', opts)).to be_truthy
99
+ end
100
+
101
+ it 'negates the vxlan multicast group value' do
102
+ commands = ['interface Vxlan1', 'no vxlan multicast-group']
103
+ expect(node).to receive(:config).with(commands)
104
+ expect(subject.set_multicast_group('Vxlan1')).to be_truthy
105
+ end
106
+
107
+ it 'defaults the multicast group setting' do
108
+ commands = ['interface Vxlan1', 'default vxlan multicast-group']
109
+ opts = { default: true }
110
+ expect(node).to receive(:config).with(commands)
111
+ expect(subject.set_multicast_group('Vxlan1', opts)).to be_truthy
112
+ end
113
+
114
+ it 'prefers default over value' do
115
+ commands = ['interface Vxlan1', 'default vxlan multicast-group']
116
+ opts = { default: true, value: '239.10.10.10' }
117
+ expect(node).to receive(:config).with(commands)
118
+ expect(subject.set_multicast_group('Vxlan1', opts)).to be_truthy
119
+ end
120
+ end
121
+
122
+ describe '#set_udp_port' do
123
+ it 'sets the vxlan udp-port' do
124
+ commands = ['interface Vxlan1', 'vxlan udp-port 1024']
125
+ opts = { value: '1024' }
126
+ expect(node).to receive(:config).with(commands)
127
+ expect(subject.set_udp_port('Vxlan1', opts)).to be_truthy
128
+ end
129
+
130
+ it 'negates the vxlan udp-port value' do
131
+ commands = ['interface Vxlan1', 'no vxlan udp-port']
132
+ expect(node).to receive(:config).with(commands)
133
+ expect(subject.set_udp_port('Vxlan1')).to be_truthy
134
+ end
135
+
136
+ it 'defaults the vxlan udp-port setting' do
137
+ commands = ['interface Vxlan1', 'default vxlan udp-port']
138
+ opts = { default: true }
139
+ expect(node).to receive(:config).with(commands)
140
+ expect(subject.set_udp_port('Vxlan1', opts)).to be_truthy
141
+ end
142
+
143
+ it 'prefers default over value' do
144
+ commands = ['interface Vxlan1', 'default vxlan udp-port']
145
+ opts = { default: true, value: '1024' }
146
+ expect(node).to receive(:config).with(commands)
147
+ expect(subject.set_udp_port('Vxlan1', opts)).to be_truthy
148
+ end
149
+ end
150
+
151
+ describe '#add_vtep' do
152
+ it 'adds value to the flood list' do
153
+ commands = ['interface Vxlan1', 'vxlan flood vtep add 1.1.1.1']
154
+ expect(node).to receive(:config).with(commands)
155
+ expect(subject.add_vtep('Vxlan1', '1.1.1.1')).to be_truthy
156
+ end
157
+ end
158
+
159
+ describe '#remove_vtep' do
160
+ it 'removes value from the flood list' do
161
+ commands = ['interface Vxlan1', 'vxlan flood vtep remove 1.1.1.1']
162
+ expect(node).to receive(:config).with(commands)
163
+ expect(subject.remove_vtep('Vxlan1', '1.1.1.1')).to be_truthy
164
+ end
165
+ end
166
+
167
+ describe '#update_vlan' do
168
+ it 'updates the vlan to vni mapping' do
169
+ commands = ['interface Vxlan1', 'vxlan vlan 10 vni 10']
170
+ expect(node).to receive(:config).with(commands)
171
+ expect(subject.update_vlan('Vxlan1', 10, 10)).to be_truthy
172
+ end
173
+ end
174
+
175
+ describe '#remove_vlan' do
176
+ it 'removes the vlan to vni mapping' do
177
+ commands = ['interface Vxlan1', 'no vxlan vlan 10 vni']
178
+ expect(node).to receive(:config).with(commands)
179
+ expect(subject.remove_vlan('Vxlan1', 10)).to be_truthy
180
+ end
181
+ end
182
+
183
+ describe '#set_description' do
184
+ it 'sets the interface description' do
185
+ commands = ['interface Vxlan1', 'description test string']
186
+ opts = { value: 'test string' }
187
+ expect(node).to receive(:config).with(commands)
188
+ expect(subject.set_description('Vxlan1', opts)).to be_truthy
189
+ end
190
+
191
+ it 'negates the interface description' do
192
+ expect(node).to receive(:config).with(['interface Vxlan1',
193
+ 'no description'])
194
+ expect(subject.set_description('Vxlan1')).to be_truthy
195
+ end
196
+
197
+ it 'defaults the interface description' do
198
+ expect(node).to receive(:config).with(['interface Vxlan1',
199
+ 'default description'])
200
+ expect(subject.set_description('Vxlan1', default: true)).to be_truthy
201
+ end
202
+
203
+ it 'default is preferred over value' do
204
+ expect(node).to receive(:config).with(['interface Vxlan1',
205
+ 'default description'])
206
+ expect(subject.set_description('Vxlan1', value: 'test',
207
+ default: true)).to be_truthy
208
+ end
209
+ end
210
+
211
+ describe '#set_shutdown' do
212
+ it 'enables the interface' do
213
+ expect(node).to receive(:config).with(['interface Vxlan1',
214
+ 'no shutdown'])
215
+ expect(subject.set_shutdown('Vxlan1', value: false)).to be_truthy
216
+ end
217
+
218
+ it 'disables the interface' do
219
+ expect(node).to receive(:config).with(['interface Vxlan1',
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
228
+ end
229
+
230
+ it 'defaults the interface state' do
231
+ expect(node).to receive(:config).with(['interface Vxlan1',
232
+ 'default shutdown'])
233
+ expect(subject.set_shutdown('Vxlan1', default: true)).to be_truthy
234
+ end
235
+
236
+ it 'default is preferred over value' do
237
+ expect(node).to receive(:config).with(['interface Vxlan1',
238
+ 'default shutdown'])
239
+ expect(subject.set_shutdown('Vxlan1', value: 'test', default: true))
240
+ .to be_truthy
241
+ end
242
+ end
243
+ end