From bafaaed7ccb5621b9a009b52f58364f8fbcb0178 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Mon, 27 Jan 2020 09:00:59 -0800 Subject: [PATCH] [dropconfig] Move prefix-handling from CLI to orchagent (#785) - Remove prefix-trimming from drop reason capability query - Remove prefix-trimming from create/add safety checks Signed-off-by: Danny Allen --- scripts/dropconfig | 16 +--------------- sonic-utilities-tests/mock_tables/state_db.json | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/scripts/dropconfig b/scripts/dropconfig index ebb43e339e5a..c9bbd3441872 100755 --- a/scripts/dropconfig +++ b/scripts/dropconfig @@ -44,10 +44,6 @@ drop_counter_config_header = ['Counter', 'Description'] drop_counter_capability_header = ['Counter Type', 'Total'] -# Drop Reason Prefixes -in_drop_reason_prefix = 'SAI_IN_DROP_REASON_' -out_drop_reason_prefix = 'SAI_OUT_DROP_REASON_' - class InvalidArgumentError(RuntimeError): def __init__(self, msg): @@ -107,10 +103,6 @@ class DropConfig(object): if supported_reasons and int(capabilities.get('count', 0)) > 0: print('\n{}'.format(counter)) for reason in supported_reasons: - if reason.startswith(in_drop_reason_prefix): - reason = reason[len(in_drop_reason_prefix):] - elif reason.startswith(out_drop_reason_prefix): - reason = reason[len(out_drop_reason_prefix):] print('\t{}'.format(reason)) def create_counter(self, counter_name, alias, group, counter_type, @@ -314,13 +306,7 @@ class DropConfig(object): if not cap_query: return None - reasons = [] - for reason in deserialize_reason_list(cap_query.get('reasons', '')): - if reason.startswith(in_drop_reason_prefix): - reasons.append(reason[len(in_drop_reason_prefix):]) - elif reason.startswith(out_drop_reason_prefix): - reasons.append(reason[len(out_drop_reason_prefix):]) - return reasons + return deserialize_reason_list(cap_query.get('reasons', '')) def deserialize_reason_list(list_str): diff --git a/sonic-utilities-tests/mock_tables/state_db.json b/sonic-utilities-tests/mock_tables/state_db.json index f3fdf3ec248d..14f60801a746 100644 --- a/sonic-utilities-tests/mock_tables/state_db.json +++ b/sonic-utilities-tests/mock_tables/state_db.json @@ -67,11 +67,11 @@ "ACL_ACTION|PACKET_ACTION": "FORWARD" }, "DEBUG_COUNTER_CAPABILITIES|PORT_INGRESS_DROPS": { - "reasons": "[SAI_IN_DROP_REASON_IP_HEADER_ERROR,SAI_IN_DROP_REASON_NO_L3_HEADER]", + "reasons": "[IP_HEADER_ERROR,NO_L3_HEADER]", "count": "4" }, "DEBUG_COUNTER_CAPABILITIES|SWITCH_EGRESS_DROPS": { - "reasons": "[SAI_IN_DROP_REASON_ACL_ANY,SAI_IN_DROP_REASON_L2_ANY,SAI_IN_DROP_REASON_L3_ANY]", + "reasons": "[ACL_ANY,L2_ANY,L3_ANY]", "count": "2" } }