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
@@ -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.
@@ -66,7 +66,7 @@ class TestRouterOspf < CiscoTestCase
66
66
  msg: "'router ospf ospfTest' not configured")
67
67
  ospf.destroy
68
68
 
69
- refute_show_match(command: 'show run all | no-more',
69
+ refute_show_match(command: 'show run all | inc feature | no-more',
70
70
  pattern: /feature ospf/,
71
71
  msg: "Error: 'feature ospf' still configured")
72
72
  end
@@ -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.
@@ -131,7 +131,7 @@ class TestRouterOspfVrf < CiscoTestCase
131
131
  cot: RouterOspfVrf::OSPF_AUTO_COST[:mbps], dm: 15_000,
132
132
  id: '9.0.0.2', l1: 130, l2: 530, l3: 1030, s1: 300,
133
133
  s2: 600, s3: 1100
134
- },
134
+ }
135
135
  },
136
136
  'bxb300' => {
137
137
  'default' => {
@@ -139,7 +139,7 @@ class TestRouterOspfVrf < CiscoTestCase
139
139
  cot: RouterOspfVrf::OSPF_AUTO_COST[:mbps], dm: 10_000,
140
140
  id: '10.0.0.3', l1: 130, l2: 530, l3: 1030, s1: 300,
141
141
  s2: 600, s3: 1100
142
- },
142
+ }
143
143
  },
144
144
  )
145
145
  # rubocop:enable Style/AlignHash
@@ -557,7 +557,7 @@ class TestRouterOspfVrf < CiscoTestCase
557
557
  cot: RouterOspfVrf::OSPF_AUTO_COST[:mbps], dm: 15_000,
558
558
  id: '9.0.0.2', l1: 130, l2: 530, l3: 1030, s1: 300,
559
559
  s2: 600, s3: 1100
560
- },
560
+ }
561
561
  },
562
562
  'bxb300' => {
563
563
  'default' => {
@@ -0,0 +1,167 @@
1
+ #
2
+ # Minitest for SnmpNotificationReceiver class
3
+ #
4
+ # Copyright (c) 2014-2016 Cisco and/or its affiliates.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require_relative 'ciscotest'
19
+ require_relative '../lib/cisco_node_utils/snmp_notification_receiver'
20
+
21
+ # TestSnmpNotificationReceiver - Minitest for SnmpNotificationReceiver
22
+ # node utility.
23
+ class TestSnmpNotificationReceiver < CiscoTestCase
24
+ def setup
25
+ # setup runs at the beginning of each test
26
+ super
27
+ no_snmpnotificationreceiver
28
+ config('vrf context red')
29
+ end
30
+
31
+ def teardown
32
+ # teardown runs at the end of each test
33
+ no_snmpnotificationreceiver
34
+ config('no vrf context red')
35
+ super
36
+ end
37
+
38
+ def no_snmpnotificationreceiver
39
+ # Turn the feature off for a clean test.
40
+ config('no snmp-server host 4.5.6.7 informs version 3 priv ab udp-port 45',
41
+ 'no snmp-server host 2004::7 traps version 3 auth cd udp-port 46')
42
+ end
43
+
44
+ # TESTS
45
+
46
+ def test_create_destroy_single
47
+ id = '4.5.6.7'
48
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
49
+
50
+ receiver = \
51
+ Cisco::SnmpNotificationReceiver.new(id,
52
+ instantiate: true,
53
+ type: 'informs',
54
+ version: '3',
55
+ security: 'priv',
56
+ username: 'ab',
57
+ port: '45',
58
+ vrf: 'red',
59
+ source_interface: interfaces[0].downcase) # rubocop:disable Metrics/LineLength
60
+
61
+ assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
62
+ assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
63
+
64
+ assert_equal(interfaces[0].downcase,
65
+ Cisco::SnmpNotificationReceiver.receivers[id].source_interface) # rubocop:disable Metrics/LineLength
66
+ assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
67
+ assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
68
+ assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
69
+ assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id].version)
70
+ assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id].vrf)
71
+ assert_equal('priv', Cisco::SnmpNotificationReceiver.receivers[id].security)
72
+
73
+ receiver.destroy
74
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
75
+ end
76
+
77
+ def test_create_destroy_single_ipv6
78
+ id = '2004::7'
79
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
80
+
81
+ receiver = \
82
+ Cisco::SnmpNotificationReceiver.new(id,
83
+ instantiate: true,
84
+ type: 'informs',
85
+ version: '3',
86
+ security: 'priv',
87
+ username: 'ab',
88
+ port: '45',
89
+ vrf: 'red',
90
+ source_interface: interfaces[0].downcase) # rubocop:disable Metrics/LineLength
91
+
92
+ assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
93
+ assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
94
+
95
+ assert_equal(interfaces[0].downcase,
96
+ Cisco::SnmpNotificationReceiver.receivers[id].source_interface) # rubocop:disable Metrics/LineLength
97
+ assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
98
+ assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
99
+ assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
100
+ assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id].version)
101
+ assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id].vrf)
102
+ assert_equal('priv', Cisco::SnmpNotificationReceiver.receivers[id].security)
103
+
104
+ receiver.destroy
105
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
106
+ end
107
+
108
+ def test_create_destroy_multiple
109
+ id = '4.5.6.7'
110
+ id2 = '2004::7'
111
+
112
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
113
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id2)
114
+
115
+ receiver = \
116
+ Cisco::SnmpNotificationReceiver.new(id,
117
+ instantiate: true,
118
+ type: 'informs',
119
+ version: '3',
120
+ security: 'priv',
121
+ username: 'ab',
122
+ port: '45',
123
+ vrf: 'red',
124
+ source_interface: interfaces[0].downcase) # rubocop:disable Metrics/LineLength
125
+
126
+ receiver2 = \
127
+ Cisco::SnmpNotificationReceiver.new(id2,
128
+ instantiate: true,
129
+ type: 'traps',
130
+ version: '3',
131
+ security: 'auth',
132
+ username: 'cd',
133
+ port: '46',
134
+ vrf: 'red',
135
+ source_interface: interfaces[1].downcase) # rubocop:disable Metrics/LineLength
136
+
137
+ assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
138
+ assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
139
+
140
+ assert_equal(interfaces[0].downcase,
141
+ Cisco::SnmpNotificationReceiver.receivers[id].source_interface) # rubocop:disable Metrics/LineLength
142
+ assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
143
+ assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
144
+ assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
145
+ assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id].version)
146
+ assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id].vrf)
147
+ assert_equal('priv', Cisco::SnmpNotificationReceiver.receivers[id].security)
148
+
149
+ assert_includes(Cisco::SnmpNotificationReceiver.receivers, id2)
150
+ assert_equal(receiver2, Cisco::SnmpNotificationReceiver.receivers[id2])
151
+
152
+ assert_equal(interfaces[1].downcase,
153
+ Cisco::SnmpNotificationReceiver.receivers[id2].source_interface) # rubocop:disable Metrics/LineLength
154
+ assert_equal('46', Cisco::SnmpNotificationReceiver.receivers[id2].port)
155
+ assert_equal('traps', Cisco::SnmpNotificationReceiver.receivers[id2].type)
156
+ assert_equal('cd', Cisco::SnmpNotificationReceiver.receivers[id2].username)
157
+ assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id2].version)
158
+ assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id2].vrf)
159
+ assert_equal('auth',
160
+ Cisco::SnmpNotificationReceiver.receivers[id2].security)
161
+
162
+ receiver.destroy
163
+ receiver2.destroy
164
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
165
+ refute_includes(Cisco::SnmpNotificationReceiver.receivers, id2)
166
+ end
167
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 Cisco and/or its affiliates.
1
+ # Copyright (c) 2013-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.
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 Cisco and/or its affiliates.
1
+ # Copyright (c) 2013-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,72 @@
1
+ #
2
+ # Minitest for snmpnotification class
3
+ #
4
+ # Copyright (c) 2014-2016 Cisco and/or its affiliates.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require_relative 'ciscotest'
19
+ require_relative '../lib/cisco_node_utils/snmpnotification'
20
+
21
+ # TestRadiusGlobal - Minitest for RadiusGlobal node utility.
22
+ class TestSnmpNotification < CiscoTestCase
23
+ def setup
24
+ # setup runs at the beginning of each test
25
+ super
26
+ no_snmp_notification
27
+ config('no feature bgp')
28
+ config('feature bgp')
29
+ end
30
+
31
+ def teardown
32
+ # teardown runs at the end of each test
33
+ no_snmp_notification
34
+ config('no feature bgp')
35
+ super
36
+ end
37
+
38
+ def no_snmp_notification
39
+ # Turn the feature off for a clean test.
40
+ config('no snmp-server enable traps')
41
+ end
42
+
43
+ # TESTS
44
+
45
+ def test_snmp_notification
46
+ # test traps returned
47
+ assert_equal(false, Cisco::SnmpNotification.notifications.empty?,
48
+ 'notifications is not empty')
49
+ assert_equal(Cisco::SnmpNotification,
50
+ Cisco::SnmpNotification.notifications['vtp notifs'].class,
51
+ 'vtp notifs exists')
52
+
53
+ # set up some traps
54
+ cfs_state = Cisco::SnmpNotification.new('cfs state-change-notif')
55
+ bgp = Cisco::SnmpNotification.new('bgp cbgp2 state-changes')
56
+
57
+ # Default Checking
58
+ assert_equal(cfs_state.enable, false)
59
+ assert_equal(bgp.enable, false)
60
+
61
+ cfs_state.enable = true
62
+ bgp.enable = true
63
+ assert_equal(cfs_state.enable, true)
64
+ assert_equal(bgp.enable, true)
65
+
66
+ # Setting back to default and re-checking
67
+ cfs_state.enable = false
68
+ bgp.enable = false
69
+ assert_equal(cfs_state.enable, false)
70
+ assert_equal(bgp.enable, false)
71
+ end
72
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 Cisco and/or its affiliates.
1
+ # Copyright (c) 2013-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.
@@ -293,122 +293,46 @@ class TestSnmpServer < CiscoTestCase
293
293
  snmpserver.packet_size = 0
294
294
  end
295
295
 
296
- def test_snmpserver_global_enforce_priv_get_default
296
+ def test_snmpserver_global_enforce_priv
297
297
  snmpserver = SnmpServer.new
298
- # default is false
299
- snmpserver.global_enforce_priv = false
300
- device_enabled = snmpserver.global_enforce_priv?
301
- if device_enabled
302
- refute_show_match(pattern: /no snmp-server globalEnforcePriv/)
303
- else
304
- assert_show_match(pattern: /no snmp-server globalEnforcePriv/)
305
- end
306
- # set to default
307
- snmpserver.global_enforce_priv = snmpserver.default_global_enforce_priv
308
- end
298
+ default = snmpserver.default_global_enforce_priv
299
+ snmpserver.global_enforce_priv = default
300
+ if default == true
301
+ assert_show_match(pattern: /^snmp-server globalEnforcePriv/)
302
+ assert(snmpserver.global_enforce_priv?)
309
303
 
310
- def test_snmpserver_global_enforce_priv_get_enabled
311
- snmpserver = SnmpServer.new
312
- snmpserver.global_enforce_priv = true
313
- device_enabled = snmpserver.global_enforce_priv?
314
- if device_enabled
315
- refute_show_match(pattern: /no snmp-server globalEnforcePriv/)
304
+ snmpserver.global_enforce_priv = false
305
+ assert_show_match(pattern: /^no snmp-server globalEnforcePriv/)
306
+ refute(snmpserver.global_enforce_priv?)
316
307
  else
317
- assert_show_match(pattern: /no snmp-server globalEnforcePriv/)
318
- end
319
- # set to default
320
- snmpserver.global_enforce_priv = snmpserver.default_global_enforce_priv
321
- end
308
+ assert_show_match(pattern: /^no snmp-server globalEnforcePriv/)
309
+ refute(snmpserver.global_enforce_priv?)
322
310
 
323
- def test_snmpserver_global_enforce_priv_set_enabled
324
- snmpserver = SnmpServer.new
325
- snmpserver.global_enforce_priv = true
326
- assert_show_match(pattern: /snmp-server globalEnforcePriv/)
327
- # set to default
328
- snmpserver.global_enforce_priv = snmpserver.default_global_enforce_priv
329
- end
330
-
331
- def test_snmpserver_global_enforce_priv_set_disabled
332
- snmpserver = SnmpServer.new
333
- snmpserver.global_enforce_priv = false
334
- assert_show_match(pattern: /no snmp-server globalEnforcePriv/)
335
- # set to default
336
- snmpserver.global_enforce_priv = snmpserver.default_global_enforce_priv
337
- end
338
-
339
- def test_snmpserver_protocol_get_default
340
- snmpserver = SnmpServer.new
341
- # set default
342
- snmpserver.protocol = true
343
- assert_show_match(pattern: /^snmp-server protocol enable/)
344
- # set to default
345
- snmpserver.protocol = snmpserver.default_protocol
346
- end
347
-
348
- def test_snmpserver_protocol_get_disabled
349
- snmpserver = SnmpServer.new
350
- snmpserver.protocol = false
351
- device_enabled = snmpserver.protocol?
352
- if device_enabled
353
- assert_show_match(pattern: /^snmp-server protocol enable/)
354
- else
355
- assert_show_match(pattern: /no snmp-server protocol enable/)
311
+ snmpserver.global_enforce_priv = true
312
+ assert_show_match(pattern: /^snmp-server globalEnforcePriv/)
313
+ assert(snmpserver.global_enforce_priv?)
356
314
  end
357
- # set to default
358
- snmpserver.protocol = snmpserver.default_protocol
359
- end
360
-
361
- def test_snmpserver_protocol_set_enabled
362
- snmpserver = SnmpServer.new
363
- snmpserver.protocol = true
364
- assert_show_match(pattern: /^snmp-server protocol enable/)
365
- # set to default
366
- snmpserver.protocol = snmpserver.default_protocol
315
+ # Cleanup
316
+ snmpserver.global_enforce_priv = snmpserver.default_global_enforce_priv
367
317
  end
368
318
 
369
- def test_snmpserver_protocol_set_disabled
319
+ def test_snmpserver_protocol_get_set
370
320
  snmpserver = SnmpServer.new
371
321
  snmpserver.protocol = false
372
- assert_show_match(pattern: /no snmp-server protocol enable/)
373
- # set to default
374
- snmpserver.protocol = snmpserver.default_protocol
322
+ assert_equal(false, snmpserver.protocol?)
323
+ snmpserver.protocol =
324
+ snmpserver.default_protocol
325
+ assert_equal(snmpserver.default_protocol,
326
+ snmpserver.protocol?)
375
327
  end
376
328
 
377
- def test_snmpserver_tcp_session_auth_get_default
329
+ def test_snmpserver_tcp_session_auth_get_set
378
330
  snmpserver = SnmpServer.new
379
- # default value is false
380
331
  snmpserver.tcp_session_auth = false
381
- device_enabled = snmpserver.tcp_session_auth?
382
- if device_enabled
383
- assert_show_match(pattern: /^snmp-server tcp-session auth/)
384
- else
385
- assert_show_match(pattern: /no snmp-server tcp-session auth/)
386
- end
387
- # set to default
388
- snmpserver.tcp_session_auth = snmpserver.default_tcp_session_auth
389
- end
390
-
391
- def test_snmpserver_tcp_session_auth_get_enabled
392
- snmpserver = SnmpServer.new
393
- snmpserver.tcp_session_auth = true
394
- assert_show_match(pattern: /^snmp-server tcp-session auth/)
395
- # set to default
396
- snmpserver.tcp_session_auth = snmpserver.default_tcp_session_auth
397
- end
398
-
399
- def test_snmpserver_tcp_session_auth_set_enabled
400
- snmpserver = SnmpServer.new
401
- snmpserver.tcp_session_auth = true
402
- assert_show_match(pattern: /^snmp-server tcp-session auth/)
403
- # set to default
404
- snmpserver.tcp_session_auth = snmpserver.default_tcp_session_auth
405
- end
406
-
407
- def test_snmpserver_tcp_session_auth_set_default
408
- snmpserver = SnmpServer.new
409
- snmpserver.tcp_session_auth = false
410
- assert_show_match(pattern: /no snmp-server tcp-session auth/)
411
- # set to default
412
- snmpserver.tcp_session_auth = snmpserver.default_tcp_session_auth
332
+ assert_equal(false, snmpserver.tcp_session_auth?)
333
+ snmpserver.tcp_session_auth =
334
+ snmpserver.default_tcp_session_auth
335
+ assert_equal(snmpserver.default_tcp_session_auth,
336
+ snmpserver.tcp_session_auth?)
413
337
  end
414
338
  end