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.
- 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,513 @@
|
|
1
|
+
# rubocop: disable Style/FileName
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cisco and/or its affiliates.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
###############################################################################
|
17
|
+
#
|
18
|
+
# WARNING! WARNING! WARNING!
|
19
|
+
#
|
20
|
+
# This file contains deprecated methods that will be removed with version 2.0.0
|
21
|
+
#
|
22
|
+
###############################################################################
|
23
|
+
|
24
|
+
require_relative 'node_util'
|
25
|
+
require 'logger'
|
26
|
+
|
27
|
+
# Cisco provider module
|
28
|
+
module Cisco
|
29
|
+
# Interface - node utility class for general interface config management
|
30
|
+
class InterfaceDeprecated < NodeUtil
|
31
|
+
PVLAN_PROPERTY = {
|
32
|
+
host_promisc: 'switchport_mode_private_vlan_host_promiscous',
|
33
|
+
allow_vlan: 'switchport_private_vlan_trunk_allowed_vlan',
|
34
|
+
trunk_assoc: 'switchport_private_vlan_association_trunk',
|
35
|
+
mapping_trunk: 'switchport_private_vlan_mapping_trunk',
|
36
|
+
vlan_mapping: 'private_vlan_mapping',
|
37
|
+
}
|
38
|
+
|
39
|
+
def deprecation_warning(method, new_prop=nil)
|
40
|
+
if new_prop.nil?
|
41
|
+
new_prop = ''
|
42
|
+
else
|
43
|
+
new_prop = "The new property name is '#{new_prop}'"
|
44
|
+
end
|
45
|
+
|
46
|
+
warn "
|
47
|
+
#########################################################################
|
48
|
+
WARNING: Method '#{method.to_s.delete('=')}'
|
49
|
+
is deprecated and should not be used.
|
50
|
+
#{new_prop}
|
51
|
+
#########################################################################
|
52
|
+
"
|
53
|
+
end
|
54
|
+
|
55
|
+
def switchport_enable_and_mode_private_vlan_host(mode_set)
|
56
|
+
deprecation_warning(__method__)
|
57
|
+
switchport_enable unless switchport
|
58
|
+
if mode_set[/(host|promiscuous)/]
|
59
|
+
config_set('DEPRECATED', 'switchport_mode_private_vlan_host',
|
60
|
+
name: @name, state: '', mode: IF_SWITCHPORT_MODE[mode_set])
|
61
|
+
else
|
62
|
+
config_set('DEPRECATED', 'switchport_mode_private_vlan_host',
|
63
|
+
name: @name, state: 'no', mode: IF_SWITCHPORT_MODE[mode_set])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def switchport_mode_private_vlan_host
|
68
|
+
mode = config_get('DEPRECATED',
|
69
|
+
'switchport_mode_private_vlan_host',
|
70
|
+
name: @name)
|
71
|
+
unless mode == default_switchport_mode_private_vlan_host
|
72
|
+
mode = IF_SWITCHPORT_MODE.key(mode)
|
73
|
+
end
|
74
|
+
mode
|
75
|
+
rescue IndexError
|
76
|
+
# Assume this is an interface that doesn't support switchport.
|
77
|
+
# Do not raise exception since the providers will prefetch this property
|
78
|
+
# regardless of interface type.
|
79
|
+
# TODO: this should probably be nil instead
|
80
|
+
return default_switchport_mode_private_vlan_host
|
81
|
+
end
|
82
|
+
|
83
|
+
def switchport_mode_private_vlan_host=(mode_set)
|
84
|
+
deprecation_warning(__method__, 'switchport_pvlan_host')
|
85
|
+
|
86
|
+
fail ArgumentError unless IF_SWITCHPORT_MODE.keys.include? mode_set
|
87
|
+
Feature.private_vlan_enable
|
88
|
+
switchport_enable_and_mode_private_vlan_host(mode_set)
|
89
|
+
end
|
90
|
+
|
91
|
+
def default_switchport_mode_private_vlan_host
|
92
|
+
config_get_default('DEPRECATED',
|
93
|
+
'switchport_mode_private_vlan_host')
|
94
|
+
end
|
95
|
+
|
96
|
+
def switchport_mode_private_vlan_host_association
|
97
|
+
result = config_get('DEPRECATED',
|
98
|
+
'switchport_mode_private_vlan_host_association',
|
99
|
+
name: @name)
|
100
|
+
unless result == default_switchport_mode_private_vlan_host_association
|
101
|
+
result = result[0].split(' ')
|
102
|
+
end
|
103
|
+
result
|
104
|
+
end
|
105
|
+
|
106
|
+
def switchport_mode_private_vlan_host_association=(vlans)
|
107
|
+
deprecation_warning(__method__, 'switchport_pvlan_host_association')
|
108
|
+
fail TypeError unless vlans.is_a?(Array) || vlans.empty?
|
109
|
+
switchport_enable unless switchport
|
110
|
+
Feature.private_vlan_enable
|
111
|
+
if vlans == default_switchport_mode_private_vlan_host_association
|
112
|
+
result = config_set('DEPRECATED',
|
113
|
+
'switchport_mode_private_vlan_host_association',
|
114
|
+
name: @name, state: 'no', vlan_pr: '', vlan_sec: '')
|
115
|
+
|
116
|
+
else
|
117
|
+
result = config_set('DEPRECATED',
|
118
|
+
'switchport_mode_private_vlan_host_association',
|
119
|
+
name: @name, state: '',
|
120
|
+
vlan_pr: vlans[0], vlan_sec: vlans[1])
|
121
|
+
|
122
|
+
end
|
123
|
+
cli_error_check(result)
|
124
|
+
end
|
125
|
+
|
126
|
+
def default_switchport_mode_private_vlan_host_association
|
127
|
+
config_get_default('DEPRECATED',
|
128
|
+
'switchport_mode_private_vlan_host_association')
|
129
|
+
end
|
130
|
+
|
131
|
+
# This api is used by private vlan to prepare the input to the setter
|
132
|
+
# method. The input can be in the following formats for vlans:
|
133
|
+
# 10-12,14. Prepare_array api is transforming this input into a flat array.
|
134
|
+
# In the example above the returned array will be 10, 11, 12, 13. Prepare
|
135
|
+
# array is first splitting the input on ',' and the than expanding the vlan
|
136
|
+
# range element like 10-12 into a flat array. The final result will
|
137
|
+
# be a flat array.
|
138
|
+
# This way we can later used the lib utility to check the delta from
|
139
|
+
# the input vlan value and the vlan configured to apply the right config.
|
140
|
+
def prepare_array(is_list)
|
141
|
+
new_list = []
|
142
|
+
is_list.each do |item|
|
143
|
+
if item.include?(',')
|
144
|
+
new_list.push(item.split(','))
|
145
|
+
else
|
146
|
+
new_list.push(item)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
new_list.flatten!
|
150
|
+
new_list.sort!
|
151
|
+
new_list.each { |item| item.gsub!('-', '..') }
|
152
|
+
is_list_new = []
|
153
|
+
new_list.each do |elem|
|
154
|
+
if elem.include?('..')
|
155
|
+
elema = elem.split('..').map { |d| Integer(d) }
|
156
|
+
elema.sort!
|
157
|
+
tr = elema[0]..elema[1]
|
158
|
+
tr.to_a.each do |item|
|
159
|
+
is_list_new.push(item.to_s)
|
160
|
+
end
|
161
|
+
else
|
162
|
+
is_list_new.push(elem)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
is_list_new
|
166
|
+
end
|
167
|
+
|
168
|
+
def configure_private_vlan_host_property(property, should_list_new,
|
169
|
+
is_list_new, pr_vlan)
|
170
|
+
delta_hash = Utils.delta_add_remove(should_list_new, is_list_new)
|
171
|
+
[:add, :remove].each do |action|
|
172
|
+
delta_hash[action].each do |vlans|
|
173
|
+
state = (action == :add) ? '' : 'no'
|
174
|
+
oper = (action == :add) ? 'add' : 'remove'
|
175
|
+
if property[/(host_promisc|mapping_trunk)/]
|
176
|
+
|
177
|
+
result = config_set('DEPRECATED', PVLAN_PROPERTY[property],
|
178
|
+
name: @name, state: state,
|
179
|
+
vlan_pr: pr_vlan, vlans: vlans)
|
180
|
+
@match_found = true
|
181
|
+
end
|
182
|
+
if property[/allow_vlan/]
|
183
|
+
result = config_set('DEPRECATED',
|
184
|
+
PVLAN_PROPERTY[property],
|
185
|
+
name: @name, state: '',
|
186
|
+
oper: oper, vlans: vlans)
|
187
|
+
end
|
188
|
+
if property[/vlan_mapping/]
|
189
|
+
result = config_set('DEPRECATED',
|
190
|
+
PVLAN_PROPERTY[property],
|
191
|
+
name: @name, state: state,
|
192
|
+
vlans: vlans)
|
193
|
+
end
|
194
|
+
cli_error_check(result)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def configure_private_vlan_trunk_property(property, should_list_new,
|
200
|
+
is_list, pr_vlan)
|
201
|
+
case property
|
202
|
+
when :trunk_assoc
|
203
|
+
is_list.each do |vlans|
|
204
|
+
vlans = vlans.split(' ')
|
205
|
+
if vlans[0].eql? should_list_new[0]
|
206
|
+
config_set('DEPRECATED',
|
207
|
+
'switchport_private_vlan_association_trunk',
|
208
|
+
name: @name, state: 'no',
|
209
|
+
vlan_pr: pr_vlan, vlan: vlans[1])
|
210
|
+
break
|
211
|
+
else
|
212
|
+
next
|
213
|
+
end
|
214
|
+
end
|
215
|
+
result = config_set('DEPRECATED', PVLAN_PROPERTY[property], name: @name,
|
216
|
+
state: '', vlan_pr: should_list_new[0],
|
217
|
+
vlan: should_list_new[1])
|
218
|
+
when :mapping_trunk
|
219
|
+
@match_found = false
|
220
|
+
is_list.each do |vlans|
|
221
|
+
vlans = vlans.split(' ')
|
222
|
+
interf_vlan_list_delta(:mapping_trunk, vlans,
|
223
|
+
should_list_new)
|
224
|
+
if @match_found
|
225
|
+
break
|
226
|
+
else
|
227
|
+
next
|
228
|
+
end
|
229
|
+
end
|
230
|
+
result = config_set('DEPRECATED', PVLAN_PROPERTY[property], name: @name,
|
231
|
+
state: '', vlan_pr: should_list_new[0],
|
232
|
+
vlans: should_list_new[1])
|
233
|
+
end
|
234
|
+
cli_error_check(result)
|
235
|
+
end
|
236
|
+
|
237
|
+
# --------------------------
|
238
|
+
# interf_vlan_list_delta is a helper function for the private_vlan_mapping
|
239
|
+
# property. It walks the delta hash and adds/removes each target private
|
240
|
+
# vlan.
|
241
|
+
|
242
|
+
def interf_vlan_list_delta(property, is_list, should_list)
|
243
|
+
pr_vlan = should_list[0]
|
244
|
+
if is_list[0].eql? should_list[0]
|
245
|
+
should_list = should_list[1].split(',')
|
246
|
+
is_list = is_list[1].split(',')
|
247
|
+
|
248
|
+
should_list_new = prepare_array(should_list)
|
249
|
+
is_list_new = prepare_array(is_list)
|
250
|
+
configure_private_vlan_host_property(property, should_list_new,
|
251
|
+
is_list_new, pr_vlan)
|
252
|
+
else
|
253
|
+
case property
|
254
|
+
when :mapping_trunk
|
255
|
+
return
|
256
|
+
end
|
257
|
+
# If primary vlan are different we can simply replacing the all
|
258
|
+
# config
|
259
|
+
if should_list == default_switchport_mode_private_vlan_host_promisc
|
260
|
+
result = config_set('DEPRECATED',
|
261
|
+
'switchport_mode_private_vlan_host_promiscous',
|
262
|
+
name: @name, state: 'no',
|
263
|
+
vlan_pr: '', vlans: '')
|
264
|
+
|
265
|
+
else
|
266
|
+
result = config_set('DEPRECATED',
|
267
|
+
'switchport_mode_private_vlan_host_promiscous',
|
268
|
+
name: @name, state: '',
|
269
|
+
vlan_pr: pr_vlan, vlans: should_list[1])
|
270
|
+
|
271
|
+
end
|
272
|
+
cli_error_check(result)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def switchport_mode_private_vlan_host_promisc
|
277
|
+
result = config_get('DEPRECATED',
|
278
|
+
'switchport_mode_private_vlan_host_promiscous',
|
279
|
+
name: @name)
|
280
|
+
unless result == default_switchport_mode_private_vlan_host_promisc
|
281
|
+
result = result[0].split(' ')
|
282
|
+
end
|
283
|
+
result
|
284
|
+
end
|
285
|
+
|
286
|
+
def switchport_mode_private_vlan_host_promisc=(vlans)
|
287
|
+
deprecation_warning(__method__, 'switchport_pvlan_promiscuous')
|
288
|
+
fail TypeError unless vlans.is_a?(Array)
|
289
|
+
fail TypeError unless vlans.empty? || vlans.length == 2
|
290
|
+
switchport_enable unless switchport
|
291
|
+
Feature.private_vlan_enable
|
292
|
+
is_list = switchport_mode_private_vlan_host_promisc
|
293
|
+
interf_vlan_list_delta(:host_promisc, is_list, vlans)
|
294
|
+
end
|
295
|
+
|
296
|
+
def default_switchport_mode_private_vlan_host_promisc
|
297
|
+
config_get_default('DEPRECATED',
|
298
|
+
'switchport_mode_private_vlan_host_promiscous')
|
299
|
+
end
|
300
|
+
|
301
|
+
def switchport_mode_private_vlan_trunk_promiscuous
|
302
|
+
config_get('DEPRECATED',
|
303
|
+
'switchport_mode_private_vlan_trunk_promiscuous',
|
304
|
+
name: @name)
|
305
|
+
rescue IndexError
|
306
|
+
# Assume this is an interface that doesn't support switchport.
|
307
|
+
# Do not raise exception since the providers will prefetch this property
|
308
|
+
# regardless of interface type.
|
309
|
+
# TODO: this should probably be nil instead
|
310
|
+
return default_switchport_mode_private_vlan_trunk_promiscuous
|
311
|
+
end
|
312
|
+
|
313
|
+
def switchport_mode_private_vlan_trunk_promiscuous=(state)
|
314
|
+
deprecation_warning(__method__, 'switchport_pvlan_trunk_promiscuous')
|
315
|
+
Feature.private_vlan_enable
|
316
|
+
switchport_enable unless switchport
|
317
|
+
if state == default_switchport_mode_private_vlan_trunk_promiscuous
|
318
|
+
config_set('DEPRECATED',
|
319
|
+
'switchport_mode_private_vlan_trunk_promiscuous',
|
320
|
+
name: @name, state: 'no')
|
321
|
+
else
|
322
|
+
config_set('DEPRECATED',
|
323
|
+
'switchport_mode_private_vlan_trunk_promiscuous',
|
324
|
+
name: @name, state: '')
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
def default_switchport_mode_private_vlan_trunk_promiscuous
|
329
|
+
config_get_default('DEPRECATED',
|
330
|
+
'switchport_mode_private_vlan_trunk_promiscuous')
|
331
|
+
end
|
332
|
+
|
333
|
+
def switchport_mode_private_vlan_trunk_secondary
|
334
|
+
config_get('DEPRECATED',
|
335
|
+
'switchport_mode_private_vlan_trunk_secondary',
|
336
|
+
name: @name)
|
337
|
+
rescue IndexError
|
338
|
+
# Assume this is an interface that doesn't support switchport.
|
339
|
+
# Do not raise exception since the providers will prefetch this property
|
340
|
+
# regardless of interface type.
|
341
|
+
# TODO: this should probably be nil instead
|
342
|
+
return default_switchport_mode_private_vlan_trunk_secondary
|
343
|
+
end
|
344
|
+
|
345
|
+
def switchport_mode_private_vlan_trunk_secondary=(state)
|
346
|
+
deprecation_warning(__method__, 'switchport_pvlan_trunk_secondary')
|
347
|
+
Feature.private_vlan_enable
|
348
|
+
switchport_enable unless switchport
|
349
|
+
if state == default_switchport_mode_private_vlan_trunk_secondary
|
350
|
+
config_set('DEPRECATED', 'switchport_mode_private_vlan_trunk_secondary',
|
351
|
+
name: @name, state: 'no')
|
352
|
+
else
|
353
|
+
config_set('DEPRECATED', 'switchport_mode_private_vlan_trunk_secondary',
|
354
|
+
name: @name, state: '')
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def default_switchport_mode_private_vlan_trunk_secondary
|
359
|
+
config_get_default('DEPRECATED',
|
360
|
+
'switchport_mode_private_vlan_trunk_secondary')
|
361
|
+
end
|
362
|
+
|
363
|
+
def switchport_private_vlan_trunk_allowed_vlan
|
364
|
+
result = config_get('DEPRECATED',
|
365
|
+
'switchport_private_vlan_trunk_allowed_vlan',
|
366
|
+
name: @name)
|
367
|
+
|
368
|
+
unless result == default_switchport_private_vlan_trunk_allowed_vlan
|
369
|
+
if result[0].eql? 'none'
|
370
|
+
result = default_switchport_private_vlan_trunk_allowed_vlan
|
371
|
+
else
|
372
|
+
result = result[0].split(',')
|
373
|
+
end
|
374
|
+
end
|
375
|
+
result
|
376
|
+
end
|
377
|
+
|
378
|
+
def switchport_private_vlan_trunk_allowed_vlan=(vlans)
|
379
|
+
deprecation_warning(__method__, 'switchport_pvlan_trunk_allowed_vlan')
|
380
|
+
fail TypeError unless vlans.is_a?(Array)
|
381
|
+
Feature.private_vlan_enable
|
382
|
+
switchport_enable unless switchport
|
383
|
+
if vlans == default_switchport_private_vlan_trunk_allowed_vlan
|
384
|
+
vlans = prepare_array(switchport_private_vlan_trunk_allowed_vlan)
|
385
|
+
# If there are no vlan presently configured, we can simply return
|
386
|
+
return if vlans == default_switchport_private_vlan_trunk_allowed_vlan
|
387
|
+
configure_private_vlan_host_property(:allow_vlan, [],
|
388
|
+
vlans, '')
|
389
|
+
else
|
390
|
+
vlans = prepare_array(vlans)
|
391
|
+
is_list = prepare_array(switchport_private_vlan_trunk_allowed_vlan)
|
392
|
+
configure_private_vlan_host_property(:allow_vlan, vlans,
|
393
|
+
is_list, '')
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
def default_switchport_private_vlan_trunk_allowed_vlan
|
398
|
+
config_get_default('DEPRECATED',
|
399
|
+
'switchport_private_vlan_trunk_allowed_vlan')
|
400
|
+
end
|
401
|
+
|
402
|
+
def switchport_private_vlan_trunk_native_vlan
|
403
|
+
config_get('DEPRECATED',
|
404
|
+
'switchport_private_vlan_trunk_native_vlan',
|
405
|
+
name: @name)
|
406
|
+
end
|
407
|
+
|
408
|
+
def switchport_private_vlan_trunk_native_vlan=(vlan)
|
409
|
+
deprecation_warning(__method__, 'switchport_pvlan_trunk_native_vlan')
|
410
|
+
Feature.private_vlan_enable
|
411
|
+
switchport_enable unless switchport
|
412
|
+
if vlan == default_switchport_private_vlan_trunk_native_vlan
|
413
|
+
config_set('DEPRECATED',
|
414
|
+
'switchport_private_vlan_trunk_native_vlan',
|
415
|
+
name: @name, state: 'no', vlan: '')
|
416
|
+
|
417
|
+
else
|
418
|
+
config_set('DEPRECATED',
|
419
|
+
'switchport_private_vlan_trunk_native_vlan',
|
420
|
+
name: @name, state: '', vlan: vlan)
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
def default_switchport_private_vlan_trunk_native_vlan
|
425
|
+
config_get_default('DEPRECATED',
|
426
|
+
'switchport_private_vlan_trunk_native_vlan')
|
427
|
+
end
|
428
|
+
|
429
|
+
def switchport_private_vlan_association_trunk
|
430
|
+
config_get('DEPRECATED',
|
431
|
+
'switchport_private_vlan_association_trunk',
|
432
|
+
name: @name)
|
433
|
+
end
|
434
|
+
|
435
|
+
def switchport_private_vlan_association_trunk=(vlans)
|
436
|
+
deprecation_warning(__method__, 'switchport_pvlan_trunk_association')
|
437
|
+
fail TypeError unless vlans.is_a?(Array) || vlans.empty?
|
438
|
+
Feature.private_vlan_enable
|
439
|
+
switchport_enable unless switchport
|
440
|
+
if vlans == default_switchport_private_vlan_association_trunk
|
441
|
+
config_set('DEPRECATED', 'switchport_private_vlan_association_trunk',
|
442
|
+
name: @name, state: 'no',
|
443
|
+
vlan_pr: '', vlan: '')
|
444
|
+
else
|
445
|
+
is_list = switchport_private_vlan_association_trunk
|
446
|
+
configure_private_vlan_trunk_property(:trunk_assoc, vlans,
|
447
|
+
is_list, vlans[0])
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
def default_switchport_private_vlan_association_trunk
|
452
|
+
config_get_default('DEPRECATED',
|
453
|
+
'switchport_private_vlan_association_trunk')
|
454
|
+
end
|
455
|
+
|
456
|
+
def switchport_private_vlan_mapping_trunk
|
457
|
+
config_get('DEPRECATED',
|
458
|
+
'switchport_private_vlan_mapping_trunk',
|
459
|
+
name: @name)
|
460
|
+
end
|
461
|
+
|
462
|
+
def switchport_private_vlan_mapping_trunk=(vlans)
|
463
|
+
deprecation_warning(__method__, 'switchport_pvlan_mapping_trunk')
|
464
|
+
fail TypeError unless vlans.is_a?(Array) || vlans.empty?
|
465
|
+
Feature.private_vlan_enable
|
466
|
+
switchport_enable unless switchport
|
467
|
+
if vlans == default_switchport_private_vlan_mapping_trunk
|
468
|
+
config_set('DEPRECATED', 'switchport_private_vlan_mapping_trunk',
|
469
|
+
name: @name, state: 'no',
|
470
|
+
vlan_pr: '', vlans: '')
|
471
|
+
else
|
472
|
+
is_list = switchport_private_vlan_mapping_trunk
|
473
|
+
configure_private_vlan_trunk_property(:mapping_trunk, vlans,
|
474
|
+
is_list, vlans[0])
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
def default_switchport_private_vlan_mapping_trunk
|
479
|
+
config_get_default('DEPRECATED',
|
480
|
+
'switchport_private_vlan_mapping_trunk')
|
481
|
+
end
|
482
|
+
|
483
|
+
def private_vlan_mapping
|
484
|
+
match = config_get('DEPRECATED',
|
485
|
+
'private_vlan_mapping',
|
486
|
+
name: @name)
|
487
|
+
match[0].delete!(' ') unless match == default_private_vlan_mapping
|
488
|
+
match
|
489
|
+
end
|
490
|
+
|
491
|
+
def private_vlan_mapping=(vlans)
|
492
|
+
deprecation_warning(__method__, 'pvlan_mapping')
|
493
|
+
fail TypeError unless vlans.is_a?(Array) || vlans.empty?
|
494
|
+
Feature.private_vlan_enable
|
495
|
+
feature_vlan_set(true)
|
496
|
+
if vlans == default_private_vlan_mapping
|
497
|
+
config_set('DEPRECATED', 'private_vlan_mapping',
|
498
|
+
name: @name, state: 'no', vlans: '')
|
499
|
+
else
|
500
|
+
is_list = private_vlan_mapping
|
501
|
+
new_is_list = prepare_array(is_list)
|
502
|
+
new_vlans = prepare_array(vlans)
|
503
|
+
configure_private_vlan_host_property(:vlan_mapping, new_vlans,
|
504
|
+
new_is_list, '')
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
def default_private_vlan_mapping
|
509
|
+
config_get_default('DEPRECATED',
|
510
|
+
'private_vlan_mapping')
|
511
|
+
end
|
512
|
+
end # Class
|
513
|
+
end # Module
|