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.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +13 -0
  5. data/.travis.yml +4 -1
  6. data/CHANGELOG.md +81 -2
  7. data/CONTRIBUTING.md +2 -17
  8. data/Gemfile +5 -0
  9. data/README.md +92 -47
  10. data/Rakefile +23 -1
  11. data/bin/git/hooks/hook_lib +7 -0
  12. data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
  13. data/bin/git/hooks/pre-commit/rubocop +7 -2
  14. data/bin/git/hooks/pre-commit/validate-diffs +18 -4
  15. data/bin/git/hooks/pre-commit/validate-yaml +18 -0
  16. data/bin/git/update-hooks +64 -6
  17. data/cisco_node_utils.gemspec +9 -6
  18. data/docs/README-develop-best-practices.md +149 -50
  19. data/docs/README-develop-node-utils-APIs.md +92 -42
  20. data/docs/README-maintainers.md +7 -4
  21. data/docs/README-test-execution.md +57 -0
  22. data/docs/cisco_node_utils.yaml.example +30 -0
  23. data/docs/template-router.rb +4 -0
  24. data/ext/mkrf_conf.rb +63 -0
  25. data/lib/.rubocop.yml +2 -2
  26. data/lib/cisco_node_utils.rb +5 -0
  27. data/lib/cisco_node_utils/aaa_authentication_login.rb +5 -6
  28. data/lib/cisco_node_utils/aaa_authorization_service.rb +1 -1
  29. data/lib/cisco_node_utils/ace.rb +165 -12
  30. data/lib/cisco_node_utils/acl.rb +2 -1
  31. data/lib/cisco_node_utils/bgp.rb +184 -21
  32. data/lib/cisco_node_utils/bgp_af.rb +94 -249
  33. data/lib/cisco_node_utils/bgp_neighbor.rb +94 -14
  34. data/lib/cisco_node_utils/bgp_neighbor_af.rb +75 -8
  35. data/lib/cisco_node_utils/bridge_domain.rb +183 -0
  36. data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
  37. data/lib/cisco_node_utils/cisco_cmn_utils.rb +85 -2
  38. data/lib/cisco_node_utils/client.rb +35 -0
  39. data/lib/cisco_node_utils/client/client.rb +234 -0
  40. data/lib/cisco_node_utils/client/grpc.rb +33 -0
  41. data/lib/cisco_node_utils/client/grpc/client.rb +311 -0
  42. data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
  43. data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
  44. data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
  45. data/lib/cisco_node_utils/client/nxapi.rb +31 -0
  46. data/lib/cisco_node_utils/client/nxapi/client.rb +305 -0
  47. data/lib/cisco_node_utils/client/utils.rb +164 -0
  48. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +222 -254
  49. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +11 -8
  50. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +22 -15
  51. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +11 -8
  52. data/lib/cisco_node_utils/cmd_ref/acl.yaml +21 -16
  53. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +239 -109
  54. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +114 -55
  55. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +76 -52
  56. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +106 -62
  57. data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +71 -0
  58. data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
  59. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +35 -14
  60. data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
  61. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +23 -17
  62. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +94 -83
  63. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +22 -17
  64. data/lib/cisco_node_utils/cmd_ref/feature.yaml +76 -26
  65. data/lib/cisco_node_utils/cmd_ref/images.yaml +3 -2
  66. data/lib/cisco_node_utils/cmd_ref/interface.yaml +381 -153
  67. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +21 -11
  68. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +21 -21
  69. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +30 -21
  70. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +18 -13
  71. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +26 -31
  72. data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
  73. data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
  74. data/lib/cisco_node_utils/cmd_ref/memory.yaml +17 -6
  75. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +10 -3
  76. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +17 -5
  77. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +33 -29
  78. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +12 -10
  79. data/lib/cisco_node_utils/cmd_ref/pim.yaml +16 -19
  80. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +40 -25
  81. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +17 -12
  82. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +71 -35
  83. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +10 -5
  84. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +6 -2
  85. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +47 -43
  86. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +13 -11
  87. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +4 -2
  88. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +23 -21
  89. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +26 -22
  90. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +19 -17
  91. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +18 -6
  92. data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +234 -0
  93. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +24 -9
  94. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +5 -3
  95. data/lib/cisco_node_utils/cmd_ref/system.yaml +4 -3
  96. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +22 -20
  97. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +27 -15
  98. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +45 -16
  99. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +21 -11
  100. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +3 -2
  101. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +60 -32
  102. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +118 -101
  103. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +54 -58
  104. data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +118 -0
  105. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +19 -25
  106. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +28 -18
  107. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +34 -17
  108. data/lib/cisco_node_utils/cmd_ref/yum.yaml +6 -4
  109. data/lib/cisco_node_utils/command_reference.rb +261 -142
  110. data/lib/cisco_node_utils/constants.rb +33 -0
  111. data/lib/cisco_node_utils/encapsulation.rb +112 -0
  112. data/lib/cisco_node_utils/environment.rb +102 -0
  113. data/lib/cisco_node_utils/evpn_vni.rb +5 -3
  114. data/lib/cisco_node_utils/exceptions.rb +111 -0
  115. data/lib/cisco_node_utils/fabricpath_global.rb +52 -35
  116. data/lib/cisco_node_utils/fabricpath_topology.rb +44 -57
  117. data/lib/cisco_node_utils/feature.rb +165 -3
  118. data/lib/cisco_node_utils/interface.rb +1051 -260
  119. data/lib/cisco_node_utils/interface_channel_group.rb +11 -10
  120. data/lib/cisco_node_utils/interface_ospf.rb +1 -2
  121. data/lib/cisco_node_utils/interface_portchannel.rb +4 -12
  122. data/lib/cisco_node_utils/interface_service_vni.rb +7 -7
  123. data/lib/cisco_node_utils/itd_device_group.rb +248 -0
  124. data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
  125. data/lib/cisco_node_utils/itd_service.rb +523 -0
  126. data/lib/cisco_node_utils/logger.rb +75 -0
  127. data/lib/cisco_node_utils/node.rb +62 -192
  128. data/lib/cisco_node_utils/node_util.rb +56 -10
  129. data/lib/cisco_node_utils/overlay_global.rb +2 -2
  130. data/lib/cisco_node_utils/pim.rb +2 -13
  131. data/lib/cisco_node_utils/pim_group_list.rb +1 -1
  132. data/lib/cisco_node_utils/pim_rp_address.rb +1 -1
  133. data/lib/cisco_node_utils/platform.rb +52 -21
  134. data/lib/cisco_node_utils/portchannel_global.rb +89 -19
  135. data/lib/cisco_node_utils/radius_server.rb +168 -37
  136. data/lib/cisco_node_utils/router_ospf.rb +20 -35
  137. data/lib/cisco_node_utils/router_ospf_vrf.rb +4 -4
  138. data/lib/cisco_node_utils/snmpserver.rb +1 -6
  139. data/lib/cisco_node_utils/snmpuser.rb +6 -4
  140. data/lib/cisco_node_utils/stp_global.rb +676 -0
  141. data/lib/cisco_node_utils/syslog_server.rb +77 -18
  142. data/lib/cisco_node_utils/syslog_settings.rb +1 -1
  143. data/lib/cisco_node_utils/tacacs_server_group.rb +8 -4
  144. data/lib/cisco_node_utils/tacacs_server_host.rb +115 -25
  145. data/lib/cisco_node_utils/vdc.rb +12 -0
  146. data/lib/cisco_node_utils/version.rb +1 -1
  147. data/lib/cisco_node_utils/vlan.rb +147 -29
  148. data/lib/cisco_node_utils/vpc.rb +55 -3
  149. data/lib/cisco_node_utils/vrf.rb +72 -11
  150. data/lib/cisco_node_utils/vrf_af.rb +114 -29
  151. data/lib/cisco_node_utils/vtp.rb +34 -52
  152. data/lib/cisco_node_utils/vxlan_vtep.rb +34 -8
  153. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +36 -4
  154. data/lib/minitest/environment_plugin.rb +31 -0
  155. data/lib/minitest/log_level_plugin.rb +41 -0
  156. data/spec/client_spec.rb +7 -0
  157. data/spec/environment_spec.rb +263 -0
  158. data/spec/grpc_client_spec.rb +23 -0
  159. data/spec/isolate/all_clients_spec.rb +9 -0
  160. data/spec/isolate/grpc_only_spec.rb +16 -0
  161. data/spec/isolate/no_clients_spec.rb +26 -0
  162. data/spec/isolate/nxapi_only_spec.rb +16 -0
  163. data/spec/nxapi_client_spec.rb +42 -0
  164. data/spec/schema.yaml +75 -0
  165. data/spec/shared_examples_for_clients.rb +14 -0
  166. data/spec/spec_helper.rb +91 -0
  167. data/spec/whitespace_spec.rb +10 -0
  168. data/spec/yaml_spec.rb +42 -0
  169. data/tests/.rubocop.yml +2 -2
  170. data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
  171. data/tests/basetest.rb +96 -36
  172. data/tests/ciscotest.rb +220 -12
  173. data/tests/cmd_config.yaml +71 -49
  174. data/tests/cmd_config_invalid.yaml +1 -1
  175. data/tests/test_aaa_authentication_login.rb +1 -0
  176. data/tests/test_aaa_authentication_login_service.rb +9 -0
  177. data/tests/test_aaa_authorization_service.rb +173 -367
  178. data/tests/test_ace.rb +171 -100
  179. data/tests/test_acl.rb +10 -1
  180. data/tests/test_bgp_af.rb +395 -728
  181. data/tests/test_bgp_neighbor.rb +274 -115
  182. data/tests/test_bgp_neighbor_af.rb +178 -77
  183. data/tests/test_bridge_domain.rb +191 -0
  184. data/tests/test_bridge_domain_vni.rb +116 -0
  185. data/tests/test_client_utils.rb +111 -0
  186. data/tests/test_command_config.rb +9 -5
  187. data/tests/test_command_reference.rb +380 -102
  188. data/tests/test_dns_domain.rb +13 -3
  189. data/tests/test_domain_name.rb +13 -3
  190. data/tests/test_encapsulation.rb +77 -0
  191. data/tests/test_evpn_vni.rb +25 -7
  192. data/tests/test_fabricpath_global.rb +167 -163
  193. data/tests/test_fabricpath_topology.rb +12 -33
  194. data/tests/test_feature.rb +215 -0
  195. data/tests/test_grpc.rb +166 -0
  196. data/tests/test_interface.rb +585 -344
  197. data/tests/test_interface_bdi.rb +80 -0
  198. data/tests/test_interface_channel_group.rb +6 -3
  199. data/tests/test_interface_ospf.rb +26 -24
  200. data/tests/test_interface_portchannel.rb +1 -0
  201. data/tests/test_interface_private_vlan.rb +724 -0
  202. data/tests/test_interface_service_vni.rb +37 -66
  203. data/tests/test_interface_svi.rb +98 -101
  204. data/tests/test_interface_switchport.rb +419 -549
  205. data/tests/test_itd_device_group.rb +145 -0
  206. data/tests/test_itd_device_group_node.rb +199 -0
  207. data/tests/test_itd_service.rb +298 -0
  208. data/tests/test_logger.rb +43 -0
  209. data/tests/test_name_server.rb +11 -2
  210. data/tests/test_node.rb +16 -75
  211. data/tests/test_node_ext.rb +174 -163
  212. data/tests/test_node_util.rb +119 -0
  213. data/tests/test_ntp_config.rb +5 -1
  214. data/tests/test_ntp_server.rb +2 -2
  215. data/tests/test_nxapi.rb +221 -0
  216. data/tests/test_overlay_global.rb +47 -38
  217. data/tests/test_pim.rb +2 -0
  218. data/tests/test_pim_group_list.rb +2 -0
  219. data/tests/test_pim_rp_address.rb +2 -0
  220. data/tests/test_platform.rb +86 -39
  221. data/tests/test_portchannel_global.rb +211 -135
  222. data/tests/test_radius_global.rb +13 -5
  223. data/tests/test_radius_server.rb +256 -104
  224. data/tests/test_radius_server_group.rb +2 -0
  225. data/tests/test_router_bgp.rb +781 -485
  226. data/tests/test_router_ospf.rb +26 -103
  227. data/tests/test_router_ospf_vrf.rb +52 -57
  228. data/tests/test_snmp_notification_receiver.rb +2 -0
  229. data/tests/test_snmpcommunity.rb +2 -0
  230. data/tests/test_snmpgroup.rb +2 -0
  231. data/tests/test_snmpnotification.rb +40 -21
  232. data/tests/test_snmpserver.rb +2 -0
  233. data/tests/test_snmpuser.rb +2 -0
  234. data/tests/test_stp_global.rb +563 -0
  235. data/tests/test_syslog_server.rb +32 -8
  236. data/tests/test_syslog_settings.rb +22 -9
  237. data/tests/test_tacacs_server.rb +32 -27
  238. data/tests/test_tacacs_server_group.rb +100 -45
  239. data/tests/test_tacacs_server_host.rb +135 -43
  240. data/tests/test_vdc.rb +2 -16
  241. data/tests/test_vlan.rb +106 -54
  242. data/tests/test_vlan_mt_full.rb +11 -21
  243. data/tests/test_vlan_private.rb +669 -0
  244. data/tests/test_vpc.rb +312 -159
  245. data/tests/test_vrf.rb +122 -113
  246. data/tests/test_vrf_af.rb +238 -0
  247. data/tests/test_vtp.rb +58 -102
  248. data/tests/test_vxlan_vtep.rb +38 -17
  249. data/tests/test_vxlan_vtep_vni.rb +61 -9
  250. data/tests/test_yum.rb +49 -25
  251. metadata +122 -36
  252. data/lib/cisco_node_utils/cmd_ref/fex.yaml +0 -9
  253. data/lib/cisco_node_utils/cmd_ref/vni.yaml +0 -76
  254. data/lib/cisco_node_utils/vni.rb +0 -227
  255. data/tests/test_vni.rb +0 -106
data/tests/test_vpc.rb CHANGED
@@ -15,39 +15,34 @@ require_relative 'ciscotest'
15
15
  require_relative '../lib/cisco_node_utils/vpc'
16
16
  require_relative '../lib/cisco_node_utils/interface'
17
17
  require_relative '../lib/cisco_node_utils/interface_channel_group'
18
+ require_relative '../lib/cisco_node_utils/platform'
18
19
 
19
20
  include Cisco
20
21
 
21
22
  # TestVpc - Minitest for Vpc node utility class
22
23
  class TestVpc < CiscoTestCase
24
+ @skip_unless_supported = 'vpc'
25
+
23
26
  def setup
24
27
  super
25
28
  no_feature_vpc
26
29
  end
27
30
 
28
31
  def teardown
29
- no_feature_vpc
30
32
  super
31
33
  end
32
34
 
33
35
  def no_feature_vpc
34
- config('terminal dont-ask ; no feature vpc')
35
- end
36
-
37
- def n5k6k_platforms?
38
- /N[56]K/ =~ node.product_id
39
- end
40
-
41
- def n3k9k_platforms?
42
- /N[39]K/ =~ node.product_id
36
+ domains = Vpc.domains
37
+ domains.each { |_key, elem| elem.destroy } unless domains.empty?
43
38
  end
44
39
 
45
40
  # TESTS
46
41
 
47
42
  def test_vpc_create
48
- @vpc = Vpc.new(100)
49
- assert(@vpc.domain == 100,
50
- "VPC domain not set correctly #{@vpc.domain}")
43
+ vpc = Vpc.new(100)
44
+ assert(vpc.domain == 100,
45
+ "VPC domain not set correctly #{vpc.domain}")
51
46
  assert(Vpc.enabled,
52
47
  'VPC feature should have been enabled')
53
48
  refute(Vpc.domains.empty?,
@@ -56,265 +51,295 @@ class TestVpc < CiscoTestCase
56
51
 
57
52
  def test_vpc_destroy
58
53
  # create and test again
59
- @vpc = Vpc.new(100)
60
- @vpc.destroy
54
+ vpc = Vpc.new(100)
55
+ vpc.destroy
61
56
  refute(Vpc.enabled, 'VPC feature should have been disabled')
62
57
  end
63
58
 
64
59
  def test_auto_recovery
65
- skip("Test not supported on #{node.product_id}") if
66
- cmd_ref.lookup('vpc', 'auto_recovery').default_value.nil?
67
- @vpc = Vpc.new(100)
68
- default_val = @vpc.auto_recovery
69
- assert_equal(default_val, @vpc.auto_recovery,
60
+ vpc = Vpc.new(100)
61
+ if validate_property_excluded?('vpc', 'auto_recovery')
62
+ assert_raises(Cisco::UnsupportedError) { vpc.auto_recovery = true }
63
+ return
64
+ end
65
+
66
+ default_val = vpc.auto_recovery
67
+ assert_equal(default_val, vpc.auto_recovery,
70
68
  "Auto recovery should be #{default_val} by default")
71
- @vpc.auto_recovery = false
72
- refute(@vpc.auto_recovery, 'Auto recovery not getting disabled')
73
- @vpc.auto_recovery = true
74
- assert(@vpc.auto_recovery, 'Auto recovery not getting set')
69
+ vpc.auto_recovery = false
70
+ refute(vpc.auto_recovery, 'Auto recovery not getting disabled')
71
+ vpc.auto_recovery = true
72
+ assert(vpc.auto_recovery, 'Auto recovery not getting set')
75
73
  end
76
74
 
77
75
  def test_auto_recovery_reload_delay
78
- @vpc = Vpc.new(100)
79
- default_value = @vpc.default_auto_recovery_reload_delay
80
- assert_equal(default_value, @vpc.auto_recovery_reload_delay,
76
+ vpc = Vpc.new(100)
77
+ default_value = vpc.default_auto_recovery_reload_delay
78
+ assert_equal(default_value, vpc.auto_recovery_reload_delay,
81
79
  "Auto recovery delay should be #{default_value}")
82
- @vpc.auto_recovery_reload_delay = 300
83
- assert_equal(300, @vpc.auto_recovery_reload_delay,
80
+ vpc.auto_recovery_reload_delay = 300
81
+ assert_equal(300, vpc.auto_recovery_reload_delay,
84
82
  'Auto recovery delay should be 300')
85
83
  end
86
84
 
87
85
  def test_delay_restore
88
- @vpc = Vpc.new(100)
89
- default_value = @vpc.default_delay_restore
90
- assert_equal(default_value, @vpc.delay_restore,
86
+ vpc = Vpc.new(100)
87
+ default_value = vpc.default_delay_restore
88
+ assert_equal(default_value, vpc.delay_restore,
91
89
  "delay_restore should be #{default_value}")
92
- @vpc.delay_restore = 1000
93
- assert_equal(1000, @vpc.delay_restore,
90
+ vpc.delay_restore = 1000
91
+ assert_equal(1000, vpc.delay_restore,
94
92
  'delay restore should be 1000')
95
93
  end
96
94
 
97
95
  def test_delay_restore_interface_vlan
98
- @vpc = Vpc.new(100)
99
- default_value = @vpc.default_delay_restore_interface_vlan
100
- assert_equal(default_value, @vpc.delay_restore_interface_vlan,
96
+ vpc = Vpc.new(100)
97
+ default_value = vpc.default_delay_restore_interface_vlan
98
+ assert_equal(default_value, vpc.delay_restore_interface_vlan,
101
99
  "delay_restore should be #{default_value}")
102
- @vpc.delay_restore_interface_vlan = 2000
103
- assert_equal(2000, @vpc.delay_restore_interface_vlan,
100
+ vpc.delay_restore_interface_vlan = 2000
101
+ assert_equal(2000, vpc.delay_restore_interface_vlan,
104
102
  'delay restore should be 2000')
105
103
  end
106
104
 
107
105
  def test_dual_active_exclude_interface_vlan_bridge_domain
108
- @vpc = Vpc.new(100)
106
+ vpc = Vpc.new(100)
109
107
  default_value =
110
- @vpc.default_dual_active_exclude_interface_vlan_bridge_domain
108
+ vpc.default_dual_active_exclude_interface_vlan_bridge_domain
111
109
  assert_equal(default_value,
112
- @vpc.dual_active_exclude_interface_vlan_bridge_domain,
110
+ vpc.dual_active_exclude_interface_vlan_bridge_domain,
113
111
  "delay_restore should be #{default_value}")
114
- @vpc.dual_active_exclude_interface_vlan_bridge_domain = '2-20,900'
112
+ vpc.dual_active_exclude_interface_vlan_bridge_domain = '2-20,900'
115
113
  assert_equal('2-20,900',
116
- @vpc.dual_active_exclude_interface_vlan_bridge_domain,
114
+ vpc.dual_active_exclude_interface_vlan_bridge_domain,
117
115
  'exclude vlan/bd should be 2-20,900')
118
116
  end
119
117
 
120
118
  def test_graceful_consistency_check
121
- @vpc = Vpc.new(100)
122
- default_val = @vpc.default_graceful_consistency_check
123
- assert_equal(default_val, @vpc.graceful_consistency_check,
119
+ vpc = Vpc.new(100)
120
+ default_val = vpc.default_graceful_consistency_check
121
+ assert_equal(default_val, vpc.graceful_consistency_check,
124
122
  "graceful_consistency_check must be #{default_val} by default")
125
- @vpc.graceful_consistency_check = false
126
- refute(@vpc.graceful_consistency_check,
123
+ vpc.graceful_consistency_check = false
124
+ refute(vpc.graceful_consistency_check,
127
125
  'graceful_consistency_check not getting disabled')
128
- @vpc.graceful_consistency_check = true
129
- assert(@vpc.graceful_consistency_check,
126
+ vpc.graceful_consistency_check = true
127
+ assert(vpc.graceful_consistency_check,
130
128
  'graceful_consistency_check not getting set')
131
129
  end
132
130
 
133
131
  def test_layer3_peer_routing
134
- skip("Test not supported on #{node.product_id}") if
135
- cmd_ref.lookup('vpc', 'layer3_peer_routing').default_value.nil?
136
- @vpc = Vpc.new(100)
137
- default_val = @vpc.default_layer3_peer_routing
138
- assert_equal(default_val, @vpc.layer3_peer_routing,
132
+ vpc = Vpc.new(100)
133
+ if validate_property_excluded?('vpc', 'layer3_peer_routing')
134
+ assert_raises(Cisco::UnsupportedError) { vpc.layer3_peer_routing = true }
135
+ return
136
+ end
137
+
138
+ default_val = vpc.default_layer3_peer_routing
139
+ assert_equal(default_val, vpc.layer3_peer_routing,
139
140
  "layer3_peer_routing should be #{default_val} by default")
140
- @vpc.layer3_peer_routing = true
141
- assert(@vpc.layer3_peer_routing, 'layer3_peer_routing not getting set')
142
- @vpc.layer3_peer_routing = false
143
- refute(@vpc.layer3_peer_routing, 'layer3_peer_routing not getting disabled')
141
+ vpc.layer3_peer_routing = true
142
+ assert(vpc.layer3_peer_routing, 'layer3_peer_routing not getting set')
143
+ vpc.layer3_peer_routing = false
144
+ refute(vpc.layer3_peer_routing, 'layer3_peer_routing not getting disabled')
144
145
  end
145
146
 
146
147
  def test_peer_keepalive
147
- @vpc = Vpc.new(100)
148
+ vpc = Vpc.new(100)
148
149
 
149
150
  # Check default values
150
- dest = @vpc.default_peer_keepalive_dest
151
+ dest = vpc.default_peer_keepalive_dest
151
152
  assert_equal('', dest, 'destination should be 1.1.1.2')
152
- source = @vpc.default_peer_keepalive_src
153
+ source = vpc.default_peer_keepalive_src
153
154
  assert_equal('', source, 'source should be 1.1.1.1')
154
- udp_port = @vpc.default_peer_keepalive_udp_port
155
+ udp_port = vpc.default_peer_keepalive_udp_port
155
156
  assert_equal(3200, udp_port, 'udp port should be 3200')
156
- vrf = @vpc.default_peer_keepalive_vrf
157
+ vrf = vpc.default_peer_keepalive_vrf
157
158
  assert_equal('management', vrf, 'vrf should be management')
158
- interval = @vpc.default_peer_keepalive_interval
159
+ interval = vpc.default_peer_keepalive_interval
159
160
  assert_equal(1000, interval, 'interval should be 1000')
160
- timeout = @vpc.default_peer_keepalive_interval_timeout
161
+ timeout = vpc.default_peer_keepalive_interval_timeout
161
162
  assert_equal(5, timeout, 'interval timeout should be 5')
162
- precedence = @vpc.default_peer_keepalive_precedence
163
+ precedence = vpc.default_peer_keepalive_precedence
163
164
  assert_equal(6, precedence, 'precedence should be 6')
164
- hold_timeout = @vpc.default_peer_keepalive_hold_timeout
165
+ hold_timeout = vpc.default_peer_keepalive_hold_timeout
165
166
  assert_equal(3, hold_timeout, 'hold timeout should be 3')
166
167
 
167
- @vpc.peer_keepalive_set('1.1.1.2', '1.1.1.1', 3800, 'management', 400, 3,
168
- 6, 3)
169
- dest = @vpc.peer_keepalive_dest
168
+ vpc.peer_keepalive_set('1.1.1.2', '1.1.1.1', 3800, 'management', 400, 3,
169
+ 6, 3)
170
+ dest = vpc.peer_keepalive_dest
170
171
  assert_equal('1.1.1.2', dest, 'destination should be 1.1.1.2')
171
- source = @vpc.peer_keepalive_src
172
+ source = vpc.peer_keepalive_src
172
173
  assert_equal('1.1.1.1', source, 'source should be 1.1.1.1')
173
- udp_port = @vpc.peer_keepalive_udp_port
174
+ udp_port = vpc.peer_keepalive_udp_port
174
175
  assert_equal(3800, udp_port, 'udp port should be 3800')
175
- vrf = @vpc.peer_keepalive_vrf
176
+ vrf = vpc.peer_keepalive_vrf
176
177
  assert_equal('management', vrf, 'vrf should be management')
177
- interval = @vpc.peer_keepalive_interval
178
+ interval = vpc.peer_keepalive_interval
178
179
  assert_equal(400, interval, 'interval should be 400')
179
- timeout = @vpc.peer_keepalive_interval_timeout
180
+ timeout = vpc.peer_keepalive_interval_timeout
180
181
  assert_equal(3, timeout, 'interval timeout should be 3')
181
- precedence = @vpc.peer_keepalive_precedence
182
+ precedence = vpc.peer_keepalive_precedence
182
183
  assert_equal(6, precedence, 'precedence should be 6')
183
- hold_timeout = @vpc.peer_keepalive_hold_timeout
184
+ hold_timeout = vpc.peer_keepalive_hold_timeout
184
185
  assert_equal(3, hold_timeout, 'hold timeout should be 3')
185
186
  end
186
187
 
187
188
  def test_peer_gateway
188
- @vpc = Vpc.new(100)
189
- default_val = @vpc.default_peer_gateway
190
- assert_equal(default_val, @vpc.peer_gateway,
189
+ vpc = Vpc.new(100)
190
+ default_val = vpc.default_peer_gateway
191
+ assert_equal(default_val, vpc.peer_gateway,
191
192
  "peer_gateway should be #{default_val} by default")
192
- @vpc.peer_gateway = true
193
- assert(@vpc.peer_gateway, 'peer_gateway not getting set')
194
- @vpc.peer_gateway = false
195
- refute(@vpc.peer_gateway, 'peer_gateway not getting disabled')
193
+ vpc.peer_gateway = true
194
+ assert(vpc.peer_gateway, 'peer_gateway not getting set')
195
+ vpc.peer_gateway = false
196
+ refute(vpc.peer_gateway, 'peer_gateway not getting disabled')
196
197
  end
197
198
 
198
199
  def test_peer_gateway_exclude_bridge_domain
199
- skip("Test not supported on #{node.product_id}") if
200
- cmd_ref.lookup('vpc', 'peer_gateway_exclude_bridge_domain').default_value
201
- .nil?
202
- @vpc = Vpc.new(100)
203
- default_val = @vpc.default_peer_gateway_exclude_bridge_domain
204
- assert_equal(default_val, @vpc.peer_gateway_exclude_bridge_domain,
200
+ vpc = Vpc.new(100)
201
+ if validate_property_excluded?('vpc', 'peer_gateway_exclude_bridge_domain')
202
+ assert_raises(Cisco::UnsupportedError) do
203
+ vpc.peer_gateway_exclude_bridge_domain = '10'
204
+ end
205
+ return
206
+ end
207
+
208
+ default_val = vpc.default_peer_gateway_exclude_bridge_domain
209
+ assert_equal(default_val, vpc.peer_gateway_exclude_bridge_domain,
205
210
  "peer_gateway exclude BD should be #{default_val} default")
206
- @vpc.peer_gateway_exclude_bridge_domain = '10-20,400'
207
- assert_equal('10-20,400', @vpc.peer_gateway_exclude_bridge_domain,
211
+ vpc.peer_gateway_exclude_bridge_domain = '10-20,400'
212
+ assert_equal('10-20,400', vpc.peer_gateway_exclude_bridge_domain,
208
213
  'peer_gateway exclude list not getting set')
209
214
  end
210
215
 
211
216
  def test_peer_gateway_exclude_vlan
212
- skip("Test not supported on #{node.product_id}") if
213
- cmd_ref.lookup('vpc', 'peer_gateway_exclude_vlan').default_value.nil?
214
- @vpc = Vpc.new(100)
215
- default_val = @vpc.default_peer_gateway_exclude_vlan
216
- assert_equal(default_val, @vpc.peer_gateway_exclude_vlan,
217
+ vpc = Vpc.new(100)
218
+ if validate_property_excluded?('vpc', 'peer_gateway_exclude_vlan')
219
+ assert_raises(Cisco::UnsupportedError) do
220
+ vpc.peer_gateway_exclude_vlan = '10'
221
+ end
222
+ return
223
+ end
224
+
225
+ default_val = vpc.default_peer_gateway_exclude_vlan
226
+ assert_equal(default_val, vpc.peer_gateway_exclude_vlan,
217
227
  "peer_gateway exclude vlan should be #{default_val} default")
218
- @vpc.peer_gateway_exclude_vlan = '10-20,400'
219
- assert_equal('10-20,400', @vpc.peer_gateway_exclude_vlan,
228
+ vpc.peer_gateway_exclude_vlan = '10-20,400'
229
+ assert_equal('10-20,400', vpc.peer_gateway_exclude_vlan,
220
230
  'peer_gateway exclude list not getting set')
221
231
  end
222
232
 
223
233
  def test_role_priority
224
- @vpc = Vpc.new(100)
225
- default_value = @vpc.default_role_priority
226
- assert_equal(default_value, @vpc.role_priority,
234
+ vpc = Vpc.new(100)
235
+ default_value = vpc.default_role_priority
236
+ assert_equal(default_value, vpc.role_priority,
227
237
  "Role priority should be #{default_value}")
228
- @vpc.role_priority = 200
229
- assert_equal(200, @vpc.role_priority,
238
+ vpc.role_priority = 200
239
+ assert_equal(200, vpc.role_priority,
230
240
  'Role priority should be 200')
231
241
  end
232
242
 
233
243
  def test_self_isolation
234
- skip('Only supported on N7K') unless node.product_id[/N7/]
244
+ vpc = Vpc.new(100)
245
+ if validate_property_excluded?('vpc', 'self_isolation')
246
+ assert_raises(Cisco::UnsupportedError) { vpc.self_isolation = true }
247
+ return
248
+ end
235
249
 
236
- @vpc = Vpc.new(100)
237
- @vpc.self_isolation = true
238
- assert_equal(true, @vpc.self_isolation,
250
+ vpc.self_isolation = true
251
+ assert_equal(true, vpc.self_isolation,
239
252
  'Self isolation should have been configured')
240
253
  end
241
254
 
242
255
  def test_shutdown
243
- skip("Test not supported on #{node.product_id}") if
244
- cmd_ref.lookup('vpc', 'layer3_peer_routing').default_value.nil?
245
- @vpc = Vpc.new(100)
256
+ vpc = Vpc.new(100)
257
+ if validate_property_excluded?('vpc', 'shutdown')
258
+ assert_raises(Cisco::UnsupportedError) { vpc.shutdown = true }
259
+ return
260
+ end
246
261
 
247
- @vpc.shutdown = @vpc.default_shutdown
248
- refute(@vpc.shutdown, 'Vpc domain should not be shutdown')
262
+ vpc.shutdown = vpc.default_shutdown
263
+ refute(vpc.shutdown, 'Vpc domain should not be shutdown')
249
264
 
250
- @vpc.shutdown = true
251
- assert(@vpc.shutdown, 'Vpc domain should be shutdown')
265
+ vpc.shutdown = true
266
+ assert(vpc.shutdown, 'Vpc domain should be shutdown')
252
267
 
253
- @vpc.shutdown = false
254
- refute(@vpc.shutdown, 'Vpc domain should not be shutdown')
268
+ vpc.shutdown = false
269
+ refute(vpc.shutdown, 'Vpc domain should not be shutdown')
255
270
  end
256
271
 
257
272
  def test_system_mac
258
- @vpc = Vpc.new(100)
259
- default_value = @vpc.default_system_mac
260
- assert_equal(default_value, @vpc.system_mac,
273
+ vpc = Vpc.new(100)
274
+ default_value = vpc.default_system_mac
275
+ assert_equal(default_value, vpc.system_mac,
261
276
  "Default system_mac should be #{default_value}")
262
277
 
263
- @vpc.system_mac = '1.1.1'
264
- assert_equal('00:01:00:01:00:01', @vpc.system_mac,
278
+ vpc.system_mac = '1.1.1'
279
+ assert_equal('00:01:00:01:00:01', vpc.system_mac,
265
280
  'Error: system_mac mismatch')
266
281
  end
267
282
 
268
283
  def test_system_priority
269
- @vpc = Vpc.new(100)
270
- default_value = @vpc.default_system_priority
271
- assert_equal(default_value, @vpc.system_priority,
284
+ vpc = Vpc.new(100)
285
+ default_value = vpc.default_system_priority
286
+ assert_equal(default_value, vpc.system_priority,
272
287
  "System priority should be #{default_value}")
273
- @vpc.system_priority = 200
274
- assert_equal(200, @vpc.system_priority,
288
+ vpc.system_priority = 200
289
+ assert_equal(200, vpc.system_priority,
275
290
  'System priority should be 200')
276
291
  end
277
292
 
278
293
  def test_track
279
- skip("Test not supported on #{node.product_id}") if
280
- cmd_ref.lookup('vpc', 'track').default_value.nil?
281
- @vpc = Vpc.new(100)
294
+ vpc = Vpc.new(100)
295
+ if validate_property_excluded?('vpc', 'track')
296
+ assert_raises(Cisco::UnsupportedError) { vpc.track = 44 }
297
+ return
298
+ end
282
299
 
283
- default_value = @vpc.default_track
284
- assert_equal(default_value, @vpc.track,
300
+ default_value = vpc.default_track
301
+ assert_equal(default_value, vpc.track,
285
302
  'default track should be 0')
286
303
 
287
- @vpc.track = 44
288
- assert_equal(44, @vpc.track, 'track should be 44')
304
+ vpc.track = 44
305
+ assert_equal(44, vpc.track, 'track should be 44')
289
306
  end
290
307
 
308
+ ##############################################################################
309
+ # Test interface properties for vPC
310
+ #
291
311
  def test_interface_vpc_id
292
- @vpc = Vpc.new(100)
293
- # test phy port vpc
294
- interface = Interface.new(interfaces[0])
295
- assert_equal(interface.vpc_id, interface.default_vpc_id,
296
- 'default vpc_id should be null')
312
+ vpc = Vpc.new(100)
297
313
  # Make sure PKA is set
298
- @vpc.peer_keepalive_set('1.1.1.2', '1.1.1.1', 3800, 'management', 400, 3,
299
- 6, 3)
314
+ vpc.peer_keepalive_set('1.1.1.2', '1.1.1.1', 3800, 'management', 400, 3,
315
+ 6, 3)
316
+ # init channel group as none first, to test phy-port vPC link
317
+ interface = InterfaceChannelGroup.new(interfaces[0])
318
+ interface.channel_group = false if interface.channel_group
300
319
  # Phy port vPC is supported only on N7K
301
320
  if /N7/ =~ node.product_id
302
- interface.switchport_mode = :trunk
303
- interface.vpc_id = 10
304
- assert_equal(10, interface.vpc_id, 'vpc_id should be 10')
305
-
306
- # negative - cannot config peer link on this
307
- e = assert_raises(CliError) do
308
- interface.vpc_peer_link = true
321
+ phy_port_iflist =
322
+ Feature.compatible_interfaces('vpc', 'phy_port_vpc_module_pids')
323
+ unless phy_port_iflist.empty?
324
+ phy_interface = Interface.new(phy_port_iflist[0])
325
+ assert_equal(phy_interface.vpc_id, phy_interface.default_vpc_id,
326
+ 'default vpc_id should be null')
327
+ phy_interface.switchport_mode = :trunk
328
+ phy_interface.vpc_id = 10
329
+ assert_equal(10, phy_interface.vpc_id, 'vpc_id should be 10')
330
+
331
+ # negative - cannot config peer link on this
332
+ e = assert_raises(CliError) do
333
+ phy_interface.vpc_peer_link = true
334
+ end
335
+ assert_match(/Invalid number/i, e.message)
336
+
337
+ # turn off vpc id
338
+ phy_interface.vpc_id = false
339
+ refute(phy_interface.vpc_id, 'vpc_id should be unset')
309
340
  end
310
- assert_match(/Invalid number/i, e.message)
311
-
312
- # turn off vpc id
313
- interface.vpc_id = false
314
- refute(interface.vpc_id, 'vpc_id should be unset')
315
341
  end
316
342
  # test port-channel vpc
317
- interface = InterfaceChannelGroup.new(interfaces[0])
318
343
  interface.channel_group = 10
319
344
  interface_pc = Interface.new('port-channel10')
320
345
  interface_pc.switchport_mode = :trunk
@@ -333,10 +358,10 @@ class TestVpc < CiscoTestCase
333
358
  end
334
359
 
335
360
  def test_interface_vpc_peer_link
336
- @vpc = Vpc.new(100)
361
+ vpc = Vpc.new(100)
337
362
  # Make sure PKA is set
338
- @vpc.peer_keepalive_set('1.1.1.2', '1.1.1.1', 3800, 'management', 400, 3,
339
- 6, 3)
363
+ vpc.peer_keepalive_set('1.1.1.2', '1.1.1.1', 3800, 'management', 400, 3,
364
+ 6, 3)
340
365
  interface = InterfaceChannelGroup.new(interfaces[1])
341
366
  interface.channel_group = 100
342
367
  interface_pc = Interface.new('port-channel100')
@@ -358,4 +383,132 @@ class TestVpc < CiscoTestCase
358
383
  end
359
384
  assert_match(/Invalid/i, e.message)
360
385
  end
386
+
387
+ ##############################################################################
388
+ # Test vPC+ properties
389
+ #
390
+
391
+ # Some properties require 'feature-set fabricpath', which will process before
392
+ # the property itself; therefore check for unsupported against the feature
393
+ # before attempting the property itself. Returns true if excluded.
394
+ def feature_set_fabricpath_excluded?
395
+ if validate_property_excluded?('fabricpath', 'feature_install')
396
+ assert_raises(Cisco::UnsupportedError) do
397
+ FabricpathGlobal.fabricpath_feature_set(:enabled)
398
+ end
399
+ return true
400
+ end
401
+ false
402
+ end
403
+
404
+ def test_fabricpath_emulated_switch_id
405
+ return if feature_set_fabricpath_excluded?
406
+ vpc = Vpc.new(100)
407
+ if validate_property_excluded?('vpc', 'fabricpath_emulated_switch_id')
408
+ assert_raises(Cisco::UnsupportedError) do
409
+ vpc.fabricpath_emulated_switch_id = false
410
+ end
411
+ return
412
+ end
413
+
414
+ refute(vpc.fabricpath_emulated_switch_id,
415
+ 'vPC+ (fabricpath switch-id) should not be enabled by default')
416
+ vpc.fabricpath_emulated_switch_id = 1000
417
+ assert_equal(1000, vpc.fabricpath_emulated_switch_id,
418
+ 'fabricpath emulated switch-id/ESWID should be 1000')
419
+ vpc.fabricpath_emulated_switch_id = false
420
+ refute(vpc.fabricpath_emulated_switch_id,
421
+ 'vPC+ (fabricpath switch-id) not getting disabled')
422
+ end
423
+
424
+ def test_fabricpath_multicast_load_balance
425
+ vpc = Vpc.new(100)
426
+ return if feature_set_fabricpath_excluded?
427
+ if validate_property_excluded?('vpc', 'fabricpath_multicast_load_balance')
428
+ assert_raises(Cisco::UnsupportedError) do
429
+ vpc.fabricpath_multicast_load_balance = false
430
+ end
431
+ return
432
+ end
433
+
434
+ refute(vpc.fabricpath_multicast_load_balance,
435
+ 'fabricpath multicast loadbalance should not be enabled by default')
436
+
437
+ vpc.fabricpath_multicast_load_balance = true
438
+ assert(vpc.fabricpath_multicast_load_balance,
439
+ 'fabricpath multicast load-balance is not enabled')
440
+
441
+ vpc.fabricpath_multicast_load_balance = false
442
+ refute(vpc.fabricpath_multicast_load_balance,
443
+ 'fabricpath multicast load-balance is not disabled')
444
+
445
+ default = vpc.default_fabricpath_multicast_load_balance
446
+ vpc.fabricpath_multicast_load_balance = default
447
+ assert_equal(default, vpc.fabricpath_multicast_load_balance,
448
+ 'fabricpath multicast load-balance is not default')
449
+ end
450
+
451
+ def test_port_channel_limit
452
+ vpc = Vpc.new(100)
453
+ if validate_property_excluded?('vpc', 'port_channel_limit')
454
+ assert_raises(Cisco::UnsupportedError) { vpc.port_channel_limit = true }
455
+ return
456
+ end
457
+
458
+ assert(vpc.port_channel_limit,
459
+ 'port_channel_limit should be enabled by default')
460
+ e = assert_raises(RuntimeError) do
461
+ vpc.port_channel_limit = false
462
+ end
463
+ assert_match(/fabricpath_switch_id configuration is required/, e.message)
464
+ vpc.fabricpath_emulated_switch_id = 1000
465
+ vpc.fabricpath_multicast_load_balance = true
466
+ vpc.port_channel_limit = false
467
+ refute(vpc.port_channel_limit,
468
+ 'port_channel_limit not getting disabled')
469
+ e = assert_raises(CliError) do
470
+ vpc.fabricpath_multicast_load_balance = false
471
+ end
472
+ assert_match(/ERROR: Configure port-channel limit first/, e.message)
473
+ vpc.port_channel_limit = true
474
+ assert(vpc.port_channel_limit,
475
+ 'port_channel_limit not getting re-enabled')
476
+ end
477
+
478
+ def test_interface_vpc_plus_peer_link
479
+ vpc = Vpc.new(100)
480
+ fabricpath_testenv_setup
481
+ if validate_property_excluded?('vpc', 'fabricpath_emulated_switch_id')
482
+ assert_raises(Cisco::UnsupportedError) do
483
+ vpc.fabricpath_emulated_switch_id = true
484
+ end
485
+ return
486
+ end
487
+
488
+ # make it vpc plus by setting a fabricpath switch-id
489
+ vpc.fabricpath_emulated_switch_id = 1000
490
+ # Make sure PKA is set
491
+ vpc.peer_keepalive_set('1.1.1.2', '1.1.1.1', 3800, 'management', 400, 3,
492
+ 6, 3)
493
+ interface = InterfaceChannelGroup.new(interfaces[1])
494
+ interface.channel_group = 100
495
+ interface_pc = Interface.new('port-channel100')
496
+ interface_pc.switchport_mode = :fabricpath
497
+ refute(interface_pc.vpc_peer_link,
498
+ 'vpc_peer_link should not be set by default')
499
+ interface_pc.vpc_peer_link = true
500
+ assert(interface_pc.vpc_peer_link, 'vpc_peer_link should be set')
501
+ interface_pc.vpc_peer_link = false
502
+ refute(interface_pc.vpc_peer_link, 'vpc_peer_link should not be set')
503
+ # clean up
504
+ interface.channel_group = false
505
+ refute(interface.channel_group, 'channel group should be unset')
506
+ # try with a phy port
507
+ interface = Interface.new(interfaces[1])
508
+ # negative - cannot config peer link on this
509
+ e = assert_raises(CliError) do
510
+ interface.vpc_peer_link = true
511
+ end
512
+ assert_match(/Invalid/i, e.message)
513
+ end
361
514
  end