cisco_node_utils 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,191 @@
1
+ # Copyright (c) 2014-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/bridge_domain'
17
+ require_relative '../lib/cisco_node_utils/vlan'
18
+
19
+ include Cisco
20
+
21
+ # TestBridgeDomain - Minitest for bridge domain class.
22
+ class TestBridgeDomain < CiscoTestCase
23
+ @skip_unless_supported = 'bridge_domain'
24
+ @@cleaned = false # rubocop:disable Style/ClassVars
25
+
26
+ def cleanup
27
+ remove_all_vlans
28
+ remove_all_bridge_domains
29
+ end
30
+
31
+ def setup
32
+ super
33
+ cleanup unless @@cleaned
34
+ @@cleaned = true # rubocop:disable Style/ClassVars
35
+ end
36
+
37
+ def teardown
38
+ cleanup
39
+ super
40
+ end
41
+
42
+ def test_single_bd_create_destroy
43
+ bd = BridgeDomain.new('100', true)
44
+ bds = BridgeDomain.bds
45
+ assert(bds.key?('100'), 'Error: failed to create bridge-domain 100')
46
+
47
+ bd.destroy
48
+ bds = BridgeDomain.bds
49
+ refute(bds.key?('100'), 'Error: failed to destroy bridge-domain 100')
50
+ end
51
+
52
+ def test_bd_create_if_vlan_exists
53
+ vlan = Vlan.new(100)
54
+ assert_raises(CliError,
55
+ 'Vlan already exist did not raise CliError') do
56
+ BridgeDomain.new(100)
57
+ end
58
+ vlan.destroy
59
+ end
60
+
61
+ def test_create_already_existing_bd
62
+ create = '100-120'
63
+ BridgeDomain.new('100-110,115')
64
+ bd = BridgeDomain.new('100-120')
65
+ bds = BridgeDomain.bds
66
+ BridgeDomain.bd_ids_to_array(create).each do |id|
67
+ assert(bds.key?(id.to_s), 'Error: failed to create bridge-domain ' << id)
68
+ end
69
+ bd.destroy
70
+ end
71
+
72
+ def test_multiple_bd_create_destroy
73
+ create = '101-102,120'
74
+ bdlist = BridgeDomain.bd_ids_to_array(create)
75
+
76
+ bd = BridgeDomain.new(create, true)
77
+ bds = BridgeDomain.bds
78
+ bdlist.each do |id|
79
+ assert(bds.key?(id.to_s), 'Error: failed to create bridge-domain ' << id)
80
+ end
81
+
82
+ bd.destroy
83
+ bds = BridgeDomain.bds
84
+ bdlist.each do |id|
85
+ refute(bds.key?(id.to_s), 'Error: failed to destroy bridge-domain ' << id)
86
+ end
87
+ end
88
+
89
+ def test_bd_create_noorder_and_space
90
+ create = '100, 90, 200, 2-4'
91
+ bd = BridgeDomain.new(create)
92
+ bds = BridgeDomain.bds
93
+ BridgeDomain.bd_ids_to_array(create).each do |id|
94
+ assert(bds.key?(id.to_s), 'Error: failed to create bridge-domain ' << id)
95
+ end
96
+ bd.destroy
97
+ end
98
+
99
+ def test_bd_shutdown
100
+ bd = BridgeDomain.new(101)
101
+ refute(bd.shutdown)
102
+ bd.shutdown = true
103
+ assert(bd.shutdown)
104
+ bd.destroy
105
+ end
106
+
107
+ def test_bd_name
108
+ bd = BridgeDomain.new(101)
109
+ assert_equal(bd.default_bd_name, bd.bd_name,
110
+ 'Error: Bridge-Domain name not initialized to default')
111
+
112
+ name = 'my_bridge'
113
+ bd.bd_name = name
114
+ assert_equal(name, bd.bd_name,
115
+ 'Error: Bridge-Domain name not updated to #{name}')
116
+
117
+ bd.bd_name = bd.default_bd_name
118
+ assert_equal(bd.default_bd_name, bd.bd_name,
119
+ 'Error: Bridge-Domain name not restored to default')
120
+ bd.destroy
121
+ end
122
+
123
+ def test_bd_fabric_control
124
+ bd = BridgeDomain.new('100')
125
+ assert_equal(bd.default_fabric_control, bd.fabric_control,
126
+ 'Error: Bridge-Domain fabric-control is not matching')
127
+ bd.fabric_control = true
128
+ assert(bd.fabric_control)
129
+ bd.destroy
130
+ end
131
+
132
+ def test_another_bd_as_fabric_control
133
+ bd = BridgeDomain.new(100)
134
+ assert_equal(bd.default_fabric_control, bd.fabric_control,
135
+ 'Error: Bridge-Domain fabric-control is not matching')
136
+ bd.fabric_control = true
137
+ assert(bd.fabric_control)
138
+ another_bd = BridgeDomain.new(101)
139
+
140
+ assert_raises(CliError,
141
+ 'BD misconfig did not raise CliError') do
142
+ another_bd.fabric_control = true
143
+ end
144
+ bd.destroy
145
+ another_bd.destroy
146
+ end
147
+
148
+ def test_invalid_bd_create
149
+ assert_raises(CliError,
150
+ 'BD misconfig did not raise CliError') do
151
+ BridgeDomain.new('90, 5000-5004,100')
152
+ end
153
+ end
154
+
155
+ def test_multiple_bd_combinations
156
+ bds = BridgeDomain.new('100-110')
157
+ bd_hash = {}
158
+ bd_hash['100'] = [true, false, 'bd100']
159
+ bd_hash['105'] = [true, true, 'bd105']
160
+ bd_hash['107'] = [true, false, 'bd107']
161
+ bd_hash['110'] = [true, false, '']
162
+ BridgeDomain.bds.each do |bd, obj|
163
+ if bd_hash.key?(bd)
164
+ obj.shutdown = bd_hash[bd][0]
165
+ assert_equal(bd_hash[bd][0], obj.shutdown,
166
+ 'Error: Bridge-Domain state is not matching')
167
+
168
+ obj.fabric_control = bd_hash[bd][1]
169
+ assert_equal(bd_hash[bd][1], obj.fabric_control,
170
+ 'Error: Bridge-Domain type is not matching')
171
+
172
+ if bd_hash[bd][2] != ''
173
+ obj.bd_name = bd_hash[bd][2]
174
+ assert_equal(bd_hash[bd][2], obj.bd_name,
175
+ 'Error: Bridge-Domain name is not matching')
176
+ else
177
+ assert_equal(obj.default_bd_name, obj.bd_name,
178
+ 'Error: Bridge-Domain name is not matching')
179
+ end
180
+ else
181
+ assert_equal(obj.default_shutdown, obj.shutdown,
182
+ 'Error: Bridge-Domain state is not matching')
183
+ assert_equal(obj.default_fabric_control, obj.fabric_control,
184
+ 'Error: Bridge-Domain type is not matching')
185
+ assert_equal(obj.default_bd_name, obj.bd_name,
186
+ 'Error: Bridge-Domain name is not matching')
187
+ end
188
+ end
189
+ bds.destroy
190
+ end
191
+ end
@@ -0,0 +1,116 @@
1
+ # Copyright (c) 2014-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/bridge_domain_vni'
17
+
18
+ include Cisco
19
+
20
+ # TestBridgeDomainVNI - Minitest for bridge domain class.
21
+ class TestBridgeDomainVNI < CiscoTestCase
22
+ @skip_unless_supported = 'bridge_domain_vni'
23
+ @@cleaned = false # rubocop:disable Style/ClassVars
24
+
25
+ def cleanup
26
+ remove_all_vlans
27
+ remove_all_bridge_domains
28
+ config_no_warn('no feature vni')
29
+ BridgeDomainVNI.range_bds.each do |_bd, obj|
30
+ obj.destroy
31
+ end
32
+ end
33
+
34
+ def setup
35
+ super
36
+ cleanup unless @@cleaned
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
+ end
43
+
44
+ def teardown
45
+ cleanup
46
+ super
47
+ end
48
+
49
+ def test_single_bd_member_vni
50
+ mt_full_interface?
51
+ bd = BridgeDomainVNI.new('100')
52
+ assert_equal(bd.default_member_vni, bd.member_vni,
53
+ 'Error: Bridge-Domain is mapped to different vnis')
54
+
55
+ vni = '6000'
56
+ bd.member_vni = vni
57
+ assert_equal(vni, bd.member_vni,
58
+ 'Error: Bridge-Domain is mapped to different vnis')
59
+
60
+ bd.member_vni = ''
61
+ assert_equal(bd.default_member_vni, bd.member_vni,
62
+ 'Error: Bridge-Domain is mapped to different vnis')
63
+
64
+ bd.destroy
65
+ end
66
+
67
+ def test_multiple_bd_member_vni
68
+ mt_full_interface?
69
+ bd = BridgeDomainVNI.new('100-110, 150, 170-171 ')
70
+ assert_equal(bd.default_member_vni, bd.member_vni,
71
+ 'Error: Bridge-Domain is mapped to different vnis')
72
+
73
+ vni = '6000-6010,6050,5070-5071'
74
+ bd.member_vni = vni
75
+ assert_equal(vni, bd.member_vni,
76
+ 'Error: Bridge-Domain is mapped to different vnis')
77
+
78
+ bd.member_vni = ''
79
+ assert_equal(bd.default_member_vni, bd.member_vni,
80
+ 'Error: Bridge-Domain is mapped to different vnis')
81
+
82
+ bd.destroy
83
+ end
84
+
85
+ def test_member_vni_empty_assign
86
+ mt_full_interface?
87
+ bd = BridgeDomainVNI.new(100)
88
+ bd.member_vni = ''
89
+ assert_equal(bd.default_member_vni, bd.member_vni,
90
+ 'Error: Bridge-Domain is mapped to different vnis')
91
+ bd.destroy
92
+ end
93
+
94
+ def test_overwrite_bd_member_vni
95
+ mt_full_interface?
96
+ bd = BridgeDomainVNI.new('100-110')
97
+ assert_equal(bd.default_member_vni, bd.member_vni,
98
+ 'Error: Bridge-Domain is mapped to different vnis')
99
+
100
+ vni = '5000-5010'
101
+ bd.member_vni = vni
102
+ assert_equal(vni, bd.member_vni,
103
+ 'Error: Bridge-Domain is mapped to different vnis')
104
+
105
+ vni = '5000-5005,6006-6010'
106
+ bd.member_vni = vni
107
+ assert_equal(vni, bd.member_vni,
108
+ 'Error: Bridge-Domain is mapped to different vnis')
109
+
110
+ bd.member_vni = ''
111
+ assert_equal(bd.default_member_vni, bd.member_vni,
112
+ 'Error: Bridge-Domain is mapped to different vnis')
113
+
114
+ bd.destroy
115
+ end
116
+ end
@@ -0,0 +1,111 @@
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 'basetest'
16
+
17
+ require_relative '../lib/cisco_node_utils/client/utils.rb'
18
+
19
+ # TestClientUtils - Minitest for Client utility functions
20
+ class TestClientUtils < Minitest::Test
21
+ def show_run_ospf
22
+ "\
23
+ router ospf foo
24
+ vrf red
25
+ log-adjacency-changes
26
+ router ospf bar
27
+ log-adjacency-changes
28
+ vrf red
29
+ log-adjacency-changes detail
30
+ vrf blue
31
+ !
32
+ router ospf baz
33
+ log-adjacency-changes detail"
34
+ end
35
+
36
+ def test_find_subconfig
37
+ result = Cisco::Client.find_subconfig(show_run_ospf, /router ospf bar/)
38
+ assert_equal("\
39
+ log-adjacency-changes
40
+ vrf red
41
+ log-adjacency-changes detail
42
+ vrf blue",
43
+ result)
44
+
45
+ assert_nil(Cisco::Client.find_subconfig(result, /vrf blue/))
46
+
47
+ assert_equal('log-adjacency-changes detail',
48
+ Cisco::Client.find_subconfig(result, /vrf red/))
49
+
50
+ assert_nil(Cisco::Client.find_subconfig(result, /vrf green/))
51
+ end
52
+
53
+ def test_filter_cli
54
+ # Unfiltered (no context / values)
55
+ assert_equal(show_run_ospf,
56
+ Cisco::Client.filter_cli(cli_output: show_run_ospf))
57
+ # Filtered by context but not by value
58
+ assert_equal("\
59
+ log-adjacency-changes
60
+ vrf red
61
+ log-adjacency-changes detail
62
+ vrf blue",
63
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
64
+ context: [/router ospf bar/]))
65
+ # Filtered by value but not by context
66
+ assert_equal(['router ospf foo', 'router ospf bar', 'router ospf baz'],
67
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
68
+ value: /router ospf .*/))
69
+ # rubocop:disable Style/WordArray
70
+
71
+ # Values with a single match group
72
+ assert_equal(['foo', 'bar', 'baz'],
73
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
74
+ value: /router ospf (.*)/))
75
+ # Values with multiple match groups
76
+ assert_equal([['ospf', 'foo'], ['ospf', 'bar'], ['ospf', 'baz']],
77
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
78
+ value: /router (\S+) (.*)/))
79
+ # rubocop:enable Style/WordArray
80
+
81
+ # Values with a single match group
82
+ # Find an entry in the parent submode, ignoring nested submodes
83
+ assert_equal(
84
+ ['log-adjacency-changes'],
85
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
86
+ value: /^log-adjacency-changes.*$/,
87
+ context: [/router ospf bar/]))
88
+ # Find an entry in a nested submode
89
+ assert_equal(
90
+ ['log-adjacency-changes detail'],
91
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
92
+ value: /^log-adjacency-changes.*$/,
93
+ context: [/router ospf bar/, /vrf red/]))
94
+ # Submode exists but does not have a match
95
+ assert_nil(
96
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
97
+ value: /^log-adjacency-changes.*$/,
98
+ context: [/router ospf bar/, /vrf blue/]))
99
+ # Submode does not exist
100
+ assert_nil(
101
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
102
+ value: /^log-adjacency-changes.*$/,
103
+ context: [/router ospf bar/, /vrf green/]))
104
+
105
+ # Entry exists in submode only
106
+ assert_nil(
107
+ Cisco::Client.filter_cli(cli_output: show_run_ospf,
108
+ value: /^log-adjacency-changes.*$/,
109
+ context: [/router ospf foo/]))
110
+ end
111
+ end
@@ -46,7 +46,7 @@ class TestCommandConfig < CiscoTestCase
46
46
 
47
47
  def compare_with_results(desired_config_str, current_key)
48
48
  retrieve_command = 'show running all'
49
- running_config_str = node.show(retrieve_command)
49
+ running_config_str = node.get(command: retrieve_command)
50
50
 
51
51
  begin
52
52
  should_config = ConfigParser::Configuration.new(desired_config_str)
@@ -71,7 +71,7 @@ class TestCommandConfig < CiscoTestCase
71
71
  cfg_string = remove_whitespace(cfg_cmd_str)
72
72
  # puts "cfg_string: \n||\n#{cfg_string}||\n"
73
73
  begin
74
- node.config(cfg_string)
74
+ node.set(values: cfg_string)
75
75
  # make sure config is present in success case
76
76
  compare_with_results(v1, k)
77
77
  rescue CliError => e
@@ -83,13 +83,17 @@ class TestCommandConfig < CiscoTestCase
83
83
  end
84
84
  end
85
85
 
86
+ def loopback
87
+ (platform == :ios_xr) ? 'Loopback' : 'loopback'
88
+ end
89
+
86
90
  def build_int_scale_config(add=true)
87
91
  add ? s = '' : s = 'no '
88
92
  current_interface = 0
89
93
  num_interfaces = 1024
90
94
  command_list = ''
91
95
  while current_interface < num_interfaces
92
- command_list += "#{s}interface loopback#{current_interface}\n"
96
+ command_list += "#{s}interface #{loopback}#{current_interface}\n"
93
97
  current_interface += 1
94
98
  end
95
99
  command_list
@@ -100,7 +104,7 @@ class TestCommandConfig < CiscoTestCase
100
104
  # ---------------------------------------------------------------------------
101
105
 
102
106
  def test_valid_config
103
- cfg_hash = load_yaml
107
+ cfg_hash = load_yaml[platform.to_s]
104
108
  begin
105
109
  send_device_config(cfg_hash)
106
110
  end
@@ -144,7 +148,7 @@ class TestCommandConfig < CiscoTestCase
144
148
  v.each_value do |v1|
145
149
  cfg_cmd_str = "#{v1.gsub(/^/, ' ')}\n"
146
150
  cfg_string = remove_whitespace(cfg_cmd_str)
147
- assert_raises(CliError) { node.config(cfg_string) }
151
+ assert_raises(Cisco::CliError) { node.set(values: cfg_string) }
148
152
  end
149
153
  end
150
154
  end