-
Notifications
You must be signed in to change notification settings - Fork 50
Feature/pc #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature/pc #150
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9b49d10
interface_port_channel and portchannel_global addition
8966e1f
Update CHANGELOG.md
fdba9f3
Update CHANGELOG.md
fb1c5af
pull req comments
0f7c84c
pull req comments
b8c2ead
Merge branch 'feature/pc' of https://github.com/saichint/cisco-networ…
bdb3ce4
review comment
fffa805
conflict cleaned
7478ab9
removed optional space from hash distribution
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # interface_portchannel | ||
| --- | ||
| _template: | ||
| config_set: ["interface %s"] | ||
| config_get_token: '/^interface %s$/i' | ||
| config_get: "show running interface all" | ||
|
|
||
| create: | ||
| config_set: "interface %s" | ||
|
|
||
| destroy: | ||
| config_set: "no interface %s" | ||
|
|
||
| lacp_graceful_convergence: | ||
| kind: boolean | ||
| auto_default: false | ||
| config_get_token_append: ['/^lacp graceful.convergence$/'] | ||
| config_set_append: ["%s lacp graceful-convergence"] | ||
| default_value: true | ||
|
|
||
| lacp_max_bundle: | ||
| kind: int | ||
| config_get_token_append: ['/^lacp max.bundle (\d+)$/'] | ||
| config_set_append: ["lacp max-bundle %s"] | ||
| /N(3|9)/: | ||
| default_value: 32 | ||
| else: | ||
| default_value: 16 | ||
|
|
||
| lacp_min_links: | ||
| kind: int | ||
| config_get_token_append: ['/^lacp min.links (\d+)$/'] | ||
| config_set_append: ["lacp min-links %s"] | ||
| default_value: 1 | ||
|
|
||
| lacp_suspend_individual: | ||
| kind: boolean | ||
| auto_default: false | ||
| config_get_token_append: ['/^lacp suspend.individual$/'] | ||
| config_set_append: ["%s lacp suspend-individual"] | ||
| default_value: true | ||
|
|
||
| port_hash_distribution: | ||
| _exclude: [/N6/, /N5/] | ||
| config_get_token_append: ['/^port-channel port hash.distribution (.*)$/'] | ||
| config_set: ["terminal dont-ask", "interface %s", "%s port-channel port hash-distribution %s", "end"] | ||
| default_value: false | ||
|
|
||
| port_load_defer: | ||
| _exclude: [/N6/, /N5/] | ||
| kind: boolean | ||
| config_get_token_append: ['/^port-channel port load.defer$/'] | ||
| config_set_append: ["%s port-channel port load-defer"] | ||
| default_value: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # portchannel_global | ||
| --- | ||
| _template: | ||
| config_get: "show running all" | ||
|
|
||
| asymmetric: | ||
| _exclude: [/N6/, /N5/, /N3/, /N9/] | ||
| default_value: false | ||
|
|
||
| bundle_hash: | ||
| /N(5|6|7)/: | ||
| default_value: 'ip' | ||
| /N(3|9)/: | ||
| default_value: 'ip-l4port' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, remove the ditto for the rest of this file |
||
|
|
||
| bundle_select: | ||
| default_value: 'src-dst' | ||
|
|
||
| concatenation: | ||
| _exclude: [/N7/, /N5/, /N6/] | ||
| default_value: false | ||
|
|
||
| hash_distribution: | ||
| _exclude: [/N6/, /N5/, /N3/, /N9/] | ||
| config_get_token: ['/^port.channel hash.distribution (.*)$/'] | ||
| config_set: ["terminal dont-ask", "port-channel hash-distribution %s", "end"] | ||
| default_value: 'adaptive' | ||
|
|
||
| hash_poly: | ||
| _exclude: [/N7/, /N3/, /N9/] | ||
| default_value: 'CRC10b' | ||
|
|
||
| load_balance_type: | ||
| kind: string | ||
| /N(5|6)/: | ||
| default_only: "ethernet" | ||
| /N7/: | ||
| default_only: "asymmetric" | ||
| /N(3|9)/: | ||
| default_only: "symmetry" | ||
|
|
||
| load_defer: | ||
| _exclude: [/N6/, /N5/, /N3/, /N9/] | ||
| kind: int | ||
| config_get_token: ['/^port.channel load.defer (\d+)$/'] | ||
| config_set: ["port-channel load-defer %s"] | ||
| default_value: 120 | ||
|
|
||
| port_channel_load_balance: | ||
| multiple: | ||
| config_get_token: '/^port-channel load-balance (.*)$/' | ||
| config_set: "port-channel load-balance %s %s %s %s %s %s" | ||
|
|
||
| resilient: | ||
| _exclude: [/N6/, /N5/, /N7/] | ||
| kind: boolean | ||
| config_get: "show running-config all" | ||
| config_get_token: '/^port-channel load-balance resilient$/' | ||
| config_set: "%s port-channel load-balance resilient" | ||
| default_value: false | ||
|
|
||
| rotate: | ||
| _exclude: [/N5/, /N6/] | ||
| kind: int | ||
| default_value: 0 | ||
|
|
||
| symmetry: | ||
| _exclude: [/N7/, /N3/, /N5/, /N6/] | ||
| default_value: false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| # December 2015, Sai Chintalapudi | ||
| # | ||
| # Copyright (c) 2015 Cisco and/or its affiliates. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| require_relative 'node_util' | ||
| require_relative 'interface' | ||
|
|
||
| # Add some interface-specific constants to the Cisco namespace | ||
| module Cisco | ||
| # InterfacePortChannel - node utility class for port channel config management | ||
| class InterfacePortChannel < NodeUtil | ||
| attr_reader :name | ||
|
|
||
| def initialize(name, instantiate=true) | ||
| fail TypeError unless name.is_a?(String) | ||
| fail ArgumentError unless name.length > 0 | ||
| @name = name.downcase | ||
| fail ArgumentError unless @name.start_with?('port-channel') | ||
|
|
||
| create if instantiate | ||
| end | ||
|
|
||
| def self.interfaces | ||
| hash = {} | ||
| intf_list = config_get('interface', 'all_interfaces') | ||
| return hash if intf_list.nil? | ||
|
|
||
| intf_list.each do |id| | ||
| id = id.downcase | ||
| next unless id.start_with?('port-channel') | ||
| hash[id] = InterfacePortChannel.new(id, false) | ||
| end | ||
| hash | ||
| end | ||
|
|
||
| def create | ||
| config_set('interface_portchannel', 'create', @name) | ||
| end | ||
|
|
||
| def destroy | ||
| config_set('interface_portchannel', 'destroy', @name) | ||
| end | ||
|
|
||
| ######################################################## | ||
| # PROPERTIES # | ||
| ######################################################## | ||
|
|
||
| def lacp_graceful_convergence | ||
| config_get('interface_portchannel', 'lacp_graceful_convergence', @name) | ||
| end | ||
|
|
||
| def lacp_graceful_convergence=(state) | ||
| no_cmd = (state ? '' : 'no') | ||
| config_set('interface_portchannel', | ||
| 'lacp_graceful_convergence', @name, no_cmd) | ||
| rescue Cisco::CliError => e | ||
| raise "[#{@name}] '#{e.command}' : #{e.clierror}" | ||
| end | ||
|
|
||
| def default_lacp_graceful_convergence | ||
| config_get_default('interface_portchannel', 'lacp_graceful_convergence') | ||
| end | ||
|
|
||
| def lacp_max_bundle | ||
| config_get('interface_portchannel', 'lacp_max_bundle', @name) | ||
| end | ||
|
|
||
| def lacp_max_bundle=(val) | ||
| config_set('interface_portchannel', 'lacp_max_bundle', @name, val) | ||
| rescue Cisco::CliError => e | ||
| raise "[#{@name}] '#{e.command}' : #{e.clierror}" | ||
| end | ||
|
|
||
| def default_lacp_max_bundle | ||
| config_get_default('interface_portchannel', 'lacp_max_bundle') | ||
| end | ||
|
|
||
| def lacp_min_links | ||
| config_get('interface_portchannel', 'lacp_min_links', @name) | ||
| end | ||
|
|
||
| def lacp_min_links=(val) | ||
| config_set('interface_portchannel', 'lacp_min_links', @name, val) | ||
| rescue Cisco::CliError => e | ||
| raise "[#{@name}] '#{e.command}' : #{e.clierror}" | ||
| end | ||
|
|
||
| def default_lacp_min_links | ||
| config_get_default('interface_portchannel', 'lacp_min_links') | ||
| end | ||
|
|
||
| def lacp_suspend_individual | ||
| config_get('interface_portchannel', 'lacp_suspend_individual', @name) | ||
| end | ||
|
|
||
| def lacp_suspend_individual=(state) | ||
| no_cmd = (state ? '' : 'no') | ||
| config_set('interface_portchannel', | ||
| 'lacp_suspend_individual', @name, no_cmd) | ||
| rescue Cisco::CliError => e | ||
| raise "[#{@name}] '#{e.command}' : #{e.clierror}" | ||
| end | ||
|
|
||
| def default_lacp_suspend_individual | ||
| config_get_default('interface_portchannel', 'lacp_suspend_individual') | ||
| end | ||
|
|
||
| def port_hash_distribution | ||
| config_get('interface_portchannel', 'port_hash_distribution', @name) | ||
| end | ||
|
|
||
| def port_hash_distribution=(val) | ||
| if val | ||
| state = '' | ||
| else | ||
| state = 'no' | ||
| val = '' | ||
| end | ||
| config_set('interface_portchannel', | ||
| 'port_hash_distribution', @name, state, val) | ||
| rescue Cisco::CliError => e | ||
| raise "[#{@name}] '#{e.command}' : #{e.clierror}" | ||
| end | ||
|
|
||
| def default_port_hash_distribution | ||
| config_get_default('interface_portchannel', 'port_hash_distribution') | ||
| end | ||
|
|
||
| def port_load_defer | ||
| config_get('interface_portchannel', 'port_load_defer', @name) | ||
| end | ||
|
|
||
| def port_load_defer=(state) | ||
| no_cmd = (state ? '' : 'no') | ||
| config_set('interface_portchannel', | ||
| 'port_load_defer', @name, no_cmd) | ||
| rescue Cisco::CliError => e | ||
| raise "[#{@name}] '#{e.command}' : #{e.clierror}" | ||
| end | ||
|
|
||
| def default_port_load_defer | ||
| config_get_default('interface_portchannel', 'port_load_defer') | ||
| end | ||
| end # Class | ||
| end # Module |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be consistent on these names - please choose
port_channelorportchannel.