cisco_node_utils 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/CHANGELOG.md +126 -1
  4. data/README.md +19 -12
  5. data/Rakefile +1 -0
  6. data/bin/git/hooks/commit-msg/enforce_style +8 -0
  7. data/cisco_node_utils.gemspec +4 -3
  8. data/docs/README-develop-best-practices.md +127 -109
  9. data/docs/README-develop-node-utils-APIs.md +47 -39
  10. data/docs/template-router.rb +3 -7
  11. data/lib/.rubocop.yml +4 -4
  12. data/lib/cisco_node_utils.rb +1 -1
  13. data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
  14. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
  15. data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
  16. data/lib/cisco_node_utils/ace.rb +196 -0
  17. data/lib/cisco_node_utils/acl.rb +100 -0
  18. data/lib/cisco_node_utils/bgp.rb +301 -163
  19. data/lib/cisco_node_utils/bgp_af.rb +187 -19
  20. data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
  21. data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
  22. data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
  23. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
  24. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
  25. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
  26. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
  27. data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
  28. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
  29. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
  30. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
  31. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
  32. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
  33. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
  34. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
  35. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
  36. data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
  37. data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
  38. data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
  39. data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
  40. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
  41. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
  42. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
  43. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
  44. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
  45. data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
  46. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
  47. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
  48. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
  49. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
  50. data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
  51. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
  52. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
  53. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
  54. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
  55. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
  56. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
  57. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
  58. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
  59. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
  60. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
  61. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
  62. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
  63. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
  64. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
  65. data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
  66. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
  67. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
  68. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
  69. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
  70. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
  71. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
  72. data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
  73. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
  74. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
  75. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
  76. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
  77. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
  78. data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
  79. data/lib/cisco_node_utils/command_reference.rb +359 -187
  80. data/lib/cisco_node_utils/configparser_lib.rb +1 -1
  81. data/lib/cisco_node_utils/dns_domain.rb +19 -5
  82. data/lib/cisco_node_utils/domain_name.rb +4 -8
  83. data/lib/cisco_node_utils/evpn_vni.rb +157 -0
  84. data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
  85. data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
  86. data/lib/cisco_node_utils/feature.rb +111 -0
  87. data/lib/cisco_node_utils/interface.rb +390 -97
  88. data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
  89. data/lib/cisco_node_utils/interface_ospf.rb +11 -34
  90. data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
  91. data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
  92. data/lib/cisco_node_utils/name_server.rb +1 -1
  93. data/lib/cisco_node_utils/node.rb +55 -249
  94. data/lib/cisco_node_utils/node_util.rb +5 -1
  95. data/lib/cisco_node_utils/ntp_config.rb +2 -2
  96. data/lib/cisco_node_utils/ntp_server.rb +14 -5
  97. data/lib/cisco_node_utils/overlay_global.rb +153 -0
  98. data/lib/cisco_node_utils/pim.rb +124 -0
  99. data/lib/cisco_node_utils/pim_group_list.rb +108 -0
  100. data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
  101. data/lib/cisco_node_utils/platform.rb +8 -9
  102. data/lib/cisco_node_utils/portchannel_global.rb +277 -0
  103. data/lib/cisco_node_utils/radius_global.rb +9 -19
  104. data/lib/cisco_node_utils/radius_server.rb +31 -41
  105. data/lib/cisco_node_utils/radius_server_group.rb +117 -0
  106. data/lib/cisco_node_utils/router_ospf.rb +1 -1
  107. data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
  108. data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
  109. data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
  110. data/lib/cisco_node_utils/snmpgroup.rb +1 -1
  111. data/lib/cisco_node_utils/snmpnotification.rb +57 -0
  112. data/lib/cisco_node_utils/snmpserver.rb +8 -17
  113. data/lib/cisco_node_utils/snmpuser.rb +67 -28
  114. data/lib/cisco_node_utils/syslog_server.rb +3 -9
  115. data/lib/cisco_node_utils/syslog_settings.rb +2 -10
  116. data/lib/cisco_node_utils/tacacs_server.rb +9 -14
  117. data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
  118. data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
  119. data/lib/cisco_node_utils/vdc.rb +88 -0
  120. data/lib/cisco_node_utils/version.rb +5 -2
  121. data/lib/cisco_node_utils/vlan.rb +71 -8
  122. data/lib/cisco_node_utils/vni.rb +227 -0
  123. data/lib/cisco_node_utils/vpc.rb +377 -0
  124. data/lib/cisco_node_utils/vrf.rb +60 -9
  125. data/lib/cisco_node_utils/vrf_af.rb +191 -0
  126. data/lib/cisco_node_utils/vtp.rb +8 -6
  127. data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
  128. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
  129. data/lib/cisco_node_utils/yum.rb +1 -1
  130. data/tests/.rubocop.yml +1 -1
  131. data/tests/basetest.rb +16 -7
  132. data/tests/ciscotest.rb +55 -13
  133. data/tests/cmd_config.yaml +2 -2
  134. data/tests/platform_info.rb +3 -2
  135. data/tests/test_aaa_authentication_login.rb +219 -0
  136. data/tests/test_aaa_authentication_login_service.rb +759 -0
  137. data/tests/test_aaa_authorization_service.rb +1041 -0
  138. data/tests/test_ace.rb +160 -0
  139. data/tests/test_acl.rb +176 -0
  140. data/tests/test_bgp_af.rb +269 -13
  141. data/tests/test_bgp_neighbor.rb +38 -40
  142. data/tests/test_bgp_neighbor_af.rb +92 -32
  143. data/tests/test_command_config.rb +5 -5
  144. data/tests/test_command_reference.rb +284 -101
  145. data/tests/test_dns_domain.rb +1 -1
  146. data/tests/test_domain_name.rb +1 -1
  147. data/tests/test_evpn_vni.rb +106 -0
  148. data/tests/test_fabricpath_global.rb +243 -0
  149. data/tests/test_fabricpath_topology.rb +98 -0
  150. data/tests/test_interface.rb +292 -74
  151. data/tests/test_interface_channel_group.rb +74 -0
  152. data/tests/test_interface_ospf.rb +9 -4
  153. data/tests/test_interface_portchannel.rb +105 -0
  154. data/tests/test_interface_service_vni.rb +232 -0
  155. data/tests/test_interface_svi.rb +77 -62
  156. data/tests/test_interface_switchport.rb +17 -5
  157. data/tests/test_name_server.rb +1 -1
  158. data/tests/test_node.rb +1 -1
  159. data/tests/test_node_ext.rb +10 -20
  160. data/tests/test_ntp_config.rb +1 -1
  161. data/tests/test_ntp_server.rb +18 -6
  162. data/tests/test_overlay_global.rb +102 -0
  163. data/tests/test_pim.rb +177 -0
  164. data/tests/test_pim_group_list.rb +181 -0
  165. data/tests/test_pim_rp_address.rb +153 -0
  166. data/tests/test_platform.rb +3 -3
  167. data/tests/test_portchannel_global.rb +202 -0
  168. data/tests/test_radius_global.rb +1 -1
  169. data/tests/test_radius_server.rb +92 -57
  170. data/tests/test_radius_server_group.rb +149 -0
  171. data/tests/test_router_bgp.rb +283 -112
  172. data/tests/test_router_ospf.rb +2 -2
  173. data/tests/test_router_ospf_vrf.rb +4 -4
  174. data/tests/test_snmp_notification_receiver.rb +167 -0
  175. data/tests/test_snmpcommunity.rb +1 -1
  176. data/tests/test_snmpgroup.rb +1 -1
  177. data/tests/test_snmpnotification.rb +72 -0
  178. data/tests/test_snmpserver.rb +29 -105
  179. data/tests/test_snmpuser.rb +32 -30
  180. data/tests/test_syslog_server.rb +36 -10
  181. data/tests/test_syslog_settings.rb +1 -1
  182. data/tests/test_tacacs_server.rb +1 -1
  183. data/tests/test_tacacs_server_group.rb +405 -0
  184. data/tests/test_tacacs_server_host.rb +1 -1
  185. data/tests/test_vdc.rb +78 -0
  186. data/tests/test_vlan.rb +74 -19
  187. data/tests/test_vlan_mt_full.rb +95 -0
  188. data/tests/test_vni.rb +106 -0
  189. data/tests/test_vpc.rb +361 -0
  190. data/tests/test_vrf.rb +172 -29
  191. data/tests/test_vtp.rb +1 -1
  192. data/tests/test_vxlan_vtep.rb +214 -0
  193. data/tests/test_vxlan_vtep_vni.rb +201 -0
  194. data/tests/test_yum.rb +1 -1
  195. metadata +120 -11
  196. data/lib/cisco_node_utils/README_YAML.md +0 -325
  197. data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
  198. data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
  199. data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
  200. data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
  201. data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
  202. 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