diff --git a/meta/templates/sai_adapter.py.tt b/meta/templates/sai_adapter.py.tt index 49121065d..b2d7b24d8 100644 --- a/meta/templates/sai_adapter.py.tt +++ b/meta/templates/sai_adapter.py.tt @@ -93,6 +93,15 @@ def [% function.thrift_name %](client [%- FOREACH attr IN apis.$api.objects.${function.object}.attrs.${function.operation} -%] ,[% br %][% attr.simple_name %]=None [%- END -%] + [%- IF function.operation == 'stats' OR function.operation == 'clear' -%] + [%- FOREACH arg IN function.adapter_preprocessed_args -%] + [%- IF arg.is_list and arg.name == 'counter_ids' -%] +,[% br %][% arg.name %]=[% function.name %]_[% arg.name %] + [%- ELSIF arg.is_attr %] + [% arg.name %] = None + [%- END -%] + [%- END -%] + [%- END -%] ): [% END -%] @@ -102,15 +111,31 @@ def [% function.thrift_name %](client [%- # Declare variables that are not part of python interface -%] [%- # but are required by thritft functions -%] [%- FOREACH arg IN function.adapter_preprocessed_args -%] - - [%- IF arg.is_list %] - [% arg.name %] = [] + [%- IF arg.is_list AND arg.name!= 'counter_ids' %] + [% function.name %]_[% arg.name %] = [] [%- ELSIF arg.is_attr %] [% arg.name %] = None [%- END -%] [%- END -%] [%- END -%] +[%- BLOCK declare_stats_variables -%] + [%- IF function.operation == 'stats' OR function.operation == 'clear' %] + [%- FOREACH arg IN function.adapter_preprocessed_args -%] + + [%- IF arg.is_list %] +[% function.name %]_[% arg.name %] = [] + [%- ELSIF arg.is_attr %] + [% arg.name %] = None + [%- END -%] + [%- END -%] + [%- FOREACH stat IN apis.$api.objects.${function.object}.stats.all %] +[% function.name %]_[% arg.name %].append([% stat.name %]) + [%- END -%] + + [%- END -%] +[%- END -%] + [%- ######################################################################## -%] [%- ######################################################################## -%] @@ -279,8 +304,10 @@ client.[% function.thrift_name %]( [%- BLOCK preprocess_stats -%] - [%- FOREACH stat IN apis.$api.objects.${function.object}.stats.all %] - [% arg.name %].append([% stat.name %]) + [%- IF arg.name != "counter_ids" -%] + [%- FOREACH stat IN apis.$api.objects.${function.object}.stats.all %] + [% function.name %]_[% arg.name %].append([% stat.name %]) + [%- END -%] [%- END -%] [%- END -%] @@ -308,13 +335,11 @@ client.[% function.thrift_name %]( [%- # Basically we do it for each list variable, we assume we have one -%] [%- FOREACH arg IN function.adapter_preprocessed_args -%] [%- IF function.operation == 'stats' OR function.operation == 'clear' %] - [%- # For 'get stats' function create stats list -%] + [%- # For 'get stats' function NOT create stats list in function body -%] [%- PROCESS preprocess_stats %] - [%- ELSIF function.operation != 'remove' %] [%- # For 'create' and 'get' functions create list of arguments -%] [%- PROCESS preprocess_attributes %] - [%- END -%] [%- END -%] @@ -400,6 +425,9 @@ client.[% function.thrift_name %]( [%- ######################################################################## -%] [%- BLOCK function_body -%] + [%- PROCESS declare_stats_variables -%] + + [%- PROCESS decorate_method IF dev_utils -%] [%- PROCESS decorate_skip_test_on_error IF skip_error -%] [%- PROCESS function_header %] @@ -407,7 +435,6 @@ client.[% function.thrift_name %]( [%- IF has_body -%] [%- PROCESS declare_variables %] - [%- PROCESS preprocess_args -%] [%- # Now, call the thrift function -%]