diff options
author | 2016-02-11 09:31:45 -0500 | |
---|---|---|
committer | 2016-02-11 09:32:25 -0500 | |
commit | 96e96afa83a47268000194ddf75ec2323e336d18 (patch) | |
tree | bd07ecebc4402524a3443f389616519fc1f179d1 /scripts/automation/trex_control_plane | |
parent | 53cb5b1f7340e72374eb30c6b5e495c63776ecd9 (diff) |
fixed 'streams' command that was broken because of my big commit
Diffstat (limited to 'scripts/automation/trex_control_plane')
4 files changed, 56 insertions, 22 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py index de96350a..0b90d3e1 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py @@ -700,10 +700,15 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface): """ pkt_buf = self._get_pkt_as_str() + return self.pkt_layers_desc_from_buffer(pkt_buf) + + @staticmethod + def pkt_layers_desc_from_buffer (pkt_buf): scapy_pkt = Ether(pkt_buf); pkt_utl = CTRexScapyPktUtl(scapy_pkt); return pkt_utl.get_pkt_layers() + def set_pkt_as_str (self, pkt_buffer): assert type(pkt_buffer)==str, "pkt_buffer should be string" self.pkt_raw = pkt_buffer diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py index de96f1ac..e319e7d3 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py @@ -180,7 +180,8 @@ class Port(object): return self.err("stream dependency error - unable to find '{0}'".format(next)) next_id = lookup[next] - stream.fields['next_stream_id'] = next_id + + stream.set_next_id(next_id) batch = [] @@ -490,39 +491,36 @@ class Port(object): ################# stream printout ###################### def generate_loaded_streams_sum(self, stream_id_list): - if self.state == self.STATE_DOWN or self.state == self.STATE_STREAMS: + if self.state == self.STATE_DOWN: return {} streams_data = {} if not stream_id_list: # if no mask has been provided, apply to all streams on port stream_id_list = self.streams.keys() - + streams_data = {stream_id: self.streams[stream_id].metadata.get('stream_sum', ["N/A"] * 6) for stream_id in stream_id_list if stream_id in self.streams} - - return {"referring_file" : "", - "streams" : streams_data} + # sort the data + return {"streams" : OrderedDict(sorted(streams_data.items())) } @staticmethod def _generate_stream_metadata(stream): meta_dict = {} - # create packet stream description - #pkt_bld_obj = packet_builder.CTRexPktBuilder() - #pkt_bld_obj.load_from_stream_obj(compiled_stream_obj) - # generate stream summary based on that - - #next_stream = "None" if stream['next_stream_id']==-1 else stream['next_stream_id'] - - meta_dict['stream_sum'] = OrderedDict([("id", stream.get_id()), - ("packet_type", "FIXME!!!"), - ("L2 len", "FIXME!!! +++4"), - ("mode", "FIXME!!!"), - ("rate_pps", "FIXME!!!"), - ("next_stream", "FIXME!!!") + + next = stream.get_next_id() + if next == -1: + next = "-" + + meta_dict['stream_sum'] = OrderedDict([("id", stream.get_id()), + ("packet_type", stream.get_pkt_type()), + ("L2 len", stream.get_pkt_len()), + ("mode", stream.get_mode()), + ("rate_pps", stream.get_pps()), + ("next_stream", next) ]) return meta_dict diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py index 183ae0c6..30f303a8 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py @@ -84,15 +84,13 @@ class CTRexInfoGenerator(object): def generate_streams_info(self, port_id_list, stream_id_list): relevant_ports = self.__get_relevant_ports(port_id_list) - return_data = OrderedDict() for port_obj in relevant_ports: streams_data = self._generate_single_port_streams_info(port_obj, stream_id_list) if not streams_data: continue - hdr_key = "Port {port}: {yaml_file}".format(port= port_obj.port_id, - yaml_file= streams_data.raw_data.get('referring_file', '')) + hdr_key = "Port {port}:".format(port= port_obj.port_id) # TODO: test for other ports with same stream structure, and join them return_data[hdr_key] = streams_data diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index 91a554ff..609006a8 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -38,6 +38,8 @@ class STLTXCont(STLTXMode): self.fields['type'] = 'continuous' self.fields['pps'] = pps + def __str__ (self): + return "Continuous" # single burst mode class STLTXSingleBurst(STLTXMode): @@ -56,6 +58,8 @@ class STLTXSingleBurst(STLTXMode): self.fields['pps'] = pps self.fields['total_pkts'] = total_pkts + def __str__ (self): + return "Single Burst" # multi burst mode class STLTXMultiBurst(STLTXMode): @@ -86,6 +90,9 @@ class STLTXMultiBurst(STLTXMode): self.fields['ibg'] = ibg self.fields['count'] = count + def __str__ (self): + return "Multi Burst" + class STLStream(object): @@ -122,6 +129,8 @@ class STLStream(object): # tag for the stream and next - can be anything self.name = name if name else random_name(8) self.next = next + + # ID self.set_id(stream_id) self.fields = {} @@ -133,6 +142,7 @@ class STLStream(object): # mode self.fields['mode'] = mode.to_json() + self.mode_desc = str(mode) self.fields['packet'] = {} self.fields['vm'] = {} @@ -146,6 +156,7 @@ class STLStream(object): # packet and VM self.fields['packet'] = packet.dump_pkt() self.fields['vm'] = packet.get_vm_data() + self.packet_desc = packet.pkt_layers_desc() if not rx_stats: self.fields['rx_stats'] = {} @@ -169,12 +180,34 @@ class STLStream(object): def set_id (self, id): self.id = id + def get_next_id (self): + return self.fields.get('next_stream_id') + + def set_next_id (self, next_stream_id): + self.fields['next_stream_id'] = next_stream_id + def get_name (self): return self.name def get_next (self): return self.next + def get_pkt_type (self): + return self.packet_desc + + def get_pkt_len (self, count_crc = True): + pkt_len = len(base64.b64decode(self.fields['packet']['binary'])) + if count_crc: + pkt_len += 4 + + return pkt_len + + def get_pps (self): + return self.fields['mode']['pps'] + + def get_mode (self): + return self.mode_desc + def to_yaml (self): return {'name': self.name, 'stream': self.fields} |