cisco_node_utils 1.1.0 → 1.2.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 -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Alex Hunsberger, Mar 2015
|
|
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.
|
|
@@ -58,9 +58,9 @@ module Cisco
|
|
|
58
58
|
total.nil? || used.nil? || free.nil?
|
|
59
59
|
|
|
60
60
|
{
|
|
61
|
-
'total' => total
|
|
62
|
-
'used' => used
|
|
63
|
-
'free' => free
|
|
61
|
+
'total' => total,
|
|
62
|
+
'used' => used,
|
|
63
|
+
'free' => free,
|
|
64
64
|
}
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -73,13 +73,12 @@ module Cisco
|
|
|
73
73
|
def self.uptime
|
|
74
74
|
u = config_get('show_version', 'uptime')
|
|
75
75
|
fail 'failed to retrieve platform uptime' if u.nil?
|
|
76
|
-
u
|
|
76
|
+
u
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
# Ex: '23113 usecs after Mon Jul 1 15:24:29 2013'
|
|
80
80
|
def self.last_reset
|
|
81
|
-
|
|
82
|
-
r.nil? ? nil : r.strip
|
|
81
|
+
config_get('show_version', 'last_reset_time')
|
|
83
82
|
end
|
|
84
83
|
|
|
85
84
|
# Ex: 'Reset Requested by CLI command reload'
|
|
@@ -165,7 +164,7 @@ module Cisco
|
|
|
165
164
|
# convert to expected format
|
|
166
165
|
virts_hsh = {}
|
|
167
166
|
virts.each do |serv|
|
|
168
|
-
# rubocop:disable Style/AlignHash
|
|
167
|
+
# rubocop:disable Style/AlignHash
|
|
169
168
|
virts_hsh[serv['name']] = {
|
|
170
169
|
'package_info' => { 'name' => serv['package_name'],
|
|
171
170
|
'path' => serv['ova_path'],
|
|
@@ -185,7 +184,7 @@ module Cisco
|
|
|
185
184
|
'cpu' => serv['cpu_reservation'],
|
|
186
185
|
},
|
|
187
186
|
}
|
|
188
|
-
# rubocop:enable Style/AlignHash
|
|
187
|
+
# rubocop:enable Style/AlignHash
|
|
189
188
|
end
|
|
190
189
|
virts_hsh
|
|
191
190
|
end
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# December 2015, Sai Chintalapudi
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
require_relative 'node_util'
|
|
18
|
+
|
|
19
|
+
module Cisco
|
|
20
|
+
# node_utils class for portchannel_global
|
|
21
|
+
class PortChannelGlobal < NodeUtil
|
|
22
|
+
attr_reader :name
|
|
23
|
+
|
|
24
|
+
def initialize(name)
|
|
25
|
+
fail TypeError unless name.is_a?(String)
|
|
26
|
+
fail ArgumentError unless name == 'default'
|
|
27
|
+
@name = name.downcase
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.globals
|
|
31
|
+
{ 'default' => PortChannelGlobal.new('default') }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
########################################################
|
|
35
|
+
# PROPERTIES #
|
|
36
|
+
########################################################
|
|
37
|
+
|
|
38
|
+
def hash_distribution
|
|
39
|
+
config_get('portchannel_global', 'hash_distribution')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def hash_distribution=(val)
|
|
43
|
+
config_set('portchannel_global',
|
|
44
|
+
'hash_distribution', val)
|
|
45
|
+
rescue Cisco::CliError => e
|
|
46
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def default_hash_distribution
|
|
50
|
+
config_get_default('portchannel_global', 'hash_distribution')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def load_defer
|
|
54
|
+
config_get('portchannel_global', 'load_defer')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def load_defer=(val)
|
|
58
|
+
config_set('portchannel_global', 'load_defer', val)
|
|
59
|
+
rescue Cisco::CliError => e
|
|
60
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def default_load_defer
|
|
64
|
+
config_get_default('portchannel_global', 'load_defer')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def resilient
|
|
68
|
+
config_get('portchannel_global', 'resilient')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def resilient=(state)
|
|
72
|
+
fail TypeError unless state == true || state == false
|
|
73
|
+
no_cmd = (state ? '' : 'no')
|
|
74
|
+
config_set('portchannel_global', 'resilient', no_cmd)
|
|
75
|
+
rescue Cisco::CliError => e
|
|
76
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def default_resilient
|
|
80
|
+
config_get_default('portchannel_global', 'resilient')
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# port-channel load-balance is a complicated command
|
|
84
|
+
# and this has so many forms in the same device and in
|
|
85
|
+
# different devices.
|
|
86
|
+
# For ex:
|
|
87
|
+
# port-channel load-balance src-dst ip rotate 4 concatenation symmetric
|
|
88
|
+
# port-channel load-balance resilient
|
|
89
|
+
# port-channel load-balance ethernet destination-mac CRC10c
|
|
90
|
+
# port-channel load-balance ethernet source-ip
|
|
91
|
+
# port-channel load-balance dst ip-l4port rotate 4 asymmetric
|
|
92
|
+
# port-channel load-balance dst ip-l4port-vlan module 9
|
|
93
|
+
# port-channel load-balance hash-modulo
|
|
94
|
+
# we need to eliminate all the clutter and get the correct
|
|
95
|
+
# line of config first and after that get index of each property
|
|
96
|
+
# and get the property value because some properties may or
|
|
97
|
+
# may not be present always.
|
|
98
|
+
# This method returns a hash
|
|
99
|
+
def port_channel_load_balance
|
|
100
|
+
lb = config_get('portchannel_global',
|
|
101
|
+
'port_channel_load_balance')
|
|
102
|
+
hash = {}
|
|
103
|
+
lb.each do |line|
|
|
104
|
+
next if line[/(internal|resilient|module|fex|hash)/]
|
|
105
|
+
params = line.split
|
|
106
|
+
lb_type = config_get('portchannel_global', 'load_balance_type')
|
|
107
|
+
case lb_type.to_sym
|
|
108
|
+
when :ethernet # n6k
|
|
109
|
+
_parse_ethernet_params(hash, params)
|
|
110
|
+
when :asymmetric # n7k
|
|
111
|
+
_parse_asymmetric_params(hash, params, line)
|
|
112
|
+
when :symmetry # n9k
|
|
113
|
+
_parse_symmetry_params(hash, params, line)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
hash
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def asymmetric
|
|
120
|
+
port_channel_load_balance[:asymmetric]
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def default_asymmetric
|
|
124
|
+
config_get_default('portchannel_global',
|
|
125
|
+
'asymmetric')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def bundle_hash
|
|
129
|
+
port_channel_load_balance[:bundle_hash]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def default_bundle_hash
|
|
133
|
+
config_get_default('portchannel_global',
|
|
134
|
+
'bundle_hash')
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def bundle_select
|
|
138
|
+
port_channel_load_balance[:bundle_select]
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def default_bundle_select
|
|
142
|
+
config_get_default('portchannel_global',
|
|
143
|
+
'bundle_select')
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def concatenation
|
|
147
|
+
port_channel_load_balance[:concatenation]
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def default_concatenation
|
|
151
|
+
config_get_default('portchannel_global',
|
|
152
|
+
'concatenation')
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def hash_poly
|
|
156
|
+
port_channel_load_balance[:hash_poly]
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def default_hash_poly
|
|
160
|
+
config_get_default('portchannel_global',
|
|
161
|
+
'hash_poly')
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def rotate
|
|
165
|
+
port_channel_load_balance[:rotate]
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def default_rotate
|
|
169
|
+
config_get_default('portchannel_global',
|
|
170
|
+
'rotate')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def symmetry
|
|
174
|
+
port_channel_load_balance[:symmetry]
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def default_symmetry
|
|
178
|
+
config_get_default('portchannel_global',
|
|
179
|
+
'symmetry')
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def port_channel_load_balance=(bselect, bhash, hpoly, asy, sy, conc, rot)
|
|
183
|
+
lb_type = config_get('portchannel_global', 'load_balance_type')
|
|
184
|
+
case lb_type.to_sym
|
|
185
|
+
when :ethernet # n6k
|
|
186
|
+
if bselect == 'src'
|
|
187
|
+
sel = 'source'
|
|
188
|
+
elsif bselect == 'dst'
|
|
189
|
+
sel = 'destination'
|
|
190
|
+
else
|
|
191
|
+
sel = 'source-dest'
|
|
192
|
+
end
|
|
193
|
+
sel_hash = sel + '-' + bhash
|
|
194
|
+
# port-channel load-balance ethernet destination-mac CRC10c
|
|
195
|
+
config_set('portchannel_global', 'port_channel_load_balance',
|
|
196
|
+
'ethernet', sel_hash, hpoly, '', '', '')
|
|
197
|
+
when :asymmetric # n7k
|
|
198
|
+
asym = (asy == true) ? 'asymmetric' : ''
|
|
199
|
+
# port-channel load-balance dst ip-l4port rotate 4 asymmetric
|
|
200
|
+
config_set('portchannel_global', 'port_channel_load_balance',
|
|
201
|
+
bselect, bhash, 'rotate', rot.to_s, asym, '')
|
|
202
|
+
when :symmetry # n9k
|
|
203
|
+
sym = sy ? 'symmetric' : ''
|
|
204
|
+
concat = conc ? 'concatenation' : ''
|
|
205
|
+
rot_str = rot.zero? ? '' : 'rotate'
|
|
206
|
+
rot_val = rot.zero? ? '' : rot.to_s
|
|
207
|
+
# port-channel load-balance src-dst ip rotate 4 concatenation symmetric
|
|
208
|
+
config_set('portchannel_global', 'port_channel_load_balance',
|
|
209
|
+
bselect, bhash, rot_str, rot_val, concat, sym)
|
|
210
|
+
end
|
|
211
|
+
rescue Cisco::CliError => e
|
|
212
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# on n6k, the bundle hash and bundle select are
|
|
216
|
+
# merged into one and so we need to break them apart,
|
|
217
|
+
# also they are called source and destination instead of
|
|
218
|
+
# src and dst as in other devices, so we convert them
|
|
219
|
+
def _parse_ethernet_params(hash, params)
|
|
220
|
+
hash_poly = params[2]
|
|
221
|
+
# hash_poly is not shown on the running config
|
|
222
|
+
# if it is default under some circumstatnces
|
|
223
|
+
hash_poly = hash_poly.nil? ? 'CRC10b' : hash_poly
|
|
224
|
+
select_hash = params[1]
|
|
225
|
+
lparams = select_hash.split('-')
|
|
226
|
+
if lparams[0].downcase == 'destination'
|
|
227
|
+
bselect = 'dst'
|
|
228
|
+
bhash = lparams[1]
|
|
229
|
+
else
|
|
230
|
+
if select_hash.include? '-dest-'
|
|
231
|
+
bselect = 'src-dst'
|
|
232
|
+
bhash = lparams[2]
|
|
233
|
+
# there are bundles hashes like ip-only and
|
|
234
|
+
# port-only specific to src-dst
|
|
235
|
+
bhash += '-only' if select_hash.include? 'only'
|
|
236
|
+
else
|
|
237
|
+
bselect = 'src'
|
|
238
|
+
bhash = lparams[1]
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
hash[:bundle_select] = bselect
|
|
242
|
+
hash[:bundle_hash] = bhash
|
|
243
|
+
hash[:hash_poly] = hash_poly
|
|
244
|
+
hash
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def _parse_asymmetric_params(hash, params, line)
|
|
248
|
+
bselect = params[0]
|
|
249
|
+
bhash = params[1]
|
|
250
|
+
# asymmetric keyword does not show up if it is false
|
|
251
|
+
asym = (line.include? 'asymmetric') ? true : false
|
|
252
|
+
ri = params.index('rotate')
|
|
253
|
+
rotate = params[ri + 1].to_i
|
|
254
|
+
hash[:bundle_select] = bselect
|
|
255
|
+
hash[:bundle_hash] = bhash
|
|
256
|
+
hash[:asymmetric] = asym
|
|
257
|
+
hash[:rotate] = rotate
|
|
258
|
+
hash
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def _parse_symmetry_params(hash, params, line)
|
|
262
|
+
bselect = params[0]
|
|
263
|
+
bhash = params[1]
|
|
264
|
+
ri = params.index('rotate')
|
|
265
|
+
rotate = params[ri + 1].to_i
|
|
266
|
+
# concatenation and symmetry keywords do not show up if false
|
|
267
|
+
concat = (line.include? 'concatenation') ? true : false
|
|
268
|
+
sym = (line.include? 'symmetric') ? true : false
|
|
269
|
+
hash[:bundle_select] = bselect
|
|
270
|
+
hash[:bundle_hash] = bhash
|
|
271
|
+
hash[:symmetry] = sym
|
|
272
|
+
hash[:rotate] = rotate
|
|
273
|
+
hash[:concatenation] = concat
|
|
274
|
+
hash
|
|
275
|
+
end
|
|
276
|
+
end # class
|
|
277
|
+
end # module
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Jonathan Tripathy et al., September 2015
|
|
4
4
|
|
|
5
|
-
# Copyright (c) 2014-
|
|
5
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
|
6
6
|
|
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
# you may not use this file except in compliance with the License.
|
|
@@ -43,14 +43,11 @@ module Cisco
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def timeout
|
|
46
|
-
|
|
47
|
-
val = val[0].to_i unless val.nil?
|
|
48
|
-
val
|
|
46
|
+
config_get('radius_global', 'timeout')
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
def default_timeout
|
|
52
|
-
|
|
53
|
-
val
|
|
50
|
+
config_get_default('radius_global', 'timeout')
|
|
54
51
|
end
|
|
55
52
|
|
|
56
53
|
def timeout=(val)
|
|
@@ -59,7 +56,7 @@ module Cisco
|
|
|
59
56
|
unless val.is_a?(Integer)
|
|
60
57
|
end
|
|
61
58
|
|
|
62
|
-
if val.nil?
|
|
59
|
+
if val.nil?
|
|
63
60
|
config_set('radius_global',
|
|
64
61
|
'timeout',
|
|
65
62
|
state: 'no',
|
|
@@ -73,14 +70,11 @@ module Cisco
|
|
|
73
70
|
end
|
|
74
71
|
|
|
75
72
|
def retransmit_count
|
|
76
|
-
|
|
77
|
-
val = val[0].to_i unless val.nil?
|
|
78
|
-
val
|
|
73
|
+
config_get('radius_global', 'retransmit')
|
|
79
74
|
end
|
|
80
75
|
|
|
81
76
|
def default_retransmit_count
|
|
82
|
-
|
|
83
|
-
val
|
|
77
|
+
config_get_default('radius_global', 'retransmit').to_i
|
|
84
78
|
end
|
|
85
79
|
|
|
86
80
|
def retransmit_count=(val)
|
|
@@ -89,7 +83,7 @@ module Cisco
|
|
|
89
83
|
unless val.is_a?(Integer)
|
|
90
84
|
end
|
|
91
85
|
|
|
92
|
-
if val.nil?
|
|
86
|
+
if val.nil?
|
|
93
87
|
config_set('radius_global',
|
|
94
88
|
'retransmit',
|
|
95
89
|
state: 'no',
|
|
@@ -103,15 +97,11 @@ module Cisco
|
|
|
103
97
|
end
|
|
104
98
|
|
|
105
99
|
def key_format
|
|
106
|
-
|
|
107
|
-
val = val[0].to_i unless val.nil?
|
|
108
|
-
val
|
|
100
|
+
config_get('radius_global', 'key_format')
|
|
109
101
|
end
|
|
110
102
|
|
|
111
103
|
def key
|
|
112
|
-
|
|
113
|
-
val = val[0] unless val.nil?
|
|
114
|
-
val
|
|
104
|
+
config_get('radius_global', 'key')
|
|
115
105
|
end
|
|
116
106
|
|
|
117
107
|
def key_set(value, format)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Jonathan Tripathy et al., September 2015
|
|
4
4
|
|
|
5
|
-
# Copyright (c) 2014-
|
|
5
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
|
6
6
|
|
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
# you may not use this file except in compliance with the License.
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
# limitations under the License.
|
|
18
18
|
|
|
19
19
|
require File.join(File.dirname(__FILE__), 'node_util')
|
|
20
|
+
require 'ipaddr'
|
|
20
21
|
|
|
21
22
|
module Cisco
|
|
22
23
|
# RadiusServer - node utility class for
|
|
@@ -25,8 +26,16 @@ module Cisco
|
|
|
25
26
|
attr_reader :name
|
|
26
27
|
|
|
27
28
|
def initialize(name, instantiate=true)
|
|
28
|
-
unless name
|
|
29
|
-
fail ArgumentError,
|
|
29
|
+
unless name =~ /^[a-zA-Z0-9\.\:]*$/
|
|
30
|
+
fail ArgumentError,
|
|
31
|
+
'Invalid value (IPv4/IPv6 address contains invalid characters)'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
IPAddr.new(name)
|
|
36
|
+
rescue
|
|
37
|
+
raise ArgumentError,
|
|
38
|
+
'Invalid value (Name is not a valid single IPv4/IPv6 address)'
|
|
30
39
|
end
|
|
31
40
|
@name = name
|
|
32
41
|
|
|
@@ -37,8 +46,7 @@ module Cisco
|
|
|
37
46
|
hash = {}
|
|
38
47
|
|
|
39
48
|
radiusservers_list = config_get('radius_server', 'hosts')
|
|
40
|
-
return hash if radiusservers_list.
|
|
41
|
-
|
|
49
|
+
return hash if radiusservers_list.empty?
|
|
42
50
|
radiusservers_list.each do |id|
|
|
43
51
|
hash[id] = RadiusServer.new(id, false)
|
|
44
52
|
end
|
|
@@ -65,14 +73,11 @@ module Cisco
|
|
|
65
73
|
end
|
|
66
74
|
|
|
67
75
|
def auth_port
|
|
68
|
-
|
|
69
|
-
val = val[0].to_i unless val.nil?
|
|
70
|
-
val
|
|
76
|
+
config_get('radius_server', 'auth-port', @name)
|
|
71
77
|
end
|
|
72
78
|
|
|
73
79
|
def default_auth_port
|
|
74
|
-
|
|
75
|
-
val
|
|
80
|
+
config_get_default('radius_server', 'auth-port')
|
|
76
81
|
end
|
|
77
82
|
|
|
78
83
|
def auth_port=(val)
|
|
@@ -81,7 +86,7 @@ module Cisco
|
|
|
81
86
|
unless val.is_a?(Integer)
|
|
82
87
|
end
|
|
83
88
|
|
|
84
|
-
if val.nil?
|
|
89
|
+
if val.nil?
|
|
85
90
|
config_set('radius_server',
|
|
86
91
|
'auth-port',
|
|
87
92
|
state: 'no',
|
|
@@ -97,14 +102,11 @@ module Cisco
|
|
|
97
102
|
end
|
|
98
103
|
|
|
99
104
|
def acct_port
|
|
100
|
-
|
|
101
|
-
val = val[0].to_i unless val.nil?
|
|
102
|
-
val
|
|
105
|
+
config_get('radius_server', 'acct-port', @name)
|
|
103
106
|
end
|
|
104
107
|
|
|
105
108
|
def default_acct_port
|
|
106
|
-
|
|
107
|
-
val
|
|
109
|
+
config_get_default('radius_server', 'acct-port')
|
|
108
110
|
end
|
|
109
111
|
|
|
110
112
|
def acct_port=(val)
|
|
@@ -113,7 +115,7 @@ module Cisco
|
|
|
113
115
|
unless val.is_a?(Integer)
|
|
114
116
|
end
|
|
115
117
|
|
|
116
|
-
if val.nil?
|
|
118
|
+
if val.nil?
|
|
117
119
|
config_set('radius_server',
|
|
118
120
|
'acct-port',
|
|
119
121
|
state: 'no',
|
|
@@ -129,14 +131,11 @@ module Cisco
|
|
|
129
131
|
end
|
|
130
132
|
|
|
131
133
|
def timeout
|
|
132
|
-
|
|
133
|
-
val = val[0].to_i unless val.nil?
|
|
134
|
-
val
|
|
134
|
+
config_get('radius_server', 'timeout', @name)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
def default_timeout
|
|
138
|
-
|
|
139
|
-
val
|
|
138
|
+
config_get_default('radius_server', 'timeout')
|
|
140
139
|
end
|
|
141
140
|
|
|
142
141
|
def timeout=(val)
|
|
@@ -145,7 +144,7 @@ module Cisco
|
|
|
145
144
|
unless val.is_a?(Integer)
|
|
146
145
|
end
|
|
147
146
|
|
|
148
|
-
if val.nil?
|
|
147
|
+
if val.nil?
|
|
149
148
|
config_set('radius_server',
|
|
150
149
|
'timeout',
|
|
151
150
|
state: 'no',
|
|
@@ -161,14 +160,11 @@ module Cisco
|
|
|
161
160
|
end
|
|
162
161
|
|
|
163
162
|
def retransmit_count
|
|
164
|
-
|
|
165
|
-
val = val[0].to_i unless val.nil?
|
|
166
|
-
val
|
|
163
|
+
config_get('radius_server', 'retransmit', @name)
|
|
167
164
|
end
|
|
168
165
|
|
|
169
166
|
def default_retransmit_count
|
|
170
|
-
|
|
171
|
-
val
|
|
167
|
+
config_get_default('radius_server', 'retransmit')
|
|
172
168
|
end
|
|
173
169
|
|
|
174
170
|
def retransmit_count=(val)
|
|
@@ -177,7 +173,7 @@ module Cisco
|
|
|
177
173
|
unless val.is_a?(Integer)
|
|
178
174
|
end
|
|
179
175
|
|
|
180
|
-
if val.nil?
|
|
176
|
+
if val.nil?
|
|
181
177
|
config_set('radius_server',
|
|
182
178
|
'retransmit',
|
|
183
179
|
state: 'no',
|
|
@@ -197,13 +193,12 @@ module Cisco
|
|
|
197
193
|
if val.nil?
|
|
198
194
|
false
|
|
199
195
|
else
|
|
200
|
-
val
|
|
196
|
+
val
|
|
201
197
|
end
|
|
202
198
|
end
|
|
203
199
|
|
|
204
200
|
def default_accounting
|
|
205
|
-
|
|
206
|
-
val
|
|
201
|
+
config_get_default('radius_server', 'accounting')
|
|
207
202
|
end
|
|
208
203
|
|
|
209
204
|
def accounting=(val)
|
|
@@ -225,13 +220,12 @@ module Cisco
|
|
|
225
220
|
if val.nil?
|
|
226
221
|
false
|
|
227
222
|
else
|
|
228
|
-
val
|
|
223
|
+
val
|
|
229
224
|
end
|
|
230
225
|
end
|
|
231
226
|
|
|
232
227
|
def default_authentication
|
|
233
|
-
|
|
234
|
-
val
|
|
228
|
+
config_get_default('radius_server', 'authentication')
|
|
235
229
|
end
|
|
236
230
|
|
|
237
231
|
def authentication=(val)
|
|
@@ -249,15 +243,11 @@ module Cisco
|
|
|
249
243
|
end
|
|
250
244
|
|
|
251
245
|
def key_format
|
|
252
|
-
|
|
253
|
-
val = val[0].to_i unless val.nil?
|
|
254
|
-
val
|
|
246
|
+
config_get('radius_server', 'key_format', @name)
|
|
255
247
|
end
|
|
256
248
|
|
|
257
249
|
def key
|
|
258
|
-
|
|
259
|
-
val = val[0] unless val.nil?
|
|
260
|
-
val
|
|
250
|
+
config_get('radius_server', 'key', @name)
|
|
261
251
|
end
|
|
262
252
|
|
|
263
253
|
def key_set(value, format)
|