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
data/tests/test_vrf.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 Cisco and/or its affiliates.
1
+ # Copyright (c) 2015-2016 Cisco and/or its affiliates.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -14,29 +14,34 @@
14
14
 
15
15
  require_relative 'ciscotest'
16
16
  require_relative '../lib/cisco_node_utils/vrf'
17
+ require_relative '../lib/cisco_node_utils/vrf_af'
18
+ require_relative '../lib/cisco_node_utils/vni'
17
19
 
18
20
  include Cisco
19
21
 
20
22
  # TestVrf - Minitest for Vrf node utility class
21
23
  class TestVrf < CiscoTestCase
22
24
  VRF_NAME_SIZE = 33
25
+ @@pre_clean_needed = true # rubocop:disable Style/ClassVars
23
26
 
24
27
  def setup
25
28
  super
26
- vrfs = Vrf.vrfs
27
- vrfs.each_value do |vrf|
28
- next unless vrf.name =~ /^test_vrf/
29
- config("no vrf context #{vrf.name}")
30
- end
29
+ remove_all_vrfs if @@pre_clean_needed
30
+ @@pre_clean_needed = false # rubocop:disable Style/ClassVars
31
+ end
32
+
33
+ def teardown
34
+ super
35
+ remove_all_vrfs
31
36
  end
32
37
 
33
- def test_vrf_collection_not_empty
38
+ def test_collection_not_empty
34
39
  vrfs = Vrf.vrfs
35
40
  refute_empty(vrfs, 'VRF collection is empty')
36
41
  assert(vrfs.key?('management'), 'VRF management does not exist')
37
42
  end
38
43
 
39
- def test_vrf_create_and_destroy
44
+ def test_create_and_destroy
40
45
  v = Vrf.new('test_vrf')
41
46
  vrfs = Vrf.vrfs
42
47
  assert(vrfs.key?('test_vrf'), 'Error: failed to create vrf test_vrf')
@@ -46,19 +51,19 @@ class TestVrf < CiscoTestCase
46
51
  refute(vrfs.key?('test_vrf'), 'Error: failed to destroy vrf test_vrf')
47
52
  end
48
53
 
49
- def test_vrf_name_type_invalid
54
+ def test_name_type_invalid
50
55
  assert_raises(TypeError, 'Wrong vrf name type did not raise type error') do
51
56
  Vrf.new(1000)
52
57
  end
53
58
  end
54
59
 
55
- def test_vrf_name_zero_length
60
+ def test_name_zero_length
56
61
  assert_raises(Cisco::CliError, "Zero length name didn't raise CliError") do
57
62
  Vrf.new('')
58
63
  end
59
64
  end
60
65
 
61
- def test_vrf_name_too_long
66
+ def test_name_too_long
62
67
  name = 'a' * VRF_NAME_SIZE
63
68
  assert_raises(Cisco::CliError,
64
69
  'vrf name misconfig did not raise CliError') do
@@ -66,27 +71,165 @@ class TestVrf < CiscoTestCase
66
71
  end
67
72
  end
68
73
 
69
- def test_vrf_shutdown_valid
70
- shutdown_states = [true, false]
71
- v = Vrf.new('test_vrf_shutdown')
72
- shutdown_states.each do |start|
73
- shutdown_states.each do |finish|
74
- v.shutdown = start
75
- assert_equal(start, v.shutdown, 'start')
76
- v.shutdown = finish
77
- assert_equal(finish, v.shutdown, 'finish')
78
- end
79
- end
74
+ def test_shutdown
75
+ v = Vrf.new('test_shutdown')
76
+ v.shutdown = true
77
+ assert(v.shutdown)
78
+ v.shutdown = false
79
+ refute(v.shutdown)
80
+
81
+ v.shutdown = true
82
+ assert(v.shutdown)
83
+ v.shutdown = v.default_shutdown
84
+ refute(v.shutdown)
85
+ v.destroy
86
+ end
87
+
88
+ def test_description
89
+ v = Vrf.new('test_description')
90
+ desc = 'tested by minitest'
91
+ v.description = desc
92
+ assert_equal(desc, v.description)
93
+
94
+ desc = v.default_description
95
+ v.description = desc
96
+ assert_equal(desc, v.description)
80
97
  v.destroy
81
98
  end
82
99
 
83
- def test_vrf_description
84
- vrf = Vrf.new('test_vrf_description')
85
- vrf.description = 'tested by minitest'
86
- assert_equal('tested by minitest', vrf.description,
87
- 'failed to set description')
88
- vrf.description = ' '
89
- assert_empty(vrf.description, 'failed to remove description')
100
+ def test_vni
101
+ skip('Platform does not support MT-lite') unless Vni.mt_lite_support
102
+ vrf = Vrf.new('test_vni')
103
+ vrf.vni = 4096
104
+ assert_equal(4096, vrf.vni,
105
+ "vrf vni should be set to '4096'")
106
+ vrf.vni = vrf.default_vni
107
+ assert_equal(vrf.default_vni, vrf.vni,
108
+ 'vrf vni should be set to default value')
90
109
  vrf.destroy
91
110
  end
111
+
112
+ def test_route_distinguisher
113
+ v = Vrf.new('blue')
114
+ v.route_distinguisher = 'auto'
115
+ assert_equal('auto', v.route_distinguisher)
116
+
117
+ v.route_distinguisher = '1:1'
118
+ assert_equal('1:1', v.route_distinguisher)
119
+
120
+ v.route_distinguisher = '2:3'
121
+ assert_equal('2:3', v.route_distinguisher)
122
+
123
+ v.route_distinguisher = v.default_route_distinguisher
124
+ assert_empty(v.route_distinguisher,
125
+ 'v route_distinguisher should *NOT* be configured')
126
+ v.destroy
127
+ end
128
+
129
+ def test_vrf_af_create_destroy
130
+ v1 = VrfAF.new('cyan', %w(ipv4 unicast))
131
+ v2 = VrfAF.new('cyan', %w(ipv6 unicast))
132
+ v3 = VrfAF.new('red', %w(ipv4 unicast))
133
+ v4 = VrfAF.new('blue', %w(ipv4 unicast))
134
+ v5 = VrfAF.new('red', %w(ipv6 unicast))
135
+ assert_equal(2, VrfAF.afs['cyan'].keys.count)
136
+ assert_equal(2, VrfAF.afs['red'].keys.count)
137
+ assert_equal(1, VrfAF.afs['blue'].keys.count)
138
+
139
+ v1.destroy
140
+ v5.destroy
141
+ assert_equal(1, VrfAF.afs['cyan'].keys.count)
142
+ assert_equal(1, VrfAF.afs['red'].keys.count)
143
+ assert_equal(1, VrfAF.afs['blue'].keys.count)
144
+
145
+ v2.destroy
146
+ v3.destroy
147
+ v4.destroy
148
+ assert_equal(0, VrfAF.afs['cyan'].keys.count)
149
+ assert_equal(0, VrfAF.afs['red'].keys.count)
150
+ assert_equal(0, VrfAF.afs['blue'].keys.count)
151
+ end
152
+
153
+ def test_route_target
154
+ [%w(ipv4 unicast), %w(ipv6 unicast)].each { |af| route_target(af) }
155
+ end
156
+
157
+ def route_target(af)
158
+ # Common tester for route-target properties. Tests evpn and non-evpn.
159
+ # route_target_both_auto
160
+ # route_target_both_auto_evpn
161
+ # route_target_export
162
+ # route_target_export_evpn
163
+ # route_target_import
164
+ # route_target_import_evpn
165
+ vrf = 'red'
166
+ v = VrfAF.new(vrf, af)
167
+
168
+ # test route target both auto and route target both auto evpn
169
+ refute(v.default_route_target_both_auto,
170
+ 'default value for route target both auto should be false')
171
+
172
+ refute(v.default_route_target_both_auto_evpn,
173
+ 'default value for route target both auto evpn should be false')
174
+
175
+ v.route_target_both_auto = true
176
+ assert(v.route_target_both_auto, "vrf context #{vrf} af #{af}: "\
177
+ 'v route-target both auto should be enabled')
178
+
179
+ v.route_target_both_auto = false
180
+ refute(v.route_target_both_auto, "vrf context #{vrf} af #{af}: "\
181
+ 'v route-target both auto should be disabled')
182
+
183
+ v.route_target_both_auto_evpn = true
184
+ assert(v.route_target_both_auto_evpn, "vrf context #{vrf} af #{af}: "\
185
+ 'v route-target both auto evpn should be enabled')
186
+
187
+ v.route_target_both_auto_evpn = false
188
+ refute(v.route_target_both_auto_evpn, "vrf context #{vrf} af #{af}: "\
189
+ 'v route-target both auto evpn should be disabled')
190
+
191
+ opts = [:import, :export]
192
+
193
+ # Master list of communities to test against
194
+ master = ['1:1', '2:2', '3:3', '4:5']
195
+
196
+ # Test 1: both/import/export when no commands are present. Each target
197
+ # option will be tested with and without evpn (6 separate types)
198
+ should = master.clone
199
+ route_target_tester(v, af, opts, should, 'Test 1')
200
+
201
+ # Test 2: remove half of the entries
202
+ should = ['1:1', '4:4']
203
+ route_target_tester(v, af, opts, should, 'Test 2')
204
+
205
+ # Test 3: restore the removed entries
206
+ should = master.clone
207
+ route_target_tester(v, af, opts, should, 'Test 3')
208
+
209
+ # Test 4: 'default'
210
+ should = v.default_route_target_import
211
+ route_target_tester(v, af, opts, should, 'Test 4')
212
+ end
213
+
214
+ def route_target_tester(v, af, opts, should, test_id)
215
+ # First configure all four property types
216
+ opts.each do |opt|
217
+ # non-evpn
218
+ v.send("route_target_#{opt}=", should)
219
+ # evpn
220
+ v.send("route_target_#{opt}_evpn=", should)
221
+ end
222
+
223
+ # Now check the results
224
+ opts.each do |opt|
225
+ # non-evpn
226
+ result = v.send("route_target_#{opt}")
227
+ assert_equal(should, result,
228
+ "#{test_id} : #{af} : route_target_#{opt}")
229
+ # evpn
230
+ result = v.send("route_target_#{opt}_evpn")
231
+ assert_equal(should, result,
232
+ "#{test_id} : #{af} : route_target_#{opt}_evpn")
233
+ end
234
+ end
92
235
  end
data/tests/test_vtp.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2015 Cisco and/or its affiliates.
1
+ # Copyright (c) 2014-2016 Cisco and/or its affiliates.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -0,0 +1,214 @@
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/feature'
17
+ require_relative '../lib/cisco_node_utils/vxlan_vtep'
18
+ require_relative '../lib/cisco_node_utils/vdc'
19
+
20
+ include Cisco
21
+
22
+ # TestVxlanGlobal - Minitest for VxlanGlobal node utility
23
+ class TestVxlanVtep < CiscoTestCase
24
+ def setup
25
+ super
26
+ skip('Platform does not support MT-full or MT-lite') unless
27
+ VxlanVtep.mt_full_support || VxlanVtep.mt_lite_support
28
+ end
29
+
30
+ def teardown
31
+ return unless Vdc.vdc_support
32
+ # Reset the vdc module type back to default
33
+ v = Vdc.new('default')
34
+ v.limit_resource_module_type = '' if v.limit_resource_module_type == 'f3'
35
+ end
36
+
37
+ def compatible_interface?
38
+ # MT-full tests require a specific linecard; either because they need a
39
+ # compatible interface or simply to enable the features. Either way
40
+ # we will provide an appropriate interface name if the linecard is present.
41
+ # Example 'show mod' output to match against:
42
+ # '9 12 10/40 Gbps Ethernet Module N7K-F312FQ-25 ok'
43
+ sh_mod = @device.cmd("sh mod | i '^[0-9]+.*N7K-F3'")[/^(\d+)\s.*N7K-F3/]
44
+ slot = sh_mod.nil? ? nil : Regexp.last_match[1]
45
+ skip('Unable to find a compatible interface in chassis') if slot.nil?
46
+
47
+ "ethernet#{slot}/1"
48
+ end
49
+
50
+ def mt_full_env_setup
51
+ skip('Platform does not support MT-full') unless VxlanVtep.mt_full_support
52
+ compatible_interface?
53
+ v = Vdc.new('default')
54
+ v.limit_resource_module_type = 'f3' unless
55
+ v.limit_resource_module_type == 'f3'
56
+ config('no feature nv overlay')
57
+ end
58
+
59
+ def mt_lite_env_setup
60
+ skip('Platform does not support MT-lite') unless VxlanVtep.mt_lite_support
61
+ config('no feature nv overlay')
62
+ config('no feature vn-segment-vlan-based')
63
+ end
64
+
65
+ def test_create_destroy_one
66
+ # VxlanVtep.new() will enable 'feature nv overlay'
67
+ mt_full_env_setup if VxlanVtep.mt_full_support
68
+ mt_lite_env_setup if VxlanVtep.mt_lite_support
69
+
70
+ id = 'nve1'
71
+ vtep = VxlanVtep.new(id)
72
+ @default_show_command = "show running | i 'interface #{id}'"
73
+
74
+ assert_show_match(pattern: /^interface #{id}$/,
75
+ msg: "failed to create interface #{id}")
76
+
77
+ assert_includes(Cisco::VxlanVtep.vteps, id)
78
+ assert_equal(Cisco::VxlanVtep.vteps[id], vtep)
79
+
80
+ vtep.destroy
81
+ refute_show_match(pattern: /^interface #{id}$/,
82
+ msg: "failed to destroy interface #{id}")
83
+ end
84
+
85
+ def test_mt_full_create_destroy_multiple
86
+ if VxlanVtep.mt_full_support
87
+ mt_full_env_setup
88
+ else
89
+ skip('Platform does not support MT-full')
90
+ end
91
+
92
+ id1 = 'nve1'
93
+ id2 = 'nve2'
94
+ id3 = 'nve3'
95
+ id4 = 'nve4'
96
+ vtep1 = VxlanVtep.new(id1)
97
+ vtep2 = VxlanVtep.new(id2)
98
+ vtep3 = VxlanVtep.new(id3)
99
+ vtep4 = VxlanVtep.new(id4)
100
+
101
+ [id1, id2, id3, id4].each do |id|
102
+ assert_show_match(command: "show running | i 'interface #{id}'",
103
+ pattern: /^interface #{id}$/,
104
+ msg: "failed to create interface #{id}")
105
+ assert_includes(Cisco::VxlanVtep.vteps, id)
106
+ end
107
+
108
+ vtep1.destroy
109
+ vtep2.destroy
110
+ vtep3.destroy
111
+ vtep4.destroy
112
+
113
+ [id1, id2, id3, id4].each do |id|
114
+ refute_show_match(command: "show running | i 'interface #{id}'",
115
+ pattern: /^interface #{id}$/,
116
+ msg: "failed to create interface #{id}")
117
+ end
118
+ end
119
+
120
+ def test_create_negative
121
+ # MT-lite supports a single nve int, MT-full supports 4.
122
+ mt_full_env_setup if VxlanVtep.mt_full_support
123
+ mt_lite_env_setup if VxlanVtep.mt_lite_support
124
+ if VxlanVtep.mt_lite_support
125
+ VxlanVtep.new('nve1')
126
+ negative_id = 'nve2'
127
+
128
+ elsif VxlanVtep.mt_full_support
129
+ mt_full_env_setup
130
+ (1..4).each { |n| VxlanVtep.new("nve#{n}") }
131
+ negative_id = 'nve5'
132
+ end
133
+
134
+ assert_raises(CliError) do
135
+ VxlanVtep.new(negative_id)
136
+ end
137
+ end
138
+
139
+ def test_description
140
+ mt_full_env_setup if VxlanVtep.mt_full_support
141
+ mt_lite_env_setup if VxlanVtep.mt_lite_support
142
+
143
+ vtep = VxlanVtep.new('nve1')
144
+
145
+ # Set description to non-default value and verify
146
+ desc = 'vxlan interface'
147
+ vtep.description = desc
148
+ assert_equal(desc, vtep.description)
149
+
150
+ # Set description to default value and verify
151
+ desc = vtep.default_description
152
+ vtep.description = desc
153
+ assert_equal(desc, vtep.description)
154
+ end
155
+
156
+ def test_host_reachability
157
+ skip("Test not supported on #{node.product_id}") if
158
+ cmd_ref.lookup('vxlan_vtep', 'host_reachability').default_value.nil?
159
+ mt_full_env_setup if VxlanVtep.mt_full_support
160
+ mt_lite_env_setup if VxlanVtep.mt_lite_support
161
+
162
+ vtep = VxlanVtep.new('nve1')
163
+
164
+ vtep.host_reachability = 'flood'
165
+ assert_equal('flood', vtep.host_reachability)
166
+ vtep.host_reachability = 'evpn'
167
+ assert_equal('evpn', vtep.host_reachability)
168
+
169
+ # Set value back to flood, currently evpn.
170
+ vtep.host_reachability = 'flood'
171
+ assert_equal('flood', vtep.host_reachability)
172
+ end
173
+
174
+ def test_shutdown
175
+ mt_full_env_setup if VxlanVtep.mt_full_support
176
+ mt_lite_env_setup if VxlanVtep.mt_lite_support
177
+
178
+ vtep = VxlanVtep.new('nve1')
179
+
180
+ vtep.shutdown = true
181
+ assert(vtep.shutdown, 'source_interface is not shutdown')
182
+
183
+ vtep.shutdown = false
184
+ refute(vtep.shutdown, 'source_interface is shutdown')
185
+
186
+ vtep.shutdown = vtep.default_shutdown
187
+ assert(vtep.shutdown, 'source_interface is not shutdown')
188
+ end
189
+
190
+ def test_source_interface
191
+ mt_full_env_setup if VxlanVtep.mt_full_support
192
+ mt_lite_env_setup if VxlanVtep.mt_lite_support
193
+
194
+ vtep = VxlanVtep.new('nve1')
195
+
196
+ # Set source_interface to non-default value
197
+ val = 'loopback55'
198
+ vtep.source_interface = val
199
+ assert_equal(val, vtep.source_interface)
200
+
201
+ # Change source_interface when nve interface is in a 'no shutdown' state
202
+ vtep.shutdown = false
203
+ val = 'loopback77'
204
+ vtep.source_interface = val
205
+ assert_equal(val, vtep.source_interface)
206
+ # source_interface should 'no shutdown' after the change.
207
+ refute(vtep.shutdown, 'source_interface is shutdown')
208
+
209
+ # Set source_interface to default value
210
+ val = vtep.default_source_interface
211
+ vtep.source_interface = val
212
+ assert_equal(val, vtep.source_interface)
213
+ end
214
+ end