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/ciscotest.rb
CHANGED
|
@@ -18,11 +18,11 @@ require_relative 'basetest'
|
|
|
18
18
|
require_relative 'platform_info'
|
|
19
19
|
require_relative '../lib/cisco_node_utils/interface'
|
|
20
20
|
require_relative '../lib/cisco_node_utils/node'
|
|
21
|
+
require_relative '../lib/cisco_node_utils/vlan'
|
|
22
|
+
require_relative '../lib/cisco_node_utils/bridge_domain'
|
|
21
23
|
|
|
22
24
|
include Cisco
|
|
23
25
|
|
|
24
|
-
Node.lazy_connect = true # we'll specify the connection info later
|
|
25
|
-
|
|
26
26
|
# CiscoTestCase - base class for all node utility minitests
|
|
27
27
|
class CiscoTestCase < TestCase
|
|
28
28
|
# rubocop:disable Style/ClassVars
|
|
@@ -31,10 +31,37 @@ class CiscoTestCase < TestCase
|
|
|
31
31
|
@@interfaces_id = nil
|
|
32
32
|
# rubocop:enable Style/ClassVars
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
# The feature (lib/cisco_node_utils/cmd_ref/<feature>.yaml) that this
|
|
35
|
+
# test case is associated with, if applicable.
|
|
36
|
+
# If the YAML file excludes this entire feature for this platform
|
|
37
|
+
# (top-level _exclude statement, not individual attributes), then
|
|
38
|
+
# all tests in this test case will be skipped.
|
|
39
|
+
@skip_unless_supported = nil
|
|
40
|
+
|
|
41
|
+
class << self
|
|
42
|
+
attr_accessor :skip_unless_supported
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.runnable_methods
|
|
46
|
+
return super if skip_unless_supported.nil?
|
|
47
|
+
return super if node.cmd_ref.supports?(skip_unless_supported)
|
|
48
|
+
# If the entire feature under test is unsupported,
|
|
49
|
+
# undefine the setup/teardown methods (if any) and skip the whole test case
|
|
50
|
+
remove_method :setup if instance_methods(false).include?(:setup)
|
|
51
|
+
remove_method :teardown if instance_methods(false).include?(:teardown)
|
|
52
|
+
[:all_skipped]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def all_skipped
|
|
56
|
+
skip("Skipping #{self.class}; feature " \
|
|
57
|
+
"'#{self.class.skip_unless_supported}' is unsupported on this node")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.node
|
|
35
61
|
unless @@node
|
|
36
|
-
|
|
37
|
-
@@node
|
|
62
|
+
# rubocop:disable Style/ClassVars
|
|
63
|
+
@@node = Node.instance
|
|
64
|
+
# rubocop:enable Style/ClassVars
|
|
38
65
|
@@node.cache_enable = true
|
|
39
66
|
@@node.cache_auto = true
|
|
40
67
|
# Record the platform we're running on
|
|
@@ -44,12 +71,16 @@ class CiscoTestCase < TestCase
|
|
|
44
71
|
puts " - image - #{@@node.system}\n\n"
|
|
45
72
|
end
|
|
46
73
|
@@node
|
|
47
|
-
rescue
|
|
74
|
+
rescue Cisco::AuthenticationFailed
|
|
48
75
|
abort "Unauthorized to connect as #{username}:#{password}@#{address}"
|
|
49
|
-
rescue
|
|
76
|
+
rescue Cisco::ClientError, TypeError, ArgumentError => e
|
|
50
77
|
abort "Error in establishing connection: #{e}"
|
|
51
78
|
end
|
|
52
79
|
|
|
80
|
+
def node
|
|
81
|
+
self.class.node
|
|
82
|
+
end
|
|
83
|
+
|
|
53
84
|
def setup
|
|
54
85
|
super
|
|
55
86
|
node
|
|
@@ -59,8 +90,20 @@ class CiscoTestCase < TestCase
|
|
|
59
90
|
node.cmd_ref
|
|
60
91
|
end
|
|
61
92
|
|
|
62
|
-
def
|
|
63
|
-
|
|
93
|
+
def self.platform
|
|
94
|
+
node.client.platform
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def platform
|
|
98
|
+
self.class.platform
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def config_and_warn_on_match(warn_match, *args)
|
|
102
|
+
if node.client.platform == :ios_xr
|
|
103
|
+
result = super(warn_match, *args, 'commit best-effort')
|
|
104
|
+
else
|
|
105
|
+
result = super
|
|
106
|
+
end
|
|
64
107
|
node.cache_flush
|
|
65
108
|
result
|
|
66
109
|
end
|
|
@@ -81,7 +124,28 @@ class CiscoTestCase < TestCase
|
|
|
81
124
|
# Compare the interface address with the current session address.
|
|
82
125
|
# and return true if they match.
|
|
83
126
|
return false if int_ip.nil?
|
|
84
|
-
int_ip == convert_dns_name(address)
|
|
127
|
+
int_ip == convert_dns_name(address.split(':')[0])
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Some NXOS hardware is not capable of supporting certain features even
|
|
131
|
+
# though the platform family in general includes support. In these cases
|
|
132
|
+
# the NU feature setter will raise a RuntimeError.
|
|
133
|
+
def hardware_supports_feature?(message)
|
|
134
|
+
patterns = ['Hardware is not capable of supporting',
|
|
135
|
+
'is unsupported on this node',
|
|
136
|
+
]
|
|
137
|
+
skip('Skip test: Feature is unsupported on this device') if
|
|
138
|
+
message[Regexp.union(patterns)]
|
|
139
|
+
flunk(message)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def validate_property_excluded?(feature, property)
|
|
143
|
+
!node.cmd_ref.supports?(feature, property)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def skip_nexus_i2_image?
|
|
147
|
+
skip("This property is not supported on Nexus 'I2' images") if
|
|
148
|
+
Utils.nexus_i2_image
|
|
85
149
|
end
|
|
86
150
|
|
|
87
151
|
def interfaces
|
|
@@ -96,7 +160,7 @@ class CiscoTestCase < TestCase
|
|
|
96
160
|
end
|
|
97
161
|
# rubocop:enable Style/ClassVars
|
|
98
162
|
end
|
|
99
|
-
|
|
163
|
+
skip "No suitable interfaces found on #{node} for this test" if
|
|
100
164
|
@@interfaces.empty?
|
|
101
165
|
@@interfaces
|
|
102
166
|
end
|
|
@@ -106,7 +170,7 @@ class CiscoTestCase < TestCase
|
|
|
106
170
|
# rubocop:disable Style/ClassVars
|
|
107
171
|
@@interfaces_id = []
|
|
108
172
|
interfaces.each do |interface|
|
|
109
|
-
id = interface.split('
|
|
173
|
+
id = interface.split('ethernet')[1]
|
|
110
174
|
@@interfaces_id << id
|
|
111
175
|
end
|
|
112
176
|
# rubocop:enable Style/ClassVars
|
|
@@ -127,6 +191,35 @@ class CiscoTestCase < TestCase
|
|
|
127
191
|
end
|
|
128
192
|
end
|
|
129
193
|
|
|
194
|
+
# Remove all router ospfs.
|
|
195
|
+
def remove_all_ospfs
|
|
196
|
+
require_relative '../lib/cisco_node_utils/router_ospf'
|
|
197
|
+
RouterOspf.routers.each do |_, obj|
|
|
198
|
+
obj.destroy
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# This testcase will remove all the bds existing in the system
|
|
203
|
+
# specifically in cleanup for minitests
|
|
204
|
+
def remove_all_bridge_domains
|
|
205
|
+
config 'system bridge-domain none' if /N7/ =~ node.product_id
|
|
206
|
+
BridgeDomain.bds.each do |_bd, obj|
|
|
207
|
+
obj.destroy
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# This testcase will remove all the vlans existing in the system
|
|
212
|
+
# specifically in cleanup for minitests
|
|
213
|
+
def remove_all_vlans
|
|
214
|
+
remove_all_bridge_domains
|
|
215
|
+
Vlan.vlans.each do |vlan, obj|
|
|
216
|
+
# skip reserved vlan
|
|
217
|
+
next if vlan == '1'
|
|
218
|
+
next if node.product_id[/N5K|N6K|N7K/] && (1002..1005).include?(vlan.to_i)
|
|
219
|
+
obj.destroy
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
130
223
|
# Remove all user vrfs.
|
|
131
224
|
def remove_all_vrfs
|
|
132
225
|
require_relative '../lib/cisco_node_utils/vrf'
|
|
@@ -135,4 +228,119 @@ class CiscoTestCase < TestCase
|
|
|
135
228
|
obj.destroy
|
|
136
229
|
end
|
|
137
230
|
end
|
|
231
|
+
|
|
232
|
+
# Remove all configurations from an interface.
|
|
233
|
+
def interface_cleanup(intf_name)
|
|
234
|
+
cfg = get_interface_cleanup_config(intf_name)
|
|
235
|
+
config(*cfg)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# setup fabricpath env if possible and populate the interfaces array
|
|
239
|
+
# otherwise cause a global skip
|
|
240
|
+
def fabricpath_testenv_setup
|
|
241
|
+
return unless node.product_id[/N7K/]
|
|
242
|
+
intf_array = Feature.compatible_interfaces('fabricpath')
|
|
243
|
+
vdc = Vdc.new(Vdc.default_vdc_name)
|
|
244
|
+
save_lr = vdc.limit_resource_module_type
|
|
245
|
+
fabricpath_lr = node.config_get('fabricpath', 'supported_modules')
|
|
246
|
+
if intf_array.empty? || save_lr != fabricpath_lr
|
|
247
|
+
# try getting the required modules into the default vdc
|
|
248
|
+
vdc.limit_resource_module_type = fabricpath_lr
|
|
249
|
+
intf_array = Feature.compatible_interfaces('fabricpath')
|
|
250
|
+
end
|
|
251
|
+
if intf_array.empty?
|
|
252
|
+
vdc.limit_resource_module_type = save_lr
|
|
253
|
+
skip('FabricPath compatible interfaces not found in this switch')
|
|
254
|
+
else
|
|
255
|
+
# rubocop:disable Style/ClassVars
|
|
256
|
+
@@interfaces = intf_array
|
|
257
|
+
# rubocop:enable Style/ClassVars
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Returns an array of commands to remove all configurations from
|
|
262
|
+
# an interface.
|
|
263
|
+
def get_interface_cleanup_config(intf_name)
|
|
264
|
+
if platform == :ios_xr
|
|
265
|
+
["no interface #{intf_name}", "interface #{intf_name} shutdown"]
|
|
266
|
+
else
|
|
267
|
+
["default interface #{intf_name}"]
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def mt_full_interface?
|
|
272
|
+
# MT-full tests require a specific linecard; either because they need a
|
|
273
|
+
# compatible interface or simply to enable the features. Either way
|
|
274
|
+
# we will provide an appropriate interface name if the linecard is present.
|
|
275
|
+
# Example 'show mod' output to match against:
|
|
276
|
+
# '9 12 10/40 Gbps Ethernet Module N7K-F312FQ-25 ok'
|
|
277
|
+
# '9 12 10/40 Gbps Ethernet Module N77-F312FQ-25 ok'
|
|
278
|
+
sh_mod_string = @device.cmd("sh mod | i '^[0-9]+.*N7[7K]-F3'")
|
|
279
|
+
sh_mod = sh_mod_string[/^(\d+)\s.*N7[7K]-F3.*ok/]
|
|
280
|
+
slot = sh_mod.nil? ? nil : Regexp.last_match[1]
|
|
281
|
+
skip('Unable to find compatible interface in chassis') if slot.nil?
|
|
282
|
+
|
|
283
|
+
"ethernet#{slot}/1"
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def vxlan_linecard?
|
|
287
|
+
# n5,6,7k tests require a specific linecard; either because they need a
|
|
288
|
+
# compatible interface or simply to enable vxlan.
|
|
289
|
+
# Example 'show mod' output to match against:
|
|
290
|
+
# '9 12 10/40 Gbps Ethernet Module N7K-F312FQ-25 ok'
|
|
291
|
+
# '9 12 10/40 Gbps Ethernet Module N77-F312FQ-25 ok'
|
|
292
|
+
# '2 6 Nexus 6xQSFP Ethernet Module N5K-C5672UP-M6Q ok'
|
|
293
|
+
# '2 6 Nexus xxQSFP Ethernet Module N6K-C6004-96Q/EF ok'
|
|
294
|
+
if node.product_id[/N(5|6)K/]
|
|
295
|
+
sh_mod_string = @device.cmd("sh mod | i '^[0-9]+.*N[56]K-C[56]'")
|
|
296
|
+
sh_mod = sh_mod_string[/^(\d+)\s.*N[56]K-C(56|6004)/]
|
|
297
|
+
skip('Unable to find compatible interface in chassis') if sh_mod.nil?
|
|
298
|
+
elsif node.product_id[/N7K/]
|
|
299
|
+
mt_full_interface?
|
|
300
|
+
else
|
|
301
|
+
return
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
# Wrapper api that can be used to execute bash shell or guestshell
|
|
306
|
+
# commands.
|
|
307
|
+
# Returns the output of the command.
|
|
308
|
+
def shell_command(command, context='bash')
|
|
309
|
+
fail "shell_command api not supported on #{node.product_id}" unless
|
|
310
|
+
node.product_id[/N3K|N8K|N9K/]
|
|
311
|
+
unless context == 'bash' || context == 'guestshell'
|
|
312
|
+
fail "Context must be either 'bash' or 'guestshell'"
|
|
313
|
+
end
|
|
314
|
+
config("run #{context} #{command}")
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def backup_resolv_file(context='bash')
|
|
318
|
+
# Configuration bleeding is only a problem on some platforms, so
|
|
319
|
+
# only backup the resolv.conf file on required plaforms.
|
|
320
|
+
return unless node.product_id[/N3K|N8K|N9K/]
|
|
321
|
+
time_stamp = Time.now.strftime('%Y-%m-%d_%H-%M-%S')
|
|
322
|
+
backup_filename = "/tmp/resolv.conf.#{time_stamp}"
|
|
323
|
+
shell_command("cp /etc/resolv.conf #{backup_filename}", context)
|
|
324
|
+
backup_filename
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def restore_resolv_file(filename, context='bash')
|
|
328
|
+
return unless node.product_id[/N3K|N8K|N9K/]
|
|
329
|
+
shell_command("sudo cp #{filename} /etc/resolv.conf", context)
|
|
330
|
+
shell_command("rm #{filename}", context)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# VDC helper for features that require a specific linecard.
|
|
334
|
+
# Allows caller to get current state or change it to a new value.
|
|
335
|
+
def vdc_lc_state(type=nil)
|
|
336
|
+
return unless node.product_id[/N7/]
|
|
337
|
+
vxlan_linecard? if type && type[/F3/i]
|
|
338
|
+
v = Vdc.new('default')
|
|
339
|
+
if type
|
|
340
|
+
# This action may be time consuming, use only if necessary.
|
|
341
|
+
v.limit_resource_module_type = type
|
|
342
|
+
else
|
|
343
|
+
v.limit_resource_module_type
|
|
344
|
+
end
|
|
345
|
+
end
|
|
138
346
|
end
|
data/tests/cmd_config.yaml
CHANGED
|
@@ -1,51 +1,73 @@
|
|
|
1
1
|
# test command config yaml file
|
|
2
2
|
---
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
feature-disable:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
3
|
+
nexus:
|
|
4
|
+
feature-enable:
|
|
5
|
+
command: |
|
|
6
|
+
feature tacacs+
|
|
7
|
+
feature ospf
|
|
8
|
+
feature bgp
|
|
9
|
+
feature pim
|
|
10
|
+
feature msdp
|
|
11
|
+
feature udld
|
|
12
|
+
feature interface-vlan
|
|
13
|
+
feature hsrp
|
|
14
|
+
feature lacp
|
|
15
|
+
feature dhcp
|
|
16
|
+
feature vtp
|
|
17
|
+
|
|
18
|
+
feature-disable:
|
|
19
|
+
command: |
|
|
20
|
+
no feature tacacs+
|
|
21
|
+
no feature ospf
|
|
22
|
+
no feature bgp
|
|
23
|
+
no feature pim
|
|
24
|
+
no feature msdp
|
|
25
|
+
no feature udld
|
|
26
|
+
no feature interface-vlan
|
|
27
|
+
no feature hsrp
|
|
28
|
+
no feature lacp
|
|
29
|
+
no feature dhcp
|
|
30
|
+
no feature vtp
|
|
31
|
+
|
|
32
|
+
feature-snmp-comm-acl-ro:
|
|
33
|
+
command: |
|
|
34
|
+
snmp-server community networkopercom group network-operator
|
|
35
|
+
snmp-server community networkopercom use-acl SNMP_RO
|
|
36
|
+
|
|
37
|
+
feature-snmp-comm-acl-rw:
|
|
38
|
+
command: |
|
|
39
|
+
snmp-server community admincom group network-admin
|
|
40
|
+
snmp-server community admincom use-acl SNMP_RW
|
|
41
|
+
|
|
42
|
+
feature-int-loopback:
|
|
43
|
+
command: >
|
|
44
|
+
interface loopback0
|
|
45
|
+
description testloopback
|
|
46
|
+
|
|
47
|
+
feature-int-portchannel:
|
|
48
|
+
command: >
|
|
49
|
+
interface port-channel100
|
|
50
|
+
description test-portchannel
|
|
51
|
+
|
|
52
|
+
ios_xr:
|
|
53
|
+
name-server:
|
|
54
|
+
command: |
|
|
55
|
+
domain name-server 10.10.10.10
|
|
56
|
+
domain name-server 10.10.10.11
|
|
57
|
+
domain name-server 10.10.10.12
|
|
58
|
+
|
|
59
|
+
no-name-server:
|
|
60
|
+
command: |
|
|
61
|
+
no domain name-server 10.10.10.10
|
|
62
|
+
no domain name-server 10.10.10.11
|
|
63
|
+
no domain name-server 10.10.10.12
|
|
64
|
+
|
|
65
|
+
lo-intf:
|
|
66
|
+
command: |
|
|
67
|
+
interface Loopback0
|
|
68
|
+
description test description
|
|
69
|
+
vrf red
|
|
70
|
+
|
|
71
|
+
no-lo-intf:
|
|
72
|
+
command: |
|
|
73
|
+
no interface Loopback0
|
|
@@ -17,6 +17,7 @@ require_relative '../lib/cisco_node_utils/aaa_authentication_login'
|
|
|
17
17
|
|
|
18
18
|
# Test class for AAA Authentication Login
|
|
19
19
|
class TestAaaAuthenticationLogin < CiscoTestCase
|
|
20
|
+
@skip_unless_supported = 'aaa_authentication_login'
|
|
20
21
|
# DEFAULT(:ascii_authentication)
|
|
21
22
|
# => false
|
|
22
23
|
# rubocop:disable Style/MethodName
|
|
@@ -21,6 +21,15 @@ AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED = :unselected
|
|
|
21
21
|
|
|
22
22
|
# Test class for AAA Authentication Login Service
|
|
23
23
|
class TestAaaAuthenticationLoginService < CiscoTestCase
|
|
24
|
+
@skip_unless_supported = 'aaa_auth_login_service'
|
|
25
|
+
|
|
26
|
+
def setup
|
|
27
|
+
super
|
|
28
|
+
# TBD: Remove once CSCuz44696 is resolved.
|
|
29
|
+
skip('This test is not currently supported on 7.0(3)I3 images') if
|
|
30
|
+
node.os_version[/7.0\(3\)I3\(/]
|
|
31
|
+
end
|
|
32
|
+
|
|
24
33
|
def unconfig_tacacs
|
|
25
34
|
config('no feature tacacs+')
|
|
26
35
|
end
|