cisco_node_utils 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +66 -0
  4. data/Gemfile +1 -0
  5. data/README.md +44 -43
  6. data/bin/.rubocop.yml +18 -0
  7. data/bin/show_running_yang.rb +233 -0
  8. data/cisco_node_utils.gemspec +1 -1
  9. data/docs/README-maintainers.md +1 -0
  10. data/docs/README-utilities.md +14 -0
  11. data/lib/.rubocop.yml +1 -1
  12. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +8 -3
  13. data/lib/cisco_node_utils/aaa_authorization_service.rb +6 -0
  14. data/lib/cisco_node_utils/bfd_global.rb +300 -0
  15. data/lib/cisco_node_utils/bgp.rb +6 -4
  16. data/lib/cisco_node_utils/bgp_af.rb +2 -0
  17. data/lib/cisco_node_utils/bgp_neighbor.rb +14 -0
  18. data/lib/cisco_node_utils/bgp_neighbor_af.rb +4 -1
  19. data/lib/cisco_node_utils/cisco_cmn_utils.rb +126 -0
  20. data/lib/cisco_node_utils/client/client.rb +6 -2
  21. data/lib/cisco_node_utils/client/grpc/client.rb +120 -36
  22. data/lib/cisco_node_utils/client/nxapi/client.rb +6 -2
  23. data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +118 -0
  24. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +14 -0
  25. data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
  26. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +7 -7
  27. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +7 -0
  28. data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +125 -0
  29. data/lib/cisco_node_utils/cmd_ref/feature.yaml +10 -0
  30. data/lib/cisco_node_utils/cmd_ref/interface.yaml +141 -49
  31. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +44 -0
  32. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +6 -0
  33. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +6 -0
  34. data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
  35. data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
  36. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +0 -3
  37. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +3 -3
  38. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +39 -15
  39. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +43 -21
  40. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +48 -19
  41. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +0 -0
  42. data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +30 -0
  43. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +18 -6
  44. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +4 -0
  45. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +1 -0
  46. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +23 -10
  47. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +8 -2
  48. data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
  49. data/lib/cisco_node_utils/cmd_ref/yum.yaml +10 -1
  50. data/lib/cisco_node_utils/constants.rb +8 -1
  51. data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
  52. data/lib/cisco_node_utils/exceptions.rb +29 -0
  53. data/lib/cisco_node_utils/feature.rb +28 -0
  54. data/lib/cisco_node_utils/interface.rb +493 -402
  55. data/lib/cisco_node_utils/interface_DEPRECATED.rb +513 -0
  56. data/lib/cisco_node_utils/interface_ospf.rb +126 -0
  57. data/lib/cisco_node_utils/interface_portchannel.rb +16 -0
  58. data/lib/cisco_node_utils/logger.rb +3 -0
  59. data/lib/cisco_node_utils/node.rb +29 -1
  60. data/lib/cisco_node_utils/overlay_global.rb +1 -12
  61. data/lib/cisco_node_utils/pim.rb +1 -0
  62. data/lib/cisco_node_utils/pim_group_list.rb +1 -0
  63. data/lib/cisco_node_utils/pim_rp_address.rb +1 -0
  64. data/lib/cisco_node_utils/platform.rb +9 -2
  65. data/lib/cisco_node_utils/router_ospf.rb +1 -1
  66. data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
  67. data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
  68. data/lib/cisco_node_utils/router_ospf_vrf.rb +17 -0
  69. data/lib/cisco_node_utils/snmp_notification_receiver.rb +27 -9
  70. data/lib/cisco_node_utils/snmpcommunity.rb +34 -8
  71. data/lib/cisco_node_utils/snmpserver.rb +4 -4
  72. data/lib/cisco_node_utils/snmpuser.rb +0 -0
  73. data/lib/cisco_node_utils/tacacs_global.rb +102 -0
  74. data/lib/cisco_node_utils/tacacs_server.rb +8 -7
  75. data/lib/cisco_node_utils/vdc.rb +25 -7
  76. data/lib/cisco_node_utils/version.rb +1 -1
  77. data/lib/cisco_node_utils/vlan.rb +30 -56
  78. data/lib/cisco_node_utils/vlan_DEPRECATED.rb +108 -0
  79. data/lib/cisco_node_utils/yang.rb +160 -0
  80. data/lib/cisco_node_utils/yum.rb +25 -32
  81. data/tests/.rubocop.yml +3 -0
  82. data/tests/ciscotest.rb +136 -19
  83. data/tests/cmd_config_invalid.yaml +1 -1
  84. data/tests/noop.rb +7 -0
  85. data/tests/tacacs_server.yaml.example +6 -0
  86. data/tests/test_aaa_authentication_login.rb +24 -1
  87. data/tests/test_aaa_authentication_login_service.rb +9 -16
  88. data/tests/test_aaa_authorization_service.rb +111 -84
  89. data/tests/test_bfd_global.rb +278 -0
  90. data/tests/test_bgp_neighbor.rb +20 -0
  91. data/tests/test_bridge_domain_vni.rb +2 -9
  92. data/tests/test_cmn_utils.rb +76 -0
  93. data/tests/test_dhcp_relay_global.rb +284 -0
  94. data/tests/test_dns_domain.rb +4 -4
  95. data/tests/test_domain_name.rb +2 -2
  96. data/tests/test_encapsulation.rb +2 -4
  97. data/tests/test_evpn_vni.rb +14 -7
  98. data/tests/test_fabricpath_global.rb +12 -13
  99. data/tests/test_feature.rb +35 -17
  100. data/tests/test_interface.rb +352 -127
  101. data/tests/test_interface_bdi.rb +2 -2
  102. data/tests/test_interface_channel_group.rb +1 -1
  103. data/tests/test_interface_ospf.rb +153 -23
  104. data/tests/test_interface_portchannel.rb +15 -6
  105. data/tests/test_interface_private_vlan.rb +200 -576
  106. data/tests/test_interface_svi.rb +5 -52
  107. data/tests/test_interface_switchport.rb +80 -240
  108. data/tests/test_itd_device_group.rb +2 -2
  109. data/tests/test_itd_device_group_node.rb +2 -2
  110. data/tests/test_itd_service.rb +1 -1
  111. data/tests/test_name_server.rb +3 -3
  112. data/tests/test_node_ext.rb +15 -17
  113. data/tests/test_ntp_config.rb +1 -1
  114. data/tests/test_ntp_server.rb +3 -3
  115. data/tests/test_nxapi.rb +1 -0
  116. data/tests/test_overlay_global.rb +15 -19
  117. data/tests/test_pim.rb +5 -5
  118. data/tests/test_pim_group_list.rb +1 -37
  119. data/tests/test_pim_rp_address.rb +1 -1
  120. data/tests/test_platform.rb +9 -11
  121. data/tests/test_portchannel_global.rb +43 -3
  122. data/tests/test_radius_server.rb +1 -1
  123. data/tests/test_radius_server_group.rb +1 -1
  124. data/tests/test_router_bgp.rb +17 -30
  125. data/tests/test_router_ospf_area.rb +433 -0
  126. data/tests/test_router_ospf_area_vlink.rb +298 -0
  127. data/tests/test_router_ospf_vrf.rb +17 -0
  128. data/tests/test_snmp_notification_receiver.rb +11 -11
  129. data/tests/test_snmpcommunity.rb +177 -69
  130. data/tests/test_snmpgroup.rb +7 -7
  131. data/tests/test_snmpserver.rb +164 -253
  132. data/tests/test_snmpuser.rb +73 -69
  133. data/tests/test_stp_global.rb +15 -15
  134. data/tests/test_syslog_settings.rb +1 -1
  135. data/tests/test_tacacs_global.rb +80 -0
  136. data/tests/test_tacacs_server.rb +129 -51
  137. data/tests/test_tacacs_server_group.rb +3 -29
  138. data/tests/test_tacacs_server_host.rb +24 -27
  139. data/tests/test_vlan.rb +57 -59
  140. data/tests/test_vlan_private.rb +271 -284
  141. data/tests/test_vpc.rb +10 -4
  142. data/tests/test_vrf.rb +2 -0
  143. data/tests/test_vrf_af.rb +2 -5
  144. data/tests/test_vtp.rb +5 -2
  145. data/tests/test_vxlan_vtep.rb +20 -44
  146. data/tests/test_vxlan_vtep_vni.rb +23 -16
  147. data/tests/test_yang.rb +369 -0
  148. data/tests/test_yum.rb +34 -42
  149. data/tests/yum_package.yaml +35 -0
  150. metadata +31 -4
  151. data/tests/test_vlan_mt_full.rb +0 -85
@@ -0,0 +1,278 @@
1
+ # Copyright (c) 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/bfd_global'
17
+
18
+ include Cisco
19
+ # TestBfdGlobal - Minitest for general functionality
20
+ # of the BfdGlobal class.
21
+ class TestBfdGlobal < CiscoTestCase
22
+ @skip_unless_supported = 'bfd_global'
23
+ # Tests
24
+
25
+ def setup
26
+ super
27
+ config 'no feature bfd'
28
+ end
29
+
30
+ def teardown
31
+ config 'no feature bfd'
32
+ super
33
+ end
34
+
35
+ def test_create_destroy
36
+ # create
37
+ bg = BfdGlobal.new
38
+ assert_equal(true, Feature.bfd_enabled?)
39
+
40
+ # destroy
41
+ bg.destroy
42
+ [:interval,
43
+ :ipv4_interval,
44
+ :ipv6_interval,
45
+ :fabricpath_interval,
46
+ :echo_interface,
47
+ :echo_rx_interval,
48
+ :ipv4_echo_rx_interval,
49
+ :ipv6_echo_rx_interval,
50
+ :fabricpath_vlan,
51
+ :slow_timer,
52
+ :ipv4_slow_timer,
53
+ :ipv6_slow_timer,
54
+ :fabricpath_slow_timer,
55
+ :startup_timer,
56
+ ].each do |prop|
57
+ assert_equal(bg.send("default_#{prop}"), bg.send("#{prop}")) if
58
+ bg.send("#{prop}")
59
+ end
60
+ end
61
+
62
+ def test_echo_interface
63
+ bg = BfdGlobal.new
64
+ config 'interface loopback 10'
65
+ default = bg.default_echo_interface
66
+ assert_equal(default, bg.echo_interface)
67
+ bg.echo_interface = 'loopback10'
68
+ assert_equal('loopback10', bg.echo_interface)
69
+ bg.echo_interface = default
70
+ assert_equal(default, bg.echo_interface)
71
+ config 'no interface loopback 10'
72
+ end
73
+
74
+ def test_fabricpath_vlan
75
+ bg = BfdGlobal.new
76
+ if validate_property_excluded?('bfd_global', 'fabricpath_vlan')
77
+ assert_nil(bg.fabricpath_vlan)
78
+ assert_raises(Cisco::UnsupportedError) do
79
+ bg.fabricpath_vlan = 100
80
+ end
81
+ return
82
+ end
83
+ assert_equal(bg.default_fabricpath_vlan, bg.fabricpath_vlan)
84
+ bg.fabricpath_vlan = 100
85
+ assert_equal(100, bg.fabricpath_vlan)
86
+ bg.fabricpath_vlan = bg.default_fabricpath_vlan
87
+ assert_equal(bg.default_fabricpath_vlan, bg.fabricpath_vlan)
88
+ end
89
+
90
+ def test_startup_timer
91
+ bg = BfdGlobal.new
92
+ if validate_property_excluded?('bfd_global', 'startup_timer')
93
+ assert_nil(bg.startup_timer)
94
+ assert_raises(Cisco::UnsupportedError) do
95
+ bg.startup_timer = 25
96
+ end
97
+ return
98
+ end
99
+ assert_equal(bg.default_startup_timer, bg.startup_timer)
100
+ bg.startup_timer = 25
101
+ assert_equal(25, bg.startup_timer)
102
+ bg.startup_timer = bg.default_startup_timer
103
+ assert_equal(bg.default_startup_timer, bg.startup_timer)
104
+ end
105
+
106
+ def test_echo_rx_interval
107
+ bg = BfdGlobal.new
108
+ if validate_property_excluded?('bfd_global', 'echo_rx_interval')
109
+ assert_nil(bg.echo_rx_interval)
110
+ assert_raises(Cisco::UnsupportedError) do
111
+ bg.echo_rx_interval = 300
112
+ end
113
+ return
114
+ end
115
+ assert_equal(bg.default_echo_rx_interval, bg.echo_rx_interval)
116
+ bg.echo_rx_interval = 300
117
+ assert_equal(300, bg.echo_rx_interval)
118
+ bg.echo_rx_interval = bg.default_echo_rx_interval
119
+ assert_equal(bg.default_echo_rx_interval, bg.echo_rx_interval)
120
+ end
121
+
122
+ def test_ipv4_echo_rx_interval
123
+ bg = BfdGlobal.new
124
+ if validate_property_excluded?('bfd_global', 'ipv4_echo_rx_interval')
125
+ assert_nil(bg.ipv4_echo_rx_interval)
126
+ assert_raises(Cisco::UnsupportedError) do
127
+ bg.ipv4_echo_rx_interval = 100
128
+ end
129
+ return
130
+ end
131
+ assert_equal(bg.default_ipv4_echo_rx_interval, bg.ipv4_echo_rx_interval)
132
+ bg.ipv4_echo_rx_interval = 100
133
+ assert_equal(100, bg.ipv4_echo_rx_interval)
134
+ bg.ipv4_echo_rx_interval = bg.default_ipv4_echo_rx_interval
135
+ assert_equal(bg.default_ipv4_echo_rx_interval, bg.ipv4_echo_rx_interval)
136
+ end
137
+
138
+ def test_ipv6_echo_rx_interval
139
+ bg = BfdGlobal.new
140
+ if validate_property_excluded?('bfd_global', 'ipv6_echo_rx_interval')
141
+ assert_nil(bg.ipv6_echo_rx_interval)
142
+ assert_raises(Cisco::UnsupportedError) do
143
+ bg.ipv6_echo_rx_interval = 100
144
+ end
145
+ return
146
+ end
147
+ assert_equal(bg.default_ipv6_echo_rx_interval, bg.ipv6_echo_rx_interval)
148
+ bg.ipv6_echo_rx_interval = 100
149
+ assert_equal(100, bg.ipv6_echo_rx_interval)
150
+ bg.ipv6_echo_rx_interval = bg.default_ipv6_echo_rx_interval
151
+ assert_equal(bg.default_ipv6_echo_rx_interval, bg.ipv6_echo_rx_interval)
152
+ end
153
+
154
+ def test_slow_timer
155
+ bg = BfdGlobal.new
156
+ assert_equal(bg.default_slow_timer, bg.slow_timer)
157
+ bg.slow_timer = 5000
158
+ assert_equal(5000, bg.slow_timer)
159
+ bg.slow_timer = bg.default_slow_timer
160
+ assert_equal(bg.default_slow_timer, bg.slow_timer)
161
+ end
162
+
163
+ def test_ipv4_slow_timer
164
+ bg = BfdGlobal.new
165
+ if validate_property_excluded?('bfd_global', 'ipv4_slow_timer')
166
+ assert_nil(bg.ipv4_slow_timer)
167
+ assert_raises(Cisco::UnsupportedError) do
168
+ bg.ipv4_slow_timer = 10_000
169
+ end
170
+ return
171
+ end
172
+ assert_equal(bg.default_ipv4_slow_timer, bg.ipv4_slow_timer)
173
+ bg.ipv4_slow_timer = 10_000
174
+ assert_equal(10_000, bg.ipv4_slow_timer)
175
+ bg.ipv4_slow_timer = bg.default_ipv4_slow_timer
176
+ assert_equal(bg.default_ipv4_slow_timer, bg.ipv4_slow_timer)
177
+ end
178
+
179
+ def test_ipv6_slow_timer
180
+ bg = BfdGlobal.new
181
+ if validate_property_excluded?('bfd_global', 'ipv6_slow_timer')
182
+ assert_nil(bg.ipv6_slow_timer)
183
+ assert_raises(Cisco::UnsupportedError) do
184
+ bg.ipv6_slow_timer = 25_000
185
+ end
186
+ return
187
+ end
188
+ assert_equal(bg.default_ipv6_slow_timer, bg.ipv6_slow_timer)
189
+ bg.ipv6_slow_timer = 25_000
190
+ assert_equal(25_000, bg.ipv6_slow_timer)
191
+ bg.ipv6_slow_timer = bg.default_ipv6_slow_timer
192
+ assert_equal(bg.default_ipv6_slow_timer, bg.ipv6_slow_timer)
193
+ end
194
+
195
+ def test_fabricpath_slow_timer
196
+ bg = BfdGlobal.new
197
+ if validate_property_excluded?('bfd_global', 'fabricpath_slow_timer')
198
+ assert_nil(bg.fabricpath_slow_timer)
199
+ assert_raises(Cisco::UnsupportedError) do
200
+ bg.fabricpath_slow_timer = 15_000
201
+ end
202
+ return
203
+ end
204
+ assert_equal(bg.default_fabricpath_slow_timer, bg.fabricpath_slow_timer)
205
+ bg.fabricpath_slow_timer = 15_000
206
+ assert_equal(15_000, bg.fabricpath_slow_timer)
207
+ bg.fabricpath_slow_timer = bg.default_fabricpath_slow_timer
208
+ assert_equal(bg.default_fabricpath_slow_timer, bg.fabricpath_slow_timer)
209
+ end
210
+
211
+ def test_interval
212
+ bg = BfdGlobal.new
213
+ arr = %w(100 100 25)
214
+ if validate_property_excluded?('bfd_global', 'interval')
215
+ assert_nil(bg.interval)
216
+ assert_raises(Cisco::UnsupportedError) do
217
+ bg.interval = arr
218
+ end
219
+ return
220
+ end
221
+ assert_equal(bg.default_interval, bg.interval)
222
+ bg.interval = arr
223
+ assert_equal(arr, bg.interval)
224
+ bg.interval = bg.default_interval
225
+ assert_equal(bg.default_interval, bg.interval)
226
+ end
227
+
228
+ def test_ipv4_interval
229
+ bg = BfdGlobal.new
230
+ arr = %w(200 200 50)
231
+ if validate_property_excluded?('bfd_global', 'ipv4_interval')
232
+ assert_nil(bg.ipv4_interval)
233
+ assert_raises(Cisco::UnsupportedError) do
234
+ bg.ipv4_interval = arr
235
+ end
236
+ return
237
+ end
238
+ assert_equal(bg.default_ipv4_interval, bg.ipv4_interval)
239
+ bg.ipv4_interval = arr
240
+ assert_equal(arr, bg.ipv4_interval)
241
+ bg.ipv4_interval = bg.default_ipv4_interval
242
+ assert_equal(bg.default_ipv4_interval, bg.ipv4_interval)
243
+ end
244
+
245
+ def test_ipv6_interval
246
+ bg = BfdGlobal.new
247
+ arr = %w(500 500 30)
248
+ if validate_property_excluded?('bfd_global', 'ipv6_interval')
249
+ assert_nil(bg.ipv6_interval)
250
+ assert_raises(Cisco::UnsupportedError) do
251
+ bg.ipv6_interval = arr
252
+ end
253
+ return
254
+ end
255
+ assert_equal(bg.default_ipv6_interval, bg.ipv6_interval)
256
+ bg.ipv6_interval = arr
257
+ assert_equal(arr, bg.ipv6_interval)
258
+ bg.ipv6_interval = bg.default_ipv6_interval
259
+ assert_equal(bg.default_ipv6_interval, bg.ipv6_interval)
260
+ end
261
+
262
+ def test_fabricpath_interval
263
+ bg = BfdGlobal.new
264
+ arr = %w(750 350 45)
265
+ if validate_property_excluded?('bfd_global', 'fabricpath_interval')
266
+ assert_nil(bg.fabricpath_interval)
267
+ assert_raises(Cisco::UnsupportedError) do
268
+ bg.fabricpath_interval = arr
269
+ end
270
+ return
271
+ end
272
+ assert_equal(bg.default_fabricpath_interval, bg.fabricpath_interval)
273
+ bg.fabricpath_interval = arr
274
+ assert_equal(arr, bg.fabricpath_interval)
275
+ bg.fabricpath_interval = bg.default_fabricpath_interval
276
+ assert_equal(bg.default_fabricpath_interval, bg.fabricpath_interval)
277
+ end
278
+ end
@@ -265,6 +265,26 @@ class TestBgpNeighbor < CiscoTestCase
265
265
  end
266
266
  end
267
267
 
268
+ def test_bfd
269
+ %w(default test_vrf).each do |vrf|
270
+ neighbor = create_neighbor(vrf)
271
+ if validate_property_excluded?('bgp_neighbor', 'bfd')
272
+ assert_nil(neighbor.bfd)
273
+ assert_nil(neighbor.default_bfd)
274
+ assert_raises(Cisco::UnsupportedError) do
275
+ neighbor.bfd = true
276
+ end
277
+ else
278
+ check = [false, true, neighbor.default_bfd]
279
+ check.each do |value|
280
+ neighbor.bfd = value
281
+ assert_equal(value, neighbor.bfd)
282
+ end
283
+ end
284
+ neighbor.destroy
285
+ end
286
+ end
287
+
268
288
  def test_ebgp_multihop
269
289
  %w(default test_vrf).each do |vrf|
270
290
  neighbor = create_neighbor(vrf)
@@ -24,7 +24,6 @@ class TestBridgeDomainVNI < CiscoTestCase
24
24
 
25
25
  def cleanup
26
26
  remove_all_vlans
27
- remove_all_bridge_domains
28
27
  config_no_warn('no feature vni')
29
28
  BridgeDomainVNI.range_bds.each do |_bd, obj|
30
29
  obj.destroy
@@ -33,21 +32,18 @@ class TestBridgeDomainVNI < CiscoTestCase
33
32
 
34
33
  def setup
35
34
  super
35
+ vdc_limit_f3_no_intf_needed(:set)
36
36
  cleanup unless @@cleaned
37
37
  @@cleaned = true # rubocop:disable Style/ClassVars
38
- mt_full_interface?
39
- v = Vdc.new('default')
40
- v.limit_resource_module_type = 'f3' unless
41
- v.limit_resource_module_type == 'f3'
42
38
  end
43
39
 
44
40
  def teardown
45
41
  cleanup
42
+ vdc_limit_f3_no_intf_needed(:clear) if first_or_last_teardown
46
43
  super
47
44
  end
48
45
 
49
46
  def test_single_bd_member_vni
50
- mt_full_interface?
51
47
  bd = BridgeDomainVNI.new('100')
52
48
  assert_equal(bd.default_member_vni, bd.member_vni,
53
49
  'Error: Bridge-Domain is mapped to different vnis')
@@ -65,7 +61,6 @@ class TestBridgeDomainVNI < CiscoTestCase
65
61
  end
66
62
 
67
63
  def test_multiple_bd_member_vni
68
- mt_full_interface?
69
64
  bd = BridgeDomainVNI.new('100-110, 150, 170-171 ')
70
65
  assert_equal(bd.default_member_vni, bd.member_vni,
71
66
  'Error: Bridge-Domain is mapped to different vnis')
@@ -83,7 +78,6 @@ class TestBridgeDomainVNI < CiscoTestCase
83
78
  end
84
79
 
85
80
  def test_member_vni_empty_assign
86
- mt_full_interface?
87
81
  bd = BridgeDomainVNI.new(100)
88
82
  bd.member_vni = ''
89
83
  assert_equal(bd.default_member_vni, bd.member_vni,
@@ -92,7 +86,6 @@ class TestBridgeDomainVNI < CiscoTestCase
92
86
  end
93
87
 
94
88
  def test_overwrite_bd_member_vni
95
- mt_full_interface?
96
89
  bd = BridgeDomainVNI.new('100-110')
97
90
  assert_equal(bd.default_member_vni, bd.member_vni,
98
91
  'Error: Bridge-Domain is mapped to different vnis')
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ # cisco_cmn_utils Unit Tests
3
+ #
4
+ # Chris Van Heuveln, May, 2016
5
+ #
6
+ # Copyright (c) 2016 Cisco and/or its affiliates.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require_relative 'ciscotest'
21
+ require_relative '../lib/cisco_node_utils/cisco_cmn_utils'
22
+
23
+ # Test utility methods in cisco_cmn_utils
24
+ class TestCmnUtils < CiscoTestCase
25
+ #
26
+ # TBD: Add tests for *all* methods in cisco_cmn_utils
27
+ #
28
+ def test_dash_range_to_ruby_range
29
+ expected = [2..5, 9..9, 4..6]
30
+
31
+ str_input = '2-5, 9, 4-6'
32
+ assert_equal(expected, Utils.dash_range_to_ruby_range(str_input))
33
+
34
+ arr_input = ['2-5', '9', '4-6']
35
+ assert_equal(expected, Utils.dash_range_to_ruby_range(arr_input))
36
+ end
37
+
38
+ def test_ruby_range_to_dash_range
39
+ str_expected = '2-5, 9, 4-6'
40
+ arr_expected = ['2-5', '9', '4-6']
41
+
42
+ input1 = [2..5, 9..9, 4..6]
43
+ input2 = input1.clone
44
+ assert_equal(str_expected, Utils.ruby_range_to_dash_range(input1, :string))
45
+ assert_equal(arr_expected, Utils.ruby_range_to_dash_range(input2, :array))
46
+ end
47
+
48
+ def test_dash_range_to_elements
49
+ expected = %w(2 3 4 5 6 9)
50
+
51
+ str_input = '2-5, 9, 4-6'
52
+ str_arr_input = ['2-5, 9, 4-6']
53
+ arr_input = str_input.split(', ')
54
+
55
+ assert_equal(expected, Utils.dash_range_to_elements(str_input))
56
+ assert_equal(expected, Utils.dash_range_to_elements(str_arr_input))
57
+ assert_equal(expected, Utils.dash_range_to_elements(arr_input))
58
+ end
59
+
60
+ def test_merge_range
61
+ expected = [2..6, 9..9]
62
+ input = [2..5, 9..9, 4..6]
63
+ assert_equal(expected, Utils.merge_range(input))
64
+ end
65
+
66
+ def test_normalize_range_array
67
+ expected = ['2-6', '9']
68
+
69
+ str_input = '2-5, 9, 4-6'
70
+ str_arr_input = ['2-5, 9, 4-6']
71
+ arr_input = str_input.split(', ')
72
+ assert_equal(expected, Utils.normalize_range_array(str_input))
73
+ assert_equal(expected, Utils.normalize_range_array(str_arr_input))
74
+ assert_equal(expected, Utils.normalize_range_array(arr_input))
75
+ end
76
+ end
@@ -0,0 +1,284 @@
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/dhcp_relay_global'
17
+
18
+ include Cisco
19
+ # TestDhcpRelayGlobal - Minitest for general functionality
20
+ # of the DhcpRelayGlobal class.
21
+ class TestDhcpRelayGlobal < CiscoTestCase
22
+ @skip_unless_supported = 'dhcp_relay_global'
23
+ DEFAULT_NAME = 'default'
24
+
25
+ # Tests
26
+
27
+ def setup
28
+ super
29
+ config_no_warn('no feature dhcp')
30
+ end
31
+
32
+ def teardown
33
+ config_no_warn('no feature dhcp') if first_or_last_teardown
34
+ super
35
+ end
36
+
37
+ def create_dhcp_relay_global
38
+ DhcpRelayGlobal.new
39
+ end
40
+
41
+ def test_collection_empty
42
+ drg = DhcpRelayGlobal.globals
43
+ assert_empty(drg)
44
+ end
45
+
46
+ def test_destroy
47
+ drg = create_dhcp_relay_global
48
+ assert_equal(true, Feature.dhcp_enabled?)
49
+
50
+ drg.destroy
51
+ [:ipv4_information_option,
52
+ :ipv4_information_option_trust,
53
+ :ipv4_information_option_vpn,
54
+ :ipv4_information_trust_all,
55
+ :ipv4_relay,
56
+ :ipv4_smart_relay,
57
+ :ipv4_src_addr_hsrp,
58
+ :ipv4_src_intf,
59
+ :ipv4_sub_option_circuit_id_custom,
60
+ :ipv4_sub_option_circuit_id_string,
61
+ :ipv4_sub_option_cisco,
62
+ :ipv6_option_cisco,
63
+ :ipv6_option_vpn,
64
+ :ipv6_relay,
65
+ :ipv6_src_intf,
66
+ ].each do |prop|
67
+ assert_equal(drg.send("default_#{prop}"), drg.send("#{prop}")) if
68
+ drg.send("#{prop}")
69
+ end
70
+ end
71
+
72
+ def test_ipv4_information_option
73
+ drg = create_dhcp_relay_global
74
+ assert_equal(drg.default_ipv4_information_option, drg.ipv4_information_option)
75
+ drg.ipv4_information_option = true
76
+ assert_equal(true, drg.ipv4_information_option)
77
+ drg.ipv4_information_option = drg.default_ipv4_information_option
78
+ assert_equal(drg.default_ipv4_information_option, drg.ipv4_information_option)
79
+ end
80
+
81
+ def test_ipv4_information_option_trust
82
+ drg = create_dhcp_relay_global
83
+ if validate_property_excluded?('dhcp_relay_global',
84
+ 'ipv4_information_option_trust')
85
+ assert_nil(drg.ipv4_information_option_trust)
86
+ assert_raises(Cisco::UnsupportedError) do
87
+ drg.ipv4_information_option_trust = true
88
+ end
89
+ return
90
+ end
91
+ assert_equal(drg.default_ipv4_information_option_trust,
92
+ drg.ipv4_information_option_trust)
93
+ drg.ipv4_information_option_trust = true
94
+ assert_equal(true, drg.ipv4_information_option_trust)
95
+ drg.ipv4_information_option_trust = drg.default_ipv4_information_option_trust
96
+ assert_equal(drg.default_ipv4_information_option_trust,
97
+ drg.ipv4_information_option_trust)
98
+ end
99
+
100
+ def test_ipv4_information_option_vpn
101
+ drg = create_dhcp_relay_global
102
+ assert_equal(drg.default_ipv4_information_option_vpn,
103
+ drg.ipv4_information_option_vpn)
104
+ drg.ipv4_information_option_vpn = true
105
+ assert_equal(true, drg.ipv4_information_option_vpn)
106
+ drg.ipv4_information_option_vpn = drg.default_ipv4_information_option_vpn
107
+ assert_equal(drg.default_ipv4_information_option_vpn,
108
+ drg.ipv4_information_option_vpn)
109
+ end
110
+
111
+ def test_ipv4_information_trust_all
112
+ drg = create_dhcp_relay_global
113
+ if validate_property_excluded?('dhcp_relay_global',
114
+ 'ipv4_information_trust_all')
115
+ assert_nil(drg.ipv4_information_trust_all)
116
+ assert_raises(Cisco::UnsupportedError) do
117
+ drg.ipv4_information_trust_all = true
118
+ end
119
+ return
120
+ end
121
+ assert_equal(drg.default_ipv4_information_trust_all,
122
+ drg.ipv4_information_trust_all)
123
+ drg.ipv4_information_trust_all = true
124
+ assert_equal(true, drg.ipv4_information_trust_all)
125
+ drg.ipv4_information_trust_all = drg.default_ipv4_information_trust_all
126
+ assert_equal(drg.default_ipv4_information_trust_all,
127
+ drg.ipv4_information_trust_all)
128
+ end
129
+
130
+ def test_ipv4_relay
131
+ drg = create_dhcp_relay_global
132
+ assert_equal(drg.default_ipv4_relay, drg.ipv4_relay)
133
+ drg.ipv4_relay = true
134
+ assert_equal(true, drg.ipv4_relay)
135
+ drg.ipv4_relay = false
136
+ assert_equal(false, drg.ipv4_relay)
137
+ drg.ipv4_relay = drg.default_ipv4_relay
138
+ assert_equal(drg.default_ipv4_relay, drg.ipv4_relay)
139
+ end
140
+
141
+ def test_ipv4_smart_relay
142
+ drg = create_dhcp_relay_global
143
+ assert_equal(drg.default_ipv4_smart_relay, drg.ipv4_smart_relay)
144
+ drg.ipv4_smart_relay = true
145
+ assert_equal(true, drg.ipv4_smart_relay)
146
+ drg.ipv4_smart_relay = drg.default_ipv4_smart_relay
147
+ assert_equal(drg.default_ipv4_smart_relay, drg.ipv4_smart_relay)
148
+ end
149
+
150
+ def test_ipv4_src_addr_hsrp
151
+ drg = create_dhcp_relay_global
152
+ if validate_property_excluded?('dhcp_relay_global',
153
+ 'ipv4_src_addr_hsrp')
154
+ assert_nil(drg.ipv4_src_addr_hsrp)
155
+ assert_raises(Cisco::UnsupportedError) do
156
+ drg.ipv4_src_addr_hsrp = true
157
+ end
158
+ return
159
+ end
160
+ assert_equal(drg.default_ipv4_src_addr_hsrp,
161
+ drg.ipv4_src_addr_hsrp)
162
+ drg.ipv4_src_addr_hsrp = true
163
+ assert_equal(true, drg.ipv4_src_addr_hsrp)
164
+ drg.ipv4_src_addr_hsrp = drg.default_ipv4_src_addr_hsrp
165
+ assert_equal(drg.default_ipv4_src_addr_hsrp,
166
+ drg.ipv4_src_addr_hsrp)
167
+ end
168
+
169
+ def test_ipv4_src_intf
170
+ drg = create_dhcp_relay_global
171
+ if validate_property_excluded?('dhcp_relay_global', 'ipv4_src_intf')
172
+ assert_nil(drg.ipv4_src_intf)
173
+ assert_raises(Cisco::UnsupportedError) do
174
+ drg.ipv4_src_intf = 'port-channel200'
175
+ end
176
+ return
177
+ end
178
+ assert_equal(drg.default_ipv4_src_intf, drg.ipv4_src_intf)
179
+ drg.ipv4_src_intf = 'port-channel200'
180
+ assert_equal('port-channel200', drg.ipv4_src_intf)
181
+ drg.ipv4_src_intf = drg.default_ipv4_src_intf
182
+ assert_equal(drg.default_ipv4_src_intf, drg.ipv4_src_intf)
183
+ end
184
+
185
+ def test_ipv4_sub_option_circuit_id_custom
186
+ skip_nexus_i2_image?
187
+ drg = create_dhcp_relay_global
188
+ if validate_property_excluded?('dhcp_relay_global',
189
+ 'ipv4_sub_option_circuit_id_custom')
190
+ assert_nil(drg.ipv4_sub_option_circuit_id_custom)
191
+ assert_raises(Cisco::UnsupportedError) do
192
+ drg.ipv4_sub_option_circuit_id_custom = true
193
+ end
194
+ return
195
+ end
196
+ assert_equal(drg.default_ipv4_sub_option_circuit_id_custom,
197
+ drg.ipv4_sub_option_circuit_id_custom)
198
+ drg.ipv4_sub_option_circuit_id_custom = true
199
+ assert_equal(true, drg.ipv4_sub_option_circuit_id_custom)
200
+ drg.ipv4_sub_option_circuit_id_custom = drg.default_ipv4_sub_option_circuit_id_custom
201
+ assert_equal(drg.default_ipv4_sub_option_circuit_id_custom,
202
+ drg.ipv4_sub_option_circuit_id_custom)
203
+ end
204
+
205
+ def test_ipv4_sub_option_circuit_id_string
206
+ drg = create_dhcp_relay_global
207
+ if validate_property_excluded?('dhcp_relay_global', 'ipv4_sub_option_circuit_id_string')
208
+ assert_nil(drg.ipv4_sub_option_circuit_id_string)
209
+ assert_raises(Cisco::UnsupportedError) do
210
+ drg.ipv4_sub_option_circuit_id_string = '%p%p'
211
+ end
212
+ return
213
+ end
214
+ assert_equal(drg.default_ipv4_sub_option_circuit_id_string, drg.ipv4_sub_option_circuit_id_string)
215
+ drg.ipv4_sub_option_circuit_id_string = '%p%p'
216
+ assert_equal('%p%p', drg.ipv4_sub_option_circuit_id_string)
217
+ drg.ipv4_sub_option_circuit_id_string = drg.default_ipv4_sub_option_circuit_id_string
218
+ assert_equal(drg.default_ipv4_sub_option_circuit_id_string, drg.ipv4_sub_option_circuit_id_string)
219
+ end
220
+
221
+ def test_ipv4_sub_option_cisco
222
+ drg = create_dhcp_relay_global
223
+ assert_equal(drg.default_ipv4_sub_option_cisco, drg.ipv4_sub_option_cisco)
224
+ drg.ipv4_sub_option_cisco = true
225
+ assert_equal(true, drg.ipv4_sub_option_cisco)
226
+ drg.ipv4_sub_option_cisco = drg.default_ipv4_sub_option_cisco
227
+ assert_equal(drg.default_ipv4_sub_option_cisco, drg.ipv4_sub_option_cisco)
228
+ end
229
+
230
+ def test_ipv6_option_cisco
231
+ drg = create_dhcp_relay_global
232
+ if validate_property_excluded?('dhcp_relay_global',
233
+ 'ipv6_option_cisco')
234
+ assert_nil(drg.ipv6_option_cisco)
235
+ assert_raises(Cisco::UnsupportedError) do
236
+ drg.ipv6_option_cisco = true
237
+ end
238
+ return
239
+ end
240
+ assert_equal(drg.default_ipv6_option_cisco,
241
+ drg.ipv6_option_cisco)
242
+ drg.ipv6_option_cisco = true
243
+ assert_equal(true, drg.ipv6_option_cisco)
244
+ drg.ipv6_option_cisco = drg.default_ipv6_option_cisco
245
+ assert_equal(drg.default_ipv6_option_cisco,
246
+ drg.ipv6_option_cisco)
247
+ end
248
+
249
+ def test_ipv6_option_vpn
250
+ drg = create_dhcp_relay_global
251
+ assert_equal(drg.default_ipv6_option_vpn, drg.ipv6_option_vpn)
252
+ drg.ipv6_option_vpn = true
253
+ assert_equal(true, drg.ipv6_option_vpn)
254
+ drg.ipv6_option_vpn = drg.default_ipv6_option_vpn
255
+ assert_equal(drg.default_ipv6_option_vpn, drg.ipv6_option_vpn)
256
+ end
257
+
258
+ def test_ipv6_relay
259
+ drg = create_dhcp_relay_global
260
+ assert_equal(drg.default_ipv6_relay, drg.ipv6_relay)
261
+ drg.ipv6_relay = true
262
+ assert_equal(true, drg.ipv6_relay)
263
+ drg.ipv6_relay = false
264
+ assert_equal(false, drg.ipv6_relay)
265
+ drg.ipv6_relay = drg.default_ipv6_relay
266
+ assert_equal(drg.default_ipv6_relay, drg.ipv6_relay)
267
+ end
268
+
269
+ def test_ipv6_src_intf
270
+ drg = create_dhcp_relay_global
271
+ if validate_property_excluded?('dhcp_relay_global', 'ipv6_src_intf')
272
+ assert_nil(drg.ipv6_src_intf)
273
+ assert_raises(Cisco::UnsupportedError) do
274
+ drg.ipv6_src_intf = 'loopback2'
275
+ end
276
+ return
277
+ end
278
+ assert_equal(drg.default_ipv6_src_intf, drg.ipv6_src_intf)
279
+ drg.ipv6_src_intf = 'loopback2 '
280
+ assert_equal('loopback2', drg.ipv6_src_intf)
281
+ drg.ipv6_src_intf = drg.default_ipv6_src_intf
282
+ assert_equal(drg.default_ipv6_src_intf, drg.ipv6_src_intf)
283
+ end
284
+ end