Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SAI-PTF] Enhance the function for getting counters in sai_adapter.py (…
…opencomputeproject#1626) * [SAI-PTF] Enhance the function for getting counters in sai_adapter.py Resolve issue opencomputeproject#1614 For the auto-generated adapter, need to add a parameter for which counter_id/counter_ids we want, in order to compatiable with current code and reduce the modification, we can define a constant parameter as the list of counter_ids, and use this constant as the default. Before ``` def sai_thrift_get_bfd_session_stats(client, bfd_session_oid): counter_ids = [] counter_ids.append(SAI_BFD_SESSION_STAT_IN_PACKETS) counter_ids.append(SAI_BFD_SESSION_STAT_OUT_PACKETS) counter_ids.append(SAI_BFD_SESSION_STAT_DROP_PACKETS) counters = [0] * 3 global status status = SAI_STATUS_SUCCESS ``` After the refactor ``` sai_get_bfd_session_stats_counter_ids = [] sai_get_bfd_session_stats_counter_ids.append(SAI_BFD_SESSION_STAT_IN_PACKETS) sai_get_bfd_session_stats_counter_ids.append(SAI_BFD_SESSION_STAT_OUT_PACKETS) sai_get_bfd_session_stats_counter_ids.append(SAI_BFD_SESSION_STAT_DROP_PACKETS) def sai_thrift_get_bfd_session_stats(client, bfd_session_oid, counter_ids=sai_get_bfd_session_stats_counter_ids): counters = [0] * 3 global status status = SAI_STATUS_SUCCESS ``` Signed-off-by: richardyu-ms <richard.yu@microsoft.com> * make some enhancement on the code, add dict which can get the enum name by id Signed-off-by: richardyu-ms <richard.yu@microsoft.com> Signed-off-by: richardyu-ms <richard.yu@microsoft.com> Co-authored-by: richardyu <richardyu@contoso.com>
- Loading branch information