-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[bgp]: Update TSA functionality #5906
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
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b78fc66
Fix protocol for ipv6 TSA route-map
pavel-shirshov d062c61
Skip route-maps, which doesn't have V4, or V6 in their names
pavel-shirshov 544f1ea
Add total_portstat.py which will output total traffic thoough the dev…
pavel-shirshov a601c93
Fix the test
39ba9c9
Move the file to the correct place
pavel-shirshov 82fcc12
Revert "Move the file to the correct place"
pavel-shirshov f58df62
Revert "Add total_portstat.py which will output total traffic thoough…
pavel-shirshov 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
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
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| route-map {{ route_map_name }} permit 2 | ||
| match ip address prefix-list PL_Loopback{{ ip_version }} | ||
| match {{ ip_protocol }} address prefix-list PL_Loopback{{ ip_version }} | ||
| set community {{ constants.bgp.traffic_shift_community }} | ||
| route-map {{ route_map_name }} deny 3 | ||
| ! |
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,62 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| from __future__ import print_function | ||
| import json | ||
| import argparse | ||
|
|
||
|
|
||
| def get_filename(): | ||
| """ Read the name of the file from the command line """ | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument('filename') | ||
| args = parser.parse_args() | ||
| return args.filename | ||
|
|
||
| def get_json(filename): | ||
| """ Open the file and parse json from it """ | ||
| js = '' | ||
| json_started = False | ||
| with open(filename) as fp: | ||
| for line in fp: | ||
| s_line = line.strip() | ||
| if s_line == '{': | ||
| json_started = True | ||
| if json_started: | ||
| js += s_line | ||
| data = json.loads(js) | ||
| return data | ||
|
|
||
| def convert_to_raw(value): | ||
| """ | ||
| Convert from a value from suffix to raw value | ||
| Example: | ||
| '1 KB/s' -> 10240.0 | ||
| """ | ||
| conversion = { | ||
| ' MB/s': 1024*1024*10, | ||
| ' KB/s': 1024*10, | ||
| ' B/s' : 1, | ||
| } | ||
| for suffix, multiplier in conversion.items(): | ||
| if value.endswith(suffix): | ||
| no_suffix_value = value.replace(suffix, '') | ||
| float_value = float(no_suffix_value) | ||
| return float_value * multiplier | ||
| raise RuntimeError("Can't convert value '%s'" % value) | ||
|
|
||
| def main(): | ||
| """ | ||
| Main function. Read the data and output result | ||
| """ | ||
| filename = get_filename() | ||
| data = get_json(filename) | ||
| rx_bps_total = 0.0 | ||
| tx_bps_total = 0.0 | ||
| for _, obj in data.items(): | ||
| rx_bps_total += convert_to_raw(obj['RX_BPS']) | ||
| tx_bps_total += convert_to_raw(obj['TX_BPS']) | ||
| print("Total RX = %d b/s" % int(rx_bps_total)) | ||
| print("Total TX = %d b/s" % int(tx_bps_total)) | ||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
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 |
|---|---|---|
|
|
@@ -5,5 +5,6 @@ | |
| } | ||
| }, | ||
| "route_map_name": "test_rm_name", | ||
| "ip_version": "V4" | ||
| "ip_version": "V4", | ||
| "ip_protocol": "ip" | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.