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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +126 -1
- data/README.md +19 -12
- data/Rakefile +1 -0
- data/bin/git/hooks/commit-msg/enforce_style +8 -0
- data/cisco_node_utils.gemspec +4 -3
- data/docs/README-develop-best-practices.md +127 -109
- data/docs/README-develop-node-utils-APIs.md +47 -39
- data/docs/template-router.rb +3 -7
- data/lib/.rubocop.yml +4 -4
- data/lib/cisco_node_utils.rb +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
- data/lib/cisco_node_utils/ace.rb +196 -0
- data/lib/cisco_node_utils/acl.rb +100 -0
- data/lib/cisco_node_utils/bgp.rb +301 -163
- data/lib/cisco_node_utils/bgp_af.rb +187 -19
- data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
- data/lib/cisco_node_utils/command_reference.rb +359 -187
- data/lib/cisco_node_utils/configparser_lib.rb +1 -1
- data/lib/cisco_node_utils/dns_domain.rb +19 -5
- data/lib/cisco_node_utils/domain_name.rb +4 -8
- data/lib/cisco_node_utils/evpn_vni.rb +157 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
- data/lib/cisco_node_utils/feature.rb +111 -0
- data/lib/cisco_node_utils/interface.rb +390 -97
- data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
- data/lib/cisco_node_utils/interface_ospf.rb +11 -34
- data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/name_server.rb +1 -1
- data/lib/cisco_node_utils/node.rb +55 -249
- data/lib/cisco_node_utils/node_util.rb +5 -1
- data/lib/cisco_node_utils/ntp_config.rb +2 -2
- data/lib/cisco_node_utils/ntp_server.rb +14 -5
- data/lib/cisco_node_utils/overlay_global.rb +153 -0
- data/lib/cisco_node_utils/pim.rb +124 -0
- data/lib/cisco_node_utils/pim_group_list.rb +108 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
- data/lib/cisco_node_utils/platform.rb +8 -9
- data/lib/cisco_node_utils/portchannel_global.rb +277 -0
- data/lib/cisco_node_utils/radius_global.rb +9 -19
- data/lib/cisco_node_utils/radius_server.rb +31 -41
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
- data/lib/cisco_node_utils/snmpgroup.rb +1 -1
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +8 -17
- data/lib/cisco_node_utils/snmpuser.rb +67 -28
- data/lib/cisco_node_utils/syslog_server.rb +3 -9
- data/lib/cisco_node_utils/syslog_settings.rb +2 -10
- data/lib/cisco_node_utils/tacacs_server.rb +9 -14
- data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
- data/lib/cisco_node_utils/vdc.rb +88 -0
- data/lib/cisco_node_utils/version.rb +5 -2
- data/lib/cisco_node_utils/vlan.rb +71 -8
- data/lib/cisco_node_utils/vni.rb +227 -0
- data/lib/cisco_node_utils/vpc.rb +377 -0
- data/lib/cisco_node_utils/vrf.rb +60 -9
- data/lib/cisco_node_utils/vrf_af.rb +191 -0
- data/lib/cisco_node_utils/vtp.rb +8 -6
- data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
- data/lib/cisco_node_utils/yum.rb +1 -1
- data/tests/.rubocop.yml +1 -1
- data/tests/basetest.rb +16 -7
- data/tests/ciscotest.rb +55 -13
- data/tests/cmd_config.yaml +2 -2
- data/tests/platform_info.rb +3 -2
- data/tests/test_aaa_authentication_login.rb +219 -0
- data/tests/test_aaa_authentication_login_service.rb +759 -0
- data/tests/test_aaa_authorization_service.rb +1041 -0
- data/tests/test_ace.rb +160 -0
- data/tests/test_acl.rb +176 -0
- data/tests/test_bgp_af.rb +269 -13
- data/tests/test_bgp_neighbor.rb +38 -40
- data/tests/test_bgp_neighbor_af.rb +92 -32
- data/tests/test_command_config.rb +5 -5
- data/tests/test_command_reference.rb +284 -101
- data/tests/test_dns_domain.rb +1 -1
- data/tests/test_domain_name.rb +1 -1
- data/tests/test_evpn_vni.rb +106 -0
- data/tests/test_fabricpath_global.rb +243 -0
- data/tests/test_fabricpath_topology.rb +98 -0
- data/tests/test_interface.rb +292 -74
- data/tests/test_interface_channel_group.rb +74 -0
- data/tests/test_interface_ospf.rb +9 -4
- data/tests/test_interface_portchannel.rb +105 -0
- data/tests/test_interface_service_vni.rb +232 -0
- data/tests/test_interface_svi.rb +77 -62
- data/tests/test_interface_switchport.rb +17 -5
- data/tests/test_name_server.rb +1 -1
- data/tests/test_node.rb +1 -1
- data/tests/test_node_ext.rb +10 -20
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +18 -6
- data/tests/test_overlay_global.rb +102 -0
- data/tests/test_pim.rb +177 -0
- data/tests/test_pim_group_list.rb +181 -0
- data/tests/test_pim_rp_address.rb +153 -0
- data/tests/test_platform.rb +3 -3
- data/tests/test_portchannel_global.rb +202 -0
- data/tests/test_radius_global.rb +1 -1
- data/tests/test_radius_server.rb +92 -57
- data/tests/test_radius_server_group.rb +149 -0
- data/tests/test_router_bgp.rb +283 -112
- data/tests/test_router_ospf.rb +2 -2
- data/tests/test_router_ospf_vrf.rb +4 -4
- data/tests/test_snmp_notification_receiver.rb +167 -0
- data/tests/test_snmpcommunity.rb +1 -1
- data/tests/test_snmpgroup.rb +1 -1
- data/tests/test_snmpnotification.rb +72 -0
- data/tests/test_snmpserver.rb +29 -105
- data/tests/test_snmpuser.rb +32 -30
- data/tests/test_syslog_server.rb +36 -10
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_server.rb +1 -1
- data/tests/test_tacacs_server_group.rb +405 -0
- data/tests/test_tacacs_server_host.rb +1 -1
- data/tests/test_vdc.rb +78 -0
- data/tests/test_vlan.rb +74 -19
- data/tests/test_vlan_mt_full.rb +95 -0
- data/tests/test_vni.rb +106 -0
- data/tests/test_vpc.rb +361 -0
- data/tests/test_vrf.rb +172 -29
- data/tests/test_vtp.rb +1 -1
- data/tests/test_vxlan_vtep.rb +214 -0
- data/tests/test_vxlan_vtep_vni.rb +201 -0
- data/tests/test_yum.rb +1 -1
- metadata +120 -11
- data/lib/cisco_node_utils/README_YAML.md +0 -325
- data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
- data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
- data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
- data/tests/platform_info.yaml +0 -10
@@ -0,0 +1,196 @@
|
|
1
|
+
# Copyright (c) 2015-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 'node_util'
|
16
|
+
|
17
|
+
module Cisco
|
18
|
+
# Ace - node utility class for Ace Configuration
|
19
|
+
class Ace < NodeUtil
|
20
|
+
attr_reader :afi, :acl_name, :seqno
|
21
|
+
|
22
|
+
def initialize(afi, acl_name, seqno)
|
23
|
+
@afi = Acl.afi_cli(afi)
|
24
|
+
@acl_name = acl_name.to_s
|
25
|
+
@seqno = seqno.to_s
|
26
|
+
set_args_keys_default
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create a hash of all aces under a given acl_name.
|
30
|
+
def self.aces
|
31
|
+
afis = %w(ipv4 ipv6)
|
32
|
+
hash = {}
|
33
|
+
afis.each do |afi|
|
34
|
+
hash[afi] = {}
|
35
|
+
acls = config_get('acl', 'all_acls', afi: Acl.afi_cli(afi))
|
36
|
+
next if acls.nil?
|
37
|
+
|
38
|
+
acls.each do |acl_name|
|
39
|
+
hash[afi][acl_name] = {}
|
40
|
+
aces = config_get('acl', 'all_aces',
|
41
|
+
afi: Acl.afi_cli(afi), acl_name: acl_name)
|
42
|
+
next if aces.nil?
|
43
|
+
|
44
|
+
aces.each do |seqno|
|
45
|
+
hash[afi][acl_name][seqno] = Ace.new(afi, acl_name, seqno)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
hash
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy
|
53
|
+
set_args_keys(state: 'no')
|
54
|
+
config_set('acl', 'ace_destroy', @set_args)
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_args_keys_default
|
58
|
+
keys = { afi: @afi, acl_name: @acl_name, seqno: @seqno }
|
59
|
+
@get_args = @set_args = keys
|
60
|
+
end
|
61
|
+
|
62
|
+
# rubocop:disable Style/AccessorMethodName
|
63
|
+
def set_args_keys(hash={})
|
64
|
+
set_args_keys_default
|
65
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
66
|
+
end
|
67
|
+
|
68
|
+
# common ace getter
|
69
|
+
def ace_get
|
70
|
+
str = config_get('acl', 'ace', @get_args)
|
71
|
+
return nil if str.nil?
|
72
|
+
|
73
|
+
# remark is a description field, needs a separate regex
|
74
|
+
# Example: <MatchData "20 remark foo bar" seqno:"20" remark:"foo bar">
|
75
|
+
remark = Regexp.new('(?<seqno>\d+) remark (?<remark>.*)').match(str)
|
76
|
+
return remark unless remark.nil?
|
77
|
+
|
78
|
+
# rubocop:disable Metrics/LineLength
|
79
|
+
regexp = Regexp.new('(?<seqno>\d+) (?<action>\S+)'\
|
80
|
+
' *(?<proto>\d+|\S+)'\
|
81
|
+
' *(?<src_addr>any|host \S+|\S+\/\d+|\S+ [:\.0-9a-fA-F]+|addrgroup \S+)*'\
|
82
|
+
' *(?<src_port>eq \S+|neq \S+|lt \S+|''gt \S+|range \S+ \S+|portgroup \S+)?'\
|
83
|
+
' *(?<dst_addr>any|host \S+|\S+\/\d+|\S+ [:\.0-9a-fA-F]+|addrgroup \S+)'\
|
84
|
+
' *(?<dst_port>eq \S+|neq \S+|lt \S+|gt \S+|range \S+ \S+|portgroup \S+)?')
|
85
|
+
# rubocop:enable Metrics/LineLength
|
86
|
+
regexp.match(str)
|
87
|
+
end
|
88
|
+
|
89
|
+
# common ace setter. Put the values you need in a hash and pass it in.
|
90
|
+
# attrs = {:action=>'permit', :proto=>'tcp', :src =>'host 1.1.1.1'}
|
91
|
+
def ace_set(attrs)
|
92
|
+
if attrs.empty?
|
93
|
+
attrs[:state] = 'no'
|
94
|
+
else
|
95
|
+
# remove existing ace first
|
96
|
+
destroy if seqno
|
97
|
+
attrs[:state] = ''
|
98
|
+
end
|
99
|
+
|
100
|
+
if attrs[:remark]
|
101
|
+
cmd = 'ace_remark'
|
102
|
+
else
|
103
|
+
cmd = 'ace'
|
104
|
+
[:action,
|
105
|
+
:proto,
|
106
|
+
:src_addr,
|
107
|
+
:src_port,
|
108
|
+
:dst_addr,
|
109
|
+
:dst_port,
|
110
|
+
].each do |p|
|
111
|
+
attrs[p] = '' if attrs[p].nil?
|
112
|
+
end
|
113
|
+
end
|
114
|
+
set_args_keys(attrs)
|
115
|
+
config_set('acl', cmd, @set_args)
|
116
|
+
end
|
117
|
+
|
118
|
+
# PROPERTIES
|
119
|
+
# ----------
|
120
|
+
def seqno
|
121
|
+
match = ace_get
|
122
|
+
return nil if match.nil?
|
123
|
+
match.names.include?('seqno') ? match[:seqno] : nil
|
124
|
+
end
|
125
|
+
|
126
|
+
def action
|
127
|
+
match = ace_get
|
128
|
+
return nil if match.nil?
|
129
|
+
match.names.include?('action') ? match[:action] : nil
|
130
|
+
end
|
131
|
+
|
132
|
+
def action=(action)
|
133
|
+
@set_args[:action] = action
|
134
|
+
end
|
135
|
+
|
136
|
+
def remark
|
137
|
+
match = ace_get
|
138
|
+
return nil if match.nil?
|
139
|
+
match.names.include?('remark') ? match[:remark] : nil
|
140
|
+
end
|
141
|
+
|
142
|
+
def remark=(remark)
|
143
|
+
@set_args[:remark] = remark
|
144
|
+
end
|
145
|
+
|
146
|
+
def proto
|
147
|
+
match = ace_get
|
148
|
+
return nil if match.nil?
|
149
|
+
match.names.include?('proto') ? match[:proto] : nil
|
150
|
+
end
|
151
|
+
|
152
|
+
def proto=(proto)
|
153
|
+
@set_args[:proto] = proto # TBD ip vs ipv4
|
154
|
+
end
|
155
|
+
|
156
|
+
def src_addr
|
157
|
+
match = ace_get
|
158
|
+
return nil if match.nil?
|
159
|
+
match.names.include?('src_addr') ? match[:src_addr] : nil
|
160
|
+
end
|
161
|
+
|
162
|
+
def src_addr=(src_addr)
|
163
|
+
@set_args[:src_addr] = src_addr
|
164
|
+
end
|
165
|
+
|
166
|
+
def src_port
|
167
|
+
match = ace_get
|
168
|
+
return nil if match.nil?
|
169
|
+
match.names.include?('src_port') ? match[:src_port] : nil
|
170
|
+
end
|
171
|
+
|
172
|
+
def src_port=(src_port)
|
173
|
+
@set_args[:src_port] = src_port
|
174
|
+
end
|
175
|
+
|
176
|
+
def dst_addr
|
177
|
+
match = ace_get
|
178
|
+
return nil if match.nil?
|
179
|
+
match.names.include?('dst_addr') ? match[:dst_addr] : nil
|
180
|
+
end
|
181
|
+
|
182
|
+
def dst_addr=(dst_addr)
|
183
|
+
@set_args[:dst_addr] = dst_addr
|
184
|
+
end
|
185
|
+
|
186
|
+
def dst_port
|
187
|
+
match = ace_get
|
188
|
+
return nil if match.nil?
|
189
|
+
match.names.include?('dst_port') ? match[:dst_port] : nil
|
190
|
+
end
|
191
|
+
|
192
|
+
def dst_port=(src_port)
|
193
|
+
@set_args[:dst_port] = src_port
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,100 @@
|
|
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 'node_util'
|
16
|
+
|
17
|
+
module Cisco
|
18
|
+
# Acl - node utility class for ACL configuration
|
19
|
+
class Acl < NodeUtil
|
20
|
+
attr_reader :acl_name, :afi
|
21
|
+
|
22
|
+
def initialize(afi, acl_name, instantiate=true)
|
23
|
+
@set_args = @get_args = { afi: Acl.afi_cli(afi), acl_name: acl_name.to_s }
|
24
|
+
create if instantiate
|
25
|
+
end
|
26
|
+
|
27
|
+
# Return all acls currently on the switch
|
28
|
+
def self.acls
|
29
|
+
afis = %w(ipv4 ipv6)
|
30
|
+
acl_hash = {}
|
31
|
+
afis.each do |afi|
|
32
|
+
acl_hash[afi] = {}
|
33
|
+
afi_cli = Acl.afi_cli(afi)
|
34
|
+
instances = config_get('acl', 'all_acls', afi: afi_cli)
|
35
|
+
|
36
|
+
next if instances.nil?
|
37
|
+
instances.each do |acl_name|
|
38
|
+
acl_hash[afi][acl_name] = Acl.new(afi, acl_name, false)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
acl_hash
|
42
|
+
end
|
43
|
+
|
44
|
+
# Platform-specific afi cli string
|
45
|
+
def self.afi_cli(afi)
|
46
|
+
fail ArgumentError, "Argument afi must be 'ipv4' or 'ipv6'" unless
|
47
|
+
afi[/(ipv4|ipv6)/]
|
48
|
+
afi[/ipv4/] ? 'ip' : afi
|
49
|
+
end
|
50
|
+
|
51
|
+
def create
|
52
|
+
config_acl('')
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy
|
56
|
+
config_acl('no')
|
57
|
+
end
|
58
|
+
|
59
|
+
def config_acl(state)
|
60
|
+
@set_args[:state] = state
|
61
|
+
config_set('acl', 'acl', @set_args)
|
62
|
+
end
|
63
|
+
|
64
|
+
# ----------
|
65
|
+
# PROPERTIES
|
66
|
+
# ----------
|
67
|
+
def stats_per_entry
|
68
|
+
config_get('acl', 'stats_per_entry', @get_args)
|
69
|
+
end
|
70
|
+
|
71
|
+
def stats_per_entry=(state)
|
72
|
+
@set_args[:state] = (state ? '' : 'no')
|
73
|
+
config_set('acl', 'stats_per_entry', @set_args)
|
74
|
+
end
|
75
|
+
|
76
|
+
def default_stats_per_entry
|
77
|
+
config_get_default('acl', 'stats_per_entry')
|
78
|
+
end
|
79
|
+
|
80
|
+
def fragments
|
81
|
+
config_get('acl', 'fragments', @get_args)
|
82
|
+
end
|
83
|
+
|
84
|
+
def fragments=(action)
|
85
|
+
@set_args[:state] = (action ? '' : 'no')
|
86
|
+
action = fragments unless action
|
87
|
+
@set_args[:action] = action
|
88
|
+
config_set('acl', 'fragments', @set_args) if action
|
89
|
+
end
|
90
|
+
|
91
|
+
def default_fragments
|
92
|
+
config_get_default('acl', 'fragments')
|
93
|
+
end
|
94
|
+
|
95
|
+
# acl == overide func
|
96
|
+
def ==(other)
|
97
|
+
acl_name == other.acl_name && afi == other.afi
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/lib/cisco_node_utils/bgp.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# June 2015, Michael G Wiebe
|
2
2
|
#
|
3
|
-
# Copyright (c) 2015 Cisco and/or its affiliates.
|
3
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +15,8 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require_relative 'node_util'
|
18
|
+
require_relative 'feature'
|
19
|
+
require_relative 'bgp_af'
|
18
20
|
|
19
21
|
module Cisco
|
20
22
|
# RouterBgp - node utility class for BGP general config management
|
@@ -24,49 +26,30 @@ module Cisco
|
|
24
26
|
def initialize(asnum, vrf='default', instantiate=true)
|
25
27
|
fail ArgumentError unless vrf.is_a? String
|
26
28
|
fail ArgumentError unless vrf.length > 0
|
27
|
-
@asnum = RouterBgp.
|
29
|
+
@asnum = RouterBgp.validate_asnum(asnum)
|
28
30
|
@vrf = vrf
|
29
|
-
|
30
|
-
@get_args = @set_args = { asnum: @asnum }
|
31
|
-
else
|
32
|
-
@get_args = @set_args = { asnum: @asnum, vrf: @vrf }
|
33
|
-
end
|
31
|
+
set_args_keys_default
|
34
32
|
create if instantiate
|
35
33
|
end
|
36
34
|
|
37
|
-
def self.process_asnum(asnum)
|
38
|
-
err_msg = "BGP asnum must be either a 'String' or an" \
|
39
|
-
" 'Integer' object"
|
40
|
-
fail ArgumentError, err_msg unless asnum.is_a?(Integer) ||
|
41
|
-
asnum.is_a?(String)
|
42
|
-
if asnum.is_a? String
|
43
|
-
# Match ASDOT '1.5' or ASPLAIN '55' strings
|
44
|
-
fail ArgumentError unless /^(\d+|\d+\.\d+)$/.match(asnum)
|
45
|
-
asnum = RouterBgp.dot_to_big(asnum) if /\d+\.\d+/.match(asnum)
|
46
|
-
end
|
47
|
-
asnum.to_i
|
48
|
-
end
|
49
|
-
|
50
35
|
# Create a hash of all router bgp default and non-default
|
51
36
|
# vrf instances
|
52
37
|
def self.routers
|
53
|
-
|
54
|
-
return {} if
|
38
|
+
asnum = config_get('bgp', 'router')
|
39
|
+
return {} if asnum.nil?
|
55
40
|
|
56
41
|
hash_final = {}
|
57
|
-
|
58
|
-
|
59
|
-
asnum
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
hash_tmp[asnum][vrf] = RouterBgp.new(asnum, vrf, false)
|
66
|
-
end
|
42
|
+
asnum = asnum.to_i unless /\d+.\d+/.match(asnum)
|
43
|
+
hash_tmp = {
|
44
|
+
asnum => { 'default' => RouterBgp.new(asnum, 'default', false) }
|
45
|
+
}
|
46
|
+
vrf_ids = config_get('bgp', 'vrf', asnum: asnum)
|
47
|
+
unless vrf_ids.nil?
|
48
|
+
vrf_ids.each do |vrf|
|
49
|
+
hash_tmp[asnum][vrf] = RouterBgp.new(asnum, vrf, false)
|
67
50
|
end
|
68
|
-
hash_final.merge!(hash_tmp)
|
69
51
|
end
|
52
|
+
hash_final.merge!(hash_tmp)
|
70
53
|
return hash_final
|
71
54
|
rescue Cisco::CliError => e
|
72
55
|
# cmd will syntax reject when feature is not enabled
|
@@ -74,44 +57,18 @@ module Cisco
|
|
74
57
|
return {}
|
75
58
|
end
|
76
59
|
|
77
|
-
def self.
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.enable(state='')
|
87
|
-
config_set('bgp', 'feature', state: state)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Convert BGP ASN ASDOT+ to ASPLAIN
|
91
|
-
def self.dot_to_big(dot_str)
|
92
|
-
fail ArgumentError unless dot_str.is_a? String
|
93
|
-
return dot_str unless /\d+\.\d+/.match(dot_str)
|
94
|
-
mask = 0b1111111111111111
|
95
|
-
high = dot_str.to_i
|
96
|
-
low = 0
|
97
|
-
low_match = dot_str.match(/\.(\d+)/)
|
98
|
-
low = low_match[1].to_i if low_match
|
99
|
-
high_bits = (mask & high) << 16
|
100
|
-
low_bits = mask & low
|
101
|
-
high_bits + low_bits
|
102
|
-
end
|
103
|
-
|
104
|
-
def router_bgp(asnum, vrf, state='')
|
105
|
-
# Only one bgp autonomous system number is allowed
|
106
|
-
# Raise an error if one is already configured that
|
107
|
-
# differs from the one being created.
|
108
|
-
configured = config_get('bgp', 'router')
|
109
|
-
if !configured.nil? && configured.first.to_s != asnum.to_s
|
110
|
-
fail %(
|
111
|
-
Changing the BGP Autonomous System Number is not allowed.
|
112
|
-
Current BGP asn: #{configured.first}
|
113
|
-
Attempted change to asn: #{asnum})
|
60
|
+
def self.validate_asnum(asnum)
|
61
|
+
err_msg = 'BGP asnum must be type String or Integer'
|
62
|
+
fail ArgumentError, err_msg unless asnum.is_a?(Integer) ||
|
63
|
+
asnum.is_a?(String)
|
64
|
+
if asnum.is_a? String
|
65
|
+
# Match ASDOT '1.5' or ASPLAIN '55' strings
|
66
|
+
fail ArgumentError unless /^(\d+|\d+\.\d+)$/.match(asnum)
|
114
67
|
end
|
68
|
+
asnum.to_s
|
69
|
+
end
|
70
|
+
|
71
|
+
def router_bgp(state='')
|
115
72
|
@set_args[:state] = state
|
116
73
|
if vrf == 'default'
|
117
74
|
config_set('bgp', 'router', @set_args)
|
@@ -121,79 +78,53 @@ module Cisco
|
|
121
78
|
set_args_keys_default
|
122
79
|
end
|
123
80
|
|
124
|
-
def enable_create_router_bgp(asnum, vrf)
|
125
|
-
RouterBgp.enable
|
126
|
-
router_bgp(asnum, vrf)
|
127
|
-
end
|
128
|
-
|
129
81
|
# Create one router bgp instance
|
130
82
|
def create
|
131
|
-
|
132
|
-
|
133
|
-
else
|
134
|
-
enable_create_router_bgp(@asnum, @vrf)
|
135
|
-
end
|
83
|
+
Feature.bgp_enable
|
84
|
+
router_bgp
|
136
85
|
end
|
137
86
|
|
138
87
|
# Destroy router bgp instance
|
139
88
|
def destroy
|
140
|
-
|
141
|
-
vrf_ids = ['default'] if vrf_ids.nil?
|
142
|
-
if vrf_ids.size == 1 || @vrf == 'default'
|
143
|
-
RouterBgp.enable('no')
|
144
|
-
else
|
145
|
-
router_bgp(asnum, @vrf, 'no')
|
146
|
-
end
|
147
|
-
rescue Cisco::CliError => e
|
148
|
-
# cmd will syntax reject when feature is not enabled
|
149
|
-
raise unless e.clierror =~ /Syntax error/
|
89
|
+
router_bgp('no')
|
150
90
|
end
|
151
91
|
|
152
92
|
# Helper method to delete @set_args hash keys
|
153
93
|
def set_args_keys_default
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
@set_args = { asnum: @asnum, vrf: @vrf }
|
158
|
-
end
|
94
|
+
@set_args = { asnum: @asnum }
|
95
|
+
@set_args[:vrf] = @vrf unless @vrf == 'default'
|
96
|
+
@get_args = @set_args
|
159
97
|
end
|
160
98
|
|
161
99
|
# Attributes:
|
162
100
|
|
163
101
|
# Bestpath Getters
|
164
102
|
def bestpath_always_compare_med
|
165
|
-
|
166
|
-
match.nil? ? default_bestpath_always_compare_med : true
|
103
|
+
config_get('bgp', 'bestpath_always_compare_med', @get_args)
|
167
104
|
end
|
168
105
|
|
169
106
|
def bestpath_aspath_multipath_relax
|
170
|
-
|
171
|
-
match.nil? ? default_bestpath_aspath_multipath_relax : true
|
107
|
+
config_get('bgp', 'bestpath_aspath_multipath_relax', @get_args)
|
172
108
|
end
|
173
109
|
|
174
110
|
def bestpath_compare_routerid
|
175
|
-
|
176
|
-
match.nil? ? default_bestpath_compare_routerid : true
|
111
|
+
config_get('bgp', 'bestpath_compare_routerid', @get_args)
|
177
112
|
end
|
178
113
|
|
179
114
|
def bestpath_cost_community_ignore
|
180
|
-
|
181
|
-
match.nil? ? default_bestpath_cost_community_ignore : true
|
115
|
+
config_get('bgp', 'bestpath_cost_community_ignore', @get_args)
|
182
116
|
end
|
183
117
|
|
184
118
|
def bestpath_med_confed
|
185
|
-
|
186
|
-
match.nil? ? default_bestpath_med_confed : true
|
119
|
+
config_get('bgp', 'bestpath_med_confed', @get_args)
|
187
120
|
end
|
188
121
|
|
189
122
|
def bestpath_med_missing_as_worst
|
190
|
-
|
191
|
-
match.nil? ? default_bestpath_med_missing_as_worst : true
|
123
|
+
config_get('bgp', 'bestpath_med_missing_as_worst', @get_args)
|
192
124
|
end
|
193
125
|
|
194
126
|
def bestpath_med_non_deterministic
|
195
|
-
|
196
|
-
match.nil? ? default_bestpath_med_non_deterministic : true
|
127
|
+
config_get('bgp', 'bestpath_med_non_deterministic', @get_args)
|
197
128
|
end
|
198
129
|
|
199
130
|
# Bestpath Setters
|
@@ -270,8 +201,7 @@ module Cisco
|
|
270
201
|
|
271
202
|
# Cluster Id (Getter/Setter/Default)
|
272
203
|
def cluster_id
|
273
|
-
|
274
|
-
match.nil? ? default_cluster_id : match.first
|
204
|
+
config_get('bgp', 'cluster_id', @get_args)
|
275
205
|
end
|
276
206
|
|
277
207
|
def cluster_id=(id)
|
@@ -279,7 +209,7 @@ module Cisco
|
|
279
209
|
# 'no bgp cluster-id'. IMO this should be possible because you
|
280
210
|
# can only configure a single bgp cluster-id.
|
281
211
|
#
|
282
|
-
# HACK: specify a dummy id when removing the
|
212
|
+
# HACK: specify a dummy id when removing the property.
|
283
213
|
dummy_id = 1
|
284
214
|
if id == default_cluster_id
|
285
215
|
@set_args[:state] = 'no'
|
@@ -298,8 +228,7 @@ module Cisco
|
|
298
228
|
|
299
229
|
# Confederation Id (Getter/Setter/Default)
|
300
230
|
def confederation_id
|
301
|
-
|
302
|
-
match.nil? ? default_confederation_id : match.first
|
231
|
+
config_get('bgp', 'confederation_id', @get_args)
|
303
232
|
end
|
304
233
|
|
305
234
|
def confederation_id=(id)
|
@@ -307,7 +236,7 @@ module Cisco
|
|
307
236
|
# 'no bgp confederation id'. IMO this should be possible
|
308
237
|
# because you can only configure a single bgp confed id.
|
309
238
|
#
|
310
|
-
# HACK: specify a dummy id when removing the
|
239
|
+
# HACK: specify a dummy id when removing the property.
|
311
240
|
dummy_id = 1
|
312
241
|
if id == default_confederation_id
|
313
242
|
@set_args[:state] = 'no'
|
@@ -324,10 +253,74 @@ module Cisco
|
|
324
253
|
config_get_default('bgp', 'confederation_id')
|
325
254
|
end
|
326
255
|
|
256
|
+
#
|
257
|
+
# disable-policy-batching (Getter/Setter/Default)
|
258
|
+
#
|
259
|
+
def disable_policy_batching
|
260
|
+
config_get('bgp', 'disable_policy_batching', @get_args)
|
261
|
+
end
|
262
|
+
|
263
|
+
def disable_policy_batching=(enable)
|
264
|
+
@set_args[:state] = (enable ? '' : 'no')
|
265
|
+
config_set('bgp', 'disable_policy_batching', @set_args)
|
266
|
+
set_args_keys_default
|
267
|
+
end
|
268
|
+
|
269
|
+
def default_disable_policy_batching
|
270
|
+
config_get_default('bgp', 'disable_policy_batching')
|
271
|
+
end
|
272
|
+
|
273
|
+
#
|
274
|
+
# disable-policy-batching ipv4 prefix-list <prefix_list>
|
275
|
+
#
|
276
|
+
def disable_policy_batching_ipv4
|
277
|
+
config_get('bgp', 'disable_policy_batching_ipv4', @get_args)
|
278
|
+
end
|
279
|
+
|
280
|
+
def disable_policy_batching_ipv4=(prefix_list)
|
281
|
+
dummy_prefixlist = 'x'
|
282
|
+
if prefix_list == default_disable_policy_batching_ipv4
|
283
|
+
@set_args[:state] = 'no'
|
284
|
+
@set_args[:prefix_list] = dummy_prefixlist
|
285
|
+
else
|
286
|
+
@set_args[:state] = ''
|
287
|
+
@set_args[:prefix_list] = prefix_list
|
288
|
+
end
|
289
|
+
config_set('bgp', 'disable_policy_batching_ipv4', @set_args)
|
290
|
+
set_args_keys_default
|
291
|
+
end
|
292
|
+
|
293
|
+
def default_disable_policy_batching_ipv4
|
294
|
+
config_get_default('bgp', 'disable_policy_batching_ipv4')
|
295
|
+
end
|
296
|
+
|
297
|
+
#
|
298
|
+
# disable-policy-batching ipv6 prefix-list <prefix_list>
|
299
|
+
#
|
300
|
+
def disable_policy_batching_ipv6
|
301
|
+
config_get('bgp', 'disable_policy_batching_ipv6', @get_args)
|
302
|
+
end
|
303
|
+
|
304
|
+
def disable_policy_batching_ipv6=(prefix_list)
|
305
|
+
dummy_prefixlist = 'x'
|
306
|
+
if prefix_list == default_disable_policy_batching_ipv6
|
307
|
+
@set_args[:state] = 'no'
|
308
|
+
@set_args[:prefix_list] = dummy_prefixlist
|
309
|
+
else
|
310
|
+
@set_args[:state] = ''
|
311
|
+
@set_args[:prefix_list] = prefix_list
|
312
|
+
end
|
313
|
+
config_set('bgp', 'disable_policy_batching_ipv6', @set_args)
|
314
|
+
set_args_keys_default
|
315
|
+
end
|
316
|
+
|
317
|
+
def default_disable_policy_batching_ipv6
|
318
|
+
config_get_default('bgp', 'disable_policy_batching_ipv6')
|
319
|
+
end
|
320
|
+
|
327
321
|
# Enforce First As (Getter/Setter/Default)
|
328
322
|
def enforce_first_as
|
329
|
-
|
330
|
-
match.nil? ? false : true
|
323
|
+
config_get('bgp', 'enforce_first_as', @get_args)
|
331
324
|
end
|
332
325
|
|
333
326
|
def enforce_first_as=(enable)
|
@@ -340,10 +333,133 @@ module Cisco
|
|
340
333
|
config_get_default('bgp', 'enforce_first_as')
|
341
334
|
end
|
342
335
|
|
336
|
+
# event-history
|
337
|
+
# event-history cli [ size <size> ]
|
338
|
+
# Nvgen as True With optional 'size <size>
|
339
|
+
def event_history_cli
|
340
|
+
match = config_get('bgp', 'event_history_cli', @get_args)
|
341
|
+
if match.is_a?(Array)
|
342
|
+
return 'false' if match[0] == 'no '
|
343
|
+
return 'size_' + match[1] if match[1]
|
344
|
+
end
|
345
|
+
default_event_history_cli
|
346
|
+
end
|
347
|
+
|
348
|
+
def event_history_cli=(val)
|
349
|
+
size = val[/small|medium|large|disable/]
|
350
|
+
@set_args[:size] = size.nil? ? '' : "size #{size}"
|
351
|
+
@set_args[:state] = val[/false/] ? 'no' : ''
|
352
|
+
config_set('bgp', 'event_history_cli', @set_args)
|
353
|
+
set_args_keys_default
|
354
|
+
end
|
355
|
+
|
356
|
+
def default_event_history_cli
|
357
|
+
config_get_default('bgp', 'event_history_cli')
|
358
|
+
end
|
359
|
+
|
360
|
+
# event-history detail [ size <size> ]
|
361
|
+
# Nvgen as True With optional 'size <size>
|
362
|
+
def event_history_detail
|
363
|
+
match = config_get('bgp', 'event_history_detail', @get_args)
|
364
|
+
# This property requires auto_default=false
|
365
|
+
if match.is_a?(Array)
|
366
|
+
return 'false' if match[0] == 'no '
|
367
|
+
return 'size_' + match[1] if match[1]
|
368
|
+
end
|
369
|
+
default_event_history_detail
|
370
|
+
end
|
371
|
+
|
372
|
+
def event_history_detail=(val)
|
373
|
+
size = val[/small|medium|large|disable/]
|
374
|
+
@set_args[:size] = size.nil? ? '' : "size #{size}"
|
375
|
+
@set_args[:state] = val[/false/] ? 'no' : ''
|
376
|
+
config_set('bgp', 'event_history_detail', @set_args)
|
377
|
+
set_args_keys_default
|
378
|
+
end
|
379
|
+
|
380
|
+
def default_event_history_detail
|
381
|
+
config_get_default('bgp', 'event_history_detail')
|
382
|
+
end
|
383
|
+
|
384
|
+
# event-history events [ size <size> ]
|
385
|
+
# Nvgen as True With optional 'size <size>
|
386
|
+
def event_history_events
|
387
|
+
match = config_get('bgp', 'event_history_events', @get_args)
|
388
|
+
if match.is_a?(Array)
|
389
|
+
return 'false' if match[0] == 'no '
|
390
|
+
return 'size_' + match[1] if match[1]
|
391
|
+
end
|
392
|
+
default_event_history_events
|
393
|
+
end
|
394
|
+
|
395
|
+
def event_history_events=(val)
|
396
|
+
size = val[/small|medium|large|disable/]
|
397
|
+
@set_args[:size] = size.nil? ? '' : "size #{size}"
|
398
|
+
@set_args[:state] = val[/false/] ? 'no' : ''
|
399
|
+
config_set('bgp', 'event_history_events', @set_args)
|
400
|
+
set_args_keys_default
|
401
|
+
end
|
402
|
+
|
403
|
+
def default_event_history_events
|
404
|
+
config_get_default('bgp', 'event_history_events')
|
405
|
+
end
|
406
|
+
|
407
|
+
# event-history periodic [ size <size> ]
|
408
|
+
# Nvgen as True With optional 'size <size>
|
409
|
+
def event_history_periodic
|
410
|
+
match = config_get('bgp', 'event_history_periodic', @get_args)
|
411
|
+
if match.is_a?(Array)
|
412
|
+
return 'false' if match[0] == 'no '
|
413
|
+
return 'size_' + match[1] if match[1]
|
414
|
+
end
|
415
|
+
default_event_history_periodic
|
416
|
+
end
|
417
|
+
|
418
|
+
def event_history_periodic=(val)
|
419
|
+
size = val[/small|medium|large|disable/]
|
420
|
+
@set_args[:size] = size.nil? ? '' : "size #{size}"
|
421
|
+
@set_args[:state] = val[/false/] ? 'no' : ''
|
422
|
+
config_set('bgp', 'event_history_periodic', @set_args)
|
423
|
+
set_args_keys_default
|
424
|
+
end
|
425
|
+
|
426
|
+
def default_event_history_periodic
|
427
|
+
config_get_default('bgp', 'event_history_periodic')
|
428
|
+
end
|
429
|
+
|
430
|
+
# Fast External fallover (Getter/Setter/Default)
|
431
|
+
def fast_external_fallover
|
432
|
+
config_get('bgp', 'fast_external_fallover', @get_args)
|
433
|
+
end
|
434
|
+
|
435
|
+
def fast_external_fallover=(enable)
|
436
|
+
@set_args[:state] = (enable ? '' : 'no')
|
437
|
+
config_set('bgp', 'fast_external_fallover', @set_args)
|
438
|
+
set_args_keys_default
|
439
|
+
end
|
440
|
+
|
441
|
+
def default_fast_external_fallover
|
442
|
+
config_get_default('bgp', 'fast_external_fallover')
|
443
|
+
end
|
444
|
+
|
445
|
+
# Flush Routes (Getter/Setter/Default)
|
446
|
+
def flush_routes
|
447
|
+
config_get('bgp', 'flush_routes', @get_args)
|
448
|
+
end
|
449
|
+
|
450
|
+
def flush_routes=(enable)
|
451
|
+
@set_args[:state] = (enable ? '' : 'no')
|
452
|
+
config_set('bgp', 'flush_routes', @set_args)
|
453
|
+
set_args_keys_default
|
454
|
+
end
|
455
|
+
|
456
|
+
def default_flush_routes
|
457
|
+
config_get_default('bgp', 'flush_routes')
|
458
|
+
end
|
459
|
+
|
343
460
|
# Confederation Peers (Getter/Setter/Default)
|
344
461
|
def confederation_peers
|
345
|
-
|
346
|
-
match.nil? ? default_confederation_peers : match.first
|
462
|
+
config_get('bgp', 'confederation_peers', @get_args)
|
347
463
|
end
|
348
464
|
|
349
465
|
def confederation_peers_set(peers)
|
@@ -368,28 +484,19 @@ module Cisco
|
|
368
484
|
|
369
485
|
# Graceful Restart Getters
|
370
486
|
def graceful_restart
|
371
|
-
|
372
|
-
match.nil? ? false : true
|
487
|
+
config_get('bgp', 'graceful_restart', @get_args)
|
373
488
|
end
|
374
489
|
|
375
490
|
def graceful_restart_timers_restart
|
376
|
-
|
377
|
-
match.nil? ? default_graceful_restart_timers_restart : match.first.to_i
|
491
|
+
config_get('bgp', 'graceful_restart_timers_restart', @get_args)
|
378
492
|
end
|
379
493
|
|
380
494
|
def graceful_restart_timers_stalepath_time
|
381
|
-
|
382
|
-
@get_args)
|
383
|
-
if match.nil?
|
384
|
-
default_graceful_restart_timers_stalepath_time
|
385
|
-
else
|
386
|
-
match.first.to_i
|
387
|
-
end
|
495
|
+
config_get('bgp', 'graceful_restart_timers_stalepath_time', @get_args)
|
388
496
|
end
|
389
497
|
|
390
498
|
def graceful_restart_helper
|
391
|
-
|
392
|
-
match.nil? ? default_graceful_restart_helper : true
|
499
|
+
config_get('bgp', 'graceful_restart_helper', @get_args)
|
393
500
|
end
|
394
501
|
|
395
502
|
# Graceful Restart Setters
|
@@ -446,10 +553,24 @@ module Cisco
|
|
446
553
|
config_get_default('bgp', 'graceful_restart_helper')
|
447
554
|
end
|
448
555
|
|
556
|
+
# Isolate (Getter/Setter/Default)
|
557
|
+
def isolate
|
558
|
+
config_get('bgp', 'isolate', @get_args)
|
559
|
+
end
|
560
|
+
|
561
|
+
def isolate=(enable)
|
562
|
+
@set_args[:state] = (enable ? '' : 'no')
|
563
|
+
config_set('bgp', 'isolate', @set_args)
|
564
|
+
set_args_keys_default
|
565
|
+
end
|
566
|
+
|
567
|
+
def default_isolate
|
568
|
+
config_get_default('bgp', 'isolate')
|
569
|
+
end
|
570
|
+
|
449
571
|
# MaxAs Limit (Getter/Setter/Default)
|
450
572
|
def maxas_limit
|
451
|
-
|
452
|
-
match.nil? ? default_maxas_limit : match.first.to_i
|
573
|
+
config_get('bgp', 'maxas_limit', @get_args)
|
453
574
|
end
|
454
575
|
|
455
576
|
def maxas_limit=(limit)
|
@@ -470,8 +591,7 @@ module Cisco
|
|
470
591
|
|
471
592
|
# Log Neighbor Changes (Getter/Setter/Default)
|
472
593
|
def log_neighbor_changes
|
473
|
-
|
474
|
-
match.nil? ? default_log_neighbor_changes : true
|
594
|
+
config_get('bgp', 'log_neighbor_changes', @get_args)
|
475
595
|
end
|
476
596
|
|
477
597
|
def log_neighbor_changes=(enable)
|
@@ -484,26 +604,24 @@ module Cisco
|
|
484
604
|
config_get_default('bgp', 'log_neighbor_changes')
|
485
605
|
end
|
486
606
|
|
487
|
-
# Neighbor fib
|
488
|
-
def
|
489
|
-
|
490
|
-
match.nil? ? default_neighbor_fib_down_accelerate : true
|
607
|
+
# Neighbor down fib accelerate (Getter/Setter/Default)
|
608
|
+
def neighbor_down_fib_accelerate
|
609
|
+
config_get('bgp', 'neighbor_down_fib_accelerate', @get_args)
|
491
610
|
end
|
492
611
|
|
493
|
-
def
|
612
|
+
def neighbor_down_fib_accelerate=(enable)
|
494
613
|
@set_args[:state] = (enable ? '' : 'no')
|
495
|
-
config_set('bgp', '
|
614
|
+
config_set('bgp', 'neighbor_down_fib_accelerate', @set_args)
|
496
615
|
set_args_keys_default
|
497
616
|
end
|
498
617
|
|
499
|
-
def
|
500
|
-
config_get_default('bgp', '
|
618
|
+
def default_neighbor_down_fib_accelerate
|
619
|
+
config_get_default('bgp', 'neighbor_down_fib_accelerate')
|
501
620
|
end
|
502
621
|
|
503
622
|
# Reconnect Interval (Getter/Setter/Default)
|
504
623
|
def reconnect_interval
|
505
|
-
|
506
|
-
match.nil? ? default_reconnect_interval : match.first.to_i
|
624
|
+
config_get('bgp', 'reconnect_interval', @get_args)
|
507
625
|
end
|
508
626
|
|
509
627
|
def reconnect_interval=(seconds)
|
@@ -522,19 +640,43 @@ module Cisco
|
|
522
640
|
config_get_default('bgp', 'reconnect_interval')
|
523
641
|
end
|
524
642
|
|
643
|
+
# route_distinguisher
|
644
|
+
# Note that this property is supported by both bgp and vrf providers.
|
645
|
+
def route_distinguisher
|
646
|
+
config_get('bgp', 'route_distinguisher', @get_args)
|
647
|
+
end
|
648
|
+
|
649
|
+
def route_distinguisher=(rd)
|
650
|
+
Feature.nv_overlay_evpn_enable
|
651
|
+
if rd == default_route_distinguisher
|
652
|
+
@set_args[:state] = 'no'
|
653
|
+
@set_args[:rd] = ''
|
654
|
+
else
|
655
|
+
@set_args[:state] = ''
|
656
|
+
@set_args[:rd] = rd
|
657
|
+
end
|
658
|
+
config_set('bgp', 'route_distinguisher', @set_args)
|
659
|
+
set_args_keys_default
|
660
|
+
end
|
661
|
+
|
662
|
+
def default_route_distinguisher
|
663
|
+
config_get_default('bgp', 'route_distinguisher')
|
664
|
+
end
|
665
|
+
|
525
666
|
# Router ID (Getter/Setter/Default)
|
526
667
|
def router_id
|
527
|
-
|
528
|
-
match.nil? ? default_router_id : match.first
|
668
|
+
config_get('bgp', 'router_id', @get_args)
|
529
669
|
end
|
530
670
|
|
531
671
|
def router_id=(id)
|
532
672
|
# In order to remove a bgp router-id you cannot simply issue
|
533
|
-
# 'no bgp router-id'.
|
534
|
-
|
673
|
+
# 'no bgp router-id'. On some platforms you can specify a dummy
|
674
|
+
# value, but on N7K at least you need the current router_id.
|
535
675
|
if id == default_router_id
|
676
|
+
# Nothing to do if router_id is already set to default.
|
677
|
+
return if router_id == default_router_id
|
536
678
|
@set_args[:state] = 'no'
|
537
|
-
@set_args[:id] =
|
679
|
+
@set_args[:id] = router_id
|
538
680
|
else
|
539
681
|
@set_args[:state] = ''
|
540
682
|
@set_args[:id] = id
|
@@ -549,8 +691,7 @@ module Cisco
|
|
549
691
|
|
550
692
|
# Shutdown (Getter/Setter/Default)
|
551
693
|
def shutdown
|
552
|
-
|
553
|
-
match.nil? ? default_shutdown : true
|
694
|
+
config_get('bgp', 'shutdown', @asnum)
|
554
695
|
end
|
555
696
|
|
556
697
|
def shutdown=(enable)
|
@@ -565,8 +706,7 @@ module Cisco
|
|
565
706
|
|
566
707
|
# Supress Fib Pending (Getter/Setter/Default)
|
567
708
|
def suppress_fib_pending
|
568
|
-
|
569
|
-
match.nil? ? default_suppress_fib_pending : true
|
709
|
+
config_get('bgp', 'suppress_fib_pending', @get_args)
|
570
710
|
end
|
571
711
|
|
572
712
|
def suppress_fib_pending=(enable)
|
@@ -582,7 +722,7 @@ module Cisco
|
|
582
722
|
# BGP Timers Getters
|
583
723
|
def timer_bgp_keepalive_hold
|
584
724
|
match = config_get('bgp', 'timer_bgp_keepalive_hold', @get_args)
|
585
|
-
match.nil? ? default_timer_bgp_keepalive_hold : match
|
725
|
+
match.nil? ? default_timer_bgp_keepalive_hold : match
|
586
726
|
end
|
587
727
|
|
588
728
|
def timer_bgp_keepalive
|
@@ -598,13 +738,11 @@ module Cisco
|
|
598
738
|
end
|
599
739
|
|
600
740
|
def timer_bestpath_limit
|
601
|
-
|
602
|
-
match.nil? ? default_timer_bestpath_limit : match.first.to_i
|
741
|
+
config_get('bgp', 'timer_bestpath_limit', @get_args)
|
603
742
|
end
|
604
743
|
|
605
744
|
def timer_bestpath_limit_always
|
606
|
-
|
607
|
-
match.nil? ? default_timer_bestpath_limit_always : true
|
745
|
+
config_get('bgp', 'timer_bestpath_limit_always', @get_args)
|
608
746
|
end
|
609
747
|
|
610
748
|
# BGP Timers Setters
|
@@ -625,9 +763,9 @@ module Cisco
|
|
625
763
|
|
626
764
|
def timer_bestpath_limit_set(seconds, always=false)
|
627
765
|
if always
|
628
|
-
|
766
|
+
opt = 'timer_bestpath_limit_always'
|
629
767
|
else
|
630
|
-
|
768
|
+
opt = 'timer_bestpath_limit'
|
631
769
|
end
|
632
770
|
if seconds == default_timer_bestpath_limit
|
633
771
|
@set_args[:state] = 'no'
|
@@ -636,7 +774,7 @@ module Cisco
|
|
636
774
|
@set_args[:state] = ''
|
637
775
|
@set_args[:seconds] = seconds
|
638
776
|
end
|
639
|
-
config_set('bgp',
|
777
|
+
config_set('bgp', opt, @set_args)
|
640
778
|
set_args_keys_default
|
641
779
|
end
|
642
780
|
|