cisco_node_utils 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +4 -1
- data/CHANGELOG.md +81 -2
- data/CONTRIBUTING.md +2 -17
- data/Gemfile +5 -0
- data/README.md +92 -47
- data/Rakefile +23 -1
- data/bin/git/hooks/hook_lib +7 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +7 -2
- data/bin/git/hooks/pre-commit/validate-diffs +18 -4
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/update-hooks +64 -6
- data/cisco_node_utils.gemspec +9 -6
- data/docs/README-develop-best-practices.md +149 -50
- data/docs/README-develop-node-utils-APIs.md +92 -42
- data/docs/README-maintainers.md +7 -4
- data/docs/README-test-execution.md +57 -0
- data/docs/cisco_node_utils.yaml.example +30 -0
- data/docs/template-router.rb +4 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +2 -2
- data/lib/cisco_node_utils.rb +5 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +5 -6
- data/lib/cisco_node_utils/aaa_authorization_service.rb +1 -1
- data/lib/cisco_node_utils/ace.rb +165 -12
- data/lib/cisco_node_utils/acl.rb +2 -1
- data/lib/cisco_node_utils/bgp.rb +184 -21
- data/lib/cisco_node_utils/bgp_af.rb +94 -249
- data/lib/cisco_node_utils/bgp_neighbor.rb +94 -14
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +75 -8
- data/lib/cisco_node_utils/bridge_domain.rb +183 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +85 -2
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/client/client.rb +234 -0
- data/lib/cisco_node_utils/client/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +311 -0
- data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
- data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
- data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
- data/lib/cisco_node_utils/client/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +305 -0
- data/lib/cisco_node_utils/client/utils.rb +164 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +222 -254
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +22 -15
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +21 -16
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +239 -109
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +114 -55
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +76 -52
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +106 -62
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +35 -14
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +23 -17
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +94 -83
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +22 -17
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +76 -26
- data/lib/cisco_node_utils/cmd_ref/images.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +381 -153
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +21 -21
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +30 -21
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +18 -13
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +26 -31
- data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
- data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +17 -6
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +10 -3
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +17 -5
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +33 -29
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +12 -10
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +16 -19
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +40 -25
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +17 -12
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +71 -35
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +10 -5
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +6 -2
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +47 -43
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +13 -11
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +4 -2
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +23 -21
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +26 -22
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +19 -17
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +18 -6
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +234 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +24 -9
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +5 -3
- data/lib/cisco_node_utils/cmd_ref/system.yaml +4 -3
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +22 -20
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +27 -15
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +45 -16
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +60 -32
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +118 -101
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +54 -58
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +118 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +19 -25
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +28 -18
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +34 -17
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +6 -4
- data/lib/cisco_node_utils/command_reference.rb +261 -142
- data/lib/cisco_node_utils/constants.rb +33 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +102 -0
- data/lib/cisco_node_utils/evpn_vni.rb +5 -3
- data/lib/cisco_node_utils/exceptions.rb +111 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +52 -35
- data/lib/cisco_node_utils/fabricpath_topology.rb +44 -57
- data/lib/cisco_node_utils/feature.rb +165 -3
- data/lib/cisco_node_utils/interface.rb +1051 -260
- data/lib/cisco_node_utils/interface_channel_group.rb +11 -10
- data/lib/cisco_node_utils/interface_ospf.rb +1 -2
- data/lib/cisco_node_utils/interface_portchannel.rb +4 -12
- data/lib/cisco_node_utils/interface_service_vni.rb +7 -7
- data/lib/cisco_node_utils/itd_device_group.rb +248 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +523 -0
- data/lib/cisco_node_utils/logger.rb +75 -0
- data/lib/cisco_node_utils/node.rb +62 -192
- data/lib/cisco_node_utils/node_util.rb +56 -10
- data/lib/cisco_node_utils/overlay_global.rb +2 -2
- data/lib/cisco_node_utils/pim.rb +2 -13
- data/lib/cisco_node_utils/pim_group_list.rb +1 -1
- data/lib/cisco_node_utils/pim_rp_address.rb +1 -1
- data/lib/cisco_node_utils/platform.rb +52 -21
- data/lib/cisco_node_utils/portchannel_global.rb +89 -19
- data/lib/cisco_node_utils/radius_server.rb +168 -37
- data/lib/cisco_node_utils/router_ospf.rb +20 -35
- data/lib/cisco_node_utils/router_ospf_vrf.rb +4 -4
- data/lib/cisco_node_utils/snmpserver.rb +1 -6
- data/lib/cisco_node_utils/snmpuser.rb +6 -4
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_server.rb +77 -18
- data/lib/cisco_node_utils/syslog_settings.rb +1 -1
- data/lib/cisco_node_utils/tacacs_server_group.rb +8 -4
- data/lib/cisco_node_utils/tacacs_server_host.rb +115 -25
- data/lib/cisco_node_utils/vdc.rb +12 -0
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vlan.rb +147 -29
- data/lib/cisco_node_utils/vpc.rb +55 -3
- data/lib/cisco_node_utils/vrf.rb +72 -11
- data/lib/cisco_node_utils/vrf_af.rb +114 -29
- data/lib/cisco_node_utils/vtp.rb +34 -52
- data/lib/cisco_node_utils/vxlan_vtep.rb +34 -8
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +36 -4
- data/lib/minitest/environment_plugin.rb +31 -0
- data/lib/minitest/log_level_plugin.rb +41 -0
- data/spec/client_spec.rb +7 -0
- data/spec/environment_spec.rb +263 -0
- data/spec/grpc_client_spec.rb +23 -0
- data/spec/isolate/all_clients_spec.rb +9 -0
- data/spec/isolate/grpc_only_spec.rb +16 -0
- data/spec/isolate/no_clients_spec.rb +26 -0
- data/spec/isolate/nxapi_only_spec.rb +16 -0
- data/spec/nxapi_client_spec.rb +42 -0
- data/spec/schema.yaml +75 -0
- data/spec/shared_examples_for_clients.rb +14 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/whitespace_spec.rb +10 -0
- data/spec/yaml_spec.rb +42 -0
- data/tests/.rubocop.yml +2 -2
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +96 -36
- data/tests/ciscotest.rb +220 -12
- data/tests/cmd_config.yaml +71 -49
- data/tests/cmd_config_invalid.yaml +1 -1
- data/tests/test_aaa_authentication_login.rb +1 -0
- data/tests/test_aaa_authentication_login_service.rb +9 -0
- data/tests/test_aaa_authorization_service.rb +173 -367
- data/tests/test_ace.rb +171 -100
- data/tests/test_acl.rb +10 -1
- data/tests/test_bgp_af.rb +395 -728
- data/tests/test_bgp_neighbor.rb +274 -115
- data/tests/test_bgp_neighbor_af.rb +178 -77
- data/tests/test_bridge_domain.rb +191 -0
- data/tests/test_bridge_domain_vni.rb +116 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_command_config.rb +9 -5
- data/tests/test_command_reference.rb +380 -102
- data/tests/test_dns_domain.rb +13 -3
- data/tests/test_domain_name.rb +13 -3
- data/tests/test_encapsulation.rb +77 -0
- data/tests/test_evpn_vni.rb +25 -7
- data/tests/test_fabricpath_global.rb +167 -163
- data/tests/test_fabricpath_topology.rb +12 -33
- data/tests/test_feature.rb +215 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_interface.rb +585 -344
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +6 -3
- data/tests/test_interface_ospf.rb +26 -24
- data/tests/test_interface_portchannel.rb +1 -0
- data/tests/test_interface_private_vlan.rb +724 -0
- data/tests/test_interface_service_vni.rb +37 -66
- data/tests/test_interface_svi.rb +98 -101
- data/tests/test_interface_switchport.rb +419 -549
- data/tests/test_itd_device_group.rb +145 -0
- data/tests/test_itd_device_group_node.rb +199 -0
- data/tests/test_itd_service.rb +298 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +11 -2
- data/tests/test_node.rb +16 -75
- data/tests/test_node_ext.rb +174 -163
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_config.rb +5 -1
- data/tests/test_ntp_server.rb +2 -2
- data/tests/test_nxapi.rb +221 -0
- data/tests/test_overlay_global.rb +47 -38
- data/tests/test_pim.rb +2 -0
- data/tests/test_pim_group_list.rb +2 -0
- data/tests/test_pim_rp_address.rb +2 -0
- data/tests/test_platform.rb +86 -39
- data/tests/test_portchannel_global.rb +211 -135
- data/tests/test_radius_global.rb +13 -5
- data/tests/test_radius_server.rb +256 -104
- data/tests/test_radius_server_group.rb +2 -0
- data/tests/test_router_bgp.rb +781 -485
- data/tests/test_router_ospf.rb +26 -103
- data/tests/test_router_ospf_vrf.rb +52 -57
- data/tests/test_snmp_notification_receiver.rb +2 -0
- data/tests/test_snmpcommunity.rb +2 -0
- data/tests/test_snmpgroup.rb +2 -0
- data/tests/test_snmpnotification.rb +40 -21
- data/tests/test_snmpserver.rb +2 -0
- data/tests/test_snmpuser.rb +2 -0
- data/tests/test_stp_global.rb +563 -0
- data/tests/test_syslog_server.rb +32 -8
- data/tests/test_syslog_settings.rb +22 -9
- data/tests/test_tacacs_server.rb +32 -27
- data/tests/test_tacacs_server_group.rb +100 -45
- data/tests/test_tacacs_server_host.rb +135 -43
- data/tests/test_vdc.rb +2 -16
- data/tests/test_vlan.rb +106 -54
- data/tests/test_vlan_mt_full.rb +11 -21
- data/tests/test_vlan_private.rb +669 -0
- data/tests/test_vpc.rb +312 -159
- data/tests/test_vrf.rb +122 -113
- data/tests/test_vrf_af.rb +238 -0
- data/tests/test_vtp.rb +58 -102
- data/tests/test_vxlan_vtep.rb +38 -17
- data/tests/test_vxlan_vtep_vni.rb +61 -9
- data/tests/test_yum.rb +49 -25
- metadata +122 -36
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +0 -9
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +0 -76
- data/lib/cisco_node_utils/vni.rb +0 -227
- data/tests/test_vni.rb +0 -106
data/tests/test_vrf.rb
CHANGED
@@ -14,8 +14,6 @@
|
|
14
14
|
|
15
15
|
require_relative 'ciscotest'
|
16
16
|
require_relative '../lib/cisco_node_utils/vrf'
|
17
|
-
require_relative '../lib/cisco_node_utils/vrf_af'
|
18
|
-
require_relative '../lib/cisco_node_utils/vni'
|
19
17
|
|
20
18
|
include Cisco
|
21
19
|
|
@@ -31,14 +29,18 @@ class TestVrf < CiscoTestCase
|
|
31
29
|
end
|
32
30
|
|
33
31
|
def teardown
|
34
|
-
super
|
35
32
|
remove_all_vrfs
|
33
|
+
super
|
36
34
|
end
|
37
35
|
|
38
|
-
def
|
36
|
+
def test_collection_default
|
39
37
|
vrfs = Vrf.vrfs
|
40
|
-
|
41
|
-
|
38
|
+
if platform == :nexus
|
39
|
+
refute_empty(vrfs, 'VRF collection is empty')
|
40
|
+
assert(vrfs.key?('management'), 'VRF management does not exist')
|
41
|
+
else
|
42
|
+
assert_empty(vrfs, 'VRF collection is not empty')
|
43
|
+
end
|
42
44
|
end
|
43
45
|
|
44
46
|
def test_create_and_destroy
|
@@ -71,16 +73,36 @@ class TestVrf < CiscoTestCase
|
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
76
|
+
# This helper is needed on some platforms to allow enough time for the
|
77
|
+
# 'shutdown' process to complete before 'no shutdown' can be successful.
|
78
|
+
def shutdown_with_sleep(obj, val)
|
79
|
+
obj.shutdown = val
|
80
|
+
rescue CliError => e
|
81
|
+
raise unless e.message[/ERROR: Shutdown of VRF .* in progress/]
|
82
|
+
sleep 1
|
83
|
+
tries ||= 1
|
84
|
+
retry unless (tries += 1) > 20
|
85
|
+
end
|
86
|
+
|
74
87
|
def test_shutdown
|
75
88
|
v = Vrf.new('test_shutdown')
|
89
|
+
if validate_property_excluded?('vrf', 'shutdown')
|
90
|
+
assert_nil(v.shutdown)
|
91
|
+
assert_nil(v.default_shutdown)
|
92
|
+
assert_raises(Cisco::UnsupportedError) { v.shutdown = true }
|
93
|
+
v.destroy
|
94
|
+
return
|
95
|
+
end
|
76
96
|
v.shutdown = true
|
77
97
|
assert(v.shutdown)
|
78
|
-
|
98
|
+
|
99
|
+
shutdown_with_sleep(v, false)
|
79
100
|
refute(v.shutdown)
|
80
101
|
|
81
102
|
v.shutdown = true
|
82
103
|
assert(v.shutdown)
|
83
|
-
|
104
|
+
|
105
|
+
shutdown_with_sleep(v, v.default_shutdown)
|
84
106
|
refute(v.shutdown)
|
85
107
|
v.destroy
|
86
108
|
end
|
@@ -97,9 +119,68 @@ class TestVrf < CiscoTestCase
|
|
97
119
|
v.destroy
|
98
120
|
end
|
99
121
|
|
122
|
+
def test_mhost
|
123
|
+
v = Vrf.new('test_mhost')
|
124
|
+
t_intf = 'Loopback100'
|
125
|
+
if validate_property_excluded?('vrf', 'mhost_default_interface')
|
126
|
+
assert_nil(v.mhost_ipv4_default_interface)
|
127
|
+
assert_nil(v.mhost_ipv6_default_interface)
|
128
|
+
assert_raises(Cisco::UnsupportedError) do
|
129
|
+
v.mhost_ipv4_default_interface = t_intf
|
130
|
+
end
|
131
|
+
assert_raises(Cisco::UnsupportedError) do
|
132
|
+
v.mhost_ipv6_default_interface = t_intf
|
133
|
+
end
|
134
|
+
v.destroy
|
135
|
+
return
|
136
|
+
end
|
137
|
+
config("interface #{t_intf}")
|
138
|
+
%w(mhost_ipv4_default_interface mhost_ipv6_default_interface).each do |mh|
|
139
|
+
df = v.send("default_#{mh}")
|
140
|
+
result = v.send("#{mh}")
|
141
|
+
assert_equal(df, result, "Test1.1 : #{mh} should be default value")
|
142
|
+
|
143
|
+
v.send("#{mh}=", t_intf)
|
144
|
+
result = v.send("#{mh}")
|
145
|
+
assert_equal(t_intf, result,
|
146
|
+
"Test2.1 :vrf #{mh} should be set to #{t_intf}")
|
147
|
+
|
148
|
+
df = v.send("default_#{mh}")
|
149
|
+
v.send("#{mh}=", "#{df}")
|
150
|
+
result = v.send("#{mh}")
|
151
|
+
assert_equal(df, result,
|
152
|
+
"Test3.1 :vrf #{mh} should be set to default value")
|
153
|
+
end
|
154
|
+
config("no interface #{t_intf}")
|
155
|
+
v.destroy
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_remote_route_filtering
|
159
|
+
v = Vrf.new('test_remote_route_filtering')
|
160
|
+
if validate_property_excluded?('vrf', 'remote_route_filtering')
|
161
|
+
refute(v.remote_route_filtering)
|
162
|
+
assert_raises(Cisco::UnsupportedError) do
|
163
|
+
v.remote_route_filtering = false
|
164
|
+
end
|
165
|
+
v.destroy
|
166
|
+
return
|
167
|
+
end
|
168
|
+
assert(v.remote_route_filtering,
|
169
|
+
'Test1.1, remote_route_filtering should be default value')
|
170
|
+
v.remote_route_filtering = false
|
171
|
+
refute(v.remote_route_filtering,
|
172
|
+
'Test2.1, remote_route_filtering should be set to false')
|
173
|
+
v.remote_route_filtering = v.default_remote_route_filtering
|
174
|
+
assert(v.remote_route_filtering,
|
175
|
+
'Test3.1, remote_route_filtering should be set to default value')
|
176
|
+
v.destroy
|
177
|
+
end
|
178
|
+
|
100
179
|
def test_vni
|
101
|
-
skip('Platform does not support MT-lite') unless Vni.mt_lite_support
|
102
180
|
vrf = Vrf.new('test_vni')
|
181
|
+
assert_equal(vrf.default_vni, vrf.vni,
|
182
|
+
'vrf vni should be set to default value')
|
183
|
+
|
103
184
|
vrf.vni = 4096
|
104
185
|
assert_equal(4096, vrf.vni,
|
105
186
|
"vrf vni should be set to '4096'")
|
@@ -107,10 +188,25 @@ class TestVrf < CiscoTestCase
|
|
107
188
|
assert_equal(vrf.default_vni, vrf.vni,
|
108
189
|
'vrf vni should be set to default value')
|
109
190
|
vrf.destroy
|
191
|
+
rescue RuntimeError => e
|
192
|
+
hardware_supports_feature?(e.message)
|
110
193
|
end
|
111
194
|
|
112
195
|
def test_route_distinguisher
|
113
|
-
|
196
|
+
skip_nexus_i2_image?
|
197
|
+
# Check for compatible linecard (if platform requires it) and set it up
|
198
|
+
vxlan_linecard?
|
199
|
+
vdc_lc_state('f3')
|
200
|
+
|
201
|
+
v = Vrf.new('green')
|
202
|
+
if validate_property_excluded?('vrf', 'route_distinguisher')
|
203
|
+
# Must be configured under BGP in IOS XR
|
204
|
+
assert_nil(v.route_distinguisher)
|
205
|
+
assert_nil(v.default_route_distinguisher)
|
206
|
+
assert_raises(Cisco::UnsupportedError) { v.route_distinguisher = 'auto' }
|
207
|
+
v.destroy
|
208
|
+
return
|
209
|
+
end
|
114
210
|
v.route_distinguisher = 'auto'
|
115
211
|
assert_equal('auto', v.route_distinguisher)
|
116
212
|
|
@@ -126,110 +222,23 @@ class TestVrf < CiscoTestCase
|
|
126
222
|
v.destroy
|
127
223
|
end
|
128
224
|
|
129
|
-
def
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
assert_equal(2, VrfAF.afs['red'].keys.count)
|
137
|
-
assert_equal(1, VrfAF.afs['blue'].keys.count)
|
138
|
-
|
139
|
-
v1.destroy
|
140
|
-
v5.destroy
|
141
|
-
assert_equal(1, VrfAF.afs['cyan'].keys.count)
|
142
|
-
assert_equal(1, VrfAF.afs['red'].keys.count)
|
143
|
-
assert_equal(1, VrfAF.afs['blue'].keys.count)
|
144
|
-
|
145
|
-
v2.destroy
|
146
|
-
v3.destroy
|
147
|
-
v4.destroy
|
148
|
-
assert_equal(0, VrfAF.afs['cyan'].keys.count)
|
149
|
-
assert_equal(0, VrfAF.afs['red'].keys.count)
|
150
|
-
assert_equal(0, VrfAF.afs['blue'].keys.count)
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_route_target
|
154
|
-
[%w(ipv4 unicast), %w(ipv6 unicast)].each { |af| route_target(af) }
|
155
|
-
end
|
156
|
-
|
157
|
-
def route_target(af)
|
158
|
-
# Common tester for route-target properties. Tests evpn and non-evpn.
|
159
|
-
# route_target_both_auto
|
160
|
-
# route_target_both_auto_evpn
|
161
|
-
# route_target_export
|
162
|
-
# route_target_export_evpn
|
163
|
-
# route_target_import
|
164
|
-
# route_target_import_evpn
|
165
|
-
vrf = 'red'
|
166
|
-
v = VrfAF.new(vrf, af)
|
167
|
-
|
168
|
-
# test route target both auto and route target both auto evpn
|
169
|
-
refute(v.default_route_target_both_auto,
|
170
|
-
'default value for route target both auto should be false')
|
171
|
-
|
172
|
-
refute(v.default_route_target_both_auto_evpn,
|
173
|
-
'default value for route target both auto evpn should be false')
|
174
|
-
|
175
|
-
v.route_target_both_auto = true
|
176
|
-
assert(v.route_target_both_auto, "vrf context #{vrf} af #{af}: "\
|
177
|
-
'v route-target both auto should be enabled')
|
178
|
-
|
179
|
-
v.route_target_both_auto = false
|
180
|
-
refute(v.route_target_both_auto, "vrf context #{vrf} af #{af}: "\
|
181
|
-
'v route-target both auto should be disabled')
|
182
|
-
|
183
|
-
v.route_target_both_auto_evpn = true
|
184
|
-
assert(v.route_target_both_auto_evpn, "vrf context #{vrf} af #{af}: "\
|
185
|
-
'v route-target both auto evpn should be enabled')
|
186
|
-
|
187
|
-
v.route_target_both_auto_evpn = false
|
188
|
-
refute(v.route_target_both_auto_evpn, "vrf context #{vrf} af #{af}: "\
|
189
|
-
'v route-target both auto evpn should be disabled')
|
190
|
-
|
191
|
-
opts = [:import, :export]
|
192
|
-
|
193
|
-
# Master list of communities to test against
|
194
|
-
master = ['1:1', '2:2', '3:3', '4:5']
|
195
|
-
|
196
|
-
# Test 1: both/import/export when no commands are present. Each target
|
197
|
-
# option will be tested with and without evpn (6 separate types)
|
198
|
-
should = master.clone
|
199
|
-
route_target_tester(v, af, opts, should, 'Test 1')
|
200
|
-
|
201
|
-
# Test 2: remove half of the entries
|
202
|
-
should = ['1:1', '4:4']
|
203
|
-
route_target_tester(v, af, opts, should, 'Test 2')
|
204
|
-
|
205
|
-
# Test 3: restore the removed entries
|
206
|
-
should = master.clone
|
207
|
-
route_target_tester(v, af, opts, should, 'Test 3')
|
208
|
-
|
209
|
-
# Test 4: 'default'
|
210
|
-
should = v.default_route_target_import
|
211
|
-
route_target_tester(v, af, opts, should, 'Test 4')
|
212
|
-
end
|
213
|
-
|
214
|
-
def route_target_tester(v, af, opts, should, test_id)
|
215
|
-
# First configure all four property types
|
216
|
-
opts.each do |opt|
|
217
|
-
# non-evpn
|
218
|
-
v.send("route_target_#{opt}=", should)
|
219
|
-
# evpn
|
220
|
-
v.send("route_target_#{opt}_evpn=", should)
|
225
|
+
def test_vpn_id
|
226
|
+
v = Vrf.new('test_vpn_id')
|
227
|
+
if validate_property_excluded?('vrf', 'vpn_id')
|
228
|
+
assert_nil(v.vpn_id)
|
229
|
+
assert_raises(Cisco::UnsupportedError) { v.vpn_id = '1:1' }
|
230
|
+
v.destroy
|
231
|
+
return
|
221
232
|
end
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
assert_equal(should, result,
|
228
|
-
"#{test_id} : #{af} : route_target_#{opt}")
|
229
|
-
# evpn
|
230
|
-
result = v.send("route_target_#{opt}_evpn")
|
231
|
-
assert_equal(should, result,
|
232
|
-
"#{test_id} : #{af} : route_target_#{opt}_evpn")
|
233
|
+
assert_equal(v.default_vpn_id, v.vpn_id,
|
234
|
+
'Test1.1, vpn_id should be default value')
|
235
|
+
%w(1:1 abcdef:12345678).each do |id|
|
236
|
+
v.vpn_id = id
|
237
|
+
assert_equal(id, v.vpn_id, "Test2.1, vpn_id should be set to #{id}")
|
233
238
|
end
|
239
|
+
v.vpn_id = v.default_vpn_id
|
240
|
+
assert_equal(v.default_vpn_id, v.vpn_id,
|
241
|
+
'Test3.1, vpn_id should be set to default value')
|
242
|
+
v.destroy
|
234
243
|
end
|
235
244
|
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative 'ciscotest'
|
16
|
+
require_relative '../lib/cisco_node_utils/vrf_af'
|
17
|
+
|
18
|
+
include Cisco
|
19
|
+
|
20
|
+
# TestVrfAf - Minitest for Vrf node utility class
|
21
|
+
class TestVrfAf < CiscoTestCase
|
22
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
23
|
+
|
24
|
+
def setup
|
25
|
+
super
|
26
|
+
return unless @@pre_clean_needed
|
27
|
+
nexus_feature_disable
|
28
|
+
remove_all_vrfs
|
29
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
nexus_feature_disable
|
34
|
+
remove_all_vrfs
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def nexus_feature_disable
|
39
|
+
config('no feature bgp')
|
40
|
+
|
41
|
+
# Some platforms complain when nv overlay is not configured
|
42
|
+
config_no_warn('no nv overlay evpn')
|
43
|
+
|
44
|
+
# Some platforms remove the 'evpn' command when 'no nv overlay evpn'
|
45
|
+
# is processed, while others must remove it explicitly.
|
46
|
+
config_no_warn('no evpn')
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_create_destroy
|
50
|
+
v1 = VrfAF.new('cyan', %w(ipv4 unicast))
|
51
|
+
v2 = VrfAF.new('cyan', %w(ipv6 unicast))
|
52
|
+
v3 = VrfAF.new('red', %w(ipv4 unicast))
|
53
|
+
v4 = VrfAF.new('blue', %w(ipv4 unicast))
|
54
|
+
v5 = VrfAF.new('red', %w(ipv6 unicast))
|
55
|
+
assert_equal(2, VrfAF.afs['cyan'].keys.count)
|
56
|
+
assert_equal(2, VrfAF.afs['red'].keys.count)
|
57
|
+
assert_equal(1, VrfAF.afs['blue'].keys.count)
|
58
|
+
|
59
|
+
v1.destroy
|
60
|
+
v5.destroy
|
61
|
+
assert_equal(1, VrfAF.afs['cyan'].keys.count)
|
62
|
+
assert_equal(1, VrfAF.afs['red'].keys.count)
|
63
|
+
assert_equal(1, VrfAF.afs['blue'].keys.count)
|
64
|
+
|
65
|
+
v2.destroy
|
66
|
+
v3.destroy
|
67
|
+
v4.destroy
|
68
|
+
assert_equal(0, VrfAF.afs['cyan'].keys.count)
|
69
|
+
assert_equal(0, VrfAF.afs['red'].keys.count)
|
70
|
+
assert_equal(0, VrfAF.afs['blue'].keys.count)
|
71
|
+
end
|
72
|
+
|
73
|
+
#-----------------------------------------
|
74
|
+
# test_route_policy
|
75
|
+
def test_route_policy
|
76
|
+
config('route-policy abc', 'end-policy') if platform == :ios_xr
|
77
|
+
[%w(ipv4 unicast), %w(ipv6 unicast)].each { |af| route_policy(af) }
|
78
|
+
config('route-policy abc', 'end-policy') if platform == :ios_xr
|
79
|
+
end
|
80
|
+
|
81
|
+
def route_policy(af)
|
82
|
+
v = VrfAF.new('black', af)
|
83
|
+
|
84
|
+
assert_nil(v.default_route_policy_import,
|
85
|
+
"Test1.1 : #{af} : route_policy_import")
|
86
|
+
assert_nil(v.default_route_policy_export,
|
87
|
+
"Test1.2 : #{af} : route_policy_export")
|
88
|
+
opts = [:import, :export]
|
89
|
+
# test route_target_import
|
90
|
+
# test route_target_export
|
91
|
+
opts.each do |opt|
|
92
|
+
# test route_policy set, from nil to name
|
93
|
+
policy_name = 'abc'
|
94
|
+
v.send("route_policy_#{opt}=", policy_name)
|
95
|
+
result = v.send("route_policy_#{opt}")
|
96
|
+
assert_equal(policy_name, result,
|
97
|
+
"Test2.1 : #{af} : route_policy_#{opt}")
|
98
|
+
|
99
|
+
# test route_policy remove, from name to nil
|
100
|
+
policy_name = nil
|
101
|
+
v.send("route_policy_#{opt}=", policy_name)
|
102
|
+
result = v.send("route_policy_#{opt}")
|
103
|
+
assert_nil(result, "Test2.2 : #{af} : route_policy_#{opt}")
|
104
|
+
|
105
|
+
# test route_policy remove, from nil to nil
|
106
|
+
v.send("route_policy_#{opt}=", policy_name)
|
107
|
+
result = v.send("route_policy_#{opt}")
|
108
|
+
assert_nil(result, "Test2.3 : #{af} : route_policy_#{opt}")
|
109
|
+
end
|
110
|
+
v.destroy
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_route_target
|
114
|
+
[%w(ipv4 unicast), %w(ipv6 unicast)].each { |af| route_target(af) }
|
115
|
+
end
|
116
|
+
|
117
|
+
def route_target(af)
|
118
|
+
#
|
119
|
+
# TBD: The evpn parts of this test need to check for compatible linecards to
|
120
|
+
# skip the evpn portions. Don't use vxlan_linecard? as that will cause all
|
121
|
+
# tests to be skipped.
|
122
|
+
#
|
123
|
+
# Common tester for route-target properties. Tests evpn and non-evpn.
|
124
|
+
# route_target_both_auto
|
125
|
+
# route_target_both_auto_evpn
|
126
|
+
# route_target_export
|
127
|
+
# route_target_export_evpn
|
128
|
+
# route_target_import
|
129
|
+
# route_target_import_evpn
|
130
|
+
vrf = 'orange'
|
131
|
+
v = VrfAF.new(vrf, af)
|
132
|
+
|
133
|
+
# test route target both auto and route target both auto evpn
|
134
|
+
refute(v.default_route_target_both_auto,
|
135
|
+
'default value for route target both auto should be false')
|
136
|
+
|
137
|
+
refute(v.default_route_target_both_auto_evpn,
|
138
|
+
'default value for route target both auto evpn should be false')
|
139
|
+
|
140
|
+
if validate_property_excluded?('vrf_af', 'route_target_both_auto')
|
141
|
+
assert_raises(Cisco::UnsupportedError) { v.route_target_both_auto = true }
|
142
|
+
else
|
143
|
+
v.route_target_both_auto = true
|
144
|
+
assert(v.route_target_both_auto, "vrf context #{vrf} af #{af}: "\
|
145
|
+
'v route-target both auto should be enabled')
|
146
|
+
|
147
|
+
v.route_target_both_auto = false
|
148
|
+
refute(v.route_target_both_auto, "vrf context #{vrf} af #{af}: "\
|
149
|
+
'v route-target both auto should be disabled')
|
150
|
+
end
|
151
|
+
|
152
|
+
if validate_property_excluded?('vrf_af', 'route_target_both_auto_evpn')
|
153
|
+
assert_raises(Cisco::UnsupportedError) do
|
154
|
+
v.route_target_both_auto_evpn = true
|
155
|
+
end
|
156
|
+
else
|
157
|
+
v.route_target_both_auto_evpn = true
|
158
|
+
assert(v.route_target_both_auto_evpn, "vrf context #{vrf} af #{af}: "\
|
159
|
+
'v route-target both auto evpn should be enabled')
|
160
|
+
|
161
|
+
v.route_target_both_auto_evpn = false
|
162
|
+
refute(v.route_target_both_auto_evpn, "vrf context #{vrf} af #{af}: "\
|
163
|
+
'v route-target both auto evpn should be disabled')
|
164
|
+
end
|
165
|
+
|
166
|
+
opts = [:import, :export]
|
167
|
+
|
168
|
+
# Master list of communities to test against
|
169
|
+
master = ['1:1', '2:2', '3:3', '4:5']
|
170
|
+
|
171
|
+
# Test 1: both/import/export when no commands are present. Each target
|
172
|
+
# option will be tested with and without evpn (6 separate types)
|
173
|
+
should = master.clone
|
174
|
+
route_target_tester(v, af, opts, should, 'Test 1')
|
175
|
+
|
176
|
+
# Test 2: remove half of the entries
|
177
|
+
should = ['1:1', '4:4']
|
178
|
+
route_target_tester(v, af, opts, should, 'Test 2')
|
179
|
+
|
180
|
+
# Test 3: restore the removed entries
|
181
|
+
should = master.clone
|
182
|
+
route_target_tester(v, af, opts, should, 'Test 3')
|
183
|
+
|
184
|
+
# Test 4: 'default'
|
185
|
+
should = v.default_route_target_import
|
186
|
+
route_target_tester(v, af, opts, should, 'Test 4')
|
187
|
+
v.destroy
|
188
|
+
end
|
189
|
+
|
190
|
+
def route_target_tester(v, af, opts, should, test_id)
|
191
|
+
# First configure all four property types
|
192
|
+
opts.each do |opt|
|
193
|
+
# non-evpn
|
194
|
+
v.send("route_target_#{opt}=", should)
|
195
|
+
# evpn
|
196
|
+
if validate_property_excluded?('vrf_af', "route_target_#{opt}_evpn")
|
197
|
+
assert_raises(Cisco::UnsupportedError, "route_target_#{opt}_evpn=") do
|
198
|
+
v.send("route_target_#{opt}_evpn=", should)
|
199
|
+
end
|
200
|
+
else
|
201
|
+
v.send("route_target_#{opt}_evpn=", should)
|
202
|
+
end
|
203
|
+
# stitching
|
204
|
+
if platform == :nexus
|
205
|
+
assert_raises(Cisco::UnsupportedError,
|
206
|
+
"route_target_#{opt}_stitching=") do
|
207
|
+
v.send("route_target_#{opt}_stitching=", should)
|
208
|
+
end
|
209
|
+
else
|
210
|
+
v.send("route_target_#{opt}_stitching=", should)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# Now check the results
|
215
|
+
opts.each do |opt|
|
216
|
+
# non-evpn
|
217
|
+
result = v.send("route_target_#{opt}")
|
218
|
+
assert_equal(should, result,
|
219
|
+
"#{test_id} : #{af} : route_target_#{opt}")
|
220
|
+
# evpn
|
221
|
+
result = v.send("route_target_#{opt}_evpn")
|
222
|
+
if validate_property_excluded?('vrf_af', "route_target_#{opt}_evpn")
|
223
|
+
assert_nil(result)
|
224
|
+
else
|
225
|
+
assert_equal(should, result,
|
226
|
+
"#{test_id} : #{af} : route_target_#{opt}_evpn")
|
227
|
+
end
|
228
|
+
# stitching
|
229
|
+
result = v.send("route_target_#{opt}_stitching")
|
230
|
+
if platform == :nexus
|
231
|
+
assert_nil(result)
|
232
|
+
else
|
233
|
+
assert_equal(should, result,
|
234
|
+
"#{test_id} : #{af} : route_target_#{opt}_stitching")
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|