1
1
import datetime
2
-
3
2
from xcvrd .xcvrd_utilities .xcvrd_utils import XCVRDUtils
4
3
from xcvrd .xcvrd_utilities .xcvr_table_helper import VDM_THRESHOLD_TYPES
5
- from xcvrd .dom .dom_utilities .common_db_utils import DBUtils
6
- from xcvrd .dom .dom_utilities .vdm_utils import VDMUtils
7
-
4
+ from xcvrd .dom .dom_utilities .db_utilities .common_db_utils import DBUtils
5
+ from xcvrd .dom .dom_utilities .vdm_utilities .vdm_utils import VDMUtils
8
6
from swsscommon import swsscommon
9
7
10
- class VDMDBUtils :
8
+ class VDMDBUtils ( DBUtils ) :
11
9
"""
12
10
This class provides utility functions for managing
13
11
DB operations related to VDM on transceivers.
14
12
"""
15
13
def __init__ (self , sfp_obj_dict , port_mapping , xcvr_table_helper , task_stopping_event , helper_logger ):
14
+ super ().__init__ (helper_logger )
16
15
self .sfp_obj_dict = sfp_obj_dict
17
16
self .port_mapping = port_mapping
18
17
self .task_stopping_event = task_stopping_event
19
18
self .xcvr_table_helper = xcvr_table_helper
20
19
self .xcvrd_utils = XCVRDUtils (sfp_obj_dict , helper_logger )
21
20
self .vdm_utils = VDMUtils (sfp_obj_dict , helper_logger )
22
- self .db_utils = DBUtils (helper_logger )
23
21
self .helper_logger = helper_logger
24
22
25
23
def post_port_diagnostic_values_to_db (self , logical_port_name , table , get_values_func , db_cache = None ):
@@ -29,13 +27,13 @@ def post_port_diagnostic_values_to_db(self, logical_port_name, table, get_values
29
27
pport_list = self .port_mapping .get_logical_to_physical (logical_port_name )
30
28
if not pport_list :
31
29
self .helper_logger .log_error (f"Post port diagnostic values to db failed for { logical_port_name } "
32
- "as no physical port found" )
30
+ "as no physical port found" )
33
31
return
34
32
physical_port = pport_list [0 ]
35
33
36
34
if physical_port not in self .sfp_obj_dict :
37
35
self .helper_logger .log_error (f"Post port diagnostic values to db failed for { logical_port_name } "
38
- "as no sfp object found" )
36
+ "as no sfp object found" )
39
37
return
40
38
41
39
if not self .xcvrd_utils .get_transceiver_presence (physical_port ):
@@ -53,7 +51,7 @@ def post_port_diagnostic_values_to_db(self, logical_port_name, table, get_values
53
51
if diagnostic_values_dict is not None :
54
52
if not diagnostic_values_dict :
55
53
return
56
- self .db_utils . beautify_info_dict (diagnostic_values_dict )
54
+ self .beautify_info_dict (diagnostic_values_dict )
57
55
fvs = swsscommon .FieldValuePairs ([(k , v ) for k , v in diagnostic_values_dict .items ()])
58
56
table .set (logical_port_name , fvs )
59
57
else :
@@ -120,13 +118,13 @@ def _post_port_vdm_thresholds_or_flags_to_db(self, logical_port_name, get_vdm_ta
120
118
# for the flags
121
119
if flag_data :
122
120
asic_id = self .port_mapping .get_asic_id_for_logical_port (logical_port_name )
123
- self .db_utils . update_flag_metadata_tables (logical_port_name , new_key , value ,
124
- vdm_values_dict_update_time ,
125
- self .xcvr_table_helper .get_vdm_flag_tbl (asic_id , threshold_type ),
126
- self .xcvr_table_helper .get_vdm_flag_change_count_tbl (asic_id , threshold_type ),
127
- self .xcvr_table_helper .get_vdm_flag_set_time_tbl (asic_id , threshold_type ),
128
- self .xcvr_table_helper .get_vdm_flag_clear_time_tbl (asic_id , threshold_type ),
129
- f"VDM { threshold_type } " )
121
+ self .update_flag_metadata_tables (logical_port_name , new_key , value ,
122
+ vdm_values_dict_update_time ,
123
+ self .xcvr_table_helper .get_vdm_flag_tbl (asic_id , threshold_type ),
124
+ self .xcvr_table_helper .get_vdm_flag_change_count_tbl (asic_id , threshold_type ),
125
+ self .xcvr_table_helper .get_vdm_flag_set_time_tbl (asic_id , threshold_type ),
126
+ self .xcvr_table_helper .get_vdm_flag_clear_time_tbl (asic_id , threshold_type ),
127
+ f"VDM { threshold_type } " )
130
128
131
129
if db_cache is not None :
132
130
# If cache is enabled, put vdm values to cache
@@ -136,7 +134,7 @@ def _post_port_vdm_thresholds_or_flags_to_db(self, logical_port_name, get_vdm_ta
136
134
137
135
for threshold_type , threshold_value_dict in vdm_threshold_type_value_dict .items ():
138
136
if threshold_value_dict :
139
- self .db_utils . beautify_info_dict (threshold_value_dict )
137
+ self .beautify_info_dict (threshold_value_dict )
140
138
fvs = swsscommon .FieldValuePairs ([(k , v ) for k , v in threshold_value_dict .items ()])
141
139
table = get_vdm_table_func (self .port_mapping .get_asic_id_for_logical_port (logical_port_name ), threshold_type )
142
140
table .set (logical_port_name , fvs )
0 commit comments