Skip to content
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

PBH CLI #3

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
559d210
Fixed codestyle
vadymhlushko-mlnx Jun 1, 2021
e20b2d0
Removed YANG validation from 'config'
vadymhlushko-mlnx Jun 2, 2021
0e44abe
Generated from updated YANG model show CLI for PBH & fixed codestyle
vadymhlushko-mlnx Jun 7, 2021
c5fe537
Added generated config CLI for PBH
vadymhlushko-mlnx Jun 7, 2021
77754cf
Fixed codestyle for config
vadymhlushko-mlnx Jun 7, 2021
2d0167f
Added 'pbh' subcommand & removed 'hash-field-list' subcommand
vadymhlushko-mlnx Jun 7, 2021
5a6ea76
Removed leaf-lists CLI commands, added example of validation click op…
vadymhlushko-mlnx Jun 8, 2021
f94e0f0
Added new data enums from YANG model
vadymhlushko-mlnx Jun 8, 2021
8dd0e7b
Added show pbh ...
vadymhlushko-mlnx Jun 8, 2021
3261502
Added sceleton for PBH UT
vadymhlushko-mlnx Jun 8, 2021
bb0a710
Fixed show pbh table output
vadymhlushko-mlnx Jun 8, 2021
6a0c248
Added 'Symmetric' field to the 'show pbh hash-field' command
vadymhlushko-mlnx Jun 8, 2021
0e20bc0
Fixed 'show pbh hash' output
vadymhlushko-mlnx Jun 8, 2021
466862d
Fixed 'show pbh rule' output
vadymhlushko-mlnx Jun 8, 2021
07000a6
Fixed codestyle for show CLI plugin
vadymhlushko-mlnx Jun 8, 2021
0305909
Added 'show pbh statistics'
vadymhlushko-mlnx Jun 10, 2021
68b07b2
Added 'flow counter' column to 'show pbh rule'
vadymhlushko-mlnx Jun 10, 2021
186ae9b
Added sort, changed symmetric check, removed unused check
vadymhlushko-mlnx Jun 10, 2021
9f2b52f
Added validation for --hash-field-list, --ip-mask
vadymhlushko-mlnx Jun 10, 2021
b2b5472
Added is_exist_in_db()
vadymhlushko-mlnx Jun 10, 2021
4dca122
Added is_match, interface_validator
vadymhlushko-mlnx Jun 11, 2021
e232188
Fixed codestyle
vadymhlushko-mlnx Jun 11, 2021
eff1729
HOT FIX
vadymhlushko-mlnx Jun 11, 2021
096602e
Fixed issue with click callbacks
vadymhlushko-mlnx Jun 13, 2021
be744a0
Fixed sort output for show CLI, typo fixes
vadymhlushko-mlnx Jun 14, 2021
3739757
Added few 'hash-field' tests
vadymhlushko-mlnx Jun 14, 2021
4d005d8
Fixed issue with 'config pbh rule update'
vadymhlushko-mlnx Jun 14, 2021
cf971b5
HOTFIX for 'config pbh rule update' is_exist_in_db()
vadymhlushko-mlnx Jun 14, 2021
e864d12
Added proper description for --ip-mask
vadymhlushko-mlnx Jun 15, 2021
3050212
Added ip_mask & hash-field validation for ADD flow
vadymhlushko-mlnx Jun 15, 2021
d97465f
Added tests for 'config pbh hash-field add' flow
vadymhlushko-mlnx Jun 15, 2021
8ae9fbf
Fixed 'hash-field' add/update, added UT
vadymhlushko-mlnx Jun 16, 2021
1648760
Added hash UT, used DB migrator
vadymhlushko-mlnx Jun 17, 2021
b0c603e
Added UT for 'pbh table', added UT for 'pbh hash' need to add update …
vadymhlushko-mlnx Jun 18, 2021
d547544
Added UT for 'pbh hash update'
vadymhlushko-mlnx Jun 18, 2021
b2e8c3f
Added UT for 'pbh rule'
vadymhlushko-mlnx Jun 18, 2021
299f64d
Fixed name of the colums for show, added update UT for pbh table, fix…
vadymhlushko-mlnx Jun 22, 2021
c3c802d
Added UT for show, fixed codestyle and errors
vadymhlushko-mlnx Jun 23, 2021
b8b06f2
Added UT for 'show pbh statistics'
vadymhlushko-mlnx Jun 23, 2021
cb04ffa
Fixed empty lines in 'show pbh statistics'
vadymhlushko-mlnx Jun 23, 2021
fdb0f6e
Added descending sort by Priority for 'show pbh rule'
vadymhlushko-mlnx Jun 23, 2021
9ecfd8f
Reworked ip_mask_hash_field_correspondence()
vadymhlushko-mlnx Jun 24, 2021
7dd8a29
Reworked pbh_re_match()
vadymhlushko-mlnx Jun 24, 2021
c8ae867
Corrected row names for 'show pbh statistics'
vadymhlushko-mlnx Jun 24, 2021
cf1d1fc
Fixed codestyle
vadymhlushko-mlnx Jun 24, 2021
a1488c0
Added function description
vadymhlushko-mlnx Jun 24, 2021
cfd04d0
Added function description
vadymhlushko-mlnx Jun 24, 2021
eeb6052
Changed name of CLI plugins
vadymhlushko-mlnx Jun 24, 2021
7a69c88
Added left alignment for numbers in show CLI group
vadymhlushko-mlnx Jun 25, 2021
f448353
Fixed LGTM errors
vadymhlushko-mlnx Jun 29, 2021
071c01c
New version for 'show pbh statistics', UT passed
vadymhlushko-mlnx Jun 29, 2021
010cf67
Added 'sonic-clear pbh'
vadymhlushko-mlnx Jun 30, 2021
3733f0b
Added UT for 'show pbh statistics' & 'sonic-clear pbh'
vadymhlushko-mlnx Jun 30, 2021
af3f25e
Codestyle improvement
vadymhlushko-mlnx Jun 30, 2021
3d3d18f
fixed LGTM warnings
vadymhlushko-mlnx Jun 30, 2021
a03c002
Added unified format for exit_with_error()
vadymhlushko-mlnx Jul 2, 2021
008eec3
Added exception handling for 'clear' subcommand
vadymhlushko-mlnx Jul 12, 2021
56bb517
Unified click error msg format
vadymhlushko-mlnx Jul 12, 2021
c0e423a
Fixed teardown for pbh_test.py
vadymhlushko-mlnx Jul 13, 2021
f51982e
Fixed LGTM error
vadymhlushko-mlnx Jul 13, 2021
fad30a7
Rework of ip_mask_hash_field_correspondence()
vadymhlushko-mlnx Jul 13, 2021
6682add
Fixed functions name
vadymhlushko-mlnx Jul 13, 2021
6bb079a
Codestyle
vadymhlushko-mlnx Jul 13, 2021
fd930ec
Added defines for config module
vadymhlushko-mlnx Jul 13, 2021
01c3cca
Added cleanup of mocked db in UT
vadymhlushko-mlnx Jul 13, 2021
c22ce2a
Codestyle and other improvement
vadymhlushko-mlnx Jul 14, 2021
048774a
improvements for show plugin
vadymhlushko-mlnx Jul 14, 2021
88992c6
Fix for regexp & added --ether-type -> need to fix UT
vadymhlushko-mlnx Jul 14, 2021
b2bad71
Fixed value for pbh regexp in UT
vadymhlushko-mlnx Jul 14, 2021
c227a73
Fixed mock db & UT for show cli
vadymhlushko-mlnx Jul 14, 2021
e7970a8
Rework of inject_symmetric_field()
vadymhlushko-mlnx Jul 14, 2021
7f208b2
Added check for --flow-counter when displaing pbh statistics
vadymhlushko-mlnx Jul 15, 2021
dd35eec
Added new UT for pbh statistics
vadymhlushko-mlnx Jul 15, 2021
438cea6
Added check for read pbh counters
vadymhlushko-mlnx Jul 15, 2021
ef680de
Reworked sonic-clear cli group for pbh
vadymhlushko-mlnx Jul 15, 2021
9471b11
Fixed help messages for config cli according to the new YANG model
vadymhlushko-mlnx Jul 15, 2021
0d28690
[pbh]: Add CLI UM.
nazariig Jul 5, 2021
a4709f8
Reworked clear after of mocked DB for UT, codestyle, changes some UT …
vadymhlushko-mlnx Jul 15, 2021
a6fae69
Added PBH CLI user manual
vadymhlushko-mlnx Jul 16, 2021
6a19368
Fixed description
vadymhlushko-mlnx Jul 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import os
import subprocess
import sys

import click
import utilities_common.cli as clicommon
import json

from utilities_common import util_base

from show.plugins.pbh import read_pbh_counters
from . import plugins


Expand Down Expand Up @@ -450,6 +451,30 @@ def translations():
run_command(cmd)


def remap_keys(dict):
return [{'key': k, 'value': v} for k, v in dict.items()]


#
# 'pbh' subcommand
#
@cli.command()
@clicommon.pass_db
def pbh(db):
""" Clear PBH counters
clear counters -- write current counters to file in /tmp
"""

pbh_rules = db.cfgdb.get_table("PBH_RULE")
pbh_counters = read_pbh_counters(pbh_rules)

try:
with open('/tmp/.pbh_counters.txt', 'w') as fp:
json.dump(remap_keys(pbh_counters), fp)
except IOError as err:
pass


# Load plugins and register them
helper = util_base.UtilHelper()
for plugin in helper.load_plugins(plugins):
Expand Down
Loading