cisco_node_utils 1.1.0 → 1.2.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 -1
- data/CHANGELOG.md +126 -1
- data/README.md +19 -12
- data/Rakefile +1 -0
- data/bin/git/hooks/commit-msg/enforce_style +8 -0
- data/cisco_node_utils.gemspec +4 -3
- data/docs/README-develop-best-practices.md +127 -109
- data/docs/README-develop-node-utils-APIs.md +47 -39
- data/docs/template-router.rb +3 -7
- data/lib/.rubocop.yml +4 -4
- data/lib/cisco_node_utils.rb +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
- data/lib/cisco_node_utils/ace.rb +196 -0
- data/lib/cisco_node_utils/acl.rb +100 -0
- data/lib/cisco_node_utils/bgp.rb +301 -163
- data/lib/cisco_node_utils/bgp_af.rb +187 -19
- data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
- data/lib/cisco_node_utils/command_reference.rb +359 -187
- data/lib/cisco_node_utils/configparser_lib.rb +1 -1
- data/lib/cisco_node_utils/dns_domain.rb +19 -5
- data/lib/cisco_node_utils/domain_name.rb +4 -8
- data/lib/cisco_node_utils/evpn_vni.rb +157 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
- data/lib/cisco_node_utils/feature.rb +111 -0
- data/lib/cisco_node_utils/interface.rb +390 -97
- data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
- data/lib/cisco_node_utils/interface_ospf.rb +11 -34
- data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/name_server.rb +1 -1
- data/lib/cisco_node_utils/node.rb +55 -249
- data/lib/cisco_node_utils/node_util.rb +5 -1
- data/lib/cisco_node_utils/ntp_config.rb +2 -2
- data/lib/cisco_node_utils/ntp_server.rb +14 -5
- data/lib/cisco_node_utils/overlay_global.rb +153 -0
- data/lib/cisco_node_utils/pim.rb +124 -0
- data/lib/cisco_node_utils/pim_group_list.rb +108 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
- data/lib/cisco_node_utils/platform.rb +8 -9
- data/lib/cisco_node_utils/portchannel_global.rb +277 -0
- data/lib/cisco_node_utils/radius_global.rb +9 -19
- data/lib/cisco_node_utils/radius_server.rb +31 -41
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
- data/lib/cisco_node_utils/snmpgroup.rb +1 -1
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +8 -17
- data/lib/cisco_node_utils/snmpuser.rb +67 -28
- data/lib/cisco_node_utils/syslog_server.rb +3 -9
- data/lib/cisco_node_utils/syslog_settings.rb +2 -10
- data/lib/cisco_node_utils/tacacs_server.rb +9 -14
- data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
- data/lib/cisco_node_utils/vdc.rb +88 -0
- data/lib/cisco_node_utils/version.rb +5 -2
- data/lib/cisco_node_utils/vlan.rb +71 -8
- data/lib/cisco_node_utils/vni.rb +227 -0
- data/lib/cisco_node_utils/vpc.rb +377 -0
- data/lib/cisco_node_utils/vrf.rb +60 -9
- data/lib/cisco_node_utils/vrf_af.rb +191 -0
- data/lib/cisco_node_utils/vtp.rb +8 -6
- data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
- data/lib/cisco_node_utils/yum.rb +1 -1
- data/tests/.rubocop.yml +1 -1
- data/tests/basetest.rb +16 -7
- data/tests/ciscotest.rb +55 -13
- data/tests/cmd_config.yaml +2 -2
- data/tests/platform_info.rb +3 -2
- data/tests/test_aaa_authentication_login.rb +219 -0
- data/tests/test_aaa_authentication_login_service.rb +759 -0
- data/tests/test_aaa_authorization_service.rb +1041 -0
- data/tests/test_ace.rb +160 -0
- data/tests/test_acl.rb +176 -0
- data/tests/test_bgp_af.rb +269 -13
- data/tests/test_bgp_neighbor.rb +38 -40
- data/tests/test_bgp_neighbor_af.rb +92 -32
- data/tests/test_command_config.rb +5 -5
- data/tests/test_command_reference.rb +284 -101
- data/tests/test_dns_domain.rb +1 -1
- data/tests/test_domain_name.rb +1 -1
- data/tests/test_evpn_vni.rb +106 -0
- data/tests/test_fabricpath_global.rb +243 -0
- data/tests/test_fabricpath_topology.rb +98 -0
- data/tests/test_interface.rb +292 -74
- data/tests/test_interface_channel_group.rb +74 -0
- data/tests/test_interface_ospf.rb +9 -4
- data/tests/test_interface_portchannel.rb +105 -0
- data/tests/test_interface_service_vni.rb +232 -0
- data/tests/test_interface_svi.rb +77 -62
- data/tests/test_interface_switchport.rb +17 -5
- data/tests/test_name_server.rb +1 -1
- data/tests/test_node.rb +1 -1
- data/tests/test_node_ext.rb +10 -20
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +18 -6
- data/tests/test_overlay_global.rb +102 -0
- data/tests/test_pim.rb +177 -0
- data/tests/test_pim_group_list.rb +181 -0
- data/tests/test_pim_rp_address.rb +153 -0
- data/tests/test_platform.rb +3 -3
- data/tests/test_portchannel_global.rb +202 -0
- data/tests/test_radius_global.rb +1 -1
- data/tests/test_radius_server.rb +92 -57
- data/tests/test_radius_server_group.rb +149 -0
- data/tests/test_router_bgp.rb +283 -112
- data/tests/test_router_ospf.rb +2 -2
- data/tests/test_router_ospf_vrf.rb +4 -4
- data/tests/test_snmp_notification_receiver.rb +167 -0
- data/tests/test_snmpcommunity.rb +1 -1
- data/tests/test_snmpgroup.rb +1 -1
- data/tests/test_snmpnotification.rb +72 -0
- data/tests/test_snmpserver.rb +29 -105
- data/tests/test_snmpuser.rb +32 -30
- data/tests/test_syslog_server.rb +36 -10
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_server.rb +1 -1
- data/tests/test_tacacs_server_group.rb +405 -0
- data/tests/test_tacacs_server_host.rb +1 -1
- data/tests/test_vdc.rb +78 -0
- data/tests/test_vlan.rb +74 -19
- data/tests/test_vlan_mt_full.rb +95 -0
- data/tests/test_vni.rb +106 -0
- data/tests/test_vpc.rb +361 -0
- data/tests/test_vrf.rb +172 -29
- data/tests/test_vtp.rb +1 -1
- data/tests/test_vxlan_vtep.rb +214 -0
- data/tests/test_vxlan_vtep_vni.rb +201 -0
- data/tests/test_yum.rb +1 -1
- metadata +120 -11
- data/lib/cisco_node_utils/README_YAML.md +0 -325
- data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
- data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
- data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
- data/tests/platform_info.yaml +0 -10
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Copyright (c) 2013-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/cisco_cmn_utils'
|
|
17
|
+
require_relative '../lib/cisco_node_utils/feature'
|
|
18
|
+
require_relative '../lib/cisco_node_utils/overlay_global'
|
|
19
|
+
|
|
20
|
+
include Cisco
|
|
21
|
+
|
|
22
|
+
# TestOverlayGlobal - Minitest for OverlayGlobal node utility
|
|
23
|
+
class TestOverlayGlobal < CiscoTestCase
|
|
24
|
+
def setup
|
|
25
|
+
super
|
|
26
|
+
config('no feature fabric forwarding')
|
|
27
|
+
config('no nv overlay evpn')
|
|
28
|
+
config('l2rib dup-host-mac-detection default')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_dup_host_ip_addr_detection
|
|
32
|
+
overlay_global = OverlayGlobal.new
|
|
33
|
+
|
|
34
|
+
# Before enabling 'nv overlay evpn', these properties do not exist
|
|
35
|
+
assert_nil(overlay_global.dup_host_ip_addr_detection_host_moves)
|
|
36
|
+
assert_nil(overlay_global.dup_host_ip_addr_detection_timeout)
|
|
37
|
+
|
|
38
|
+
# Set them to the default value and they should now be present
|
|
39
|
+
default = [overlay_global.default_dup_host_ip_addr_detection_host_moves,
|
|
40
|
+
overlay_global.default_dup_host_ip_addr_detection_timeout]
|
|
41
|
+
overlay_global.dup_host_ip_addr_detection_set(*default)
|
|
42
|
+
assert_equal(default[0],
|
|
43
|
+
overlay_global.dup_host_ip_addr_detection_host_moves)
|
|
44
|
+
assert_equal(default[1],
|
|
45
|
+
overlay_global.dup_host_ip_addr_detection_timeout)
|
|
46
|
+
assert(Feature.nv_overlay_evpn_enabled?)
|
|
47
|
+
|
|
48
|
+
# Set them to non-default values
|
|
49
|
+
val = [200, 20]
|
|
50
|
+
overlay_global.dup_host_ip_addr_detection_set(*val)
|
|
51
|
+
assert_equal(val, overlay_global.dup_host_ip_addr_detection)
|
|
52
|
+
assert_equal(val[0],
|
|
53
|
+
overlay_global.dup_host_ip_addr_detection_host_moves)
|
|
54
|
+
assert_equal(val[1],
|
|
55
|
+
overlay_global.dup_host_ip_addr_detection_timeout)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_dup_host_mac_detection
|
|
59
|
+
overlay_global = OverlayGlobal.new
|
|
60
|
+
# These properties always exist, even without 'nv overlay evpn'
|
|
61
|
+
default = [overlay_global.default_dup_host_mac_detection_host_moves,
|
|
62
|
+
overlay_global.default_dup_host_mac_detection_timeout]
|
|
63
|
+
assert_equal(default, overlay_global.dup_host_mac_detection)
|
|
64
|
+
refute(Feature.nv_overlay_evpn_enabled?)
|
|
65
|
+
|
|
66
|
+
# Set to a non-default value
|
|
67
|
+
val = [160, 16]
|
|
68
|
+
overlay_global.dup_host_mac_detection_set(*val)
|
|
69
|
+
assert_equal(val, overlay_global.dup_host_mac_detection)
|
|
70
|
+
refute(Feature.nv_overlay_evpn_enabled?)
|
|
71
|
+
|
|
72
|
+
# Use the special defaulter method
|
|
73
|
+
overlay_global.dup_host_mac_detection_default
|
|
74
|
+
assert_equal(default, overlay_global.dup_host_mac_detection)
|
|
75
|
+
refute(Feature.nv_overlay_evpn_enabled?)
|
|
76
|
+
|
|
77
|
+
# Set explicitly to default too
|
|
78
|
+
overlay_global.dup_host_mac_detection_set(*default)
|
|
79
|
+
assert_equal(default, overlay_global.dup_host_mac_detection)
|
|
80
|
+
refute(Feature.nv_overlay_evpn_enabled?)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_anycast_gateway_mac
|
|
84
|
+
overlay_global = OverlayGlobal.new
|
|
85
|
+
# Before enabling 'nv overlay evpn', this property does not exist
|
|
86
|
+
assert_nil(overlay_global.anycast_gateway_mac)
|
|
87
|
+
|
|
88
|
+
# Explicitly set to default and it should be enabled
|
|
89
|
+
overlay_global.anycast_gateway_mac = \
|
|
90
|
+
overlay_global.default_anycast_gateway_mac
|
|
91
|
+
assert_equal(overlay_global.default_anycast_gateway_mac,
|
|
92
|
+
overlay_global.anycast_gateway_mac)
|
|
93
|
+
assert(Feature.nv_overlay_evpn_enabled?)
|
|
94
|
+
|
|
95
|
+
# Set to various non-default values
|
|
96
|
+
%w(1.1.1 55.a10.ffff 1223.3445.5668).each do |mac|
|
|
97
|
+
overlay_global.anycast_gateway_mac = mac
|
|
98
|
+
assert_equal(Utils.zero_pad_macaddr(mac),
|
|
99
|
+
overlay_global.anycast_gateway_mac)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
data/tests/test_pim.rb
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Copyright (c) 2013-2016 Cisco and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Smitha Gopalan, November 2015
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#-------------------------------------------------------------------------------
|
|
17
|
+
# CLI: <afi> pim ssm-range <range> (under different VRFs)
|
|
18
|
+
#-------------------------------------------------------------------------------
|
|
19
|
+
# Testcases: All Tests create all instances within a test
|
|
20
|
+
# 1. test_single_ssm_range_single_vrf:
|
|
21
|
+
# vrf default, ip pim ssm-range 229.0.0.0/8
|
|
22
|
+
#
|
|
23
|
+
# 2. test_single_ssm_range_none_single_vrf:
|
|
24
|
+
# vrf default, ip pim ssm-range none
|
|
25
|
+
#
|
|
26
|
+
# 3. test_multiple_ssm_range_multiple_vrfs:
|
|
27
|
+
# vrf default, ip pim ssm-range 229.0.0.0/8 225.0.0.0/8 224.0.0.0/8
|
|
28
|
+
# vrf red, ip pim ssm-range 230.0.0.0/8 228.0.0.0/8 224.0.0.0/8
|
|
29
|
+
# vrf black, ip pim ssm-range none
|
|
30
|
+
#
|
|
31
|
+
# 4. test_multiple_ssm_range_overwrite_multiple_vrfs:
|
|
32
|
+
# vrf default, ip pim ssm-range 229.0.0.0/8 225.0.0.0/8 224.0.0.0/8
|
|
33
|
+
# vrf red, ip pim ssm-range 230.0.0.0/8 228.0.0.0/8 224.0.0.0/8 ->
|
|
34
|
+
# gets overwritten to
|
|
35
|
+
# vrf red, ip pim ssm-range none
|
|
36
|
+
#
|
|
37
|
+
# 5. test_single_invalid_ssm_range_single_vrf:
|
|
38
|
+
# vrf default, ip pim ssm-range 1.1.1.1/8
|
|
39
|
+
#-------------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
require_relative 'ciscotest'
|
|
42
|
+
require_relative '../lib/cisco_node_utils/pim'
|
|
43
|
+
|
|
44
|
+
include Cisco
|
|
45
|
+
|
|
46
|
+
# TestPim - Minitest for Pim Feature
|
|
47
|
+
class TestPim < CiscoTestCase
|
|
48
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
|
49
|
+
|
|
50
|
+
# Enables feature pim
|
|
51
|
+
#---------------------
|
|
52
|
+
def setup
|
|
53
|
+
super
|
|
54
|
+
remove_all_pims if @@pre_clean_needed
|
|
55
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def teardown
|
|
59
|
+
super
|
|
60
|
+
remove_all_pims
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def remove_all_pims
|
|
64
|
+
Pim.pims.each do |_afi, vrfs|
|
|
65
|
+
vrfs.each do |_vrf, obj|
|
|
66
|
+
obj.destroy
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Creates single ssm range under default vrf
|
|
72
|
+
#-----------------------------------------------
|
|
73
|
+
def create_single_ssm_range_single_vrf(afi)
|
|
74
|
+
range = '229.0.0.0/8'
|
|
75
|
+
p1 = Pim.new(afi, 'default')
|
|
76
|
+
p1.ssm_range = (range)
|
|
77
|
+
assert_equal(p1.ssm_range.split.sort.join(' '), range.split.sort.join(' '))
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Tests single ssm range none under default vrf
|
|
81
|
+
#-----------------------------------------------
|
|
82
|
+
def test_single_ssm_range_single_vrf
|
|
83
|
+
%w(ipv4).each do |afi|
|
|
84
|
+
create_single_ssm_range_single_vrf(afi)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Creates single ssm range none under default vrf
|
|
89
|
+
#-----------------------------------------------
|
|
90
|
+
def create_single_ssm_range_none_single_vrf(afi)
|
|
91
|
+
range = 'none'
|
|
92
|
+
p1 = Pim.new(afi, 'default')
|
|
93
|
+
p1.ssm_range = (range)
|
|
94
|
+
assert_equal(p1.ssm_range.split.sort.join(' '), range.split.sort.join(' '))
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Tests single ssm range none under default vrf
|
|
98
|
+
#-----------------------------------------------
|
|
99
|
+
def test_single_ssm_range_none_single_vrf
|
|
100
|
+
%w(ipv4).each do |afi|
|
|
101
|
+
create_single_ssm_range_none_single_vrf(afi)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Creates multiple ssm ranges under different vrfs
|
|
106
|
+
#-----------------------------------------------
|
|
107
|
+
def create_multiple_ssm_range_multiple_vrfs(afi)
|
|
108
|
+
range1 = '229.0.0.0/8 225.0.0.0/8 224.0.0.0/8'
|
|
109
|
+
range2 = '230.0.0.0/8 228.0.0.0/8 224.0.0.0/8'
|
|
110
|
+
range3 = 'none'
|
|
111
|
+
p1 = Pim.new(afi, 'default')
|
|
112
|
+
p2 = Pim.new(afi, 'red')
|
|
113
|
+
p3 = Pim.new(afi, 'black')
|
|
114
|
+
p1.ssm_range = (range1)
|
|
115
|
+
p2.ssm_range = (range2)
|
|
116
|
+
p3.ssm_range = (range3)
|
|
117
|
+
assert_equal(p1.ssm_range.split.sort.join(' '), range1.split.sort.join(' '))
|
|
118
|
+
assert_equal(p2.ssm_range.split.sort.join(' '), range2.split.sort.join(' '))
|
|
119
|
+
assert_equal(p3.ssm_range.split.sort.join(' '), range3.split.sort.join(' '))
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Tests multiple ssm ranges under different vrfs
|
|
123
|
+
#-----------------------------------------------
|
|
124
|
+
def test_multiple_ssm_range_multiple_vrfs
|
|
125
|
+
%w(ipv4).each do |afi|
|
|
126
|
+
create_multiple_ssm_range_multiple_vrfs(afi)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Creates multiple ssm ranges overwrite under different vrfs
|
|
131
|
+
#-----------------------------------------------
|
|
132
|
+
def create_multiple_ssm_range_overwrite_multiple_vrfs(afi)
|
|
133
|
+
range1 = '229.0.0.0/8 225.0.0.0/8 224.0.0.0/8'
|
|
134
|
+
range2 = '230.0.0.0/8 228.0.0.0/8 224.0.0.0/8'
|
|
135
|
+
range3 = 'none'
|
|
136
|
+
p1 = Pim.new(afi, 'default')
|
|
137
|
+
p2 = Pim.new(afi, 'red')
|
|
138
|
+
p1.ssm_range = (range1)
|
|
139
|
+
p2.ssm_range = (range2)
|
|
140
|
+
assert_equal(p1.ssm_range.split.sort.join(' '), range1.split.sort.join(' '))
|
|
141
|
+
assert_equal(p2.ssm_range.split.sort.join(' '), range2.split.sort.join(' '))
|
|
142
|
+
p2.ssm_range = (range3)
|
|
143
|
+
assert_equal(p2.ssm_range.split.sort.join(' '), range3.split.sort.join(' '))
|
|
144
|
+
|
|
145
|
+
p1.destroy
|
|
146
|
+
assert('none', p1.ssm_range)
|
|
147
|
+
|
|
148
|
+
p2.destroy
|
|
149
|
+
assert('none', p2.ssm_range)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Tests multiple ssm ranges overwrite under different vrfs
|
|
153
|
+
#-----------------------------------------------
|
|
154
|
+
def test_multiple_ssm_range_overwrite_multiple_vrfs
|
|
155
|
+
%w(ipv4).each do |afi|
|
|
156
|
+
create_multiple_ssm_range_overwrite_multiple_vrfs(afi)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Creates single invalid ssm range under vrf default
|
|
161
|
+
#---------------------------------------------------
|
|
162
|
+
def create_single_invalid_ssm_range_single_vrf(afi)
|
|
163
|
+
range = '1.1.1.1/8'
|
|
164
|
+
p1 = Pim.new(afi, 'default')
|
|
165
|
+
assert_raises(CliError) do
|
|
166
|
+
p1.ssm_range = (range)
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Tests single invalid ssm range under vrf default
|
|
171
|
+
#---------------------------------------------------
|
|
172
|
+
def test_single_invalid_ssm_range_single_vrf
|
|
173
|
+
%w(ipv4).each do |afi|
|
|
174
|
+
create_single_invalid_ssm_range_single_vrf(afi)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Copyright (c) 2013-2016 Cisco and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Smitha Gopalan, November 2015
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#-----------------------------------------------------------
|
|
17
|
+
# CLI: <afi> pim rp-address <rp-address> group-list <group>
|
|
18
|
+
# (under different VRFs)
|
|
19
|
+
#-----------------------------------------------------------
|
|
20
|
+
# Testcases: All Tests create and destroy all instances within a test
|
|
21
|
+
#
|
|
22
|
+
# 1. test_all_group_lists
|
|
23
|
+
#
|
|
24
|
+
# 2. test_single_rpaddr_single_invalid_grouplist_single_vrf:
|
|
25
|
+
# vrf default, ip pim rp-address 25.25.25.25 group-list 25.0.0.0/8
|
|
26
|
+
#-------------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
require_relative 'ciscotest'
|
|
29
|
+
require_relative '../lib/cisco_node_utils/pim_group_list'
|
|
30
|
+
|
|
31
|
+
include Cisco
|
|
32
|
+
|
|
33
|
+
# TestPim - Minitest for PimGrouplist
|
|
34
|
+
class TestPimGroupList < CiscoTestCase
|
|
35
|
+
# Enables feature pim
|
|
36
|
+
#--------------------
|
|
37
|
+
def setup
|
|
38
|
+
super
|
|
39
|
+
config('no feature pim')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Test Pim.group_lists
|
|
43
|
+
# - multiple vrfs, groups, rp_addrs
|
|
44
|
+
# - same rp_addr, different group
|
|
45
|
+
# - same rp_addr, different vrf
|
|
46
|
+
# - same group, different rp_addr
|
|
47
|
+
# - same group, different vrf
|
|
48
|
+
#--------------------------------------------
|
|
49
|
+
def all_group_lists(afi)
|
|
50
|
+
rp_addr1 = '11.11.11.11'
|
|
51
|
+
rp_addr2 = '22.22.22.22'
|
|
52
|
+
grouplist1 = '227.0.0.0/8'
|
|
53
|
+
grouplist2 = '228.0.0.0/8'
|
|
54
|
+
|
|
55
|
+
# Basic setup
|
|
56
|
+
vrf = 'default'
|
|
57
|
+
pd1 = PimGroupList.new(afi, vrf, rp_addr1, grouplist1)
|
|
58
|
+
pd2 = PimGroupList.new(afi, vrf, rp_addr2, grouplist2)
|
|
59
|
+
hash = PimGroupList.group_lists
|
|
60
|
+
assert(hash.key?(afi))
|
|
61
|
+
assert(hash[afi].key?(vrf))
|
|
62
|
+
assert_equal(2, hash[afi][vrf].keys.count,
|
|
63
|
+
"hash[#{afi}][#{vrf}] should have 2 group lists")
|
|
64
|
+
assert(hash[afi][vrf].key?([rp_addr1, grouplist1]),
|
|
65
|
+
"hash[#{afi}][#{vrf}] does not contain [#{rp_addr1}, #{grouplist1}]")
|
|
66
|
+
assert(hash[afi][vrf].key?([rp_addr2, grouplist2]),
|
|
67
|
+
"hash[#{afi}][#{vrf}] does not contain [#{rp_addr2}, #{grouplist2}]")
|
|
68
|
+
|
|
69
|
+
# vrf with same rp_addrs/groups as in default
|
|
70
|
+
vrf = 'red'
|
|
71
|
+
pd3 = PimGroupList.new(afi, vrf, rp_addr1, grouplist1)
|
|
72
|
+
pd4 = PimGroupList.new(afi, vrf, rp_addr2, grouplist2)
|
|
73
|
+
hash = PimGroupList.group_lists
|
|
74
|
+
assert_equal(2, hash[afi].keys.count,
|
|
75
|
+
"hash[#{afi}] does not have 2 vrfs")
|
|
76
|
+
assert(hash[afi].key?(vrf))
|
|
77
|
+
assert_equal(2, hash[afi][vrf].keys.count,
|
|
78
|
+
"hash[#{afi}][#{vrf}] should have 2 group lists")
|
|
79
|
+
assert(hash[afi][vrf].key?([rp_addr1, grouplist1]),
|
|
80
|
+
"hash[#{afi}][#{vrf}] does not contain [#{rp_addr1}, #{grouplist1}]")
|
|
81
|
+
assert(hash[afi][vrf].key?([rp_addr2, grouplist2]),
|
|
82
|
+
"hash[#{afi}][#{vrf}] does not contain [#{rp_addr2}, #{grouplist2}]")
|
|
83
|
+
|
|
84
|
+
# different vrf, same rps / diff groups, etc.
|
|
85
|
+
vrf = 'black'
|
|
86
|
+
rp_addr7 = '7.7.7.7'
|
|
87
|
+
pd5 = PimGroupList.new(afi, vrf, rp_addr1, grouplist1)
|
|
88
|
+
pd6 = PimGroupList.new(afi, vrf, rp_addr1, grouplist2)
|
|
89
|
+
pd7 = PimGroupList.new(afi, vrf, rp_addr7, grouplist2)
|
|
90
|
+
hash = PimGroupList.group_lists
|
|
91
|
+
assert_equal(3, hash[afi].keys.count,
|
|
92
|
+
"hash[#{afi}] does not have 3 vrfs")
|
|
93
|
+
assert(hash[afi].key?(vrf))
|
|
94
|
+
assert_equal(3, hash[afi][vrf].keys.count,
|
|
95
|
+
"hash[#{afi}][#{vrf}] should have 3 group lists")
|
|
96
|
+
assert(hash[afi][vrf].key?([rp_addr1, grouplist1]),
|
|
97
|
+
"hash[#{afi}][#{vrf}] does not contain [#{rp_addr1}, #{grouplist2}]")
|
|
98
|
+
assert(hash[afi][vrf].key?([rp_addr1, grouplist2]),
|
|
99
|
+
"hash[#{afi}][#{vrf}] does not contain [#{rp_addr1}, #{grouplist2}]")
|
|
100
|
+
assert(hash[afi][vrf].key?([rp_addr7, grouplist2]),
|
|
101
|
+
"hash[#{afi}][#{vrf}] does not contain [#{rp_addr7}, #{grouplist2}]")
|
|
102
|
+
|
|
103
|
+
# Test removal
|
|
104
|
+
vrf = 'default'
|
|
105
|
+
pd1.destroy
|
|
106
|
+
hash = PimGroupList.group_lists
|
|
107
|
+
assert_equal(1, hash[afi][vrf].keys.count,
|
|
108
|
+
"hash[#{afi}][#{vrf}] should have 1 group lists")
|
|
109
|
+
refute(hash[afi][vrf].key?([rp_addr1, grouplist1]),
|
|
110
|
+
"hash[#{afi}][#{vrf}] should not contain "\
|
|
111
|
+
"[#{rp_addr1}, #{grouplist1}]")
|
|
112
|
+
|
|
113
|
+
vrf = 'red'
|
|
114
|
+
pd3.destroy
|
|
115
|
+
hash = PimGroupList.group_lists
|
|
116
|
+
assert_equal(1, hash[afi][vrf].keys.count,
|
|
117
|
+
"hash[#{afi}][#{vrf}] should have 1 group lists")
|
|
118
|
+
refute(hash[afi][vrf].key?([rp_addr1, grouplist1]),
|
|
119
|
+
"hash[#{afi}][#{vrf}] should not contain "\
|
|
120
|
+
"[#{rp_addr1}, #{grouplist1}]")
|
|
121
|
+
|
|
122
|
+
vrf = 'black'
|
|
123
|
+
pd5.destroy
|
|
124
|
+
pd7.destroy
|
|
125
|
+
hash = PimGroupList.group_lists
|
|
126
|
+
assert_equal(1, hash[afi][vrf].keys.count,
|
|
127
|
+
"hash[#{afi}][#{vrf}] should have 1 group lists")
|
|
128
|
+
refute(hash[afi][vrf].key?([rp_addr1, grouplist1]),
|
|
129
|
+
"hash[#{afi}][#{vrf}] should not contain "\
|
|
130
|
+
"[#{rp_addr1}, #{grouplist1}]")
|
|
131
|
+
pd2.destroy
|
|
132
|
+
pd4.destroy
|
|
133
|
+
pd6.destroy
|
|
134
|
+
hash = PimGroupList.group_lists
|
|
135
|
+
assert_empty(hash[afi], 'hash[#{afi}] is not empty')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Tests Pim.group_lists
|
|
139
|
+
#------------------------------------------
|
|
140
|
+
def test_all_group_lists
|
|
141
|
+
%w(ipv4).each do |afi|
|
|
142
|
+
all_group_lists(afi)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Creates single invalid rp address single grouplist vrf default
|
|
147
|
+
#---------------------------------------------------------------
|
|
148
|
+
def create_single_invalid_rpaddr_single_grouplist_single_vrf(afi)
|
|
149
|
+
rp_addr = '256.256.256.256'
|
|
150
|
+
grouplist = '224.0.0.0/8'
|
|
151
|
+
assert_raises(CliError) do
|
|
152
|
+
PimGroupList.new(afi, 'default', rp_addr, grouplist)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Tests single invalid rp address single grouplist vrf default
|
|
157
|
+
#---------------------------------------------------------------
|
|
158
|
+
def test_single_invalid_rpaddr_single_grouplist_single_vrf
|
|
159
|
+
%w(ipv4).each do |afi|
|
|
160
|
+
create_single_invalid_rpaddr_single_grouplist_single_vrf(afi)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Creates single rp address single invalid grouplist single vrf
|
|
165
|
+
#---------------------------------------------------------------
|
|
166
|
+
def create_single_rpaddr_single_invalid_grouplist_single_vrf(afi)
|
|
167
|
+
rp_addr = '25.25.25.25'
|
|
168
|
+
grouplist = '25.0.0.0/8'
|
|
169
|
+
assert_raises(CliError) do
|
|
170
|
+
PimGroupList.new(afi, 'red', rp_addr, grouplist)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Tests single rp address single invalid grouplist single vrf
|
|
175
|
+
#---------------------------------------------------------------
|
|
176
|
+
def test_single_rpaddr_single_invalid_grouplist_single_vrf
|
|
177
|
+
%w(ipv4).each do |afi|
|
|
178
|
+
create_single_rpaddr_single_invalid_grouplist_single_vrf(afi)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|