Skip to content

Commit a4f194c

Browse files
committed
trex_astf_client: use proper to_json_str call
The profile object returned from ASTFProfile.load can be of type ASTFProfileLight if the passed "profile" is a path to a json profile file. ASTFProfileLight has a different to_json_str signature, and calling the method assuming the returned profile object is of type ASTFProfile will lead to failures in this case.
1 parent c38790f commit a4f194c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/automation/trex_control_plane/interactive/trex/astf/trex_astf_client.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ..stl.trex_stl_client import STLClient
2121

2222
from .trex_astf_port import ASTFPort
23-
from .trex_astf_profile import ASTFProfile
23+
from .trex_astf_profile import ASTFProfile, ASTFProfileLight
2424
from .topo import ASTFTopologyManager
2525
from .tunnels_topo import TunnelsTopo
2626
from .stats.traffic import CAstfTrafficStats
@@ -614,7 +614,10 @@ def load_profile(self, profile, tunables = {}, pid_input = DEFAULT_PROFILE_ID):
614614
if profile is None:
615615
return
616616

617-
profile_json = profile.to_json_str(pretty = False, sort_keys = True)
617+
if isinstance(profile, ASTFProfileLight):
618+
profile_json = profile.to_json_str()
619+
else:
620+
profile_json = profile.to_json_str(pretty = False, sort_keys = True)
618621

619622
self.ctx.logger.pre_cmd('Loading traffic at acquired ports.')
620623
rc = self._upload_fragmented('profile_fragment', profile_json, pid_input = pid_input)

0 commit comments

Comments
 (0)