cisco_node_utils 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +66 -0
- data/Gemfile +1 -0
- data/README.md +44 -43
- data/bin/.rubocop.yml +18 -0
- data/bin/show_running_yang.rb +233 -0
- data/cisco_node_utils.gemspec +1 -1
- data/docs/README-maintainers.md +1 -0
- data/docs/README-utilities.md +14 -0
- data/lib/.rubocop.yml +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +8 -3
- data/lib/cisco_node_utils/aaa_authorization_service.rb +6 -0
- data/lib/cisco_node_utils/bfd_global.rb +300 -0
- data/lib/cisco_node_utils/bgp.rb +6 -4
- data/lib/cisco_node_utils/bgp_af.rb +2 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +14 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +4 -1
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +126 -0
- data/lib/cisco_node_utils/client/client.rb +6 -2
- data/lib/cisco_node_utils/client/grpc/client.rb +120 -36
- data/lib/cisco_node_utils/client/nxapi/client.rb +6 -2
- data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +118 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +7 -7
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +125 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +141 -49
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +44 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +0 -3
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +3 -3
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +39 -15
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +43 -21
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +48 -19
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +0 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +30 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +18 -6
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +4 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +1 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +23 -10
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +8 -2
- data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +10 -1
- data/lib/cisco_node_utils/constants.rb +8 -1
- data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
- data/lib/cisco_node_utils/exceptions.rb +29 -0
- data/lib/cisco_node_utils/feature.rb +28 -0
- data/lib/cisco_node_utils/interface.rb +493 -402
- data/lib/cisco_node_utils/interface_DEPRECATED.rb +513 -0
- data/lib/cisco_node_utils/interface_ospf.rb +126 -0
- data/lib/cisco_node_utils/interface_portchannel.rb +16 -0
- data/lib/cisco_node_utils/logger.rb +3 -0
- data/lib/cisco_node_utils/node.rb +29 -1
- data/lib/cisco_node_utils/overlay_global.rb +1 -12
- data/lib/cisco_node_utils/pim.rb +1 -0
- data/lib/cisco_node_utils/pim_group_list.rb +1 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +1 -0
- data/lib/cisco_node_utils/platform.rb +9 -2
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
- data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
- data/lib/cisco_node_utils/router_ospf_vrf.rb +17 -0
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +27 -9
- data/lib/cisco_node_utils/snmpcommunity.rb +34 -8
- data/lib/cisco_node_utils/snmpserver.rb +4 -4
- data/lib/cisco_node_utils/snmpuser.rb +0 -0
- data/lib/cisco_node_utils/tacacs_global.rb +102 -0
- data/lib/cisco_node_utils/tacacs_server.rb +8 -7
- data/lib/cisco_node_utils/vdc.rb +25 -7
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vlan.rb +30 -56
- data/lib/cisco_node_utils/vlan_DEPRECATED.rb +108 -0
- data/lib/cisco_node_utils/yang.rb +160 -0
- data/lib/cisco_node_utils/yum.rb +25 -32
- data/tests/.rubocop.yml +3 -0
- data/tests/ciscotest.rb +136 -19
- data/tests/cmd_config_invalid.yaml +1 -1
- data/tests/noop.rb +7 -0
- data/tests/tacacs_server.yaml.example +6 -0
- data/tests/test_aaa_authentication_login.rb +24 -1
- data/tests/test_aaa_authentication_login_service.rb +9 -16
- data/tests/test_aaa_authorization_service.rb +111 -84
- data/tests/test_bfd_global.rb +278 -0
- data/tests/test_bgp_neighbor.rb +20 -0
- data/tests/test_bridge_domain_vni.rb +2 -9
- data/tests/test_cmn_utils.rb +76 -0
- data/tests/test_dhcp_relay_global.rb +284 -0
- data/tests/test_dns_domain.rb +4 -4
- data/tests/test_domain_name.rb +2 -2
- data/tests/test_encapsulation.rb +2 -4
- data/tests/test_evpn_vni.rb +14 -7
- data/tests/test_fabricpath_global.rb +12 -13
- data/tests/test_feature.rb +35 -17
- data/tests/test_interface.rb +352 -127
- data/tests/test_interface_bdi.rb +2 -2
- data/tests/test_interface_channel_group.rb +1 -1
- data/tests/test_interface_ospf.rb +153 -23
- data/tests/test_interface_portchannel.rb +15 -6
- data/tests/test_interface_private_vlan.rb +200 -576
- data/tests/test_interface_svi.rb +5 -52
- data/tests/test_interface_switchport.rb +80 -240
- data/tests/test_itd_device_group.rb +2 -2
- data/tests/test_itd_device_group_node.rb +2 -2
- data/tests/test_itd_service.rb +1 -1
- data/tests/test_name_server.rb +3 -3
- data/tests/test_node_ext.rb +15 -17
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +3 -3
- data/tests/test_nxapi.rb +1 -0
- data/tests/test_overlay_global.rb +15 -19
- data/tests/test_pim.rb +5 -5
- data/tests/test_pim_group_list.rb +1 -37
- data/tests/test_pim_rp_address.rb +1 -1
- data/tests/test_platform.rb +9 -11
- data/tests/test_portchannel_global.rb +43 -3
- data/tests/test_radius_server.rb +1 -1
- data/tests/test_radius_server_group.rb +1 -1
- data/tests/test_router_bgp.rb +17 -30
- data/tests/test_router_ospf_area.rb +433 -0
- data/tests/test_router_ospf_area_vlink.rb +298 -0
- data/tests/test_router_ospf_vrf.rb +17 -0
- data/tests/test_snmp_notification_receiver.rb +11 -11
- data/tests/test_snmpcommunity.rb +177 -69
- data/tests/test_snmpgroup.rb +7 -7
- data/tests/test_snmpserver.rb +164 -253
- data/tests/test_snmpuser.rb +73 -69
- data/tests/test_stp_global.rb +15 -15
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_global.rb +80 -0
- data/tests/test_tacacs_server.rb +129 -51
- data/tests/test_tacacs_server_group.rb +3 -29
- data/tests/test_tacacs_server_host.rb +24 -27
- data/tests/test_vlan.rb +57 -59
- data/tests/test_vlan_private.rb +271 -284
- data/tests/test_vpc.rb +10 -4
- data/tests/test_vrf.rb +2 -0
- data/tests/test_vrf_af.rb +2 -5
- data/tests/test_vtp.rb +5 -2
- data/tests/test_vxlan_vtep.rb +20 -44
- data/tests/test_vxlan_vtep_vni.rb +23 -16
- data/tests/test_yang.rb +369 -0
- data/tests/test_yum.rb +34 -42
- data/tests/yum_package.yaml +35 -0
- metadata +31 -4
- data/tests/test_vlan_mt_full.rb +0 -85
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NXAPI implementation of Router OSPF Area Virtual-link class
|
|
3
|
+
#
|
|
4
|
+
# June 2016, Sai Chintalapudi
|
|
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 'node_util'
|
|
21
|
+
require_relative 'router_ospf_vrf'
|
|
22
|
+
|
|
23
|
+
module Cisco
|
|
24
|
+
# node_utils class for ospf_area_vlink
|
|
25
|
+
class RouterOspfAreaVirtualLink < NodeUtil
|
|
26
|
+
attr_reader :router, :vrf, :area_id, :vl
|
|
27
|
+
|
|
28
|
+
def initialize(ospf_router, vrf_name, area_id, virtual_link,
|
|
29
|
+
instantiate=true)
|
|
30
|
+
fail TypeError unless ospf_router.is_a?(String)
|
|
31
|
+
fail TypeError unless vrf_name.is_a?(String)
|
|
32
|
+
fail ArgumentError unless ospf_router.length > 0
|
|
33
|
+
fail ArgumentError unless vrf_name.length > 0
|
|
34
|
+
@area_id = area_id.to_s
|
|
35
|
+
fail ArgumentError if @area_id.empty?
|
|
36
|
+
fail ArgumentError unless virtual_link.length > 0
|
|
37
|
+
|
|
38
|
+
# Convert to dot-notation
|
|
39
|
+
@router = ospf_router
|
|
40
|
+
@vrf = vrf_name
|
|
41
|
+
@area_id = IPAddr.new(area_id.to_i, Socket::AF_INET) unless @area_id[/\./]
|
|
42
|
+
@vl = virtual_link
|
|
43
|
+
|
|
44
|
+
set_args_keys_default
|
|
45
|
+
create if instantiate
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.virtual_links
|
|
49
|
+
hash = {}
|
|
50
|
+
RouterOspf.routers.each do |name, _obj|
|
|
51
|
+
# get all virtual_links under default vrf
|
|
52
|
+
links = config_get('ospf_area_vlink', 'virtual_links', name: name)
|
|
53
|
+
unless links.nil?
|
|
54
|
+
hash[name] = {}
|
|
55
|
+
hash[name]['default'] = {}
|
|
56
|
+
links.each do |area, vl|
|
|
57
|
+
hash[name]['default'][area] ||= {}
|
|
58
|
+
hash[name]['default'][area][vl] =
|
|
59
|
+
RouterOspfAreaVirtualLink.new(name, 'default', area, vl, false)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
vrf_ids = config_get('ospf', 'vrf', name: name)
|
|
63
|
+
next if vrf_ids.nil?
|
|
64
|
+
vrf_ids.each do |vrf|
|
|
65
|
+
# get all virtual_links under each vrf
|
|
66
|
+
links = config_get('ospf_area_vlink', 'virtual_links',
|
|
67
|
+
name: name, vrf: vrf)
|
|
68
|
+
next if links.nil?
|
|
69
|
+
hash[name] ||= {}
|
|
70
|
+
hash[name][vrf] = {}
|
|
71
|
+
links.each do |area, vl|
|
|
72
|
+
hash[name][vrf][area] ||= {}
|
|
73
|
+
hash[name][vrf][area][vl] =
|
|
74
|
+
RouterOspfAreaVirtualLink.new(name, vrf, area, vl, false)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
hash
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Helper method to delete @set_args hash keys
|
|
82
|
+
def set_args_keys_default
|
|
83
|
+
@set_args = { name: @router, area: @area_id, vl: @vl }
|
|
84
|
+
@set_args[:vrf] = @vrf unless @vrf == 'default'
|
|
85
|
+
@get_args = @set_args
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# rubocop:disable Style/AccessorMethodName
|
|
89
|
+
def set_args_keys(hash={})
|
|
90
|
+
set_args_keys_default
|
|
91
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Create one router ospf area virtual-link instance
|
|
95
|
+
def create
|
|
96
|
+
RouterOspfVrf.new(@router, @vrf)
|
|
97
|
+
set_args_keys(state: '')
|
|
98
|
+
config_set('ospf_area_vlink', 'virtual_links', @set_args)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def destroy
|
|
102
|
+
return unless Feature.ospf_enabled?
|
|
103
|
+
set_args_keys(state: 'no')
|
|
104
|
+
config_set('ospf_area_vlink', 'virtual_links', @set_args)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def ==(other)
|
|
108
|
+
(ospf_router == other.ospf_router) &&
|
|
109
|
+
(vrf_name == other.vrf_name) && (area_id == other.area_id) &&
|
|
110
|
+
(vl == other.vl)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
########################################################
|
|
114
|
+
# PROPERTIES #
|
|
115
|
+
########################################################
|
|
116
|
+
|
|
117
|
+
# CLI can be either of the following or none
|
|
118
|
+
# authentication
|
|
119
|
+
# authentication message-digest
|
|
120
|
+
# authentication null
|
|
121
|
+
def authentication
|
|
122
|
+
auth = config_get('ospf_area_vlink', 'authentication', @get_args)
|
|
123
|
+
return default_authentication unless auth
|
|
124
|
+
if auth.include?('message-digest')
|
|
125
|
+
return 'md5'
|
|
126
|
+
elsif auth.include?('null')
|
|
127
|
+
return 'null'
|
|
128
|
+
else
|
|
129
|
+
return 'cleartext'
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def authentication=(val)
|
|
134
|
+
state = val ? '' : 'no'
|
|
135
|
+
if val.to_s == 'md5'
|
|
136
|
+
auth = 'message-digest'
|
|
137
|
+
elsif val.to_s == 'null'
|
|
138
|
+
auth = 'null'
|
|
139
|
+
else
|
|
140
|
+
auth = ''
|
|
141
|
+
end
|
|
142
|
+
set_args_keys(state: state, auth: auth)
|
|
143
|
+
config_set('ospf_area_vlink', 'authentication', @set_args)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def default_authentication
|
|
147
|
+
config_get_default('ospf_area_vlink', 'authentication')
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def auth_key_chain
|
|
151
|
+
config_get('ospf_area_vlink', 'auth_key_chain', @get_args)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def auth_key_chain=(val)
|
|
155
|
+
state = val ? '' : 'no'
|
|
156
|
+
id = val ? val : ''
|
|
157
|
+
set_args_keys(state: state, key_id: id)
|
|
158
|
+
config_set('ospf_area_vlink', 'auth_key_chain', @set_args)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def default_auth_key_chain
|
|
162
|
+
config_get_default('ospf_area_vlink', 'auth_key_chain')
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def authentication_key_encryption_type
|
|
166
|
+
Encryption.cli_to_symbol(
|
|
167
|
+
config_get('ospf_area_vlink', 'authentication_key_enc_type', @get_args))
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def default_authentication_key_encryption_type
|
|
171
|
+
Encryption.cli_to_symbol(
|
|
172
|
+
config_get_default('ospf_area_vlink', 'authentication_key_enc_type'))
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def authentication_key_password
|
|
176
|
+
config_get('ospf_area_vlink', 'authentication_key_password', @get_args)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def default_authentication_key_password
|
|
180
|
+
config_get_default('ospf_area_vlink', 'authentication_key_password')
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# example CLI:
|
|
184
|
+
# authentication-key 3 3109a60f51374a0d
|
|
185
|
+
# To remove the authentication-key altogether,
|
|
186
|
+
# set the password to empty string
|
|
187
|
+
def authentication_key_set(enctype, pw)
|
|
188
|
+
state = pw.empty? ? 'no' : ''
|
|
189
|
+
enctype = pw.empty? ? '' : Encryption.symbol_to_cli(enctype)
|
|
190
|
+
set_args_keys(state: state, enctype: enctype, password: pw)
|
|
191
|
+
config_set('ospf_area_vlink', 'authentication_key_set', @set_args)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def message_digest_algorithm_type
|
|
195
|
+
config_get('ospf_area_vlink', 'message_digest_key_alg_type',
|
|
196
|
+
@get_args).to_sym
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def default_message_digest_algorithm_type
|
|
200
|
+
config_get_default('ospf_area_vlink',
|
|
201
|
+
'message_digest_key_alg_type').to_sym
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def message_digest_encryption_type
|
|
205
|
+
Encryption.cli_to_symbol(
|
|
206
|
+
config_get('ospf_area_vlink', 'message_digest_key_enc_type', @get_args))
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def default_message_digest_encryption_type
|
|
210
|
+
Encryption.cli_to_symbol(
|
|
211
|
+
config_get_default('ospf_area_vlink', 'message_digest_key_enc_type'))
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def message_digest_key_id
|
|
215
|
+
config_get('ospf_area_vlink', 'message_digest_key_id', @get_args)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def default_message_digest_key_id
|
|
219
|
+
config_get_default('ospf_area_vlink', 'message_digest_key_id')
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def message_digest_password
|
|
223
|
+
config_get('ospf_area_vlink', 'message_digest_key_password', @get_args)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def default_message_digest_password
|
|
227
|
+
config_get_default('ospf_area_vlink', 'message_digest_key_password')
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# example CLI:
|
|
231
|
+
# message-digest-key 39 md5 7 046E1803362E595C260E0B240619050A2D
|
|
232
|
+
# To remove the message-digest-key altogether,
|
|
233
|
+
# set the password to empty string
|
|
234
|
+
def message_digest_key_set(keyid, algtype, enctype, pw)
|
|
235
|
+
return if pw.empty? && message_digest_password.empty?
|
|
236
|
+
# To remove the configuration, the entire previous
|
|
237
|
+
# configuration must be given with 'no' cmd
|
|
238
|
+
state = pw.empty? ? 'no' : ''
|
|
239
|
+
algtype = pw.empty? ? message_digest_algorithm_type : algtype.to_s
|
|
240
|
+
if pw.empty?
|
|
241
|
+
enctype = Encryption.symbol_to_cli(
|
|
242
|
+
message_digest_encryption_type.to_sym)
|
|
243
|
+
else
|
|
244
|
+
enctype = Encryption.symbol_to_cli(enctype)
|
|
245
|
+
end
|
|
246
|
+
keyid = pw.empty? ? message_digest_key_id : keyid
|
|
247
|
+
pw = pw.empty? ? message_digest_password : pw
|
|
248
|
+
set_args_keys(state: state, keyid: keyid, algtype: algtype,
|
|
249
|
+
enctype: enctype, password: pw)
|
|
250
|
+
config_set('ospf_area_vlink', 'message_digest_key_set', @set_args)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def dead_interval
|
|
254
|
+
config_get('ospf_area_vlink', 'dead_interval', @get_args)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def dead_interval=(val)
|
|
258
|
+
state = val == default_dead_interval ? 'no' : ''
|
|
259
|
+
interval = val == default_dead_interval ? '' : val
|
|
260
|
+
set_args_keys(state: state, interval: interval)
|
|
261
|
+
config_set('ospf_area_vlink', 'dead_interval', @set_args)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def default_dead_interval
|
|
265
|
+
config_get_default('ospf_area_vlink', 'dead_interval')
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def hello_interval
|
|
269
|
+
config_get('ospf_area_vlink', 'hello_interval', @get_args)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def hello_interval=(val)
|
|
273
|
+
state = val == default_hello_interval ? 'no' : ''
|
|
274
|
+
interval = val == default_hello_interval ? '' : val
|
|
275
|
+
set_args_keys(state: state, interval: interval)
|
|
276
|
+
config_set('ospf_area_vlink', 'hello_interval', @set_args)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def default_hello_interval
|
|
280
|
+
config_get_default('ospf_area_vlink', 'hello_interval')
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def retransmit_interval
|
|
284
|
+
config_get('ospf_area_vlink', 'retransmit_interval', @get_args)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def retransmit_interval=(val)
|
|
288
|
+
state = val == default_retransmit_interval ? 'no' : ''
|
|
289
|
+
interval = val == default_retransmit_interval ? '' : val
|
|
290
|
+
set_args_keys(state: state, interval: interval)
|
|
291
|
+
config_set('ospf_area_vlink', 'retransmit_interval', @set_args)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def default_retransmit_interval
|
|
295
|
+
config_get_default('ospf_area_vlink', 'retransmit_interval')
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def transmit_delay
|
|
299
|
+
config_get('ospf_area_vlink', 'transmit_delay', @get_args)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def transmit_delay=(val)
|
|
303
|
+
state = val == default_transmit_delay ? 'no' : ''
|
|
304
|
+
delay = val == default_transmit_delay ? '' : val
|
|
305
|
+
set_args_keys(state: state, delay: delay)
|
|
306
|
+
config_set('ospf_area_vlink', 'transmit_delay', @set_args)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
def default_transmit_delay
|
|
310
|
+
config_get_default('ospf_area_vlink', 'transmit_delay')
|
|
311
|
+
end
|
|
312
|
+
end # class
|
|
313
|
+
end # module
|
|
@@ -108,6 +108,23 @@ module Cisco
|
|
|
108
108
|
config_get_default('ospf', 'auto_cost')
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
+
def bfd
|
|
112
|
+
config_get('ospf', 'bfd', @get_args)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def bfd=(state)
|
|
116
|
+
return if state == bfd
|
|
117
|
+
no_cmd = (state ? '' : 'no')
|
|
118
|
+
@set_args[:state] = no_cmd
|
|
119
|
+
Feature.bfd_enable
|
|
120
|
+
config_set('ospf', 'bfd', @set_args)
|
|
121
|
+
delete_set_args_keys([:state])
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def default_bfd
|
|
125
|
+
config_get_default('ospf', 'bfd')
|
|
126
|
+
end
|
|
127
|
+
|
|
111
128
|
def default_metric
|
|
112
129
|
config_get('ospf', 'default_metric', @get_args)
|
|
113
130
|
end
|
|
@@ -21,7 +21,7 @@ module Cisco
|
|
|
21
21
|
class SnmpNotificationReceiver < NodeUtil
|
|
22
22
|
attr_reader :name
|
|
23
23
|
|
|
24
|
-
def initialize(name,
|
|
24
|
+
def initialize(name, # rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity, LineLength, AbcSize
|
|
25
25
|
instantiate: true,
|
|
26
26
|
type: '',
|
|
27
27
|
version: '',
|
|
@@ -67,7 +67,7 @@ module Cisco
|
|
|
67
67
|
state: '',
|
|
68
68
|
ip: name,
|
|
69
69
|
type: type,
|
|
70
|
-
version: version,
|
|
70
|
+
version: version.empty? ? '' : "version #{version}",
|
|
71
71
|
security: security,
|
|
72
72
|
username: username,
|
|
73
73
|
udp_port: port.empty? ? '' : "udp-port #{port}")
|
|
@@ -81,11 +81,19 @@ module Cisco
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
return if vrf.empty?
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
if platform == :nexus
|
|
85
|
+
config_set('snmp_notification_receiver',
|
|
86
|
+
'vrf',
|
|
87
|
+
ip: name,
|
|
88
|
+
vrf: vrf,
|
|
89
|
+
port: port.empty? ? '' : "udp-port #{port}")
|
|
90
|
+
else
|
|
91
|
+
config_set('snmp_notification_receiver',
|
|
92
|
+
'vrf',
|
|
93
|
+
vrf: vrf,
|
|
94
|
+
ip: name,
|
|
95
|
+
username: username)
|
|
96
|
+
end
|
|
89
97
|
end
|
|
90
98
|
|
|
91
99
|
def self.receivers
|
|
@@ -113,7 +121,7 @@ module Cisco
|
|
|
113
121
|
state: 'no',
|
|
114
122
|
ip: name,
|
|
115
123
|
type: type,
|
|
116
|
-
version: version,
|
|
124
|
+
version: version.nil? ? '' : "version #{version}",
|
|
117
125
|
security: security.nil? ? '' : "#{security}",
|
|
118
126
|
username: username,
|
|
119
127
|
udp_port: port.nil? ? '' : "udp-port #{port}")
|
|
@@ -146,7 +154,17 @@ module Cisco
|
|
|
146
154
|
end
|
|
147
155
|
|
|
148
156
|
def vrf
|
|
149
|
-
|
|
157
|
+
if platform == :nexus
|
|
158
|
+
config_get('snmp_notification_receiver', 'vrf', @name)
|
|
159
|
+
else
|
|
160
|
+
# get all vrf
|
|
161
|
+
all_vrf = config_get('snmp_notification_receiver', 'vrf_all')
|
|
162
|
+
all_vrf.each do |vrf|
|
|
163
|
+
vrf_list = config_get('snmp_notification_receiver', 'vrf_values', vrf: vrf) # rubocop:disable Metrics/LineLength
|
|
164
|
+
# if vrf contains @name return vrf
|
|
165
|
+
return vrf if vrf_list.include?(@name)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
150
168
|
end
|
|
151
169
|
|
|
152
170
|
def source_interface
|
|
@@ -22,10 +22,23 @@ module Cisco
|
|
|
22
22
|
@communities = nil
|
|
23
23
|
|
|
24
24
|
def initialize(name, group, instantiate=true)
|
|
25
|
-
fail TypeError unless name.is_a?(String)
|
|
25
|
+
fail TypeError unless name.is_a?(String)
|
|
26
|
+
fail TypeError unless group.is_a?(String)
|
|
26
27
|
@name = name
|
|
27
28
|
return unless instantiate
|
|
28
|
-
|
|
29
|
+
if platform == :nexus
|
|
30
|
+
config_set('snmp_community', 'community',
|
|
31
|
+
state: '',
|
|
32
|
+
name: @name,
|
|
33
|
+
group: group)
|
|
34
|
+
else
|
|
35
|
+
config_set('snmp_community', 'community',
|
|
36
|
+
state: '',
|
|
37
|
+
name: @name)
|
|
38
|
+
# create the mapping for group
|
|
39
|
+
config_set('snmp_community', 'group_simple', state: '', group: group)
|
|
40
|
+
config_set('snmp_community', 'group_community_mapping', name: @name, group: group) # rubocop:disable Metrics/LineLength
|
|
41
|
+
end
|
|
29
42
|
end
|
|
30
43
|
|
|
31
44
|
def self.communities
|
|
@@ -41,7 +54,10 @@ module Cisco
|
|
|
41
54
|
|
|
42
55
|
def destroy
|
|
43
56
|
# CLI requires specifying a group even for "no" commands
|
|
44
|
-
config_set('snmp_community', 'community',
|
|
57
|
+
config_set('snmp_community', 'community',
|
|
58
|
+
state: 'no',
|
|
59
|
+
name: @name,
|
|
60
|
+
group: 'null')
|
|
45
61
|
end
|
|
46
62
|
|
|
47
63
|
# name is read only
|
|
@@ -50,12 +66,22 @@ module Cisco
|
|
|
50
66
|
# end
|
|
51
67
|
|
|
52
68
|
def group
|
|
53
|
-
|
|
69
|
+
if platform == :nexus
|
|
70
|
+
config_get('snmp_community', 'group', name: @name)
|
|
71
|
+
else
|
|
72
|
+
config_get('snmp_community', 'group_community_mapping', name: @name)
|
|
73
|
+
end
|
|
54
74
|
end
|
|
55
75
|
|
|
56
76
|
def group=(group)
|
|
57
77
|
fail TypeError unless group.is_a?(String)
|
|
58
|
-
|
|
78
|
+
if platform == :nexus
|
|
79
|
+
config_set('snmp_community', 'group', name: @name, group: group)
|
|
80
|
+
else
|
|
81
|
+
# create the mapping
|
|
82
|
+
config_set('snmp_community', 'group_simple', group: group)
|
|
83
|
+
config_set('snmp_community', 'group_community_mapping', name: @name, group: group) # rubocop:disable Metrics/LineLength
|
|
84
|
+
end
|
|
59
85
|
end
|
|
60
86
|
|
|
61
87
|
def self.default_group
|
|
@@ -63,16 +89,16 @@ module Cisco
|
|
|
63
89
|
end
|
|
64
90
|
|
|
65
91
|
def acl
|
|
66
|
-
config_get('snmp_community', 'acl', @name)
|
|
92
|
+
config_get('snmp_community', 'acl', name: @name)
|
|
67
93
|
end
|
|
68
94
|
|
|
69
95
|
def acl=(acl)
|
|
70
96
|
fail TypeError unless acl.is_a?(String)
|
|
71
97
|
if acl.empty?
|
|
72
98
|
acl = self.acl
|
|
73
|
-
config_set('snmp_community', 'acl', 'no', @name, acl) unless acl.empty?
|
|
99
|
+
config_set('snmp_community', 'acl', state: 'no', name: @name, acl: acl) unless acl.empty? # rubocop:disable Metrics/LineLength
|
|
74
100
|
else
|
|
75
|
-
config_set('snmp_community', 'acl', '', @name, acl)
|
|
101
|
+
config_set('snmp_community', 'acl', state: '', name: @name, acl: acl)
|
|
76
102
|
end
|
|
77
103
|
end
|
|
78
104
|
|