cisco_node_utils 1.2.0 → 1.3.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 +2 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +4 -1
- data/CHANGELOG.md +81 -2
- data/CONTRIBUTING.md +2 -17
- data/Gemfile +5 -0
- data/README.md +92 -47
- data/Rakefile +23 -1
- data/bin/git/hooks/hook_lib +7 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +7 -2
- data/bin/git/hooks/pre-commit/validate-diffs +18 -4
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/update-hooks +64 -6
- data/cisco_node_utils.gemspec +9 -6
- data/docs/README-develop-best-practices.md +149 -50
- data/docs/README-develop-node-utils-APIs.md +92 -42
- data/docs/README-maintainers.md +7 -4
- data/docs/README-test-execution.md +57 -0
- data/docs/cisco_node_utils.yaml.example +30 -0
- data/docs/template-router.rb +4 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +2 -2
- data/lib/cisco_node_utils.rb +5 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +5 -6
- data/lib/cisco_node_utils/aaa_authorization_service.rb +1 -1
- data/lib/cisco_node_utils/ace.rb +165 -12
- data/lib/cisco_node_utils/acl.rb +2 -1
- data/lib/cisco_node_utils/bgp.rb +184 -21
- data/lib/cisco_node_utils/bgp_af.rb +94 -249
- data/lib/cisco_node_utils/bgp_neighbor.rb +94 -14
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +75 -8
- data/lib/cisco_node_utils/bridge_domain.rb +183 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +85 -2
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/client/client.rb +234 -0
- data/lib/cisco_node_utils/client/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +311 -0
- data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
- data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
- data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
- data/lib/cisco_node_utils/client/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +305 -0
- data/lib/cisco_node_utils/client/utils.rb +164 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +222 -254
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +22 -15
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +21 -16
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +239 -109
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +114 -55
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +76 -52
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +106 -62
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +35 -14
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +23 -17
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +94 -83
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +22 -17
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +76 -26
- data/lib/cisco_node_utils/cmd_ref/images.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +381 -153
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +21 -21
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +30 -21
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +18 -13
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +26 -31
- data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
- data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +17 -6
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +10 -3
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +17 -5
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +33 -29
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +12 -10
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +16 -19
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +40 -25
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +17 -12
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +71 -35
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +10 -5
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +6 -2
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +47 -43
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +13 -11
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +4 -2
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +23 -21
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +26 -22
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +19 -17
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +18 -6
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +234 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +24 -9
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +5 -3
- data/lib/cisco_node_utils/cmd_ref/system.yaml +4 -3
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +22 -20
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +27 -15
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +45 -16
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +60 -32
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +118 -101
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +54 -58
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +118 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +19 -25
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +28 -18
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +34 -17
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +6 -4
- data/lib/cisco_node_utils/command_reference.rb +261 -142
- data/lib/cisco_node_utils/constants.rb +33 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +102 -0
- data/lib/cisco_node_utils/evpn_vni.rb +5 -3
- data/lib/cisco_node_utils/exceptions.rb +111 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +52 -35
- data/lib/cisco_node_utils/fabricpath_topology.rb +44 -57
- data/lib/cisco_node_utils/feature.rb +165 -3
- data/lib/cisco_node_utils/interface.rb +1051 -260
- data/lib/cisco_node_utils/interface_channel_group.rb +11 -10
- data/lib/cisco_node_utils/interface_ospf.rb +1 -2
- data/lib/cisco_node_utils/interface_portchannel.rb +4 -12
- data/lib/cisco_node_utils/interface_service_vni.rb +7 -7
- data/lib/cisco_node_utils/itd_device_group.rb +248 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +523 -0
- data/lib/cisco_node_utils/logger.rb +75 -0
- data/lib/cisco_node_utils/node.rb +62 -192
- data/lib/cisco_node_utils/node_util.rb +56 -10
- data/lib/cisco_node_utils/overlay_global.rb +2 -2
- data/lib/cisco_node_utils/pim.rb +2 -13
- data/lib/cisco_node_utils/pim_group_list.rb +1 -1
- data/lib/cisco_node_utils/pim_rp_address.rb +1 -1
- data/lib/cisco_node_utils/platform.rb +52 -21
- data/lib/cisco_node_utils/portchannel_global.rb +89 -19
- data/lib/cisco_node_utils/radius_server.rb +168 -37
- data/lib/cisco_node_utils/router_ospf.rb +20 -35
- data/lib/cisco_node_utils/router_ospf_vrf.rb +4 -4
- data/lib/cisco_node_utils/snmpserver.rb +1 -6
- data/lib/cisco_node_utils/snmpuser.rb +6 -4
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_server.rb +77 -18
- data/lib/cisco_node_utils/syslog_settings.rb +1 -1
- data/lib/cisco_node_utils/tacacs_server_group.rb +8 -4
- data/lib/cisco_node_utils/tacacs_server_host.rb +115 -25
- data/lib/cisco_node_utils/vdc.rb +12 -0
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vlan.rb +147 -29
- data/lib/cisco_node_utils/vpc.rb +55 -3
- data/lib/cisco_node_utils/vrf.rb +72 -11
- data/lib/cisco_node_utils/vrf_af.rb +114 -29
- data/lib/cisco_node_utils/vtp.rb +34 -52
- data/lib/cisco_node_utils/vxlan_vtep.rb +34 -8
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +36 -4
- data/lib/minitest/environment_plugin.rb +31 -0
- data/lib/minitest/log_level_plugin.rb +41 -0
- data/spec/client_spec.rb +7 -0
- data/spec/environment_spec.rb +263 -0
- data/spec/grpc_client_spec.rb +23 -0
- data/spec/isolate/all_clients_spec.rb +9 -0
- data/spec/isolate/grpc_only_spec.rb +16 -0
- data/spec/isolate/no_clients_spec.rb +26 -0
- data/spec/isolate/nxapi_only_spec.rb +16 -0
- data/spec/nxapi_client_spec.rb +42 -0
- data/spec/schema.yaml +75 -0
- data/spec/shared_examples_for_clients.rb +14 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/whitespace_spec.rb +10 -0
- data/spec/yaml_spec.rb +42 -0
- data/tests/.rubocop.yml +2 -2
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +96 -36
- data/tests/ciscotest.rb +220 -12
- data/tests/cmd_config.yaml +71 -49
- data/tests/cmd_config_invalid.yaml +1 -1
- data/tests/test_aaa_authentication_login.rb +1 -0
- data/tests/test_aaa_authentication_login_service.rb +9 -0
- data/tests/test_aaa_authorization_service.rb +173 -367
- data/tests/test_ace.rb +171 -100
- data/tests/test_acl.rb +10 -1
- data/tests/test_bgp_af.rb +395 -728
- data/tests/test_bgp_neighbor.rb +274 -115
- data/tests/test_bgp_neighbor_af.rb +178 -77
- data/tests/test_bridge_domain.rb +191 -0
- data/tests/test_bridge_domain_vni.rb +116 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_command_config.rb +9 -5
- data/tests/test_command_reference.rb +380 -102
- data/tests/test_dns_domain.rb +13 -3
- data/tests/test_domain_name.rb +13 -3
- data/tests/test_encapsulation.rb +77 -0
- data/tests/test_evpn_vni.rb +25 -7
- data/tests/test_fabricpath_global.rb +167 -163
- data/tests/test_fabricpath_topology.rb +12 -33
- data/tests/test_feature.rb +215 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_interface.rb +585 -344
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +6 -3
- data/tests/test_interface_ospf.rb +26 -24
- data/tests/test_interface_portchannel.rb +1 -0
- data/tests/test_interface_private_vlan.rb +724 -0
- data/tests/test_interface_service_vni.rb +37 -66
- data/tests/test_interface_svi.rb +98 -101
- data/tests/test_interface_switchport.rb +419 -549
- data/tests/test_itd_device_group.rb +145 -0
- data/tests/test_itd_device_group_node.rb +199 -0
- data/tests/test_itd_service.rb +298 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +11 -2
- data/tests/test_node.rb +16 -75
- data/tests/test_node_ext.rb +174 -163
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_config.rb +5 -1
- data/tests/test_ntp_server.rb +2 -2
- data/tests/test_nxapi.rb +221 -0
- data/tests/test_overlay_global.rb +47 -38
- data/tests/test_pim.rb +2 -0
- data/tests/test_pim_group_list.rb +2 -0
- data/tests/test_pim_rp_address.rb +2 -0
- data/tests/test_platform.rb +86 -39
- data/tests/test_portchannel_global.rb +211 -135
- data/tests/test_radius_global.rb +13 -5
- data/tests/test_radius_server.rb +256 -104
- data/tests/test_radius_server_group.rb +2 -0
- data/tests/test_router_bgp.rb +781 -485
- data/tests/test_router_ospf.rb +26 -103
- data/tests/test_router_ospf_vrf.rb +52 -57
- data/tests/test_snmp_notification_receiver.rb +2 -0
- data/tests/test_snmpcommunity.rb +2 -0
- data/tests/test_snmpgroup.rb +2 -0
- data/tests/test_snmpnotification.rb +40 -21
- data/tests/test_snmpserver.rb +2 -0
- data/tests/test_snmpuser.rb +2 -0
- data/tests/test_stp_global.rb +563 -0
- data/tests/test_syslog_server.rb +32 -8
- data/tests/test_syslog_settings.rb +22 -9
- data/tests/test_tacacs_server.rb +32 -27
- data/tests/test_tacacs_server_group.rb +100 -45
- data/tests/test_tacacs_server_host.rb +135 -43
- data/tests/test_vdc.rb +2 -16
- data/tests/test_vlan.rb +106 -54
- data/tests/test_vlan_mt_full.rb +11 -21
- data/tests/test_vlan_private.rb +669 -0
- data/tests/test_vpc.rb +312 -159
- data/tests/test_vrf.rb +122 -113
- data/tests/test_vrf_af.rb +238 -0
- data/tests/test_vtp.rb +58 -102
- data/tests/test_vxlan_vtep.rb +38 -17
- data/tests/test_vxlan_vtep_vni.rb +61 -9
- data/tests/test_yum.rb +49 -25
- metadata +122 -36
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +0 -9
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +0 -76
- data/lib/cisco_node_utils/vni.rb +0 -227
- data/tests/test_vni.rb +0 -106
|
@@ -19,6 +19,7 @@ require_relative 'cisco_cmn_utils'
|
|
|
19
19
|
require_relative 'node_util'
|
|
20
20
|
require_relative 'feature'
|
|
21
21
|
require_relative 'bgp'
|
|
22
|
+
require_relative 'logger'
|
|
22
23
|
|
|
23
24
|
module Cisco
|
|
24
25
|
# RouterBgpAF - node utility class for BGP address-family config management
|
|
@@ -58,7 +59,10 @@ module Cisco
|
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
def create
|
|
61
|
-
|
|
62
|
+
if platform == :nexus
|
|
63
|
+
Feature.bgp_enable
|
|
64
|
+
Feature.nv_overlay_evpn_enable if @safi[/evpn/]
|
|
65
|
+
end
|
|
62
66
|
set_args_keys(state: '')
|
|
63
67
|
config_set('bgp', 'address_family', @set_args)
|
|
64
68
|
end
|
|
@@ -86,49 +90,34 @@ module Cisco
|
|
|
86
90
|
# PROPERTIES #
|
|
87
91
|
########################################################
|
|
88
92
|
|
|
93
|
+
def fail_unsupported(callee)
|
|
94
|
+
fail Cisco::UnsupportedError.new('bgp_af', callee.to_s)
|
|
95
|
+
end
|
|
96
|
+
|
|
89
97
|
#
|
|
90
98
|
# Client to client (Getter/Setter/Default)
|
|
91
99
|
#
|
|
92
|
-
def client_to_client
|
|
93
|
-
state = config_get('bgp_af', 'client_to_client', @get_args)
|
|
94
|
-
state ? true : false
|
|
95
|
-
end
|
|
96
100
|
|
|
97
101
|
def client_to_client=(state)
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
# IOS XR uses "client-to-client reflection disable",
|
|
103
|
+
# so turning it "on" means disabling it.
|
|
104
|
+
# Thus we invert the desired state before telling the CLI what to do:
|
|
105
|
+
state = !state if ios_xr?
|
|
106
|
+
set_args_keys(state: (state ? '' : 'no'))
|
|
100
107
|
config_set('bgp_af', 'client_to_client', @set_args)
|
|
101
108
|
end
|
|
102
109
|
|
|
103
|
-
def default_client_to_client
|
|
104
|
-
config_get_default('bgp_af', 'client_to_client')
|
|
105
|
-
end
|
|
106
|
-
|
|
107
110
|
#
|
|
108
111
|
# Default Information (Getter/Setter/Default)
|
|
109
112
|
#
|
|
110
|
-
def default_information_originate
|
|
111
|
-
state = config_get('bgp_af', 'default_information', @get_args)
|
|
112
|
-
state ? true : false
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def default_information_originate=(state)
|
|
116
|
-
state = (state ? '' : 'no')
|
|
117
|
-
set_args_keys(state: state)
|
|
118
|
-
config_set('bgp_af', 'default_information', @set_args)
|
|
119
|
-
end
|
|
120
113
|
|
|
121
|
-
def
|
|
122
|
-
|
|
114
|
+
def default_information_originate
|
|
115
|
+
config_get('bgp_af', 'default_information_originate', @get_args)
|
|
123
116
|
end
|
|
124
117
|
|
|
125
118
|
#
|
|
126
119
|
# Next Hop route map (Getter/Setter/Default)
|
|
127
120
|
#
|
|
128
|
-
def next_hop_route_map
|
|
129
|
-
config_get('bgp_af', 'next_hop_route_map', @get_args)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
121
|
def next_hop_route_map=(route_map)
|
|
133
122
|
route_map.strip!
|
|
134
123
|
if route_map.empty?
|
|
@@ -144,67 +133,9 @@ module Cisco
|
|
|
144
133
|
config_set('bgp_af', 'next_hop_route_map', @set_args)
|
|
145
134
|
end
|
|
146
135
|
|
|
147
|
-
def default_next_hop_route_map
|
|
148
|
-
config_get_default('bgp_af', 'next_hop_route_map')
|
|
149
|
-
end
|
|
150
|
-
|
|
151
136
|
#
|
|
152
137
|
# additional paths (Getter/Setter/Default)
|
|
153
138
|
#
|
|
154
|
-
|
|
155
|
-
# additional_paths_send
|
|
156
|
-
def additional_paths_send
|
|
157
|
-
state = config_get('bgp_af', 'additional_paths_send', @get_args)
|
|
158
|
-
state ? true : false
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def additional_paths_send=(state)
|
|
162
|
-
state = (state ? '' : 'no')
|
|
163
|
-
set_args_keys(state: state)
|
|
164
|
-
config_set('bgp_af', 'additional_paths_send', @set_args)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def default_additional_paths_send
|
|
168
|
-
config_get_default('bgp_af', 'additional_paths_send')
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
# additional_paths_receive
|
|
172
|
-
def additional_paths_receive
|
|
173
|
-
state = config_get('bgp_af', 'additional_paths_receive', @get_args)
|
|
174
|
-
state ? true : false
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def additional_paths_receive=(state)
|
|
178
|
-
state = (state ? '' : 'no')
|
|
179
|
-
set_args_keys(state: state)
|
|
180
|
-
config_set('bgp_af', 'additional_paths_receive', @set_args)
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def default_additional_paths_receive
|
|
184
|
-
config_get_default('bgp_af', 'additional_paths_receive')
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
# additional_paths_install
|
|
188
|
-
def additional_paths_install
|
|
189
|
-
state = config_get('bgp_af', 'additional_paths_install', @get_args)
|
|
190
|
-
state ? true : false
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def additional_paths_install=(state)
|
|
194
|
-
state = (state ? '' : 'no')
|
|
195
|
-
set_args_keys(state: state)
|
|
196
|
-
config_set('bgp_af', 'additional_paths_install', @set_args)
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def default_additional_paths_install
|
|
200
|
-
config_get_default('bgp_af', 'additional_paths_install')
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
# additional_paths_selection
|
|
204
|
-
def additional_paths_selection
|
|
205
|
-
config_get('bgp_af', 'additional_paths_selection', @get_args)
|
|
206
|
-
end
|
|
207
|
-
|
|
208
139
|
def additional_paths_selection=(route_map)
|
|
209
140
|
route_map.strip!
|
|
210
141
|
if route_map.empty?
|
|
@@ -216,29 +147,21 @@ module Cisco
|
|
|
216
147
|
route_map = additional_paths_selection
|
|
217
148
|
end
|
|
218
149
|
end
|
|
219
|
-
set_args_keys(state: state, route_map: route_map)
|
|
150
|
+
set_args_keys(state: state, route_map: route_map, route_policy: route_map)
|
|
220
151
|
config_set('bgp_af', 'additional_paths_selection', @set_args)
|
|
221
152
|
end
|
|
222
153
|
|
|
223
|
-
def default_additional_paths_selection
|
|
224
|
-
config_get_default('bgp_af', 'additional_paths_selection')
|
|
225
|
-
end
|
|
226
|
-
|
|
227
154
|
# advertise_l2vpn_evpn
|
|
228
155
|
def advertise_l2vpn_evpn
|
|
229
156
|
config_get('bgp_af', 'advertise_l2vpn_evpn', @get_args)
|
|
230
157
|
end
|
|
231
158
|
|
|
232
159
|
def advertise_l2vpn_evpn=(state)
|
|
233
|
-
Feature.nv_overlay_evpn_enable
|
|
160
|
+
Feature.nv_overlay_evpn_enable if platform == :nexus
|
|
234
161
|
set_args_keys(state: (state ? '' : 'no'))
|
|
235
162
|
config_set('bgp_af', 'advertise_l2vpn_evpn', @set_args)
|
|
236
163
|
end
|
|
237
164
|
|
|
238
|
-
def default_advertise_l2vpn_evpn
|
|
239
|
-
config_get_default('bgp_af', 'advertise_l2vpn_evpn')
|
|
240
|
-
end
|
|
241
|
-
|
|
242
165
|
#
|
|
243
166
|
# dampen_igp_metric (Getter/Setter/Default)
|
|
244
167
|
#
|
|
@@ -259,10 +182,6 @@ module Cisco
|
|
|
259
182
|
config_set('bgp_af', 'dampen_igp_metric', @set_args)
|
|
260
183
|
end
|
|
261
184
|
|
|
262
|
-
def default_dampen_igp_metric
|
|
263
|
-
config_get_default('bgp_af', 'dampen_igp_metric')
|
|
264
|
-
end
|
|
265
|
-
|
|
266
185
|
#
|
|
267
186
|
# dampening (Getter/Setter/Default)
|
|
268
187
|
#
|
|
@@ -273,21 +192,17 @@ module Cisco
|
|
|
273
192
|
# Value Meaning
|
|
274
193
|
# ----- -------
|
|
275
194
|
# nil Dampening is not configured
|
|
276
|
-
#
|
|
195
|
+
# [] Dampening is configured with no options
|
|
277
196
|
# [1,3,4,5,nil] Dampening + decay, reuse, suppress, suppress_max
|
|
278
|
-
# [nil,nil,nil,'route-map'] Dampening + routemap
|
|
197
|
+
# [nil,nil,nil,nil,'route-map'] Dampening + routemap
|
|
279
198
|
def dampening
|
|
280
199
|
data = config_get('bgp_af', 'dampening', @get_args)
|
|
281
|
-
|
|
282
|
-
if data.nil?
|
|
283
|
-
# no dampening
|
|
284
|
-
return nil
|
|
285
|
-
end
|
|
200
|
+
return nil if data.nil? # no dampening
|
|
286
201
|
|
|
287
202
|
data = data.flatten
|
|
288
203
|
|
|
289
204
|
# dampening nil nil nil nil nil
|
|
290
|
-
val =
|
|
205
|
+
val = []
|
|
291
206
|
|
|
292
207
|
if !data[4].nil?
|
|
293
208
|
# dampening nil nil nil nil route-map
|
|
@@ -311,7 +226,7 @@ module Cisco
|
|
|
311
226
|
# is configured because they are mutually exclusive.
|
|
312
227
|
def dampening_half_time
|
|
313
228
|
return nil if dampening.nil? || dampening_routemap_configured?
|
|
314
|
-
if dampening.is_a?(Array)
|
|
229
|
+
if dampening.is_a?(Array) && !dampening.empty?
|
|
315
230
|
dampening[0].to_i
|
|
316
231
|
else
|
|
317
232
|
default_dampening_half_time
|
|
@@ -320,7 +235,7 @@ module Cisco
|
|
|
320
235
|
|
|
321
236
|
def dampening_reuse_time
|
|
322
237
|
return nil if dampening.nil? || dampening_routemap_configured?
|
|
323
|
-
if dampening.is_a?(Array)
|
|
238
|
+
if dampening.is_a?(Array) && !dampening.empty?
|
|
324
239
|
dampening[1].to_i
|
|
325
240
|
else
|
|
326
241
|
default_dampening_reuse_time
|
|
@@ -329,7 +244,7 @@ module Cisco
|
|
|
329
244
|
|
|
330
245
|
def dampening_suppress_time
|
|
331
246
|
return nil if dampening.nil? || dampening_routemap_configured?
|
|
332
|
-
if dampening.is_a?(Array)
|
|
247
|
+
if dampening.is_a?(Array) && !dampening.empty?
|
|
333
248
|
dampening[2].to_i
|
|
334
249
|
else
|
|
335
250
|
default_dampening_suppress_time
|
|
@@ -338,7 +253,7 @@ module Cisco
|
|
|
338
253
|
|
|
339
254
|
def dampening_max_suppress_time
|
|
340
255
|
return nil if dampening.nil? || dampening_routemap_configured?
|
|
341
|
-
if dampening.is_a?(Array)
|
|
256
|
+
if dampening.is_a?(Array) && !dampening.empty?
|
|
342
257
|
dampening[3].to_i
|
|
343
258
|
else
|
|
344
259
|
default_dampening_max_suppress_time
|
|
@@ -376,10 +291,10 @@ module Cisco
|
|
|
376
291
|
if damp_array.nil?
|
|
377
292
|
# 'no dampening ...' command - no dampening handles all cases
|
|
378
293
|
state = 'no'
|
|
379
|
-
|
|
294
|
+
Cisco::Logger.debug("Dampening 'no dampening'")
|
|
380
295
|
elsif damp_array.empty?
|
|
381
296
|
# 'dampening' command - nothing to do here
|
|
382
|
-
|
|
297
|
+
Cisco::Logger.debug("Dampening 'dampening'")
|
|
383
298
|
elsif damp_array.size == 4
|
|
384
299
|
# 'dampening dampening_decay dampening_reuse \
|
|
385
300
|
# dampening_suppress dampening_suppress_max' command
|
|
@@ -387,15 +302,13 @@ module Cisco
|
|
|
387
302
|
reuse = damp_array[1]
|
|
388
303
|
suppress = damp_array[2]
|
|
389
304
|
suppress_max = damp_array[3]
|
|
390
|
-
|
|
391
|
-
|
|
305
|
+
Cisco::Logger.debug("Dampening 'dampening #{damp_array.join(' ')}''")
|
|
306
|
+
else
|
|
392
307
|
# 'dampening route-map WORD' command
|
|
393
|
-
route_map = "route-map #{damp_array}"
|
|
308
|
+
route_map = "route-map #{damp_array}" if platform == :nexus
|
|
309
|
+
route_map = "route-policy #{damp_array}" if platform == :ios_xr
|
|
394
310
|
route_map.strip!
|
|
395
|
-
|
|
396
|
-
else
|
|
397
|
-
# Array not in a valid format
|
|
398
|
-
fail ArgumentError
|
|
311
|
+
Cisco::Logger.debug("Dampening 'dampening route-map #{route_map}'")
|
|
399
312
|
end
|
|
400
313
|
|
|
401
314
|
# Set final args
|
|
@@ -407,36 +320,9 @@ module Cisco
|
|
|
407
320
|
suppress: suppress,
|
|
408
321
|
suppress_max: suppress_max,
|
|
409
322
|
)
|
|
410
|
-
CiscoLogger.debug("Dampening args=#{@set_args}")
|
|
411
|
-
config_set('bgp_af', 'dampening', @set_args)
|
|
412
|
-
end
|
|
413
|
-
|
|
414
|
-
def default_dampening
|
|
415
|
-
config_get_default('bgp_af', 'dampening')
|
|
416
|
-
end
|
|
417
|
-
|
|
418
|
-
def default_dampening_state
|
|
419
|
-
config_get_default('bgp_af', 'dampening_state')
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
def default_dampening_max_suppress_time
|
|
423
|
-
config_get_default('bgp_af', 'dampening_max_suppress_time')
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
def default_dampening_half_time
|
|
427
|
-
config_get_default('bgp_af', 'dampening_half_time')
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
def default_dampening_reuse_time
|
|
431
|
-
config_get_default('bgp_af', 'dampening_reuse_time')
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
def default_dampening_routemap
|
|
435
|
-
config_get_default('bgp_af', 'dampening_routemap')
|
|
436
|
-
end
|
|
437
323
|
|
|
438
|
-
|
|
439
|
-
|
|
324
|
+
Cisco::Logger.debug("Dampening args=#{@set_args}")
|
|
325
|
+
config_set('bgp_af', 'dampening', @set_args)
|
|
440
326
|
end
|
|
441
327
|
|
|
442
328
|
#
|
|
@@ -465,33 +351,10 @@ module Cisco
|
|
|
465
351
|
local.to_i
|
|
466
352
|
end
|
|
467
353
|
|
|
468
|
-
def distance
|
|
469
|
-
match = config_get('bgp_af', 'distance', @get_args)
|
|
470
|
-
match.nil? ? default_distance : match
|
|
471
|
-
end
|
|
472
|
-
|
|
473
|
-
def default_distance_ebgp
|
|
474
|
-
config_get_default('bgp_af', 'distance_ebgp')
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
def default_distance_ibgp
|
|
478
|
-
config_get_default('bgp_af', 'distance_ibgp')
|
|
479
|
-
end
|
|
480
|
-
|
|
481
|
-
def default_distance_local
|
|
482
|
-
config_get_default('bgp_af', 'distance_local')
|
|
483
|
-
end
|
|
484
|
-
|
|
485
|
-
def default_distance
|
|
486
|
-
["#{default_distance_ebgp}", "#{default_distance_ibgp}",
|
|
487
|
-
"#{default_distance_local}"]
|
|
488
|
-
end
|
|
489
|
-
|
|
490
354
|
#
|
|
491
355
|
# default_metric (Getter/Setter/Default)
|
|
492
356
|
#
|
|
493
357
|
|
|
494
|
-
# default_metric
|
|
495
358
|
def default_metric
|
|
496
359
|
config_get('bgp_af', 'default_metric', @get_args)
|
|
497
360
|
end
|
|
@@ -505,25 +368,23 @@ module Cisco
|
|
|
505
368
|
config_set('bgp_af', 'default_metric', @set_args)
|
|
506
369
|
end
|
|
507
370
|
|
|
508
|
-
def default_default_metric
|
|
509
|
-
config_get_default('bgp_af', 'default_metric')
|
|
510
|
-
end
|
|
511
|
-
|
|
512
371
|
#
|
|
513
372
|
# inject_map (Getter/Setter/Default)
|
|
514
373
|
#
|
|
515
374
|
|
|
516
375
|
def inject_map
|
|
517
|
-
cmds = config_get('bgp_af', 'inject_map', @get_args)
|
|
518
|
-
cmds.sort
|
|
376
|
+
cmds = config_get('bgp_af', 'inject_map', @get_args)
|
|
377
|
+
cmds.nil? ? nil : cmds.each(&:compact!).sort
|
|
519
378
|
end
|
|
520
379
|
|
|
521
380
|
def inject_map=(should_list)
|
|
522
|
-
|
|
381
|
+
c = inject_map
|
|
382
|
+
fail_unsupported(__callee__) if c.nil?
|
|
383
|
+
delta_hash = Utils.delta_add_remove(should_list, c)
|
|
523
384
|
return if delta_hash.values.flatten.empty?
|
|
524
385
|
[:add, :remove].each do |action|
|
|
525
|
-
|
|
526
|
-
|
|
386
|
+
Cisco::Logger.debug("inject_map delta #{@get_args}\n #{action}: " \
|
|
387
|
+
"#{delta_hash[action]}")
|
|
527
388
|
delta_hash[action].each do |inject, exist, copy|
|
|
528
389
|
# inject & exist are mandatory, copy is optional
|
|
529
390
|
state = (action == :add) ? '' : 'no'
|
|
@@ -534,55 +395,30 @@ module Cisco
|
|
|
534
395
|
end
|
|
535
396
|
end
|
|
536
397
|
|
|
537
|
-
def default_inject_map
|
|
538
|
-
config_get_default('bgp_af', 'inject_map')
|
|
539
|
-
end
|
|
540
|
-
|
|
541
398
|
#
|
|
542
399
|
# maximum_paths (Getter/Setter/Default)
|
|
543
400
|
#
|
|
544
401
|
|
|
545
|
-
# maximum_paths
|
|
546
|
-
def maximum_paths
|
|
547
|
-
config_get('bgp_af', 'maximum_paths', @get_args)
|
|
548
|
-
end
|
|
549
|
-
|
|
550
402
|
def maximum_paths=(val)
|
|
551
403
|
set_args_keys(state: (val == default_maximum_paths) ? 'no' : '',
|
|
552
404
|
num: (val == default_maximum_paths) ? '' : val)
|
|
553
405
|
config_set('bgp_af', 'maximum_paths', @set_args)
|
|
554
406
|
end
|
|
555
407
|
|
|
556
|
-
def default_maximum_paths
|
|
557
|
-
config_get_default('bgp_af', 'maximum_paths')
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
#
|
|
561
|
-
# maximum_paths_ibgp (Getter/Setter/Default)
|
|
562
|
-
#
|
|
563
|
-
|
|
564
|
-
# maximum_paths_ibgp
|
|
565
|
-
def maximum_paths_ibgp
|
|
566
|
-
config_get('bgp_af', 'maximum_paths_ibgp', @get_args)
|
|
567
|
-
end
|
|
568
|
-
|
|
569
408
|
def maximum_paths_ibgp=(val)
|
|
570
409
|
set_args_keys(state: (val == default_maximum_paths_ibgp) ? 'no' : '',
|
|
571
410
|
num: (val == default_maximum_paths_ibgp) ? '' : val)
|
|
572
411
|
config_set('bgp_af', 'maximum_paths_ibgp', @set_args)
|
|
573
412
|
end
|
|
574
413
|
|
|
575
|
-
def default_maximum_paths_ibgp
|
|
576
|
-
config_get_default('bgp_af', 'maximum_paths_ibgp')
|
|
577
|
-
end
|
|
578
|
-
|
|
579
414
|
#
|
|
580
415
|
# Networks (Getter/Setter/Default)
|
|
581
416
|
#
|
|
582
417
|
|
|
583
418
|
# Build an array of all network commands currently on the device
|
|
584
419
|
def networks
|
|
585
|
-
config_get('bgp_af', '
|
|
420
|
+
c = config_get('bgp_af', 'networks', @get_args)
|
|
421
|
+
c.nil? ? nil : c.each(&:compact!)
|
|
586
422
|
end
|
|
587
423
|
|
|
588
424
|
# networks setter.
|
|
@@ -591,29 +427,30 @@ module Cisco
|
|
|
591
427
|
delta_hash = Utils.delta_add_remove(should_list, networks)
|
|
592
428
|
return if delta_hash.values.flatten.empty?
|
|
593
429
|
[:add, :remove].each do |action|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
delta_hash[action].each do |network,
|
|
430
|
+
Cisco::Logger.debug("networks delta #{@get_args}\n #{action}: " \
|
|
431
|
+
"#{delta_hash[action]}")
|
|
432
|
+
delta_hash[action].each do |network, route_map_policy|
|
|
597
433
|
state = (action == :add) ? '' : 'no'
|
|
598
434
|
network = Utils.process_network_mask(network)
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
435
|
+
unless route_map_policy.nil?
|
|
436
|
+
route_map = "route-map #{route_map_policy}"
|
|
437
|
+
route_policy = "route-policy #{route_map_policy}"
|
|
438
|
+
end
|
|
439
|
+
set_args_keys(state: state, network: network, route_map: route_map,
|
|
440
|
+
route_policy: route_policy)
|
|
441
|
+
config_set('bgp_af', 'networks', @set_args)
|
|
602
442
|
end
|
|
603
443
|
end
|
|
604
444
|
end
|
|
605
445
|
|
|
606
|
-
def default_networks
|
|
607
|
-
config_get_default('bgp_af', 'network')
|
|
608
|
-
end
|
|
609
|
-
|
|
610
446
|
#
|
|
611
447
|
# Redistribute (Getter/Setter/Default)
|
|
612
448
|
#
|
|
613
449
|
|
|
614
450
|
# Build an array of all redistribute commands currently on the device
|
|
615
451
|
def redistribute
|
|
616
|
-
config_get('bgp_af', 'redistribute', @get_args)
|
|
452
|
+
c = config_get('bgp_af', 'redistribute', @get_args)
|
|
453
|
+
c.nil? ? nil : c.each(&:compact!).sort
|
|
617
454
|
end
|
|
618
455
|
|
|
619
456
|
# redistribute setter.
|
|
@@ -622,8 +459,8 @@ module Cisco
|
|
|
622
459
|
delta_hash = Utils.delta_add_remove(should, redistribute)
|
|
623
460
|
return if delta_hash.values.flatten.empty?
|
|
624
461
|
[:add, :remove].each do |action|
|
|
625
|
-
|
|
626
|
-
|
|
462
|
+
Cisco::Logger.debug("redistribute delta #{@get_args}\n #{action}: " \
|
|
463
|
+
"#{delta_hash[action]}")
|
|
627
464
|
delta_hash[action].each do |protocol, policy|
|
|
628
465
|
state = (action == :add) ? '' : 'no'
|
|
629
466
|
set_args_keys(state: state, protocol: protocol, policy: policy)
|
|
@@ -639,34 +476,10 @@ module Cisco
|
|
|
639
476
|
config_get_default('bgp_af', 'redistribute')
|
|
640
477
|
end
|
|
641
478
|
|
|
642
|
-
#
|
|
643
|
-
# Suppress Inactive (Getter/Setter/Default)
|
|
644
|
-
#
|
|
645
|
-
def suppress_inactive
|
|
646
|
-
config_get('bgp_af', 'suppress_inactive', @get_args)
|
|
647
|
-
end
|
|
648
|
-
|
|
649
|
-
def suppress_inactive=(state)
|
|
650
|
-
set_args_keys(state: state ? '' : 'no')
|
|
651
|
-
config_set('bgp_af', 'suppress_inactive', @set_args)
|
|
652
|
-
end
|
|
653
|
-
|
|
654
|
-
def default_suppress_inactive
|
|
655
|
-
config_get_default('bgp_af', 'suppress_inactive')
|
|
656
|
-
end
|
|
657
|
-
|
|
658
479
|
#
|
|
659
480
|
# Table Map (Getter/Setter/Default)
|
|
660
481
|
#
|
|
661
482
|
|
|
662
|
-
def table_map
|
|
663
|
-
config_get('bgp_af', 'table_map', @get_args)
|
|
664
|
-
end
|
|
665
|
-
|
|
666
|
-
def table_map_filter
|
|
667
|
-
config_get('bgp_af', 'table_map_filter', @get_args)
|
|
668
|
-
end
|
|
669
|
-
|
|
670
483
|
def table_map_set(map, filter=false)
|
|
671
484
|
# To remove table map we can not use 'no table-map'
|
|
672
485
|
# Dummy-map specified to work around this
|
|
@@ -687,12 +500,44 @@ module Cisco
|
|
|
687
500
|
set_args_keys_default
|
|
688
501
|
end
|
|
689
502
|
|
|
690
|
-
|
|
691
|
-
|
|
503
|
+
##########################################
|
|
504
|
+
# Universal Getter, Default Getter, and Setter
|
|
505
|
+
#
|
|
506
|
+
def method_missing(*args)
|
|
507
|
+
name = args[0].to_s
|
|
508
|
+
if args.length == 1 # Getter
|
|
509
|
+
if name =~ /^default_(.*)$/
|
|
510
|
+
config_get_default('bgp_af', Regexp.last_match(1))
|
|
511
|
+
else
|
|
512
|
+
config_get('bgp_af', name, @get_args)
|
|
513
|
+
end
|
|
514
|
+
elsif args.length == 2 && name =~ /^(.*)=$/ # Setter
|
|
515
|
+
set_args_keys(state: args[1] ? '' : 'no')
|
|
516
|
+
config_set('bgp_af', Regexp.last_match(1), @set_args)
|
|
517
|
+
else
|
|
518
|
+
super
|
|
519
|
+
end
|
|
692
520
|
end
|
|
693
521
|
|
|
694
|
-
|
|
695
|
-
|
|
522
|
+
# Is the given name available in the YAML?
|
|
523
|
+
def respond_to?(method_sym, _include_private=false)
|
|
524
|
+
name = method_sym.to_s
|
|
525
|
+
key = :getter?
|
|
526
|
+
if name =~ /^(.*)=$/
|
|
527
|
+
name = Regexp.last_match(1)
|
|
528
|
+
# Use table_map_set() to set these properties
|
|
529
|
+
return false if name == 'table_map' || name == 'table_map_filter'
|
|
530
|
+
key = :setter?
|
|
531
|
+
elsif name =~ /^default_(.*)$/
|
|
532
|
+
name = Regexp.last_match(1)
|
|
533
|
+
key = :default_value?
|
|
534
|
+
end
|
|
535
|
+
begin
|
|
536
|
+
ref = node.cmd_ref.lookup('bgp_af', name)
|
|
537
|
+
ref.send(key)
|
|
538
|
+
rescue IndexError
|
|
539
|
+
super
|
|
540
|
+
end
|
|
696
541
|
end
|
|
697
542
|
end
|
|
698
543
|
end
|