Skip to content

Commit

Permalink
trex_astf_client: use proper to_json_str call
Browse files Browse the repository at this point in the history
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.

Signed-off-by: bzalkilani <[email protected]>
  • Loading branch information
bzalkilani committed Aug 22, 2023
1 parent c38790f commit 909fec4
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ..stl.trex_stl_client import STLClient

from .trex_astf_port import ASTFPort
from .trex_astf_profile import ASTFProfile
from .trex_astf_profile import ASTFProfile, ASTFProfileLight
from .topo import ASTFTopologyManager
from .tunnels_topo import TunnelsTopo
from .stats.traffic import CAstfTrafficStats
Expand Down Expand Up @@ -614,7 +614,10 @@ def load_profile(self, profile, tunables = {}, pid_input = DEFAULT_PROFILE_ID):
if profile is None:
return

profile_json = profile.to_json_str(pretty = False, sort_keys = True)
if isinstance(profile, ASTFProfileLight):
profile_json = profile.to_json_str()
else:
profile_json = profile.to_json_str(pretty = False, sort_keys = True)

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

0 comments on commit 909fec4

Please sign in to comment.