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,153 @@
|
|
1
|
+
# VXLAN global provider class
|
2
|
+
# Provides configuration of anycast gateways and duplicate host IP and
|
3
|
+
# mac detection
|
4
|
+
#
|
5
|
+
# Alok Aggarwal, October 2015
|
6
|
+
#
|
7
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
|
21
|
+
require_relative 'cisco_cmn_utils'
|
22
|
+
require_relative 'feature'
|
23
|
+
require_relative 'node_util'
|
24
|
+
|
25
|
+
module Cisco
|
26
|
+
# node_utils class for overlay_global
|
27
|
+
class OverlayGlobal < NodeUtil
|
28
|
+
# ----------
|
29
|
+
# PROPERTIES
|
30
|
+
# ----------
|
31
|
+
|
32
|
+
# dup-host-ip-addr-detection
|
33
|
+
def dup_host_ip_addr_detection
|
34
|
+
return nil unless Feature.nv_overlay_evpn_enabled?
|
35
|
+
match = config_get('overlay_global', 'dup_host_ip_addr_detection')
|
36
|
+
if match.nil?
|
37
|
+
default_dup_host_ip_addr_detection
|
38
|
+
else
|
39
|
+
match.collect(&:to_i)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def dup_host_ip_addr_detection_host_moves
|
44
|
+
host_moves, _timeout = dup_host_ip_addr_detection
|
45
|
+
host_moves
|
46
|
+
end
|
47
|
+
|
48
|
+
def dup_host_ip_addr_detection_timeout
|
49
|
+
_host_moves, timeout = dup_host_ip_addr_detection
|
50
|
+
timeout
|
51
|
+
end
|
52
|
+
|
53
|
+
def dup_host_ip_addr_detection_set(host_moves, timeout)
|
54
|
+
Feature.nv_overlay_evpn_enable
|
55
|
+
if host_moves == default_dup_host_ip_addr_detection_host_moves &&
|
56
|
+
timeout == default_dup_host_ip_addr_detection_timeout
|
57
|
+
state = 'no'
|
58
|
+
else
|
59
|
+
state = ''
|
60
|
+
end
|
61
|
+
set_args = { state: state, host_moves: host_moves, timeout: timeout }
|
62
|
+
config_set('overlay_global', 'dup_host_ip_addr_detection', set_args)
|
63
|
+
end
|
64
|
+
|
65
|
+
def default_dup_host_ip_addr_detection
|
66
|
+
[default_dup_host_ip_addr_detection_host_moves,
|
67
|
+
default_dup_host_ip_addr_detection_timeout]
|
68
|
+
end
|
69
|
+
|
70
|
+
def default_dup_host_ip_addr_detection_host_moves
|
71
|
+
config_get_default('overlay_global',
|
72
|
+
'dup_host_ip_addr_detection_host_moves')
|
73
|
+
end
|
74
|
+
|
75
|
+
def default_dup_host_ip_addr_detection_timeout
|
76
|
+
config_get_default('overlay_global', 'dup_host_ip_addr_detection_timeout')
|
77
|
+
end
|
78
|
+
|
79
|
+
# dup-host-mac-detection
|
80
|
+
def dup_host_mac_detection
|
81
|
+
match = config_get('overlay_global', 'dup_host_mac_detection')
|
82
|
+
if match.nil?
|
83
|
+
default_dup_host_mac_detection
|
84
|
+
else
|
85
|
+
match.collect(&:to_i)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def dup_host_mac_detection_host_moves
|
90
|
+
host_moves, _timeout = dup_host_mac_detection
|
91
|
+
host_moves
|
92
|
+
end
|
93
|
+
|
94
|
+
def dup_host_mac_detection_timeout
|
95
|
+
_host_moves, timeout = dup_host_mac_detection
|
96
|
+
timeout
|
97
|
+
end
|
98
|
+
|
99
|
+
def dup_host_mac_detection_set(host_moves, timeout)
|
100
|
+
set_args = { host_moves: host_moves, timeout: timeout }
|
101
|
+
if host_moves == default_dup_host_mac_detection_host_moves &&
|
102
|
+
timeout == default_dup_host_mac_detection_timeout
|
103
|
+
dup_host_mac_detection_default
|
104
|
+
else
|
105
|
+
config_set('overlay_global', 'dup_host_mac_detection', set_args)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def dup_host_mac_detection_default
|
110
|
+
config_set('overlay_global', 'dup_host_mac_detection_default')
|
111
|
+
end
|
112
|
+
|
113
|
+
def default_dup_host_mac_detection
|
114
|
+
[default_dup_host_mac_detection_host_moves,
|
115
|
+
default_dup_host_mac_detection_timeout]
|
116
|
+
end
|
117
|
+
|
118
|
+
def default_dup_host_mac_detection_host_moves
|
119
|
+
config_get_default('overlay_global', 'dup_host_mac_detection_host_moves')
|
120
|
+
end
|
121
|
+
|
122
|
+
def default_dup_host_mac_detection_timeout
|
123
|
+
config_get_default('overlay_global', 'dup_host_mac_detection_timeout')
|
124
|
+
end
|
125
|
+
|
126
|
+
# anycast-gateway-mac
|
127
|
+
def anycast_gateway_mac
|
128
|
+
return nil unless Feature.nv_overlay_evpn_enabled?
|
129
|
+
mac = config_get('overlay_global', 'anycast_gateway_mac')
|
130
|
+
# This value gets 0-padded when nvgened, so we need to convert it.
|
131
|
+
Utils.zero_pad_macaddr(mac).nil? ? default_anycast_gateway_mac : mac
|
132
|
+
end
|
133
|
+
|
134
|
+
def anycast_gateway_mac=(mac_addr)
|
135
|
+
fail TypeError unless mac_addr.is_a?(String)
|
136
|
+
|
137
|
+
Feature.nv_overlay_evpn_enable
|
138
|
+
Feature.fabric_forwarding_enable
|
139
|
+
if mac_addr == default_anycast_gateway_mac
|
140
|
+
state = 'no'
|
141
|
+
mac_addr = ''
|
142
|
+
else
|
143
|
+
state = ''
|
144
|
+
end
|
145
|
+
config_set('overlay_global', 'anycast_gateway_mac',
|
146
|
+
state: state, mac_addr: mac_addr)
|
147
|
+
end
|
148
|
+
|
149
|
+
def default_anycast_gateway_mac
|
150
|
+
config_get_default('overlay_global', 'anycast_gateway_mac')
|
151
|
+
end
|
152
|
+
end # class
|
153
|
+
end # module
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#
|
2
|
+
# NXAPI implementation of PIM class
|
3
|
+
#
|
4
|
+
# Smitha Gopalan, November 2015
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
require_relative 'node_util'
|
21
|
+
|
22
|
+
module Cisco
|
23
|
+
# node_utils class for Pim
|
24
|
+
class Pim < NodeUtil
|
25
|
+
attr_reader :vrf, :afi
|
26
|
+
|
27
|
+
# Constructor with vrf
|
28
|
+
# ---------------------
|
29
|
+
def initialize(afi, vrf, instantiate=true)
|
30
|
+
fail ArgumentError unless vrf.is_a?(String) || vrf.length > 0
|
31
|
+
@vrf = vrf
|
32
|
+
@afi = Pim.afi_cli(afi)
|
33
|
+
set_args_keys_default
|
34
|
+
|
35
|
+
Pim.feature_enable if instantiate
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.feature_enabled
|
39
|
+
config_get('pim', 'feature')
|
40
|
+
rescue Cisco::CliError => e
|
41
|
+
# cmd will syntax reject when feature is not enabled
|
42
|
+
raise unless e.clierror =~ /Syntax error/
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.feature_enable
|
47
|
+
config_set('pim', 'feature')
|
48
|
+
end
|
49
|
+
|
50
|
+
# self.pims returns a hash of all current pim objects.
|
51
|
+
# There will be one object for each vrf. This method has slightly different
|
52
|
+
# behavior than most of the other "get all objects" methods because the
|
53
|
+
# pim properties are standalone and do not reside in a "pim" container;
|
54
|
+
# therefore, this method simply returns a pim object for each vrf
|
55
|
+
# regardless of whether there are any specific pim properties currently
|
56
|
+
# defined for the context.
|
57
|
+
def self.pims
|
58
|
+
afis = %w(ipv4) # TBD: No support for ipv6 at this time
|
59
|
+
hash_final = {}
|
60
|
+
afis.each do |afi|
|
61
|
+
hash_final[afi] = {}
|
62
|
+
default_vrf = 'default'
|
63
|
+
hash_final[afi][default_vrf] = Pim.new(afi, default_vrf, false)
|
64
|
+
|
65
|
+
# Now the vrf's
|
66
|
+
vrf_ids = config_get('vrf', 'all_vrfs')
|
67
|
+
vrf_ids.delete_if { |vrf_id| vrf_id == 'management' }
|
68
|
+
vrf_ids.each do |vrf|
|
69
|
+
hash_final[afi][vrf] = Pim.new(afi, vrf, false)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
hash_final
|
73
|
+
rescue Cisco::CliError => e
|
74
|
+
# cmd will syntax reject when feature is not enabled
|
75
|
+
raise unless e.clierror =~ /Syntax error/
|
76
|
+
return {}
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.afi_cli(afi)
|
80
|
+
# Add ipv6 support later
|
81
|
+
fail ArgumentError, "Argument afi must be 'ipv4'" unless
|
82
|
+
afi[/(ipv4)/]
|
83
|
+
afi[/ipv4/] ? 'ip' : afi
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_args_keys_default
|
87
|
+
keys = { afi: @afi }
|
88
|
+
keys[:vrf] = @vrf unless @vrf == 'default'
|
89
|
+
@get_args = @set_args = keys
|
90
|
+
end
|
91
|
+
|
92
|
+
def set_args_keys(hash={}) # rubocop:disable Style/AccessorMethodName
|
93
|
+
set_args_keys_default
|
94
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
95
|
+
end
|
96
|
+
|
97
|
+
# This destroy method is different than most because pim does not have a
|
98
|
+
# "container" for properties, they simply exist in a given vrf context.
|
99
|
+
# For that reason destroy needs to explicitly set each property
|
100
|
+
# to its default state.
|
101
|
+
def destroy
|
102
|
+
self.ssm_range = ''
|
103
|
+
end
|
104
|
+
|
105
|
+
#-----------
|
106
|
+
# Properties
|
107
|
+
#-----------
|
108
|
+
def ssm_range
|
109
|
+
config_get('pim', 'ssm_range', @get_args)
|
110
|
+
end
|
111
|
+
|
112
|
+
def ssm_range=(range)
|
113
|
+
if range.empty?
|
114
|
+
state = 'no'
|
115
|
+
range = ssm_range
|
116
|
+
return if range.nil?
|
117
|
+
else
|
118
|
+
state = ''
|
119
|
+
end
|
120
|
+
set_args_keys(state: state, ssm_range: range)
|
121
|
+
config_set('pim', 'ssm_range', @set_args)
|
122
|
+
end
|
123
|
+
end # Class
|
124
|
+
end # Module
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# NXAPI implementation of the PimGroupList class
|
2
|
+
#
|
3
|
+
# Smitha Gopalan, November 2015
|
4
|
+
#
|
5
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'node_util'
|
20
|
+
require_relative 'pim'
|
21
|
+
|
22
|
+
module Cisco
|
23
|
+
# node_utils class for pim grouplist
|
24
|
+
class PimGroupList < NodeUtil
|
25
|
+
attr_reader :afi, :rp_addr, :group, :vrf
|
26
|
+
|
27
|
+
# Constructor with grouplist and vrf
|
28
|
+
# ----------------------------------
|
29
|
+
def initialize(afi, vrf, rp_addr, group, instantiate=true)
|
30
|
+
fail ArgumentError unless vrf.is_a?(String) || vrf.length > 0
|
31
|
+
@afi = Pim.afi_cli(afi)
|
32
|
+
@rp_addr = rp_addr
|
33
|
+
@group = group
|
34
|
+
@vrf = vrf
|
35
|
+
set_args_keys_default
|
36
|
+
|
37
|
+
create if instantiate
|
38
|
+
end
|
39
|
+
|
40
|
+
# Create a hash of [afi][vrf][rp-addr,grouplist]
|
41
|
+
# --------------------------------------------------
|
42
|
+
def self.group_lists
|
43
|
+
afis = %w(ipv4) # TBD ipv6
|
44
|
+
hash = {}
|
45
|
+
afis.each do |afi|
|
46
|
+
hash[afi] = {}
|
47
|
+
default_vrf = 'default'
|
48
|
+
get_args = { afi: Pim.afi_cli(afi) }
|
49
|
+
rp_addrs = config_get('pim', 'all_group_lists', get_args)
|
50
|
+
unless rp_addrs.nil?
|
51
|
+
rp_addrs.each do |addr_and_group|
|
52
|
+
addr, group = addr_and_group
|
53
|
+
hash[afi][default_vrf] ||= {}
|
54
|
+
hash[afi][default_vrf][addr_and_group] =
|
55
|
+
PimGroupList.new(afi, default_vrf, addr, group, false)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
vrf_ids = config_get('vrf', 'all_vrfs')
|
59
|
+
vrf_ids.each do |vrf|
|
60
|
+
get_args = { vrf: vrf, afi: Pim.afi_cli(afi) }
|
61
|
+
rp_addrs = config_get('pim', 'all_group_lists', get_args)
|
62
|
+
next if rp_addrs.nil?
|
63
|
+
rp_addrs.each do |addr_and_group|
|
64
|
+
hash[afi][vrf] ||= {}
|
65
|
+
addr, group = addr_and_group
|
66
|
+
hash[afi][vrf][addr_and_group] =
|
67
|
+
PimGroupList.new(afi, vrf, addr, group, false)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
hash
|
72
|
+
rescue Cisco::CliError => e
|
73
|
+
# cmd will syntax reject when feature is not enabled
|
74
|
+
raise unless e.clierror =~ /Syntax error/
|
75
|
+
return {}
|
76
|
+
end
|
77
|
+
|
78
|
+
# set_args_keys_default
|
79
|
+
# ---------------------
|
80
|
+
def set_args_keys_default
|
81
|
+
keys = { afi: @afi, addr: @rp_addr, group: @group }
|
82
|
+
keys[:vrf] = @vrf unless @vrf == 'default'
|
83
|
+
@get_args = @set_args = keys
|
84
|
+
end
|
85
|
+
|
86
|
+
# set_args_key
|
87
|
+
# -------------
|
88
|
+
def set_args_keys(hash={}) # rubocop:disable Style/AccessorMethodName
|
89
|
+
set_args_keys_default
|
90
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
91
|
+
end
|
92
|
+
|
93
|
+
# Create pim grouplist instance
|
94
|
+
# ---------------------------------
|
95
|
+
def create
|
96
|
+
Pim.feature_enable unless Pim.feature_enabled
|
97
|
+
set_args_keys(state: '')
|
98
|
+
config_set('pim', 'group_list', @set_args)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Destroy pim grouplist instance
|
102
|
+
# ----------------------------------
|
103
|
+
def destroy
|
104
|
+
set_args_keys(state: 'no')
|
105
|
+
config_set('pim', 'group_list', @set_args)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# NXAPI implementation of the PimRpAddress class
|
2
|
+
#
|
3
|
+
# Smitha Gopalan, November 2015
|
4
|
+
#
|
5
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'node_util'
|
20
|
+
require_relative 'pim'
|
21
|
+
|
22
|
+
module Cisco
|
23
|
+
# node_utils class for pim_rp_address
|
24
|
+
class PimRpAddress < NodeUtil
|
25
|
+
attr_reader :afi, :rp_addr, :vrf
|
26
|
+
|
27
|
+
# Constructor with afi, rp_address and vrf
|
28
|
+
# -----------------------------------------
|
29
|
+
def initialize(afi, vrf, rp_addr, instantiate=true)
|
30
|
+
fail ArgumentError unless vrf.is_a?(String) || vrf.length > 0
|
31
|
+
@afi = Pim.afi_cli(afi)
|
32
|
+
@rp_addr = rp_addr
|
33
|
+
@vrf = vrf
|
34
|
+
create if instantiate
|
35
|
+
end
|
36
|
+
|
37
|
+
# Create a hash of [afi][vrf][rp_address]
|
38
|
+
# ------------------------------------------------
|
39
|
+
def self.rp_addresses
|
40
|
+
afis = %w(ipv4) # TBD ipv6
|
41
|
+
hash = {}
|
42
|
+
afis.each do |afi|
|
43
|
+
hash[afi] = {}
|
44
|
+
default_vrf = 'default'
|
45
|
+
get_args = { afi: Pim.afi_cli(afi) }
|
46
|
+
rp_addrs = config_get('pim', 'all_rp_addresses', get_args)
|
47
|
+
unless rp_addrs.nil?
|
48
|
+
rp_addrs.each do |addr|
|
49
|
+
hash[afi][default_vrf] ||= {}
|
50
|
+
hash[afi][default_vrf][addr] =
|
51
|
+
PimRpAddress.new(afi, default_vrf, addr, false)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
vrf_ids = config_get('vrf', 'all_vrfs')
|
55
|
+
vrf_ids.each do |vrf|
|
56
|
+
get_args = { afi: Pim.afi_cli(afi), vrf: vrf }
|
57
|
+
rp_addrs = config_get('pim', 'all_rp_addresses', get_args)
|
58
|
+
next if rp_addrs.nil?
|
59
|
+
rp_addrs.each do |addr|
|
60
|
+
hash[afi][vrf] ||= {}
|
61
|
+
hash[afi][vrf][addr] = PimRpAddress.new(afi, vrf, addr, false)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
hash
|
66
|
+
rescue Cisco::CliError => e
|
67
|
+
# cmd will syntax reject when feature is not enabled
|
68
|
+
raise unless e.clierror =~ /Syntax error/
|
69
|
+
return {}
|
70
|
+
end
|
71
|
+
|
72
|
+
# set_args_keys_default
|
73
|
+
# ----------------------
|
74
|
+
def set_args_keys_default
|
75
|
+
keys = { afi: @afi, addr: @rp_addr }
|
76
|
+
keys[:vrf] = @vrf unless @vrf == 'default'
|
77
|
+
@get_args = @set_args = keys
|
78
|
+
end
|
79
|
+
|
80
|
+
# set_args_key
|
81
|
+
# -------------
|
82
|
+
def set_args_keys(hash={}) # rubocop:disable Style/AccessorMethodName
|
83
|
+
set_args_keys_default
|
84
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
85
|
+
end
|
86
|
+
|
87
|
+
# Create pim rp_addr instance
|
88
|
+
# ------------------------------
|
89
|
+
def create
|
90
|
+
Pim.feature_enable unless Pim.feature_enabled
|
91
|
+
set_args_keys(state: '')
|
92
|
+
config_set('pim', 'rp_address', @set_args)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Destroy pim rp_addr instance
|
96
|
+
# ------------------------------
|
97
|
+
def destroy
|
98
|
+
set_args_keys(state: 'no')
|
99
|
+
config_set('pim', 'rp_address', @set_args)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|