cisco_node_utils 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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_bgp_neighbor.rb
CHANGED
|
@@ -20,95 +20,164 @@
|
|
|
20
20
|
require_relative 'ciscotest'
|
|
21
21
|
require_relative '../lib/cisco_node_utils/bgp'
|
|
22
22
|
require_relative '../lib/cisco_node_utils/bgp_neighbor'
|
|
23
|
+
require_relative '../lib/cisco_node_utils/logger'
|
|
23
24
|
|
|
24
25
|
# TestBgpNeighbor - Minitest for RouterBgpNeighbor node utility class
|
|
25
26
|
class TestBgpNeighbor < CiscoTestCase
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@@pre_clean_needed = true
|
|
30
|
-
# rubocop:enable Style/ClassVars
|
|
27
|
+
ASN = 55
|
|
28
|
+
ADDR = '1.1.1.1'
|
|
29
|
+
REMOTE_ASN = 99
|
|
30
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
|
31
31
|
|
|
32
32
|
def setup
|
|
33
33
|
super
|
|
34
34
|
remove_all_bgps if @@pre_clean_needed
|
|
35
35
|
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
|
36
36
|
# BGP Neighbor requires the presence of a basic bgp global config
|
|
37
|
-
RouterBgp.new(
|
|
37
|
+
RouterBgp.new(ASN)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def teardown
|
|
41
|
-
super
|
|
42
41
|
remove_all_bgps
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Returns some test data for use in several tests.
|
|
46
|
+
def test_data
|
|
47
|
+
test_data = []
|
|
48
|
+
test_data << { vrf: 'default', neighbors: ['1.1.1.1'] }
|
|
49
|
+
|
|
50
|
+
if platform == :ios_xr
|
|
51
|
+
# XR doesn't support prefix/len addresses
|
|
52
|
+
test_data << { vrf: 'red',
|
|
53
|
+
neighbors: ['2.2.2.0', '2000::2'] }
|
|
54
|
+
else
|
|
55
|
+
test_data << { vrf: 'red',
|
|
56
|
+
neighbors: ['2.2.2.0/24', '2000::2', '2000:123:38::/64'] }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Finds and returns the neighbor with the specified address
|
|
61
|
+
# and vrf, or nil if it is not found.
|
|
62
|
+
def find_neighbor(addr, vrf='default',
|
|
63
|
+
bgp_neighbors=RouterBgpNeighbor.neighbors)
|
|
64
|
+
bgp_neighbors.each_value do |vrfs|
|
|
65
|
+
vrfs.each do |vrf_name, neighbors|
|
|
66
|
+
next unless vrf_name == vrf
|
|
67
|
+
neighbors.each_value do |neighbor|
|
|
68
|
+
next unless neighbor.nbr == addr
|
|
69
|
+
Cisco::Logger.debug("neighbor '#{addr}' with vrf '#{vrf}' found")
|
|
70
|
+
return neighbor
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
Cisco::Logger.debug("neighbor '#{addr}' with vrf '#{vrf}' not found")
|
|
75
|
+
nil
|
|
43
76
|
end
|
|
44
77
|
|
|
78
|
+
# Does the neighbor with the specified address and vrf exist?
|
|
79
|
+
def neighbor_exists?(addr, vrf='default',
|
|
80
|
+
bgp_neighbors=RouterBgpNeighbor.neighbors)
|
|
81
|
+
find_neighbor(addr, vrf, bgp_neighbors) != nil
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Finds the neighbor with the specified address in the
|
|
85
|
+
# output from a show cmd. Returns the matching line of
|
|
86
|
+
# output if found, otherwise nil.
|
|
45
87
|
def get_bgpneighbor_match_line(addr, vrf='default')
|
|
88
|
+
regex = /neighbor #{addr}/
|
|
46
89
|
if vrf == 'default'
|
|
47
|
-
|
|
90
|
+
if platform == :ios_xr
|
|
91
|
+
cmd = 'show run router bgp'
|
|
92
|
+
regex = /^ neighbor #{addr}/
|
|
93
|
+
else
|
|
94
|
+
cmd = "show run bgp all | section 'router bgp' | no-more"
|
|
95
|
+
end
|
|
48
96
|
else
|
|
49
|
-
|
|
97
|
+
if platform == :ios_xr
|
|
98
|
+
cmd = "show run router bgp #{ASN} vrf #{vrf}"
|
|
99
|
+
else
|
|
100
|
+
cmd = "show run bgp all | section 'vrf #{vrf}' | no-more"
|
|
101
|
+
end
|
|
50
102
|
end
|
|
51
|
-
CiscoLogger.debug("matching #{addr} with vrf #{vrf}")
|
|
52
103
|
s = @device.cmd("#{cmd}")
|
|
53
|
-
|
|
54
|
-
|
|
104
|
+
Cisco::Logger.debug("matching '#{addr}' with vrf '#{vrf}', output: \n#{s}")
|
|
105
|
+
line = regex.match(s)
|
|
106
|
+
Cisco::Logger.debug(line)
|
|
55
107
|
line
|
|
56
108
|
end
|
|
57
109
|
|
|
110
|
+
# Creates a neighbor for use in tests, and sets its remote_as.
|
|
111
|
+
def create_neighbor(vrf, addr=ADDR)
|
|
112
|
+
neighbor = RouterBgpNeighbor.new(ASN, vrf, addr)
|
|
113
|
+
|
|
114
|
+
# XR requires a remote_as in order to set other properties
|
|
115
|
+
# (description, password, etc.)
|
|
116
|
+
neighbor.remote_as = REMOTE_ASN
|
|
117
|
+
neighbor
|
|
118
|
+
end
|
|
119
|
+
|
|
58
120
|
def test_collection_empty
|
|
59
|
-
|
|
121
|
+
remove_all_bgps
|
|
60
122
|
neighbors = RouterBgpNeighbor.neighbors
|
|
61
123
|
assert_empty(neighbors, 'BGP neighbor collection is not empty')
|
|
62
124
|
end
|
|
63
125
|
|
|
64
126
|
def test_collection_not_empty
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
127
|
+
test_data_hash = {}
|
|
128
|
+
|
|
129
|
+
cmds = ['router bgp 55']
|
|
130
|
+
|
|
131
|
+
test = test_data
|
|
132
|
+
test.each do |d|
|
|
133
|
+
test_data_hash[d[:vrf]] = d[:neighbors]
|
|
134
|
+
cmds << "vrf #{d[:vrf]}" unless d[:vrf] == 'default'
|
|
135
|
+
d[:neighbors].each do |neighbor|
|
|
136
|
+
cmds << "neighbor #{neighbor}" << "remote-as #{REMOTE_ASN}"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
config(*cmds)
|
|
141
|
+
|
|
71
142
|
bgp_neighbors = RouterBgpNeighbor.neighbors
|
|
72
143
|
refute_empty(bgp_neighbors, 'BGP neighbor collection is empty')
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
144
|
+
|
|
145
|
+
# see if all expected neighbors are there
|
|
146
|
+
test.each do |d|
|
|
147
|
+
d[:neighbors].each do |neighbor|
|
|
148
|
+
# see if the neighbor exists in the list returned by the API
|
|
149
|
+
assert(neighbor_exists?(neighbor, d[:vrf], bgp_neighbors),
|
|
150
|
+
'Did not find in neighbor list: '\
|
|
151
|
+
"nbr '#{neighbor}', vrf '#{d[:vrf]}'")
|
|
152
|
+
|
|
153
|
+
# see if the neighbor exists via show cmd output
|
|
154
|
+
line = get_bgpneighbor_match_line(neighbor, d[:vrf])
|
|
155
|
+
refute_nil(line, 'Did not find in show output: '\
|
|
156
|
+
"nbr '#{neighbor}', vrf '#{d[:vrf]}'")
|
|
86
157
|
end
|
|
87
158
|
end
|
|
88
159
|
end
|
|
89
160
|
|
|
90
161
|
def test_create_destroy
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
address.each do |addr, expected_addr|
|
|
99
|
-
neighbor = RouterBgpNeighbor.new(@@asn, vrf, addr)
|
|
100
|
-
line = get_bgpneighbor_match_line(expected_addr, vrf)
|
|
101
|
-
refute_nil(line, "Error: failed to create bgp neighbor #{addr}")
|
|
162
|
+
test_data.each do |d|
|
|
163
|
+
d[:neighbors].each do |addr|
|
|
164
|
+
neighbor = create_neighbor(d[:vrf], addr)
|
|
165
|
+
exists = neighbor_exists?(addr, d[:vrf])
|
|
166
|
+
assert(exists, "Failed to create bgp neighbor #{addr}")
|
|
167
|
+
line = get_bgpneighbor_match_line(addr, d[:vrf])
|
|
168
|
+
refute_nil(line, "failed to create bgp neighbor #{addr}")
|
|
102
169
|
neighbor.destroy
|
|
103
|
-
|
|
104
|
-
|
|
170
|
+
exists = neighbor_exists?(addr, d[:vrf])
|
|
171
|
+
refute(exists, "Failed to delete bgp neighbor #{addr}")
|
|
172
|
+
line = get_bgpneighbor_match_line(addr, d[:vrf])
|
|
173
|
+
assert_nil(line, "failed to delete bgp neighbor #{addr}")
|
|
105
174
|
end
|
|
106
175
|
end
|
|
107
176
|
end
|
|
108
177
|
|
|
109
178
|
def test_description
|
|
110
179
|
%w(default test_vrf).each do |vrf|
|
|
111
|
-
neighbor =
|
|
180
|
+
neighbor = create_neighbor(vrf)
|
|
112
181
|
description = "tested by mini test for vrf #{vrf}"
|
|
113
182
|
neighbor.description = description
|
|
114
183
|
assert_equal(description, neighbor.description)
|
|
@@ -121,15 +190,14 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
121
190
|
end
|
|
122
191
|
|
|
123
192
|
def test_multiple_descriptions
|
|
124
|
-
# First create multiple routers with multiple
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
neighbor = RouterBgpNeighbor.new(@@asn, vrf, addr)
|
|
130
|
-
neighbor.description = "#{vrf}:#{addr}"
|
|
193
|
+
# First create multiple routers with multiple descriptions.
|
|
194
|
+
test_data.each do |d|
|
|
195
|
+
d[:neighbors].each do |addr|
|
|
196
|
+
neighbor = create_neighbor(d[:vrf], addr)
|
|
197
|
+
neighbor.description = "#{d[:vrf]}:#{addr}"
|
|
131
198
|
end
|
|
132
199
|
end
|
|
200
|
+
|
|
133
201
|
# Now test if the description has been correctly set
|
|
134
202
|
RouterBgpNeighbor.neighbors.each_value do |bgp_vrfs|
|
|
135
203
|
bgp_vrfs.each do |vrf, neighbors|
|
|
@@ -147,7 +215,7 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
147
215
|
|
|
148
216
|
def test_connected_check
|
|
149
217
|
%w(default test_vrf).each do |vrf|
|
|
150
|
-
neighbor =
|
|
218
|
+
neighbor = create_neighbor(vrf)
|
|
151
219
|
check = [true, false, neighbor.default_connected_check]
|
|
152
220
|
check.each do |value|
|
|
153
221
|
neighbor.connected_check = value
|
|
@@ -159,11 +227,19 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
159
227
|
|
|
160
228
|
def test_capability_negotiation
|
|
161
229
|
%w(default test_vrf).each do |vrf|
|
|
162
|
-
neighbor =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
neighbor.
|
|
166
|
-
|
|
230
|
+
neighbor = create_neighbor(vrf)
|
|
231
|
+
if platform == :ios_xr
|
|
232
|
+
assert_nil(neighbor.capability_negotiation)
|
|
233
|
+
assert_nil(neighbor.default_capability_negotiation)
|
|
234
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
235
|
+
neighbor.capability_negotiation = true
|
|
236
|
+
end
|
|
237
|
+
else
|
|
238
|
+
check = [true, false, neighbor.default_capability_negotiation]
|
|
239
|
+
check.each do |value|
|
|
240
|
+
neighbor.capability_negotiation = value
|
|
241
|
+
assert_equal(value, neighbor.capability_negotiation)
|
|
242
|
+
end
|
|
167
243
|
end
|
|
168
244
|
neighbor.destroy
|
|
169
245
|
end
|
|
@@ -171,11 +247,19 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
171
247
|
|
|
172
248
|
def test_dynamic_capability
|
|
173
249
|
%w(default test_vrf).each do |vrf|
|
|
174
|
-
neighbor =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
neighbor.
|
|
178
|
-
|
|
250
|
+
neighbor = create_neighbor(vrf)
|
|
251
|
+
if platform == :ios_xr
|
|
252
|
+
assert_nil(neighbor.dynamic_capability)
|
|
253
|
+
assert_nil(neighbor.default_dynamic_capability)
|
|
254
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
255
|
+
neighbor.dynamic_capability = true
|
|
256
|
+
end
|
|
257
|
+
else
|
|
258
|
+
check = [true, false, neighbor.default_dynamic_capability]
|
|
259
|
+
check.each do |value|
|
|
260
|
+
neighbor.dynamic_capability = value
|
|
261
|
+
assert_equal(value, neighbor.dynamic_capability)
|
|
262
|
+
end
|
|
179
263
|
end
|
|
180
264
|
neighbor.destroy
|
|
181
265
|
end
|
|
@@ -183,7 +267,7 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
183
267
|
|
|
184
268
|
def test_ebgp_multihop
|
|
185
269
|
%w(default test_vrf).each do |vrf|
|
|
186
|
-
neighbor =
|
|
270
|
+
neighbor = create_neighbor(vrf)
|
|
187
271
|
ttls = [24, neighbor.default_ebgp_multihop]
|
|
188
272
|
ttls.each do |ebgp_multihop|
|
|
189
273
|
neighbor.ebgp_multihop = ebgp_multihop
|
|
@@ -195,8 +279,9 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
195
279
|
|
|
196
280
|
def test_local_as
|
|
197
281
|
%w(default test_vrf).each do |vrf|
|
|
198
|
-
neighbor =
|
|
199
|
-
[42, '52', '1.1', neighbor.default_local_as]
|
|
282
|
+
neighbor = create_neighbor(vrf)
|
|
283
|
+
local_asnum = [42, '52', '1.1', neighbor.default_local_as]
|
|
284
|
+
local_asnum.each do |asnum|
|
|
200
285
|
neighbor.local_as = asnum
|
|
201
286
|
assert_equal(asnum.to_s, neighbor.local_as)
|
|
202
287
|
end
|
|
@@ -210,10 +295,20 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
210
295
|
end
|
|
211
296
|
|
|
212
297
|
def test_log_neighbor_changes
|
|
298
|
+
if platform == :ios_xr || node.product_id[/N(5|6|7)/]
|
|
299
|
+
b = create_neighbor('blue')
|
|
300
|
+
assert_nil(b.log_neighbor_changes)
|
|
301
|
+
assert_nil(b.default_log_neighbor_changes)
|
|
302
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
303
|
+
b.log_neighbor_changes = :enable
|
|
304
|
+
end
|
|
305
|
+
return
|
|
306
|
+
end
|
|
213
307
|
%w(default test_vrf).each do |vrf|
|
|
214
|
-
neighbor =
|
|
308
|
+
neighbor = create_neighbor(vrf)
|
|
215
309
|
check = [:enable, :disable, :inherit, 'enable', 'disable', 'inherit',
|
|
216
310
|
neighbor.default_log_neighbor_changes]
|
|
311
|
+
|
|
217
312
|
check.each do |value|
|
|
218
313
|
neighbor.log_neighbor_changes = value
|
|
219
314
|
assert_equal(value.to_sym, neighbor.log_neighbor_changes)
|
|
@@ -224,22 +319,32 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
224
319
|
|
|
225
320
|
def test_low_memory_exempt
|
|
226
321
|
%w(default test_vrf).each do |vrf|
|
|
227
|
-
neighbor =
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
neighbor.
|
|
231
|
-
|
|
322
|
+
neighbor = create_neighbor(vrf)
|
|
323
|
+
if platform == :ios_xr
|
|
324
|
+
assert_nil(neighbor.low_memory_exempt)
|
|
325
|
+
assert_nil(neighbor.default_low_memory_exempt)
|
|
326
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
327
|
+
neighbor.low_memory_exempt = true
|
|
328
|
+
end
|
|
329
|
+
else
|
|
330
|
+
check = [true, false, neighbor.default_low_memory_exempt]
|
|
331
|
+
check.each do |value|
|
|
332
|
+
neighbor.low_memory_exempt = value
|
|
333
|
+
assert_equal(value, neighbor.low_memory_exempt)
|
|
334
|
+
end
|
|
232
335
|
end
|
|
233
336
|
neighbor.destroy
|
|
234
337
|
end
|
|
235
338
|
end
|
|
236
339
|
|
|
237
340
|
def test_maximum_peers
|
|
341
|
+
skip('Maximum-peers does not apply to IOS XR') if platform == :ios_xr
|
|
342
|
+
|
|
238
343
|
# only "address/prefix" type of neighbor address will accept
|
|
239
|
-
# maximum_peers command
|
|
344
|
+
# maximum_peers command, so not supported on XR
|
|
240
345
|
addr = '1.1.1.0/24'
|
|
241
346
|
%w(default test_vrf).each do |vrf|
|
|
242
|
-
neighbor =
|
|
347
|
+
neighbor = create_neighbor(vrf, addr)
|
|
243
348
|
peers = [200, neighbor.default_maximum_peers]
|
|
244
349
|
peers.each do |num|
|
|
245
350
|
neighbor.maximum_peers = num
|
|
@@ -251,20 +356,39 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
251
356
|
|
|
252
357
|
def test_password
|
|
253
358
|
%w(default test_vrf).each do |vrf|
|
|
254
|
-
neighbor =
|
|
359
|
+
neighbor = create_neighbor(vrf)
|
|
255
360
|
passwords = {}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
361
|
+
if platform == :ios_xr
|
|
362
|
+
passwords[:cleartext] = 'test'
|
|
363
|
+
passwords[:md5] = '386c0565965f89de'
|
|
364
|
+
# not currently supporting XR specific 'password inheritance-disable'
|
|
365
|
+
else
|
|
366
|
+
passwords[:cleartext] = 'test'
|
|
367
|
+
passwords[:"3des"] = '386c0565965f89de'
|
|
368
|
+
passwords[:cisco_type_7] = '046E1803362E595C260E0B240619050A2D'
|
|
369
|
+
end
|
|
259
370
|
|
|
260
371
|
passwords.each do |type, password|
|
|
261
372
|
neighbor.password_set(password, type)
|
|
262
|
-
if
|
|
263
|
-
|
|
264
|
-
|
|
373
|
+
if platform == :ios_xr
|
|
374
|
+
if type == :cleartext
|
|
375
|
+
# will always be type "encrypted" on XR
|
|
376
|
+
assert_equal(:md5, neighbor.password_type)
|
|
377
|
+
# don't know what the encrypted password will look like
|
|
378
|
+
# so just make sure it is not empty
|
|
379
|
+
refute_empty(neighbor.password)
|
|
380
|
+
else
|
|
381
|
+
assert_equal(type, neighbor.password_type)
|
|
382
|
+
assert_equal(password, neighbor.password)
|
|
383
|
+
end
|
|
265
384
|
else
|
|
266
|
-
|
|
267
|
-
|
|
385
|
+
if type == :cleartext
|
|
386
|
+
assert_equal(:"3des", neighbor.password_type)
|
|
387
|
+
assert_equal(passwords[:"3des"], neighbor.password)
|
|
388
|
+
else
|
|
389
|
+
assert_equal(type, neighbor.password_type)
|
|
390
|
+
assert_equal(password, neighbor.password)
|
|
391
|
+
end
|
|
268
392
|
end
|
|
269
393
|
# now test removing the password setting
|
|
270
394
|
neighbor.password_set(' ')
|
|
@@ -277,35 +401,42 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
277
401
|
end
|
|
278
402
|
end
|
|
279
403
|
|
|
280
|
-
def
|
|
404
|
+
def test_default_password_type
|
|
281
405
|
%w(default test_vrf).each do |vrf|
|
|
282
|
-
neighbor =
|
|
406
|
+
neighbor = create_neighbor(vrf)
|
|
283
407
|
password = 'test'
|
|
284
408
|
expected_password = '386c0565965f89de'
|
|
285
409
|
|
|
410
|
+
test = proc do
|
|
411
|
+
if platform == :ios_xr
|
|
412
|
+
assert_equal(:md5, neighbor.password_type)
|
|
413
|
+
refute_empty(neighbor.password)
|
|
414
|
+
else
|
|
415
|
+
assert_equal(expected_password, neighbor.password)
|
|
416
|
+
assert_equal(:"3des", neighbor.password_type)
|
|
417
|
+
end
|
|
418
|
+
# clear password
|
|
419
|
+
neighbor.password_set('')
|
|
420
|
+
assert(neighbor.password.empty?)
|
|
421
|
+
end
|
|
422
|
+
|
|
286
423
|
# Test 1: if we don't set password type, default should be cleartext,
|
|
287
|
-
# we can verify by checking return type to be
|
|
424
|
+
# we can verify by checking return type to be
|
|
425
|
+
# :3des/:md5, and encrypted text.
|
|
288
426
|
neighbor.password_set(password)
|
|
289
|
-
|
|
290
|
-
assert_equal(:"3des", neighbor.password_type)
|
|
291
|
-
# clear password
|
|
292
|
-
neighbor.password_set('')
|
|
293
|
-
assert(neighbor.password.empty?)
|
|
427
|
+
test.call
|
|
294
428
|
|
|
295
429
|
# Test 2: we set explicitly the password type to be default password type:
|
|
296
430
|
# cleartext, and verify.
|
|
297
431
|
neighbor.password_set(password, neighbor.default_password_type)
|
|
298
|
-
|
|
299
|
-
assert_equal(:"3des", neighbor.password_type)
|
|
300
|
-
neighbor.password_set('')
|
|
301
|
-
assert(neighbor.password.empty?)
|
|
432
|
+
test.call
|
|
302
433
|
neighbor.destroy
|
|
303
434
|
end
|
|
304
435
|
end
|
|
305
436
|
|
|
306
437
|
def test_remote_as
|
|
307
438
|
%w(default test_vrf).each do |vrf|
|
|
308
|
-
neighbor = RouterBgpNeighbor.new(
|
|
439
|
+
neighbor = RouterBgpNeighbor.new(ASN, vrf, ADDR)
|
|
309
440
|
[42, '1.1', neighbor.default_remote_as].each do |asnum|
|
|
310
441
|
neighbor.remote_as = asnum
|
|
311
442
|
assert_equal(asnum.to_s, neighbor.remote_as)
|
|
@@ -316,24 +447,33 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
316
447
|
|
|
317
448
|
def test_remove_private_as_options
|
|
318
449
|
%w(default test_vrf).each do |vrf|
|
|
319
|
-
neighbor =
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
450
|
+
neighbor = create_neighbor(vrf)
|
|
451
|
+
if platform == :ios_xr
|
|
452
|
+
assert_nil(neighbor.remove_private_as)
|
|
453
|
+
assert_nil(neighbor.default_remove_private_as)
|
|
454
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
455
|
+
neighbor.remove_private_as = :enable
|
|
456
|
+
end
|
|
457
|
+
else
|
|
458
|
+
options = [:enable, :disable, :all, :"replace-as", 'enable', 'disable',
|
|
459
|
+
'all', 'replace-as', neighbor.default_remove_private_as]
|
|
460
|
+
|
|
461
|
+
options.each do |option|
|
|
462
|
+
neighbor.remove_private_as = option
|
|
463
|
+
assert_equal(option.to_sym, neighbor.remove_private_as)
|
|
464
|
+
end
|
|
326
465
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
466
|
+
neighbor.remove_private_as = neighbor.default_remove_private_as
|
|
467
|
+
assert_equal(neighbor.default_remove_private_as,
|
|
468
|
+
neighbor.remove_private_as)
|
|
469
|
+
end
|
|
330
470
|
neighbor.destroy
|
|
331
471
|
end
|
|
332
472
|
end
|
|
333
473
|
|
|
334
474
|
def test_shutdown
|
|
335
475
|
%w(default test_vrf).each do |vrf|
|
|
336
|
-
neighbor =
|
|
476
|
+
neighbor = create_neighbor(vrf)
|
|
337
477
|
check = [true, false, neighbor.default_shutdown]
|
|
338
478
|
check.each do |value|
|
|
339
479
|
neighbor.shutdown = value
|
|
@@ -345,7 +485,7 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
345
485
|
|
|
346
486
|
def test_suppress_4_byte_as
|
|
347
487
|
%w(default test_vrf).each do |vrf|
|
|
348
|
-
neighbor =
|
|
488
|
+
neighbor = create_neighbor(vrf)
|
|
349
489
|
check = [true, false, neighbor.default_suppress_4_byte_as]
|
|
350
490
|
check.each do |value|
|
|
351
491
|
neighbor.suppress_4_byte_as = value
|
|
@@ -357,7 +497,7 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
357
497
|
|
|
358
498
|
def test_timers
|
|
359
499
|
%w(default test_vrf).each do |vrf|
|
|
360
|
-
neighbor =
|
|
500
|
+
neighbor = create_neighbor(vrf)
|
|
361
501
|
timers = [{ keep: 40, hold: 90 },
|
|
362
502
|
{ keep: neighbor.default_timers_keepalive,
|
|
363
503
|
hold: neighbor.default_timers_holdtime },
|
|
@@ -374,9 +514,28 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
374
514
|
end
|
|
375
515
|
end
|
|
376
516
|
|
|
517
|
+
def test_transport_passive_mode
|
|
518
|
+
%w(default test_vrf).each do |vrf|
|
|
519
|
+
neighbor = create_neighbor(vrf)
|
|
520
|
+
check = []
|
|
521
|
+
if platform == :ios_xr
|
|
522
|
+
check = [:active_only, :passive_only, :both, :none,
|
|
523
|
+
neighbor.default_transport_passive_mode]
|
|
524
|
+
else
|
|
525
|
+
check = [:passive_only, :none,
|
|
526
|
+
neighbor.default_transport_passive_mode]
|
|
527
|
+
end
|
|
528
|
+
check.each do |value|
|
|
529
|
+
neighbor.transport_passive_mode = value
|
|
530
|
+
assert_equal(value, neighbor.transport_passive_mode)
|
|
531
|
+
end
|
|
532
|
+
neighbor.destroy
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
377
536
|
def test_transport_passive_only
|
|
378
537
|
%w(default test_vrf).each do |vrf|
|
|
379
|
-
neighbor =
|
|
538
|
+
neighbor = create_neighbor(vrf)
|
|
380
539
|
check = [true, false, neighbor.default_transport_passive_only]
|
|
381
540
|
check.each do |value|
|
|
382
541
|
neighbor.transport_passive_only = value
|
|
@@ -388,10 +547,10 @@ class TestBgpNeighbor < CiscoTestCase
|
|
|
388
547
|
|
|
389
548
|
def test_update_source
|
|
390
549
|
%w(default test_vrf).each do |vrf|
|
|
391
|
-
neighbor =
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
550
|
+
neighbor = create_neighbor(vrf)
|
|
551
|
+
test_interfaces = ['loopback1', interfaces[0], interfaces[0].downcase,
|
|
552
|
+
neighbor.default_update_source]
|
|
553
|
+
test_interfaces.each do |interface|
|
|
395
554
|
neighbor.update_source = interface
|
|
396
555
|
assert_equal(interface.downcase, neighbor.update_source)
|
|
397
556
|
end
|