You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def get_pkt_drops(duthost, cli_cmd, asic_index):
"""
@summary: Parse output of "portstat" or "intfstat" commands and convert it to the dictionary.
@param module: The AnsibleModule object
@param cli_cmd: one of supported CLI commands - "portstat -j" or "intfstat -j"
@return: Return dictionary of parsed counters
"""
# Get namespace from asic_index.
namespace = duthost.get_namespace_from_asic_id(asic_index)
# Frame the correct cli command
# the L2 commands need _SUFFIX and L3 commands need _PREFIX
if cli_cmd == GET_L3_COUNTERS:
CMD_PREFIX = NAMESPACE_PREFIX if (namespace is not None and duthost.is_multi_asic) else ''
cli_cmd = CMD_PREFIX + cli_cmd
elif cli_cmd == GET_L2_COUNTERS:
CMD_SUFFIX = NAMESPACE_SUFFIX if (namespace is not None and duthost.is_multi_asic) else ''
cli_cmd = cli_cmd + CMD_SUFFIX
stdout = duthost.command(cli_cmd.format(namespace))
stdout = stdout["stdout"]
match = re.search("Last cached time was.*\n", stdout)
if match:
stdout = re.sub("Last cached time was.*\n", "", stdout)
try:
return json.loads(stdout)
except Exception as err:
> raise Exception("Failed to parse output of '{}', err={}".format(cli_cmd, str(err)))
E Exception: Failed to parse output of 'portstat -j -n {} ', err=Extra data: line 274 column 1 - line 274 column 84 (char 6315 - 6398)
Thanks @kartik-arista , then the issue shoudl be open against sonic-buildimage then?
I initially filed under sonic-mgmt because I wasn't sure if the change needed to be made in sonic-mgmt to adjust for the new output or fixing the original CLI.
Steps to reproduce the issue:
run test_drop_counters.py
This should fail on any platform.
Additional information you deem important:
is the relevant code block.
Running the command on a device:
The above string is the issue because it is not properly parseable in JSON.
This change appears to have been introduced with
sonic-net/sonic-utilities#2466
The text was updated successfully, but these errors were encountered: