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,124 @@
|
|
1
|
+
# January 2016, Chris Van Heuveln
|
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
|
+
# Add some interface-specific constants to the Cisco namespace
|
20
|
+
module Cisco
|
21
|
+
# Interface - node utility class for general interface config management
|
22
|
+
class InterfaceChannelGroup < NodeUtil
|
23
|
+
attr_reader :name
|
24
|
+
|
25
|
+
def initialize(name)
|
26
|
+
validate_args(name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.interfaces
|
30
|
+
hash = {}
|
31
|
+
all = config_get('interface_channel_group', 'all_interfaces')
|
32
|
+
return hash if all.nil?
|
33
|
+
|
34
|
+
all.each do |id|
|
35
|
+
id = id.downcase
|
36
|
+
hash[id] = InterfaceChannelGroup.new(id)
|
37
|
+
end
|
38
|
+
hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def validate_args(name)
|
42
|
+
fail TypeError unless name.is_a?(String)
|
43
|
+
fail ArgumentError unless name.length > 0
|
44
|
+
fail "channel_group is not supported on #{name}" unless
|
45
|
+
name[/Ethernet/i]
|
46
|
+
@name = name.downcase
|
47
|
+
set_args_keys
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_args_keys(hash={}) # rubocop:disable Style/AccessorMethodName
|
51
|
+
@get_args = { name: @name }
|
52
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
53
|
+
end
|
54
|
+
|
55
|
+
def fail_cli(e)
|
56
|
+
fail "[#{@name}] '#{e.command}' : #{e.clierror}"
|
57
|
+
end
|
58
|
+
|
59
|
+
########################################################
|
60
|
+
# PROPERTIES #
|
61
|
+
########################################################
|
62
|
+
|
63
|
+
def channel_group
|
64
|
+
config_get('interface_channel_group', 'channel_group', @get_args)
|
65
|
+
end
|
66
|
+
|
67
|
+
def channel_group=(group)
|
68
|
+
# 'force' is needed by cli_nxos to handle the case where a port-channel
|
69
|
+
# interface is created prior to the channel-group cli; in which case
|
70
|
+
# the properties of the port-channel interface will be different from
|
71
|
+
# the ethernet interface. 'force' is not needed if the port-channel is
|
72
|
+
# created as a result of the channel-group cli but since it does no
|
73
|
+
# harm we will use it every time.
|
74
|
+
if group
|
75
|
+
state = ''
|
76
|
+
force = 'force'
|
77
|
+
else
|
78
|
+
state = 'no'
|
79
|
+
group = force = ''
|
80
|
+
end
|
81
|
+
config_set('interface_channel_group', 'channel_group',
|
82
|
+
set_args_keys(state: state, group: group, force: force))
|
83
|
+
rescue Cisco::CliError => e
|
84
|
+
fail_cli(e)
|
85
|
+
end
|
86
|
+
|
87
|
+
def default_channel_group
|
88
|
+
config_get_default('interface_channel_group', 'channel_group')
|
89
|
+
end
|
90
|
+
|
91
|
+
# ----------------------------
|
92
|
+
def description
|
93
|
+
config_get('interface_channel_group', 'description', @get_args)
|
94
|
+
end
|
95
|
+
|
96
|
+
def description=(desc)
|
97
|
+
state = desc.strip.empty? ? 'no' : ''
|
98
|
+
config_set('interface_channel_group', 'description',
|
99
|
+
set_args_keys(state: state, desc: desc))
|
100
|
+
rescue Cisco::CliError => e
|
101
|
+
fail_cli(e)
|
102
|
+
end
|
103
|
+
|
104
|
+
def default_description
|
105
|
+
config_get_default('interface_channel_group', 'description')
|
106
|
+
end
|
107
|
+
|
108
|
+
# ----------------------------
|
109
|
+
def shutdown
|
110
|
+
config_get('interface_channel_group', 'shutdown', @get_args)
|
111
|
+
end
|
112
|
+
|
113
|
+
def shutdown=(state)
|
114
|
+
config_set('interface_channel_group', 'shutdown',
|
115
|
+
set_args_keys(state: state ? '' : 'no'))
|
116
|
+
rescue Cisco::CliError => e
|
117
|
+
fail_cli(e)
|
118
|
+
end
|
119
|
+
|
120
|
+
def default_shutdown
|
121
|
+
config_get_default('interface_channel_group', 'shutdown')
|
122
|
+
end
|
123
|
+
end # Class
|
124
|
+
end # Module
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# March 2015, Alex Hunsberger
|
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.
|
@@ -59,8 +59,6 @@ module Cisco
|
|
59
59
|
intf_list.each do |name|
|
60
60
|
match = config_get('interface_ospf', 'area', name)
|
61
61
|
next if match.nil?
|
62
|
-
# should only be a single match under a given interface
|
63
|
-
match = match.first
|
64
62
|
# ip router ospf <name> area <area>
|
65
63
|
ospf = match[0]
|
66
64
|
area = match[1]
|
@@ -74,7 +72,7 @@ module Cisco
|
|
74
72
|
def area
|
75
73
|
match = config_get('interface_ospf', 'area', @interface.name)
|
76
74
|
return nil if match.nil?
|
77
|
-
val = match[
|
75
|
+
val = match[1]
|
78
76
|
# Coerce numeric area to the expected dot-decimal format.
|
79
77
|
val = IPAddr.new(val.to_i, Socket::AF_INET).to_s unless val.match(/\./)
|
80
78
|
val
|
@@ -103,8 +101,7 @@ module Cisco
|
|
103
101
|
end
|
104
102
|
|
105
103
|
def message_digest
|
106
|
-
|
107
|
-
@interface.name).nil?
|
104
|
+
config_get('interface_ospf', 'message_digest', @interface.name)
|
108
105
|
end
|
109
106
|
|
110
107
|
# interface %s
|
@@ -119,10 +116,7 @@ module Cisco
|
|
119
116
|
end
|
120
117
|
|
121
118
|
def message_digest_key_id
|
122
|
-
|
123
|
-
@interface.name)
|
124
|
-
# regex in yaml returns an array result, use .first to get match
|
125
|
-
match.nil? ? default_message_digest_key_id : match.first.to_i
|
119
|
+
config_get('interface_ospf', 'message_digest_key_id', @interface.name)
|
126
120
|
end
|
127
121
|
|
128
122
|
def default_message_digest_algorithm_type
|
@@ -133,8 +127,7 @@ module Cisco
|
|
133
127
|
def message_digest_algorithm_type
|
134
128
|
match = config_get('interface_ospf', 'message_digest_alg_type',
|
135
129
|
@interface.name)
|
136
|
-
|
137
|
-
match.nil? ? default_message_digest_algorithm_type : match.first.to_sym
|
130
|
+
match.to_sym
|
138
131
|
end
|
139
132
|
|
140
133
|
def default_message_digest_encryption_type
|
@@ -145,18 +138,11 @@ module Cisco
|
|
145
138
|
def message_digest_encryption_type
|
146
139
|
match = config_get('interface_ospf', 'message_digest_enc_type',
|
147
140
|
@interface.name)
|
148
|
-
|
149
|
-
if match.nil?
|
150
|
-
default_message_digest_encryption_type
|
151
|
-
else
|
152
|
-
Encryption.cli_to_symbol(match.first)
|
153
|
-
end
|
141
|
+
Encryption.cli_to_symbol(match)
|
154
142
|
end
|
155
143
|
|
156
144
|
def message_digest_password
|
157
|
-
|
158
|
-
@interface.name)
|
159
|
-
match.nil? ? nil : match.first
|
145
|
+
config_get('interface_ospf', 'message_digest_password', @interface.name)
|
160
146
|
end
|
161
147
|
|
162
148
|
# interface %s
|
@@ -177,9 +163,7 @@ module Cisco
|
|
177
163
|
end
|
178
164
|
|
179
165
|
def cost
|
180
|
-
|
181
|
-
# regex in yaml returns an array result, use .first to get match
|
182
|
-
match.nil? ? default_cost : match.first.to_i
|
166
|
+
config_get('interface_ospf', 'cost', @interface.name)
|
183
167
|
end
|
184
168
|
|
185
169
|
def default_cost
|
@@ -197,10 +181,7 @@ module Cisco
|
|
197
181
|
end
|
198
182
|
|
199
183
|
def hello_interval
|
200
|
-
|
201
|
-
@interface.name)
|
202
|
-
# regex in yaml returns an array result, use .first to get match
|
203
|
-
match.nil? ? default_hello_interval : match.first.to_i
|
184
|
+
config_get('interface_ospf', 'hello_interval', @interface.name)
|
204
185
|
end
|
205
186
|
|
206
187
|
def default_hello_interval
|
@@ -215,10 +196,7 @@ module Cisco
|
|
215
196
|
end
|
216
197
|
|
217
198
|
def dead_interval
|
218
|
-
|
219
|
-
@interface.name)
|
220
|
-
# regex in yaml returns an array result, use .first to get match
|
221
|
-
match.nil? ? default_dead_interval : match.first.to_i
|
199
|
+
config_get('interface_ospf', 'dead_interval', @interface.name)
|
222
200
|
end
|
223
201
|
|
224
202
|
def default_dead_interval
|
@@ -237,8 +215,7 @@ module Cisco
|
|
237
215
|
end
|
238
216
|
|
239
217
|
def passive_interface
|
240
|
-
|
241
|
-
@interface.name).nil?
|
218
|
+
config_get('interface_ospf', 'passive_interface', @interface.name)
|
242
219
|
end
|
243
220
|
|
244
221
|
# interface %s
|
@@ -0,0 +1,157 @@
|
|
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
|
+
require_relative 'interface'
|
19
|
+
|
20
|
+
# Add some interface-specific constants to the Cisco namespace
|
21
|
+
module Cisco
|
22
|
+
# InterfacePortChannel - node utility class for port channel config management
|
23
|
+
class InterfacePortChannel < NodeUtil
|
24
|
+
attr_reader :name
|
25
|
+
|
26
|
+
def initialize(name, instantiate=true)
|
27
|
+
fail TypeError unless name.is_a?(String)
|
28
|
+
fail ArgumentError unless name.length > 0
|
29
|
+
@name = name.downcase
|
30
|
+
fail ArgumentError unless @name.start_with?('port-channel')
|
31
|
+
|
32
|
+
create if instantiate
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.interfaces
|
36
|
+
hash = {}
|
37
|
+
intf_list = config_get('interface', 'all_interfaces')
|
38
|
+
return hash if intf_list.nil?
|
39
|
+
|
40
|
+
intf_list.each do |id|
|
41
|
+
id = id.downcase
|
42
|
+
next unless id.start_with?('port-channel')
|
43
|
+
hash[id] = InterfacePortChannel.new(id, false)
|
44
|
+
end
|
45
|
+
hash
|
46
|
+
end
|
47
|
+
|
48
|
+
def create
|
49
|
+
config_set('interface_portchannel', 'create', @name)
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy
|
53
|
+
config_set('interface_portchannel', 'destroy', @name)
|
54
|
+
end
|
55
|
+
|
56
|
+
########################################################
|
57
|
+
# PROPERTIES #
|
58
|
+
########################################################
|
59
|
+
|
60
|
+
def lacp_graceful_convergence
|
61
|
+
config_get('interface_portchannel', 'lacp_graceful_convergence', @name)
|
62
|
+
end
|
63
|
+
|
64
|
+
def lacp_graceful_convergence=(state)
|
65
|
+
no_cmd = (state ? '' : 'no')
|
66
|
+
config_set('interface_portchannel',
|
67
|
+
'lacp_graceful_convergence', @name, no_cmd)
|
68
|
+
rescue Cisco::CliError => e
|
69
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def default_lacp_graceful_convergence
|
73
|
+
config_get_default('interface_portchannel', 'lacp_graceful_convergence')
|
74
|
+
end
|
75
|
+
|
76
|
+
def lacp_max_bundle
|
77
|
+
config_get('interface_portchannel', 'lacp_max_bundle', @name)
|
78
|
+
end
|
79
|
+
|
80
|
+
def lacp_max_bundle=(val)
|
81
|
+
config_set('interface_portchannel', 'lacp_max_bundle', @name, val)
|
82
|
+
rescue Cisco::CliError => e
|
83
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
84
|
+
end
|
85
|
+
|
86
|
+
def default_lacp_max_bundle
|
87
|
+
config_get_default('interface_portchannel', 'lacp_max_bundle')
|
88
|
+
end
|
89
|
+
|
90
|
+
def lacp_min_links
|
91
|
+
config_get('interface_portchannel', 'lacp_min_links', @name)
|
92
|
+
end
|
93
|
+
|
94
|
+
def lacp_min_links=(val)
|
95
|
+
config_set('interface_portchannel', 'lacp_min_links', @name, val)
|
96
|
+
rescue Cisco::CliError => e
|
97
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
98
|
+
end
|
99
|
+
|
100
|
+
def default_lacp_min_links
|
101
|
+
config_get_default('interface_portchannel', 'lacp_min_links')
|
102
|
+
end
|
103
|
+
|
104
|
+
def lacp_suspend_individual
|
105
|
+
config_get('interface_portchannel', 'lacp_suspend_individual', @name)
|
106
|
+
end
|
107
|
+
|
108
|
+
def lacp_suspend_individual=(state)
|
109
|
+
no_cmd = (state ? '' : 'no')
|
110
|
+
config_set('interface_portchannel',
|
111
|
+
'lacp_suspend_individual', @name, no_cmd)
|
112
|
+
rescue Cisco::CliError => e
|
113
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def default_lacp_suspend_individual
|
117
|
+
config_get_default('interface_portchannel', 'lacp_suspend_individual')
|
118
|
+
end
|
119
|
+
|
120
|
+
def port_hash_distribution
|
121
|
+
config_get('interface_portchannel', 'port_hash_distribution', @name)
|
122
|
+
end
|
123
|
+
|
124
|
+
def port_hash_distribution=(val)
|
125
|
+
if val
|
126
|
+
state = ''
|
127
|
+
else
|
128
|
+
state = 'no'
|
129
|
+
val = ''
|
130
|
+
end
|
131
|
+
config_set('interface_portchannel',
|
132
|
+
'port_hash_distribution', @name, state, val)
|
133
|
+
rescue Cisco::CliError => e
|
134
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
135
|
+
end
|
136
|
+
|
137
|
+
def default_port_hash_distribution
|
138
|
+
config_get_default('interface_portchannel', 'port_hash_distribution')
|
139
|
+
end
|
140
|
+
|
141
|
+
def port_load_defer
|
142
|
+
config_get('interface_portchannel', 'port_load_defer', @name)
|
143
|
+
end
|
144
|
+
|
145
|
+
def port_load_defer=(state)
|
146
|
+
no_cmd = (state ? '' : 'no')
|
147
|
+
config_set('interface_portchannel',
|
148
|
+
'port_load_defer', @name, no_cmd)
|
149
|
+
rescue Cisco::CliError => e
|
150
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
151
|
+
end
|
152
|
+
|
153
|
+
def default_port_load_defer
|
154
|
+
config_get_default('interface_portchannel', 'port_load_defer')
|
155
|
+
end
|
156
|
+
end # Class
|
157
|
+
end # Module
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# December 2015, Chris Van Heuveln
|
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
|
+
require_relative 'vni'
|
19
|
+
|
20
|
+
module Cisco
|
21
|
+
# InterfaceServiceVni - node utility class for Service VNI Instance commands
|
22
|
+
class InterfaceServiceVni < NodeUtil
|
23
|
+
attr_reader :name
|
24
|
+
|
25
|
+
def initialize(intf, sid, instantiate=true)
|
26
|
+
@name = intf.to_s.downcase
|
27
|
+
@sid = sid.to_s
|
28
|
+
fail ArgumentError if @name.empty? || @sid.empty?
|
29
|
+
set_args_keys_default
|
30
|
+
create if instantiate
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.svc_vni_ids
|
34
|
+
hash = {}
|
35
|
+
intf_list = config_get('interface', 'all_interfaces')
|
36
|
+
return hash if intf_list.nil?
|
37
|
+
|
38
|
+
intf_list.each do |intf|
|
39
|
+
intf.downcase!
|
40
|
+
svc_ids = config_get('interface_service_vni', 'all_service_vni_ids',
|
41
|
+
name: intf)
|
42
|
+
next if svc_ids.nil?
|
43
|
+
hash[intf] = {}
|
44
|
+
svc_ids.each do |sid|
|
45
|
+
hash[intf][sid] = InterfaceServiceVni.new(intf, sid, false)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
hash
|
49
|
+
end
|
50
|
+
|
51
|
+
def create
|
52
|
+
Vni.feature_vni_enable unless Vni.feature_vni_enabled
|
53
|
+
@set_args[:state] = ''
|
54
|
+
config_set('interface_service_vni', 'create_destroy', @set_args)
|
55
|
+
end
|
56
|
+
|
57
|
+
def destroy
|
58
|
+
@set_args[:state] = 'no'
|
59
|
+
config_set('interface_service_vni', 'create_destroy', @set_args)
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_args_keys_default
|
63
|
+
keys = { name: @name, sid: @sid }
|
64
|
+
@get_args = @set_args = keys
|
65
|
+
end
|
66
|
+
|
67
|
+
# rubocop:disable Style/AccessorMethodName
|
68
|
+
def set_args_keys(hash={})
|
69
|
+
set_args_keys_default
|
70
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
71
|
+
end
|
72
|
+
# rubocop:enable Style/AccessorMethodNamefor
|
73
|
+
|
74
|
+
########################################################
|
75
|
+
# PROPERTIES #
|
76
|
+
########################################################
|
77
|
+
|
78
|
+
#
|
79
|
+
# encapsulation_profile_vni
|
80
|
+
#
|
81
|
+
# cli: service instance 1 vni
|
82
|
+
# encapsulation profile vni_500_5000 default
|
83
|
+
# type: 'vni_500_5000'
|
84
|
+
def encapsulation_profile_vni
|
85
|
+
config_get('interface_service_vni', 'encapsulation_profile_vni',
|
86
|
+
@get_args)
|
87
|
+
end
|
88
|
+
|
89
|
+
def encapsulation_profile_vni=(profile)
|
90
|
+
Vni.feature_vni_enable unless Vni.feature_vni_enabled
|
91
|
+
state = profile.empty? ? 'no' : ''
|
92
|
+
current = encapsulation_profile_vni
|
93
|
+
|
94
|
+
if state[/no/]
|
95
|
+
config_set('interface_service_vni', 'encapsulation_profile_vni',
|
96
|
+
set_args_keys(state: state, profile: current)) unless
|
97
|
+
current.empty?
|
98
|
+
else
|
99
|
+
# Remove current profile before adding a new one
|
100
|
+
config_set('interface_service_vni', 'encapsulation_profile_vni',
|
101
|
+
set_args_keys(state: 'no', profile: current)) unless
|
102
|
+
current.empty?
|
103
|
+
config_set('interface_service_vni', 'encapsulation_profile_vni',
|
104
|
+
set_args_keys(state: state, profile: profile))
|
105
|
+
end
|
106
|
+
rescue Cisco::CliError => e
|
107
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def default_encapsulation_profile_vni
|
111
|
+
config_get_default('interface_service_vni', 'encapsulation_profile_vni')
|
112
|
+
end
|
113
|
+
|
114
|
+
#
|
115
|
+
# shutdown
|
116
|
+
#
|
117
|
+
def shutdown
|
118
|
+
config_get('interface_service_vni', 'shutdown', @get_args)
|
119
|
+
end
|
120
|
+
|
121
|
+
def shutdown=(state)
|
122
|
+
config_set('interface_service_vni', 'shutdown',
|
123
|
+
set_args_keys(state: state ? '' : 'no'))
|
124
|
+
rescue Cisco::CliError => e
|
125
|
+
raise "[#{@name}] '#{e.command}' : #{e.clierror}"
|
126
|
+
end
|
127
|
+
|
128
|
+
def default_shutdown
|
129
|
+
config_get_default('interface_service_vni', 'shutdown')
|
130
|
+
end
|
131
|
+
end # Class
|
132
|
+
end # Module
|