|
25 | 25 | Y_CABLE_ACTIVE_TOR_INDICATOR = 645 |
26 | 26 | Y_CABLE_MANUAL_SWITCH_COUNT = 669 |
27 | 27 |
|
| 28 | +SYSLOG_IDENTIFIER = "sonic_y_cable" |
| 29 | + |
28 | 30 | # Global logger instance for helper functions and classes to log |
29 | 31 | helper_logger = logger.Logger(SYSLOG_IDENTIFIER) |
30 | 32 |
|
@@ -145,15 +147,15 @@ def check_read_side(physical_port): |
145 | 147 | helper_logger.log_error("platform_chassis is not loaded, failed to check read side") |
146 | 148 | return -1 |
147 | 149 |
|
148 | | - regval_read = struct.unpack(">i", result) |
| 150 | + regval_read = struct.unpack(">B", result) |
149 | 151 |
|
150 | | - if ((regval_read >> 2) & 0x01): |
| 152 | + if ((regval_read[0] >> 2) & 0x01): |
151 | 153 | helper_logger.log_info("Reading from TOR A") |
152 | 154 | return 1 |
153 | | - elif ((regval_read >> 1) & 0x01): |
| 155 | + elif ((regval_read[0] >> 1) & 0x01): |
154 | 156 | helper_logger.log_info("Reading from TOR B") |
155 | 157 | return 2 |
156 | | - elif (regval_read & 0x01): |
| 158 | + elif (regval_read[0] & 0x01): |
157 | 159 | helper_logger.log_info("Reading from NIC side") |
158 | 160 | return 0 |
159 | 161 | else: |
@@ -196,15 +198,15 @@ def check_active_linked_tor_side(physical_port): |
196 | 198 | helper_logger.log_error("platform_chassis is not loaded, failed to check Active Linked and routing TOR side") |
197 | 199 | return -1 |
198 | 200 |
|
199 | | - regval_read = struct.unpack(">i", result) |
| 201 | + regval_read = struct.unpack(">B", result) |
200 | 202 |
|
201 | | - if ((regval_read >> 1) & 0x01): |
| 203 | + if ((regval_read[0] >> 1) & 0x01): |
202 | 204 | helper_logger.log_info("TOR B active linked and actively routing") |
203 | 205 | return 2 |
204 | | - elif ((regval_read) & 0x01): |
| 206 | + elif ((regval_read[0]) & 0x01): |
205 | 207 | helper_logger.log_info("TOR A standby linked and actively routing") |
206 | 208 | return 1 |
207 | | - elif regval_read == 0: |
| 209 | + elif regval_read[0] == 0: |
208 | 210 | helper_logger.log_info("Nothing linked for routing") |
209 | 211 | return 0 |
210 | 212 | else: |
@@ -245,9 +247,9 @@ def check_if_link_is_active_for_NIC(physical_port): |
245 | 247 | helper_logger.log_error("platform_chassis is not loaded, failed to check if link is Active on NIC side") |
246 | 248 | return -1 |
247 | 249 |
|
248 | | - regval_read = struct.unpack(">i", result) |
| 250 | + regval_read = struct.unpack(">B", result) |
249 | 251 |
|
250 | | - if (regval_read & 0x01): |
| 252 | + if (regval_read[0] & 0x01): |
251 | 253 | helper_logger.log_info("NIC link is up") |
252 | 254 | return True |
253 | 255 | else: |
@@ -285,9 +287,9 @@ def check_if_link_is_active_for_torA(physical_port): |
285 | 287 | helper_logger.log_error("platform_chassis is not loaded, failed to check if link is Active on TOR A side") |
286 | 288 | return -1 |
287 | 289 |
|
288 | | - regval_read = struct.unpack(">i", result) |
| 290 | + regval_read = struct.unpack(">B", result) |
289 | 291 |
|
290 | | - if ((regval_read >> 2) & 0x01): |
| 292 | + if ((regval_read[0] >> 2) & 0x01): |
291 | 293 | helper_logger.log_info("TOR A link is up") |
292 | 294 | return True |
293 | 295 | else: |
@@ -325,9 +327,9 @@ def check_if_link_is_active_for_torB(physical_port): |
325 | 327 | helper_logger.log_error("platform_chassis is not loaded, failed to check if link is Active on TOR B side") |
326 | 328 | return -1 |
327 | 329 |
|
328 | | - regval_read = struct.unpack(">i", result) |
| 330 | + regval_read = struct.unpack(">B", result) |
329 | 331 |
|
330 | | - if ((regval_read >> 1) & 0x01): |
| 332 | + if ((regval_read[0] >> 1) & 0x01): |
331 | 333 | helper_logger.log_info("TOR B link is up") |
332 | 334 | return True |
333 | 335 | else: |
|
0 commit comments