@@ -2255,4 +2255,188 @@ def muxdirection(db, port, json_output):
22552255 if rc_exit == False :
22562256 sys .exit (EXIT_FAIL )
22572257
2258+ @muxcable .command ()
2259+ @click .argument ('port' , metavar = '<port_name>' , required = True , default = None )
2260+ @click .argument ('option' , required = False , default = None )
2261+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL , help = "display the output in json format" )
2262+ @clicommon .pass_db
2263+ def queueinfo (db , port , option , json_output ):
2264+ """Show muxcable debug deump registers information, preagreed by vendors"""
2265+
2266+ port = platform_sfputil_helper .get_interface_name (port , db )
2267+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2268+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD_ARG" )
2269+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2270+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
2271+
2272+ if port is not None :
2273+
2274+ res_dict = {}
2275+ result = {}
2276+ param_dict = {}
2277+ param_dict ["option" ] = option
2278+
2279+
2280+ res_dict [0 ] = CONFIG_FAIL
2281+ res_dict [1 ] = "unknown"
2282+
2283+ res_dict = update_and_get_response_for_xcvr_cmd (
2284+ "get_ber" , "status" , "True" , "XCVRD_GET_BER_CMD" , "XCVRD_GET_BER_CMD_ARG" , "XCVRD_GET_BER_RSP" , port , 100 , param_dict , "queue_info" )
2285+
2286+ if res_dict [1 ] == "True" :
2287+ result = get_result (port , res_dict , "fec" , result , "XCVRD_GET_BER_RES" )
2288+
2289+
2290+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2291+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD_ARG" )
2292+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2293+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
2294+ port = platform_sfputil_helper .get_interface_alias (port , db )
2295+
2296+ if json_output :
2297+ click .echo ("{}" .format (json .dumps (result , indent = 4 )))
2298+ else :
2299+ headers = ['PORT' , 'ATTR' , 'VALUE' ]
2300+ res = [[port ]+ [key ] + [val ] for key , val in result .items ()]
2301+ click .echo (tabulate (res , headers = headers ))
2302+ else :
2303+ click .echo ("Did not get a valid Port for debug dump registers" .format (port ))
2304+ sys .exit (CONFIG_FAIL )
2305+
2306+
2307+ @muxcable .command ()
2308+ @click .argument ('port' , metavar = '<port_name>' , required = True , default = None )
2309+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL , help = "display the output in json format" )
2310+ @clicommon .pass_db
2311+ def health (db , port , json_output ):
2312+ """Show muxcable health information """
2313+
2314+ port = platform_sfputil_helper .get_interface_name (port , db )
2315+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2316+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2317+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
2318+
2319+ if port is not None :
2320+
2321+ res_dict = {}
2322+ result = {}
2323+
2324+
2325+ res_dict [0 ] = CONFIG_FAIL
2326+ res_dict [1 ] = "unknown"
2327+
2328+ res_dict = update_and_get_response_for_xcvr_cmd (
2329+ "get_ber" , "status" , "True" , "XCVRD_GET_BER_CMD" , None , "XCVRD_GET_BER_RSP" , port , 10 , None , "health_check" )
2330+
2331+ if res_dict [1 ] == "True" :
2332+ result = get_result (port , res_dict , "fec" , result , "XCVRD_GET_BER_RES" )
2333+
2334+
2335+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2336+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2337+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
2338+
2339+ port = platform_sfputil_helper .get_interface_alias (port , db )
2340+
2341+ if json_output :
2342+ click .echo ("{}" .format (json .dumps (result , indent = 4 )))
2343+ else :
2344+ headers = ['PORT' , 'ATTR' , 'HEALTH' ]
2345+ res = [[port ]+ [key ] + [val ] for key , val in result .items ()]
2346+ click .echo (tabulate (res , headers = headers ))
2347+ else :
2348+ click .echo ("Did not get a valid Port for cable alive status" .format (port ))
2349+ sys .exit (CONFIG_FAIL )
2350+
2351+ @muxcable .command ()
2352+ @click .argument ('port' , metavar = '<port_name>' , required = True , default = None )
2353+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL , help = "display the output in json format" )
2354+ @clicommon .pass_db
2355+ def resetcause (db , port , json_output ):
2356+ """Show muxcable health information """
2357+
2358+ port = platform_sfputil_helper .get_interface_name (port , db )
2359+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2360+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2361+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
2362+
2363+ if port is not None :
2364+
2365+ res_dict = {}
2366+ result = {}
2367+
2368+
2369+ res_dict [0 ] = CONFIG_FAIL
2370+ res_dict [1 ] = "unknown"
2371+
2372+ res_dict = update_and_get_response_for_xcvr_cmd (
2373+ "get_ber" , "status" , "True" , "XCVRD_GET_BER_CMD" , None , "XCVRD_GET_BER_RSP" , port , 10 , None , "reset_cause" )
2374+
2375+ if res_dict [1 ] == "True" :
2376+ result = get_result (port , res_dict , "fec" , result , "XCVRD_GET_BER_RES" )
2377+
2378+
2379+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2380+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2381+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
22582382
2383+ port = platform_sfputil_helper .get_interface_alias (port , db )
2384+
2385+ if json_output :
2386+ click .echo ("{}" .format (json .dumps (result , indent = 4 )))
2387+ else :
2388+ headers = ['PORT' , 'ATTR' , 'RESETCAUSE' ]
2389+ res = [[port ]+ [key ] + [val ] for key , val in result .items ()]
2390+ click .echo (tabulate (res , headers = headers ))
2391+ else :
2392+ click .echo ("Did not get a valid Port for cable alive status" .format (port ))
2393+ sys .exit (CONFIG_FAIL )
2394+
2395+ @muxcable .command ()
2396+ @click .argument ('port' , metavar = '<port_name>' , required = True , default = None )
2397+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL , help = "display the output in json format" )
2398+ @clicommon .pass_db
2399+ def operationtime (db , port , json_output ):
2400+ """Show muxcable operation time """
2401+
2402+ port = platform_sfputil_helper .get_interface_name (port , db )
2403+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2404+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2405+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
2406+
2407+ if port is not None :
2408+
2409+ res_dict = {}
2410+ result = {}
2411+
2412+
2413+ res_dict [0 ] = CONFIG_FAIL
2414+ res_dict [1 ] = "unknown"
2415+
2416+ res_dict = update_and_get_response_for_xcvr_cmd (
2417+ "get_ber" , "status" , "True" , "XCVRD_GET_BER_CMD" , None , "XCVRD_GET_BER_RSP" , port , 10 , None , "operation_time" )
2418+
2419+ if res_dict [1 ] == "True" :
2420+ result = get_result (port , res_dict , "fec" , result , "XCVRD_GET_BER_RES" )
2421+
2422+
2423+ delete_all_keys_in_db_table ("APPL_DB" , "XCVRD_GET_BER_CMD" )
2424+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RSP" )
2425+ delete_all_keys_in_db_table ("STATE_DB" , "XCVRD_GET_BER_RES" )
2426+
2427+ port = platform_sfputil_helper .get_interface_alias (port , db )
2428+
2429+ actual_time = result .get ("cable" )
2430+ if actual_time is not None :
2431+ time = '{0:02.0f}:{1:02.0f}' .format (* divmod (int (actual_time ) * 60 , 60 ))
2432+ result ['cable' ] = time
2433+
2434+ if json_output :
2435+ click .echo ("{}" .format (json .dumps (result , indent = 4 )))
2436+ else :
2437+ headers = ['PORT' , 'ATTR' , 'OPERATION_TIME' ]
2438+ res = [[port ]+ [key ] + [val ] for key , val in result .items ()]
2439+ click .echo (tabulate (res , headers = headers ))
2440+ else :
2441+ click .echo ("Did not get a valid Port for cable alive status" .format (port ))
2442+ sys .exit (CONFIG_FAIL )
0 commit comments