cisco_node_utils 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +81 -1
- data/.travis.yml +9 -0
- data/CHANGELOG.md +72 -6
- data/CONTRIBUTING.md +32 -7
- data/README.md +70 -7
- data/Rakefile +17 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +81 -0
- data/bin/git/hooks/hook_lib +108 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/rubocop +20 -0
- data/bin/git/hooks/pre-commit/validate-diffs +31 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +65 -0
- data/cisco_node_utils.gemspec +9 -3
- data/docs/README-develop-best-practices.md +404 -0
- data/docs/README-develop-node-utils-APIs.md +215 -365
- data/docs/README-maintainers.md +33 -3
- data/docs/template-router.rb +89 -91
- data/docs/template-test_router.rb +52 -55
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils.rb +2 -19
- data/lib/cisco_node_utils/README_YAML.md +1 -9
- data/lib/cisco_node_utils/bgp.rb +664 -0
- data/lib/cisco_node_utils/bgp_af.rb +530 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +425 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +709 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +59 -25
- data/lib/cisco_node_utils/command_reference.rb +72 -74
- data/lib/cisco_node_utils/command_reference_common.yaml +174 -9
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +535 -0
- data/lib/cisco_node_utils/command_reference_n7k.yaml +4 -0
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -9
- data/lib/cisco_node_utils/configparser_lib.rb +152 -147
- data/lib/cisco_node_utils/dns_domain.rb +79 -0
- data/lib/cisco_node_utils/domain_name.rb +71 -0
- data/lib/cisco_node_utils/interface.rb +167 -161
- data/lib/cisco_node_utils/interface_ospf.rb +78 -81
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +154 -198
- data/lib/cisco_node_utils/node_util.rb +61 -0
- data/lib/cisco_node_utils/ntp_config.rb +65 -0
- data/lib/cisco_node_utils/ntp_server.rb +76 -0
- data/lib/cisco_node_utils/platform.rb +174 -165
- data/lib/cisco_node_utils/radius_global.rb +146 -0
- data/lib/cisco_node_utils/radius_server.rb +295 -0
- data/lib/cisco_node_utils/router_ospf.rb +59 -63
- data/lib/cisco_node_utils/router_ospf_vrf.rb +226 -210
- data/lib/cisco_node_utils/snmpcommunity.rb +52 -58
- data/lib/cisco_node_utils/snmpgroup.rb +22 -23
- data/lib/cisco_node_utils/snmpserver.rb +99 -103
- data/lib/cisco_node_utils/snmpuser.rb +294 -274
- data/lib/cisco_node_utils/syslog_server.rb +92 -0
- data/lib/cisco_node_utils/syslog_settings.rb +69 -0
- data/lib/cisco_node_utils/tacacs_server.rb +137 -133
- data/lib/cisco_node_utils/tacacs_server_host.rb +84 -87
- data/lib/cisco_node_utils/version.rb +2 -1
- data/lib/cisco_node_utils/vlan.rb +28 -31
- data/lib/cisco_node_utils/vrf.rb +80 -0
- data/lib/cisco_node_utils/vtp.rb +100 -97
- data/lib/cisco_node_utils/yum.rb +15 -17
- data/tests/.rubocop.yml +15 -0
- data/tests/basetest.rb +81 -36
- data/tests/ciscotest.rb +38 -78
- data/{lib/cisco_node_utils → tests}/platform_info.rb +12 -8
- data/{lib/cisco_node_utils → tests}/platform_info.yaml +1 -1
- data/tests/test_bgp_af.rb +920 -0
- data/tests/test_bgp_neighbor.rb +403 -0
- data/tests/test_bgp_neighbor_af.rb +589 -0
- data/tests/test_command_config.rb +65 -62
- data/tests/test_command_reference.rb +31 -45
- data/tests/test_dns_domain.rb +113 -0
- data/tests/test_domain_name.rb +86 -0
- data/tests/test_interface.rb +424 -548
- data/tests/test_interface_ospf.rb +248 -432
- data/tests/test_interface_svi.rb +56 -79
- data/tests/test_interface_switchport.rb +196 -272
- data/tests/test_name_server.rb +85 -0
- data/tests/test_node.rb +7 -6
- data/tests/test_node_ext.rb +133 -186
- data/tests/test_ntp_config.rb +49 -0
- data/tests/test_ntp_server.rb +74 -0
- data/tests/test_platform.rb +58 -37
- data/tests/test_radius_global.rb +78 -0
- data/tests/test_radius_server.rb +185 -0
- data/tests/test_router_bgp.rb +838 -0
- data/tests/test_router_ospf.rb +49 -80
- data/tests/test_router_ospf_vrf.rb +274 -392
- data/tests/test_snmpcommunity.rb +128 -172
- data/tests/test_snmpgroup.rb +12 -14
- data/tests/test_snmpserver.rb +160 -189
- data/tests/test_snmpuser.rb +568 -717
- data/tests/test_syslog_server.rb +88 -0
- data/tests/test_syslog_settings.rb +54 -0
- data/tests/test_tacacs_server.rb +113 -148
- data/tests/test_tacacs_server_host.rb +108 -161
- data/tests/test_vlan.rb +63 -79
- data/tests/test_vrf.rb +92 -0
- data/tests/test_vtp.rb +108 -126
- data/tests/test_yum.rb +47 -41
- metadata +92 -56
- data/.rubocop_todo.yml +0 -293
- data/docs/.rubocop.yml +0 -13
- data/docs/template-feature.rb +0 -45
- data/docs/template-test_feature.rb +0 -51
- data/tests/test_all_cisco.rb +0 -46
|
@@ -12,272 +12,206 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/cisco_cmn_utils'
|
|
17
|
+
require_relative '../lib/cisco_node_utils/interface_ospf'
|
|
18
|
+
require_relative '../lib/cisco_node_utils/router_ospf'
|
|
19
19
|
|
|
20
20
|
include Cisco
|
|
21
21
|
|
|
22
|
+
# TestInterfaceOspf - Minitest for InterfaceOspf node utility class.
|
|
22
23
|
class TestInterfaceOspf < CiscoTestCase
|
|
23
|
-
def
|
|
24
|
-
|
|
24
|
+
def setup
|
|
25
|
+
super
|
|
26
|
+
config 'no feature ospf'
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
29
|
+
def teardown
|
|
30
|
+
config 'no feature ospf'
|
|
31
|
+
super
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def interface_switchport_enable(ifname, enable)
|
|
34
|
-
@device.cmd("configure terminal")
|
|
35
|
-
@device.cmd("interface #{ifname}")
|
|
36
35
|
if enable == true
|
|
37
|
-
|
|
36
|
+
config("interface #{ifname}", 'switchport')
|
|
38
37
|
else
|
|
39
|
-
|
|
38
|
+
config("interface #{ifname}", 'no switchport')
|
|
40
39
|
end
|
|
41
|
-
@device.cmd("end")
|
|
42
|
-
node.cache_flush
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def interfaceospf_interface_destroy(interface)
|
|
46
|
-
interface.destroy
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def interfaceospf_interfaces_destroy(interfaces)
|
|
50
|
-
interfaces.each { |name, interface|
|
|
51
|
-
interfaceospf_interface_destroy(interface)
|
|
52
|
-
}
|
|
53
40
|
end
|
|
54
41
|
|
|
55
|
-
def
|
|
56
|
-
|
|
57
|
-
"sec \"interface .#{name[1..-1]}$\" | no-more")
|
|
58
|
-
line = pattern.match(s)
|
|
59
|
-
line
|
|
42
|
+
def show_cmd(name)
|
|
43
|
+
"show run interface #{name} all | no-more"
|
|
60
44
|
end
|
|
61
45
|
|
|
62
|
-
def create_routerospf(ospfname=
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@device.cmd("end")
|
|
66
|
-
node.cache_flush
|
|
67
|
-
routerospf = RouterOspf.new(ospfname, false)
|
|
46
|
+
def create_routerospf(ospfname='ospfTest')
|
|
47
|
+
config('feature ospf')
|
|
48
|
+
RouterOspf.new(ospfname, false)
|
|
68
49
|
end
|
|
69
50
|
|
|
70
|
-
def create_interfaceospf(routerospf, ifname=interfaces[0], area=
|
|
51
|
+
def create_interfaceospf(routerospf, ifname=interfaces[0], area='0.0.0.0')
|
|
52
|
+
@default_show_command = show_cmd(ifname)
|
|
71
53
|
interface_switchport_enable(ifname, false)
|
|
72
|
-
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def interface_ethernet_default(ethernet_id=interfaces_id[0])
|
|
76
|
-
@device.cmd("configure terminal")
|
|
77
|
-
@device.cmd("default interface ethernet #{ethernet_id}")
|
|
78
|
-
@device.cmd("end")
|
|
79
|
-
node.cache_flush
|
|
54
|
+
InterfaceOspf.new(ifname, routerospf.name, area)
|
|
80
55
|
end
|
|
81
56
|
|
|
82
57
|
def test_get_set_area
|
|
83
58
|
# setup a loopback to use
|
|
84
|
-
|
|
85
|
-
@device.cmd("interface loopback12")
|
|
86
|
-
@device.cmd("end")
|
|
87
|
-
node.cache_flush
|
|
59
|
+
config('interface loopback12')
|
|
88
60
|
|
|
89
|
-
int_ospf = InterfaceOspf.new(
|
|
61
|
+
int_ospf = InterfaceOspf.new('loopback12', '12', '0.0.0.0')
|
|
90
62
|
|
|
91
63
|
# test invalid
|
|
92
64
|
assert_raises(CliError) do
|
|
93
|
-
int_ospf.area =
|
|
65
|
+
int_ospf.area = 'Blue'
|
|
94
66
|
end
|
|
95
67
|
|
|
96
68
|
# test get/set ip address form
|
|
97
|
-
int_ospf.area =
|
|
98
|
-
assert_equal(int_ospf.area,
|
|
69
|
+
int_ospf.area = '0.0.0.4'
|
|
70
|
+
assert_equal(int_ospf.area, '0.0.0.4')
|
|
99
71
|
|
|
100
72
|
# test get/set integer form.
|
|
101
73
|
# Note: the area getter will munge the value to dotted decimal.
|
|
102
|
-
int_ospf.area =
|
|
103
|
-
assert_equal(int_ospf.area,
|
|
74
|
+
int_ospf.area = '3'
|
|
75
|
+
assert_equal(int_ospf.area, '0.0.0.3')
|
|
104
76
|
|
|
105
77
|
# cleanup
|
|
106
|
-
|
|
107
|
-
@device.cmd("configure terminal")
|
|
108
|
-
@device.cmd("no interface loopback12")
|
|
109
|
-
@device.cmd("end")
|
|
110
|
-
node.cache_flush
|
|
78
|
+
config('no interface loopback12')
|
|
111
79
|
end
|
|
112
80
|
|
|
113
81
|
def test_interfaceospf_collection_empty
|
|
114
|
-
|
|
115
|
-
@device.cmd("no feature ospf")
|
|
116
|
-
@device.cmd("feature ospf")
|
|
117
|
-
@device.cmd("router ospf TestOSPF")
|
|
118
|
-
@device.cmd("end")
|
|
119
|
-
node.cache_flush
|
|
82
|
+
config('no feature ospf', 'feature ospf', 'router ospf TestOSPF')
|
|
120
83
|
|
|
121
84
|
routers = RouterOspf.routers()
|
|
122
|
-
routers.
|
|
85
|
+
routers.each_value do |router|
|
|
123
86
|
interfaces = InterfaceOspf.interfaces(router.name)
|
|
124
87
|
assert_empty(interfaces,
|
|
125
|
-
|
|
88
|
+
'InterfaceOspf collection is not empty')
|
|
126
89
|
end
|
|
127
|
-
routerospf_routers_destroy(routers)
|
|
128
90
|
end
|
|
129
91
|
|
|
130
92
|
def test_interfaceospf_collection_not_empty
|
|
131
93
|
ifname1 = interfaces[1].downcase
|
|
132
94
|
ifname2 = interfaces[2].downcase
|
|
133
|
-
ospf1 =
|
|
134
|
-
ospf2 =
|
|
95
|
+
ospf1 = 'TestOSPF'
|
|
96
|
+
ospf2 = 'bxb300'
|
|
135
97
|
# pre-configure
|
|
136
98
|
interface_switchport_enable(ifname1, false)
|
|
137
99
|
interface_switchport_enable(ifname2, false)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
@device.cmd("end")
|
|
148
|
-
node.cache_flush
|
|
100
|
+
config('no feature ospf',
|
|
101
|
+
'feature ospf',
|
|
102
|
+
"router ospf #{ospf1}",
|
|
103
|
+
"interface #{ifname1}",
|
|
104
|
+
"ip router ospf #{ospf1} area 0.0.0.0",
|
|
105
|
+
"router ospf #{ospf2}",
|
|
106
|
+
"interface #{ifname2}",
|
|
107
|
+
"ip router ospf #{ospf2} area 10.6.6.1",
|
|
108
|
+
)
|
|
149
109
|
|
|
150
110
|
routers = RouterOspf.routers()
|
|
151
111
|
# validate the collection
|
|
152
|
-
routers.
|
|
112
|
+
routers.each_value do |router|
|
|
153
113
|
interfaces = InterfaceOspf.interfaces(router.name)
|
|
154
114
|
refute_empty(interfaces,
|
|
155
|
-
|
|
156
|
-
assert_equal(1, interfaces.size
|
|
115
|
+
'InterfaceOspf collection is empty')
|
|
116
|
+
assert_equal(1, interfaces.size,
|
|
157
117
|
"InterfaceOspf collection (#{interfaces}) size is not 1")
|
|
158
|
-
interfaces.each do |
|
|
118
|
+
interfaces.each do |ifname, interface|
|
|
159
119
|
pattern = (/\s+ip router ospf #{router.name} area #{interface.area}/)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
"area #{interface.area} not found under #{ifname}")
|
|
120
|
+
assert_show_match(command: show_cmd(ifname),
|
|
121
|
+
pattern: pattern)
|
|
163
122
|
# using default check, since not configured anything
|
|
164
|
-
assert_equal(node.config_get_default(
|
|
123
|
+
assert_equal(node.config_get_default('interface_ospf', 'cost'),
|
|
165
124
|
interface.cost,
|
|
166
|
-
|
|
167
|
-
assert_equal(node.config_get_default(
|
|
168
|
-
|
|
125
|
+
'Error: get cost failed')
|
|
126
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
127
|
+
'hello_interval'),
|
|
169
128
|
interface.hello_interval,
|
|
170
|
-
|
|
171
|
-
assert_equal(node.config_get_default(
|
|
172
|
-
|
|
129
|
+
'Error: get hello interval failed')
|
|
130
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
131
|
+
'dead_interval'),
|
|
173
132
|
interface.dead_interval,
|
|
174
|
-
|
|
175
|
-
assert_equal(node.config_get_default(
|
|
176
|
-
|
|
133
|
+
'Error: get dead interval failed')
|
|
134
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
135
|
+
'passive_interface'),
|
|
177
136
|
interface.passive_interface,
|
|
178
|
-
|
|
179
|
-
assert_equal(node.config_get_default(
|
|
180
|
-
|
|
137
|
+
'Error: passive interface get failed')
|
|
138
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
139
|
+
'message_digest'),
|
|
181
140
|
interface.message_digest,
|
|
182
|
-
|
|
183
|
-
assert_equal(node.config_get_default(
|
|
184
|
-
|
|
141
|
+
'Error: message digest get failed')
|
|
142
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
143
|
+
'message_digest_key_id'),
|
|
185
144
|
interface.message_digest_key_id,
|
|
186
|
-
|
|
145
|
+
'Error: message digest key get failed')
|
|
187
146
|
end
|
|
188
|
-
interfaceospf_interfaces_destroy(interfaces)
|
|
189
147
|
end
|
|
190
|
-
routerospf_routers_destroy(routers)
|
|
191
|
-
interface_ethernet_default(interfaces_id[2])
|
|
192
|
-
interface_ethernet_default(interfaces_id[1])
|
|
193
148
|
end
|
|
194
149
|
|
|
195
150
|
def test_interfaceospf_create_routerospf_nil
|
|
196
151
|
assert_raises(TypeError) do
|
|
197
|
-
|
|
152
|
+
InterfaceOspf.new(interfaces[0], nil, '0.0.0.0')
|
|
198
153
|
end
|
|
199
154
|
end
|
|
200
155
|
|
|
201
156
|
def test_interfaceospf_create_interface_name_zero_length
|
|
202
|
-
name =
|
|
157
|
+
name = 'ospfTest'
|
|
203
158
|
ospf = RouterOspf.new(name)
|
|
204
159
|
assert_raises(ArgumentError) do
|
|
205
|
-
|
|
160
|
+
InterfaceOspf.new('', ospf.name, '0.0.0.0')
|
|
206
161
|
end
|
|
207
|
-
routerospf_router_destroy(ospf)
|
|
208
162
|
end
|
|
209
163
|
|
|
210
164
|
def test_interfaceospf_create_interface_area_zero_length
|
|
211
|
-
name =
|
|
165
|
+
name = 'ospfTest'
|
|
212
166
|
ospf = RouterOspf.new(name)
|
|
213
167
|
assert_raises(ArgumentError) do
|
|
214
|
-
|
|
168
|
+
InterfaceOspf.new(interfaces[0], ospf.name, '')
|
|
215
169
|
end
|
|
216
|
-
routerospf_router_destroy(ospf)
|
|
217
170
|
end
|
|
218
171
|
|
|
219
172
|
def test_routerospf_create_valid
|
|
220
173
|
ospf = create_routerospf
|
|
221
174
|
ifname = interfaces[1]
|
|
222
|
-
area =
|
|
175
|
+
area = '0.0.0.0'
|
|
223
176
|
interface_switchport_enable(ifname, false)
|
|
224
177
|
interface = InterfaceOspf.new(ifname, ospf.name, area)
|
|
225
178
|
pattern = (/\s+ip router ospf #{ospf.name} area #{area}/)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
"not configured")
|
|
179
|
+
assert_show_match(command: show_cmd(ifname),
|
|
180
|
+
pattern: pattern)
|
|
229
181
|
assert_equal(ifname.downcase, interface.interface.name,
|
|
230
|
-
|
|
182
|
+
'Error: interface name get value mismatch ')
|
|
231
183
|
assert_equal(area, interface.area,
|
|
232
|
-
|
|
233
|
-
interfaceospf_interface_destroy(interface)
|
|
234
|
-
routerospf_router_destroy(ospf)
|
|
235
|
-
interface_ethernet_default(interfaces_id[1])
|
|
184
|
+
'Error: area get value mismatch ')
|
|
236
185
|
end
|
|
237
186
|
|
|
238
187
|
def test_interfaceospf_destroy
|
|
239
188
|
ifname = interfaces[1]
|
|
240
|
-
area =
|
|
189
|
+
area = '0.0.0.0'
|
|
241
190
|
ospf = create_routerospf
|
|
242
191
|
interface = create_interfaceospf(ospf, ifname, area)
|
|
243
192
|
interface.destroy
|
|
244
|
-
pattern
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
"not destroyed")
|
|
193
|
+
refute_show_match(pattern: /\s+ip router ospf #{ospf.name} area #{area}/,
|
|
194
|
+
msg: "'ip router ospf #{ospf.name} area #{area}' " \
|
|
195
|
+
'not destroyed')
|
|
248
196
|
# check all the attributes are set to default.
|
|
249
|
-
pattern
|
|
250
|
-
|
|
251
|
-
assert_nil(line,
|
|
252
|
-
"Error: 'ip ospf #{ospf.name} cost' not removed")
|
|
197
|
+
refute_show_match(pattern: /^\s+ip ospf cost \S+/,
|
|
198
|
+
msg: "'cost' not removed")
|
|
253
199
|
|
|
254
|
-
pattern
|
|
255
|
-
|
|
256
|
-
assert_nil(line,
|
|
257
|
-
"Error: 'ip ospf #{ospf.name} hello-interval' not removed")
|
|
200
|
+
refute_show_match(pattern: /^\s+ip ospf hello-interval \S+/,
|
|
201
|
+
msg: "'hello-interval' not removed")
|
|
258
202
|
|
|
259
203
|
# with default CLI still shows the value
|
|
260
|
-
pattern
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
pattern = (/^\s+ip ospf passive-interface/)
|
|
266
|
-
line = get_interfaceospf_match_line(ifname, pattern)
|
|
267
|
-
assert_nil(line,
|
|
268
|
-
"Error: 'ip ospf #{ospf.name} passive interface' not removed")
|
|
269
|
-
|
|
270
|
-
routerospf_router_destroy(ospf)
|
|
271
|
-
interface_ethernet_default(interfaces_id[1])
|
|
204
|
+
refute_show_match(pattern: /^\s+ip ospf dead-interval \S+/,
|
|
205
|
+
msg: "'dead-interval' not removed")
|
|
206
|
+
|
|
207
|
+
refute_show_match(pattern: /^\s+ip ospf passive-interface/,
|
|
208
|
+
msg: "'passive interface' not removed")
|
|
272
209
|
end
|
|
273
210
|
|
|
274
211
|
def test_routerospf_get_parent
|
|
275
212
|
ospf = create_routerospf
|
|
276
213
|
interface = create_interfaceospf(ospf)
|
|
277
214
|
assert_equal(ospf.name, interface.ospf_name)
|
|
278
|
-
interfaceospf_interface_destroy(interface)
|
|
279
|
-
routerospf_router_destroy(ospf)
|
|
280
|
-
interface_ethernet_default()
|
|
281
215
|
end
|
|
282
216
|
|
|
283
217
|
def test_interfaceospf_cost_invalid_range
|
|
@@ -285,15 +219,12 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
285
219
|
interface = create_interfaceospf(ospf)
|
|
286
220
|
# upper range
|
|
287
221
|
assert_raises(CliError) do
|
|
288
|
-
interface.cost =
|
|
222
|
+
interface.cost = 65_536
|
|
289
223
|
end
|
|
290
224
|
# lower range just removes the config.
|
|
291
225
|
# assert_raises(RuntimeError) do
|
|
292
226
|
# interface.cost = 0
|
|
293
227
|
# end
|
|
294
|
-
interfaceospf_interface_destroy(interface)
|
|
295
|
-
routerospf_router_destroy(ospf)
|
|
296
|
-
interface_ethernet_default()
|
|
297
228
|
end
|
|
298
229
|
|
|
299
230
|
def test_interfaceospf_cost
|
|
@@ -302,21 +233,14 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
302
233
|
cost = 1000
|
|
303
234
|
# set with value
|
|
304
235
|
interface.cost = cost
|
|
305
|
-
pattern
|
|
306
|
-
|
|
307
|
-
refute_nil(line,
|
|
308
|
-
"Error: cost missing in CLI")
|
|
236
|
+
assert_show_match(pattern: /\s+ip ospf cost #{cost}/,
|
|
237
|
+
msg: 'Error: cost missing in CLI')
|
|
309
238
|
assert_equal(cost, interface.cost,
|
|
310
|
-
|
|
239
|
+
'Error: cost get value mismatch')
|
|
311
240
|
# set default
|
|
312
241
|
interface.cost = interface.default_cost
|
|
313
|
-
pattern
|
|
314
|
-
|
|
315
|
-
assert_nil(line,
|
|
316
|
-
"Error: default cost set failed")
|
|
317
|
-
interfaceospf_interface_destroy(interface)
|
|
318
|
-
routerospf_router_destroy(ospf)
|
|
319
|
-
interface_ethernet_default()
|
|
242
|
+
refute_show_match(pattern: /\s+ip ospf cost(.*)/,
|
|
243
|
+
msg: 'Error: default cost set failed')
|
|
320
244
|
end
|
|
321
245
|
|
|
322
246
|
def test_interfaceospf_hello_interval_invalid_range
|
|
@@ -324,15 +248,12 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
324
248
|
interface = create_interfaceospf(ospf)
|
|
325
249
|
# upper range
|
|
326
250
|
assert_raises(CliError) do
|
|
327
|
-
interface.hello_interval =
|
|
251
|
+
interface.hello_interval = 65_536
|
|
328
252
|
end
|
|
329
253
|
# lower range
|
|
330
254
|
assert_raises(CliError) do
|
|
331
255
|
interface.hello_interval = 0
|
|
332
256
|
end
|
|
333
|
-
interfaceospf_interface_destroy(interface)
|
|
334
|
-
routerospf_router_destroy(ospf)
|
|
335
|
-
interface_ethernet_default()
|
|
336
257
|
end
|
|
337
258
|
|
|
338
259
|
def test_interfaceospf_hello_interval
|
|
@@ -341,42 +262,32 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
341
262
|
interval = 90
|
|
342
263
|
# set with value
|
|
343
264
|
interface.hello_interval = interval
|
|
344
|
-
pattern
|
|
345
|
-
|
|
346
|
-
refute_nil(line,
|
|
347
|
-
"Error: hello-interval missing in CLI")
|
|
265
|
+
assert_show_match(pattern: /\s+ip ospf hello-interval #{interval}/,
|
|
266
|
+
msg: 'Error: hello-interval missing in CLI')
|
|
348
267
|
assert_equal(interval, interface.hello_interval,
|
|
349
|
-
|
|
268
|
+
'Error: hello-interval get value mismatch')
|
|
350
269
|
|
|
351
270
|
# set default, when we set default CLI does not show it
|
|
352
271
|
interface.hello_interval = interface.default_hello_interval
|
|
353
|
-
pattern
|
|
354
|
-
|
|
355
|
-
assert_nil(line,
|
|
356
|
-
"Error: default hello-interval set failed")
|
|
357
|
-
interfaceospf_interface_destroy(interface)
|
|
358
|
-
routerospf_router_destroy(ospf)
|
|
359
|
-
interface_ethernet_default()
|
|
272
|
+
refute_show_match(pattern: /\s+ip ospf hello-interval(.*)/,
|
|
273
|
+
msg: 'Error: default hello-interval set failed')
|
|
360
274
|
end
|
|
361
275
|
|
|
362
276
|
def test_interfaceospf_dead_interval_invalid_range
|
|
363
277
|
ospf = create_routerospf
|
|
364
278
|
interface = create_interfaceospf(ospf)
|
|
365
279
|
|
|
366
|
-
ref = cmd_ref.lookup(
|
|
367
|
-
assert(ref,
|
|
280
|
+
ref = cmd_ref.lookup('interface_ospf', 'dead_interval')
|
|
281
|
+
assert(ref, 'Error, reference not found for dead_interval')
|
|
368
282
|
|
|
369
283
|
# upper range
|
|
370
284
|
assert_raises(CliError) do
|
|
371
|
-
interface.dead_interval =
|
|
285
|
+
interface.dead_interval = 262_141
|
|
372
286
|
end
|
|
373
287
|
# lower range
|
|
374
288
|
assert_raises(CliError) do
|
|
375
289
|
interface.dead_interval = 0
|
|
376
290
|
end
|
|
377
|
-
interfaceospf_interface_destroy(interface)
|
|
378
|
-
routerospf_router_destroy(ospf)
|
|
379
|
-
interface_ethernet_default()
|
|
380
291
|
end
|
|
381
292
|
|
|
382
293
|
def test_interfaceospf_dead_interval
|
|
@@ -385,21 +296,15 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
385
296
|
interval = 150
|
|
386
297
|
# set with value
|
|
387
298
|
interface.dead_interval = interval
|
|
388
|
-
pattern
|
|
389
|
-
|
|
390
|
-
refute_nil(line,
|
|
391
|
-
"Error: dead-interval missing in CLI")
|
|
299
|
+
assert_show_match(pattern: /\s+ip ospf dead-interval #{interval}/,
|
|
300
|
+
msg: 'Error: dead-interval missing in CLI')
|
|
392
301
|
assert_equal(interval, interface.dead_interval,
|
|
393
|
-
|
|
302
|
+
'Error: dead-interval get value mismatch')
|
|
394
303
|
# set default, the CLI shows with default value
|
|
395
304
|
interface.dead_interval = interface.default_dead_interval
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
"Error: default dead-interval set failed")
|
|
400
|
-
interfaceospf_interface_destroy(interface)
|
|
401
|
-
routerospf_router_destroy(ospf)
|
|
402
|
-
interface_ethernet_default()
|
|
305
|
+
assert_show_match(
|
|
306
|
+
pattern: /^\s+ip ospf dead-interval #{interface.default_dead_interval}/,
|
|
307
|
+
msg: 'Error: default dead-interval set failed')
|
|
403
308
|
end
|
|
404
309
|
|
|
405
310
|
def test_interfaceospf_passive_interface
|
|
@@ -408,46 +313,32 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
408
313
|
|
|
409
314
|
# set with value
|
|
410
315
|
interface.passive_interface = true
|
|
411
|
-
pattern
|
|
412
|
-
|
|
413
|
-
refute_nil(line, "Error: passive interface enable missing in CLI")
|
|
316
|
+
assert_show_match(pattern: /\s+ip ospf passive-interface/,
|
|
317
|
+
msg: 'passive interface enable missing in CLI')
|
|
414
318
|
assert(interface.passive_interface,
|
|
415
|
-
|
|
319
|
+
'Error: passive interface get value mismatch')
|
|
416
320
|
|
|
417
321
|
# get default and set
|
|
418
322
|
interface.passive_interface = interface.default_passive_interface
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
line = get_interfaceospf_match_line(interface.interface.name, pattern)
|
|
422
|
-
refute_nil(line,
|
|
423
|
-
"Error: default passive interface set failed")
|
|
424
|
-
interfaceospf_interface_destroy(interface)
|
|
425
|
-
routerospf_router_destroy(ospf)
|
|
426
|
-
interface_ethernet_default()
|
|
323
|
+
assert_show_match(pattern: /\s+no ip ospf passive-interface/,
|
|
324
|
+
msg: 'default passive interface set failed')
|
|
427
325
|
end
|
|
428
326
|
|
|
429
327
|
def test_interfaceospf_create_valid_multiple
|
|
430
328
|
# ospf and interfaces[0]
|
|
431
329
|
ospf = create_routerospf
|
|
432
330
|
interface = create_interfaceospf(ospf)
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
"not configured")
|
|
331
|
+
assert_show_match(
|
|
332
|
+
pattern: /\s+ip router ospf #{ospf.name} area #{interface.area}/,
|
|
333
|
+
msg: "'ip router ospf #{ospf.name} default area' not configured")
|
|
437
334
|
|
|
438
335
|
# ospf and interfaces_id[2]
|
|
439
336
|
ifname = interfaces[2]
|
|
440
|
-
area =
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
"Error: 'ip router ospf #{ospf.name} area #{area}' not configured")
|
|
446
|
-
interfaceospf_interface_destroy(interface)
|
|
447
|
-
interfaceospf_interface_destroy(interface1)
|
|
448
|
-
routerospf_router_destroy(ospf)
|
|
449
|
-
interface_ethernet_default()
|
|
450
|
-
interface_ethernet_default(interfaces_id[2])
|
|
337
|
+
area = '1.1.1.1'
|
|
338
|
+
create_interfaceospf(ospf, ifname, area)
|
|
339
|
+
assert_show_match(
|
|
340
|
+
pattern: /\s+ip router ospf #{ospf.name} area #{area}/,
|
|
341
|
+
msg: "'ip router ospf #{ospf.name} area #{area}' is not configured")
|
|
451
342
|
end
|
|
452
343
|
|
|
453
344
|
def test_interfaceospf_create_multiple_delete_one
|
|
@@ -457,189 +348,141 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
457
348
|
|
|
458
349
|
# ospf and interfaces_id[2]
|
|
459
350
|
ifname = interfaces[2]
|
|
460
|
-
area =
|
|
351
|
+
area = '1.1.1.1'
|
|
461
352
|
interface1 = create_interfaceospf(ospf, ifname, area)
|
|
462
353
|
assert_equal(ifname.downcase, interface1.interface.name,
|
|
463
|
-
"Error: 'ip router ospf #{ospf.name} area #{area}' "
|
|
464
|
-
|
|
354
|
+
"Error: 'ip router ospf #{ospf.name} area #{area}' " \
|
|
355
|
+
'not configured')
|
|
465
356
|
|
|
466
357
|
# delete ospf instance from interfaces_id[2]
|
|
467
358
|
interface1.destroy
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
359
|
+
refute_show_match(
|
|
360
|
+
command: show_cmd(ifname),
|
|
361
|
+
pattern: /\s+ip router ospf #{ospf.name} area #{area}/,
|
|
362
|
+
msg: "'ip router ospf #{ospf.name} area #{area}' not deleted")
|
|
472
363
|
|
|
473
364
|
# check other interface association still exist.
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
"not configured")
|
|
479
|
-
|
|
480
|
-
interfaceospf_interface_destroy(interface)
|
|
481
|
-
routerospf_router_destroy(ospf)
|
|
482
|
-
interface_ethernet_default()
|
|
483
|
-
interface_ethernet_default(interfaces_id[2])
|
|
365
|
+
assert_show_match(
|
|
366
|
+
command: show_cmd(interface.interface.name),
|
|
367
|
+
pattern: /\s+ip router ospf #{ospf.name} area #{interface.area}/,
|
|
368
|
+
msg: "'ip router ospf #{ospf.name} default area' not configured")
|
|
484
369
|
end
|
|
485
370
|
|
|
486
|
-
def
|
|
487
|
-
|
|
488
|
-
known_failure = s[/ERROR:.*port channel not present/]
|
|
489
|
-
refute(known_failure, "ERROR: port channel not present")
|
|
490
|
-
|
|
491
|
-
ospf_h = Hash.new { |h, k| h[k] = {} }
|
|
492
|
-
ospf_h["ospfTest"] = {
|
|
493
|
-
interfaces[0].downcase => {
|
|
494
|
-
:area => "0.0.0.0", :cost => 10, :hello => 30, :dead => 120,
|
|
495
|
-
:pass => true,
|
|
496
|
-
},
|
|
497
|
-
interfaces[1].downcase => {
|
|
498
|
-
:area => "1.1.1.38", :dead => 40, :pass => false,
|
|
499
|
-
},
|
|
500
|
-
"vlan101" => {
|
|
501
|
-
:area => "2.2.2.101", :cost => 5, :hello => 20, :dead => 80,
|
|
502
|
-
:pass => true,
|
|
503
|
-
},
|
|
504
|
-
}
|
|
505
|
-
ospf_h["TestOspfInt"] = {
|
|
506
|
-
interfaces[2].downcase => {
|
|
507
|
-
:area => "0.0.0.19",
|
|
508
|
-
},
|
|
509
|
-
"vlan290" => {
|
|
510
|
-
:area => "2.2.2.29", :cost => 200, :hello => 30, :dead => 120,
|
|
511
|
-
:pass => true,
|
|
512
|
-
},
|
|
513
|
-
"port-channel100" => {
|
|
514
|
-
:area => "3.2.2.29", :cost => 25, :hello => 50, :dead => 200,
|
|
515
|
-
:pass => false,
|
|
516
|
-
},
|
|
517
|
-
}
|
|
518
|
-
# enable feature ospf
|
|
519
|
-
@device.cmd("configure terminal")
|
|
520
|
-
@device.cmd("no feature ospf") # cleanup prev configs
|
|
521
|
-
@device.cmd("feature ospf")
|
|
522
|
-
@device.cmd("feature interface-vlan")
|
|
523
|
-
@device.cmd("default interface interfaces[0] ")
|
|
524
|
-
@device.cmd("default interface interfaces[1] ")
|
|
525
|
-
@device.cmd("default interface interfaces[2] ")
|
|
526
|
-
@device.cmd("end")
|
|
527
|
-
|
|
528
|
-
# pre-configure
|
|
529
|
-
ospf_h.each do | k, v|
|
|
371
|
+
def configure_from_hash(hash)
|
|
372
|
+
hash.each do |k, v|
|
|
530
373
|
# puts "TEST: pre-config hash key : #{k}"
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
@device.cmd("end")
|
|
534
|
-
v.each do | k1, v1|
|
|
374
|
+
config("router ospf #{k}")
|
|
375
|
+
v.each do |k1, v1|
|
|
535
376
|
# puts "TEST: pre-config k1: v1 '#{k1} : #{v1}'"
|
|
536
|
-
|
|
537
|
-
@device.cmd("interface #{k1}")
|
|
377
|
+
cfg = ["interface #{k1}"]
|
|
538
378
|
if !(/^ethernet\d.\d/).match(k1.to_s).nil? ||
|
|
539
379
|
!(/^port-channel\d/).match(k1.to_s).nil?
|
|
540
|
-
|
|
380
|
+
cfg << 'no switchport'
|
|
541
381
|
# puts "switchport disable: #{k1}"
|
|
542
382
|
end
|
|
543
383
|
# puts "k1: #{k1}, k: #{k}, area #{v1[:area]}"
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
384
|
+
cfg << "ip router ospf #{k} area #{v1[:area]}"
|
|
385
|
+
cfg << "ip ospf cost #{v1[:cost]}" unless v1[:cost].nil?
|
|
386
|
+
cfg << "ip ospf hello-interval #{v1[:hello]}" unless v1[:hello].nil?
|
|
387
|
+
cfg << "ip ospf dead-interval #{v1[:dead]}" unless v1[:dead].nil?
|
|
388
|
+
cfg << 'ip ospf passive-interface' if !v1[:pass].nil? &&
|
|
389
|
+
v1[:pass] == true
|
|
390
|
+
config(*cfg)
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def multiple_interface_config_hash
|
|
396
|
+
# rubocop:disable Style/AlignHash
|
|
397
|
+
hash = {
|
|
398
|
+
'ospfTest' => {
|
|
399
|
+
interfaces[0].downcase => {
|
|
400
|
+
area: '0.0.0.0', cost: 10, hello: 30, dead: 120, pass: true },
|
|
401
|
+
interfaces[1].downcase => {
|
|
402
|
+
area: '1.1.1.38', dead: 40, pass: false },
|
|
403
|
+
'vlan101' => {
|
|
404
|
+
area: '2.2.2.101', cost: 5, hello: 20, dead: 80, pass: true },
|
|
405
|
+
},
|
|
406
|
+
'TestOspfInt' => {
|
|
407
|
+
interfaces[2].downcase => {
|
|
408
|
+
area: '0.0.0.19' },
|
|
409
|
+
'vlan290' => {
|
|
410
|
+
area: '2.2.2.29', cost: 200, hello: 30, dead: 120, pass: true },
|
|
411
|
+
'port-channel100' => {
|
|
412
|
+
area: '3.2.2.29', cost: 25, hello: 50, dead: 200, pass: false },
|
|
413
|
+
},
|
|
414
|
+
}
|
|
415
|
+
# rubocop:enable Style/AlignHash
|
|
416
|
+
# Set defaults
|
|
417
|
+
hash.each_key do |name|
|
|
418
|
+
hash[name].each_value do |hv|
|
|
419
|
+
hv[:cost] ||= node.config_get_default('interface_ospf', 'cost')
|
|
420
|
+
hv[:hello] ||= node.config_get_default('interface_ospf',
|
|
421
|
+
'hello_interval')
|
|
422
|
+
hv[:dead] ||= node.config_get_default('interface_ospf',
|
|
423
|
+
'dead_interval')
|
|
424
|
+
hv[:pass] ||= node.config_get_default('interface_ospf',
|
|
425
|
+
'passive_interface')
|
|
551
426
|
end
|
|
552
|
-
@device.cmd("end")
|
|
553
427
|
end
|
|
554
|
-
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def test_interfaceospf_collection_multiple_interface
|
|
431
|
+
s = config('int port-channel 42', 'descr foo')
|
|
432
|
+
known_failure = s[/ERROR:.*port channel not present/]
|
|
433
|
+
refute(known_failure, 'ERROR: port channel not present')
|
|
434
|
+
|
|
435
|
+
ospf_h = multiple_interface_config_hash
|
|
436
|
+
|
|
437
|
+
# enable feature ospf
|
|
438
|
+
config('no feature ospf',
|
|
439
|
+
'feature ospf',
|
|
440
|
+
'feature interface-vlan',
|
|
441
|
+
'default interface interfaces[0]',
|
|
442
|
+
'default interface interfaces[1]',
|
|
443
|
+
'default interface interfaces[2]',
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
# pre-configure
|
|
447
|
+
configure_from_hash(ospf_h)
|
|
555
448
|
|
|
556
449
|
routers = RouterOspf.routers()
|
|
557
450
|
# validate the collection
|
|
558
|
-
routers.each do |
|
|
451
|
+
routers.each do |name, router|
|
|
559
452
|
interfaces = InterfaceOspf.interfaces(router.name)
|
|
560
|
-
refute_empty(interfaces,
|
|
453
|
+
refute_empty(interfaces, 'InterfaceOspf collection is empty')
|
|
561
454
|
assert_includes(ospf_h, name)
|
|
562
455
|
ospfh = ospf_h.fetch(name)
|
|
563
|
-
assert_equal(ospfh.size
|
|
456
|
+
assert_equal(ospfh.size, interfaces.size,
|
|
564
457
|
"InterfaceOspf #{name} collection size mismatch")
|
|
565
|
-
interfaces.each do |
|
|
458
|
+
interfaces.each do |ifname, interface|
|
|
566
459
|
assert_includes(ospfh, ifname)
|
|
567
460
|
hv = ospfh.fetch(ifname)
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
461
|
+
assert_show_match(
|
|
462
|
+
command: show_cmd(ifname),
|
|
463
|
+
pattern: /\s+ip router ospf #{name} area #{hv[:area]}/,
|
|
464
|
+
msg: "Error: ip router ospf #{name} area #{hv[:area]} "\
|
|
571
465
|
"not found under #{ifname}")
|
|
572
466
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
assert_equal(hv[:cost], interface.cost,
|
|
581
|
-
"Error: get cost failed")
|
|
582
|
-
end
|
|
583
|
-
# check the hello
|
|
584
|
-
if hv[:hello].nil?
|
|
585
|
-
assert_equal(node.config_get_default("interface_ospf",
|
|
586
|
-
"hello_interval"),
|
|
587
|
-
interface.hello_interval,
|
|
588
|
-
"Error: get default hello interval failed")
|
|
589
|
-
else
|
|
590
|
-
assert_equal(hv[:hello], interface.hello_interval,
|
|
591
|
-
"Error: get hello interval failed")
|
|
592
|
-
end
|
|
593
|
-
# check the dead
|
|
594
|
-
if hv[:dead].nil?
|
|
595
|
-
assert_equal(node.config_get_default("interface_ospf",
|
|
596
|
-
"dead_interval"),
|
|
597
|
-
interface.dead_interval,
|
|
598
|
-
"Error: get dead interval failed")
|
|
599
|
-
else
|
|
600
|
-
assert_equal(hv[:dead], interface.dead_interval,
|
|
601
|
-
"Error: get dead interval failed")
|
|
602
|
-
end
|
|
603
|
-
# check passive interface
|
|
604
|
-
if hv[:pass].nil?
|
|
605
|
-
assert_equal(node.config_get_default("interface_ospf",
|
|
606
|
-
"passive_interface"),
|
|
607
|
-
interface.passive_interface,
|
|
608
|
-
"Error: passive interface get failed")
|
|
609
|
-
else
|
|
610
|
-
assert_equal(hv[:pass], interface.passive_interface,
|
|
611
|
-
"Error: passive interface get failed")
|
|
612
|
-
end
|
|
467
|
+
assert_equal(hv[:cost], interface.cost, 'Error: get cost failed')
|
|
468
|
+
assert_equal(hv[:hello], interface.hello_interval,
|
|
469
|
+
'Error: get hello interval failed')
|
|
470
|
+
assert_equal(hv[:dead], interface.dead_interval,
|
|
471
|
+
'Error: get dead interval failed')
|
|
472
|
+
assert_equal(hv[:pass], interface.passive_interface,
|
|
473
|
+
'Error: passive interface get failed')
|
|
613
474
|
end
|
|
614
|
-
# cleanup interfaces
|
|
615
|
-
# node.debug=true
|
|
616
|
-
interfaceospf_interfaces_destroy(interfaces)
|
|
617
|
-
# node.debug=true
|
|
618
|
-
interfaces=nil
|
|
619
475
|
end # interfaces hash
|
|
620
476
|
# clean up
|
|
621
|
-
routerospf_routers_destroy(routers)
|
|
622
|
-
routers=nil
|
|
623
477
|
|
|
624
478
|
# disable feature interface-vlan
|
|
625
|
-
|
|
626
|
-
@device.cmd("no feature interface-vlan")
|
|
627
|
-
@device.cmd("end")
|
|
479
|
+
config('no feature interface-vlan')
|
|
628
480
|
# clean up port channel
|
|
629
|
-
ospf_h.
|
|
630
|
-
v.
|
|
631
|
-
|
|
632
|
-
@device.cmd("configure terminal")
|
|
633
|
-
@device.cmd("no interface #{k1}")
|
|
634
|
-
@device.cmd("end")
|
|
635
|
-
end
|
|
481
|
+
ospf_h.each_value do |v|
|
|
482
|
+
v.each_key do |k1|
|
|
483
|
+
config("no interface #{k1}") if (/^port-channel\d/).match(k1)
|
|
636
484
|
end # v each
|
|
637
485
|
end # ospf_h each
|
|
638
|
-
node.cache_flush
|
|
639
|
-
|
|
640
|
-
interface_ethernet_default(interfaces_id[0])
|
|
641
|
-
interface_ethernet_default(interfaces_id[1])
|
|
642
|
-
interface_ethernet_default(interfaces_id[2])
|
|
643
486
|
end
|
|
644
487
|
|
|
645
488
|
def test_interfaceospf_message_digest
|
|
@@ -649,22 +492,17 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
649
492
|
# set with value
|
|
650
493
|
interface.message_digest = true
|
|
651
494
|
pattern = (/^\s+ip ospf authentication message-digest$/)
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
"Error: message digest enable missing in CLI")
|
|
495
|
+
assert_show_match(pattern: pattern,
|
|
496
|
+
msg: 'Error: message digest enable missing in CLI')
|
|
655
497
|
assert(interface.message_digest,
|
|
656
|
-
|
|
498
|
+
'Error: message digest get value mismatch')
|
|
657
499
|
|
|
658
500
|
# get default and set
|
|
659
501
|
interface.message_digest = interface.default_message_digest
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
"Error: default message digest set failed")
|
|
502
|
+
refute_show_match(pattern: pattern,
|
|
503
|
+
msg: 'Error: default message digest set failed')
|
|
663
504
|
refute(interface.message_digest,
|
|
664
|
-
|
|
665
|
-
interfaceospf_interface_destroy(interface)
|
|
666
|
-
routerospf_router_destroy(ospf)
|
|
667
|
-
interface_ethernet_default()
|
|
505
|
+
'Error: message digest get value mismatch')
|
|
668
506
|
end
|
|
669
507
|
|
|
670
508
|
def test_interfaceospf_message_digest_key
|
|
@@ -676,13 +514,11 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
676
514
|
encr = :cleartext
|
|
677
515
|
|
|
678
516
|
# set with value
|
|
679
|
-
interface.message_digest_key_set(keyid, algo, encr,
|
|
517
|
+
interface.message_digest_key_set(keyid, algo, encr, 'test123')
|
|
680
518
|
# need to revist TODO
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
"Error: message digest authentication with cleartext " +
|
|
685
|
-
"missing in CLI")
|
|
519
|
+
line = assert_show_match(
|
|
520
|
+
pattern: /^\s+ip ospf message-digest-key #{keyid} md5 \S \S+$/,
|
|
521
|
+
msg: 'message digest authentication with cleartext missing in CLI')
|
|
686
522
|
# TODO: assert(interface.message_digest,
|
|
687
523
|
# "Error: message digest get value mismatch")
|
|
688
524
|
# check key id exist
|
|
@@ -690,7 +526,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
690
526
|
"Error: message digest key #{keyid} not present")
|
|
691
527
|
# save encrypted password
|
|
692
528
|
md = /3 (\S+)$/.match(line.to_s)
|
|
693
|
-
encrypted_password = md.to_s.split(
|
|
529
|
+
encrypted_password = md.to_s.split(' ').last
|
|
694
530
|
assert_equal(encrypted_password, interface.message_digest_password)
|
|
695
531
|
|
|
696
532
|
# Check other attributes:
|
|
@@ -700,11 +536,9 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
700
536
|
# unconfigure auth
|
|
701
537
|
keyid = interface.default_message_digest_key_id
|
|
702
538
|
encr = :cleartext
|
|
703
|
-
interface.message_digest_key_set(keyid, algo, encr,
|
|
704
|
-
pattern
|
|
705
|
-
|
|
706
|
-
assert_nil(line,
|
|
707
|
-
"Error: message digest authentication still present in CLI")
|
|
539
|
+
interface.message_digest_key_set(keyid, algo, encr, 'test123')
|
|
540
|
+
refute_show_match(pattern: /^\s+ip ospf message-digest-key #{keyid} .+/,
|
|
541
|
+
msg: 'message digest auth still present in CLI')
|
|
708
542
|
assert_equal(interface.message_digest_key_id,
|
|
709
543
|
interface.default_message_digest_key_id)
|
|
710
544
|
assert_equal(interface.message_digest_algorithm_type,
|
|
@@ -716,11 +550,9 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
716
550
|
keyid = 1
|
|
717
551
|
encr = :"3des"
|
|
718
552
|
interface.message_digest_key_set(keyid, algo, encr, encrypted_password)
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
"Error: message digest authentication with 3DES missing " +
|
|
723
|
-
"in CLI")
|
|
553
|
+
assert_show_match(
|
|
554
|
+
pattern: /^\s+ip ospf message-digest-key #{keyid} md5 3 \S+$/,
|
|
555
|
+
msg: 'message digest authentication with 3DES missing in CLI')
|
|
724
556
|
assert_equal(keyid, interface.message_digest_key_id)
|
|
725
557
|
assert_equal(algo, interface.message_digest_algorithm_type)
|
|
726
558
|
assert_equal(encr, interface.message_digest_encryption_type)
|
|
@@ -730,18 +562,12 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
730
562
|
keyid = 1
|
|
731
563
|
encr = :cisco_type_7
|
|
732
564
|
interface.message_digest_key_set(keyid, algo, encr, encrypted_password)
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
"Error: message digest authentication with cisco type 7 " +
|
|
737
|
-
"missing in CLI")
|
|
565
|
+
assert_show_match(
|
|
566
|
+
pattern: /^\s+ip ospf message-digest-key #{keyid} md5 7 \S+$/,
|
|
567
|
+
msg: 'message digest authentication with cisco type 7 missing in CLI')
|
|
738
568
|
assert_equal(keyid, interface.message_digest_key_id)
|
|
739
569
|
assert_equal(algo, interface.message_digest_algorithm_type)
|
|
740
570
|
assert_equal(encr, interface.message_digest_encryption_type)
|
|
741
|
-
|
|
742
|
-
interfaceospf_interface_destroy(interface)
|
|
743
|
-
routerospf_router_destroy(ospf)
|
|
744
|
-
interface_ethernet_default()
|
|
745
571
|
end
|
|
746
572
|
|
|
747
573
|
def test_interfaceospf_message_digest_key_invalid_password
|
|
@@ -752,44 +578,34 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
752
578
|
keyid = 1
|
|
753
579
|
algo = :md5
|
|
754
580
|
encr = :cleartext
|
|
755
|
-
password =
|
|
581
|
+
password = ''
|
|
756
582
|
assert_raises(ArgumentError) do
|
|
757
583
|
interface.message_digest_key_set(keyid, algo, encr, password)
|
|
758
584
|
end
|
|
759
585
|
|
|
760
586
|
# mismatch password and encryption
|
|
761
587
|
encr = :"3des"
|
|
762
|
-
password =
|
|
588
|
+
password = 'test123'
|
|
763
589
|
assert_raises(CliError) do
|
|
764
590
|
interface.message_digest_key_set(keyid, algo, encr, password)
|
|
765
591
|
end
|
|
766
|
-
|
|
767
|
-
interfaceospf_interface_destroy(interface)
|
|
768
|
-
routerospf_router_destroy(ospf)
|
|
769
|
-
interface_ethernet_default()
|
|
770
592
|
end
|
|
771
593
|
|
|
772
594
|
def test_interfaceospf_nonexistent
|
|
773
595
|
# If the interface does exist but the OSPF instance does not, this is OK
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
@device.cmd("end")
|
|
777
|
-
node.cache_flush
|
|
778
|
-
interface = InterfaceOspf.new("loopback122", "nonexistentOspf", "0")
|
|
596
|
+
config('interface loopback122')
|
|
597
|
+
interface = InterfaceOspf.new('loopback122', 'nonexistentOspf', '0')
|
|
779
598
|
|
|
780
599
|
# Note: the area getter will munge the value to dotted decimal.
|
|
781
|
-
assert_equal(interface.area,
|
|
600
|
+
assert_equal(interface.area, '0.0.0.0')
|
|
782
601
|
assert_equal(interface.hello_interval, interface.default_hello_interval)
|
|
783
602
|
|
|
784
603
|
interface.destroy
|
|
785
604
|
|
|
786
605
|
# If the interface doesn't exist, InterfaceOspf should raise an error
|
|
787
|
-
|
|
788
|
-
@device.cmd("no interface loopback122")
|
|
789
|
-
@device.cmd("end")
|
|
790
|
-
node.cache_flush
|
|
606
|
+
config('no interface loopback122')
|
|
791
607
|
assert_raises(RuntimeError) do
|
|
792
|
-
interface = InterfaceOspf.new(
|
|
608
|
+
interface = InterfaceOspf.new('loopback122', 'nonexistentOspf', '0')
|
|
793
609
|
end
|
|
794
610
|
end
|
|
795
611
|
end
|