From 15dd490ab91bd6a28277de2e4eca9727fd99cb27 Mon Sep 17 00:00:00 2001 From: Vinod Kumar <119973184+vikumarks@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:45:02 -0700 Subject: [PATCH] print ixia stats (#417) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * QUAGGA_CONFIG update QUAGGA_CONFIG there is no policy (route-map) defined for peer-group IXIA. Due to that it is not able to receive routes In/Out. If we add “no bgp ebgp-requires-policy”, it advertises and receives the routes from other peers and traffic flows fine. * print ixia app error log added code to print ixia error log when start_protocols stop_protocols --------- Co-authored-by: vkuma82 --- .../DentOsTestbed/Requirements.txt | 1 + .../ixnetwork/ixnetwork_ixia_client_impl.py | 36 ++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/DentOS_Framework/DentOsTestbed/Requirements.txt b/DentOS_Framework/DentOsTestbed/Requirements.txt index e7ccfdfc..e1156afb 100644 --- a/DentOS_Framework/DentOsTestbed/Requirements.txt +++ b/DentOS_Framework/DentOsTestbed/Requirements.txt @@ -9,3 +9,4 @@ pytest-html pytest-repeat ixnetwork_restpy>=1.1.10 pyvis == 0.1.9 +tabulate diff --git a/DentOS_Framework/DentOsTestbedLib/src/dent_os_testbed/lib/traffic/ixnetwork/ixnetwork_ixia_client_impl.py b/DentOS_Framework/DentOsTestbedLib/src/dent_os_testbed/lib/traffic/ixnetwork/ixnetwork_ixia_client_impl.py index 24db9d37..3f580460 100644 --- a/DentOS_Framework/DentOsTestbedLib/src/dent_os_testbed/lib/traffic/ixnetwork/ixnetwork_ixia_client_impl.py +++ b/DentOS_Framework/DentOsTestbedLib/src/dent_os_testbed/lib/traffic/ixnetwork/ixnetwork_ixia_client_impl.py @@ -1,6 +1,7 @@ import os import sys import time +from tabulate import tabulate from dent_os_testbed.lib.traffic.ixnetwork.ixnetwork_ixia_client import IxnetworkIxiaClient from ixnetwork_restpy.assistants.statistics.statviewassistant import StatViewAssistant as SVA @@ -48,6 +49,7 @@ def run_connect(self, device, command, *argv, **kwarg): if command == 'disconnect': if IxnetworkIxiaClientImpl.session is not None: device.applog.info('Removing Session ID: %d' % IxnetworkIxiaClientImpl.session.Id) + self._CheckErrorsLog(device) IxnetworkIxiaClientImpl.session.remove() IxnetworkIxiaClientImpl.session = None IxnetworkIxiaClientImpl.ixnet = None @@ -279,6 +281,8 @@ def run_config(self, device, command, *argv, **kwarg): if not found: out = IxnetworkIxiaClientImpl.session.UploadFile(fname, name) out = IxnetworkIxiaClientImpl.ixnet.LoadConfig(Files(name)) + # get the traffic items back + IxnetworkIxiaClientImpl.tis = IxnetworkIxiaClientImpl.ixnet.Traffic.TrafficItem.find() elif command == 'save_config': out = IxnetworkIxiaClientImpl.ixnet.SaveConfig(Files(name)) out += IxnetworkIxiaClientImpl.session.DownloadFile(name, fname) @@ -357,6 +361,19 @@ def __update_field(self, field, value): field.Auto = False field.update(**param) + def _CheckErrorsLog(self, device): + device.applog.info('CheckIxNetwork Errors Log') + ixnet = IxnetworkIxiaClientImpl.ixnet + try: + errors = ixnet.Globals.AppErrors.find().Error.find() + columns = ['LastModified', 'Type', 'Code', 'Count', 'Description'] + rows = [[i.LastModified, i.ErrorLevel, i.ErrorCode, i.InstanceCount, i.Name + ':' + i.Description] for i in errors] + device.applog.info(os.linesep + tabulate(rows, headers=columns, tablefmt='grid')) + return 0 + except Exception as ex: + device.applog.info('ERROR:'+str(ex)) + return 1 + def __update_frame_rate(self, config_element, pkt_data): """ Update frame rate type and frame rate from pkt_data @@ -712,11 +729,11 @@ def run_traffic_item(self, device, command, *argv, **kwarg): if attempts > 3: device.applog.info(f'INFO: Traffic not stopped after {attempts * time_to_sleep} Seconds') elif command == 'get_stats': - device.applog.info('Getting Stats') stats_type = 'Port Statistics' params = kwarg['params'] if params or params[0]: stats_type = params[0].get('stats_type', stats_type) + device.applog.info('Getting Stats {}'.format(stats_type)) stats = SVA(IxnetworkIxiaClientImpl.ixnet, stats_type) # device.applog.info(stats) return 0, stats @@ -781,13 +798,22 @@ def run_protocol(self, device, command, *argv, **kwarg): else: ep.SendNs() # ipv6 time.sleep(5) - device.applog.info('Generating Traffic') - IxnetworkIxiaClientImpl.ixnet.Traffic.TrafficItem.find().Generate() - device.applog.info('Applying Traffic') - IxnetworkIxiaClientImpl.ixnet.Traffic.Apply() + try: + device.applog.info('Generating Traffic') + IxnetworkIxiaClientImpl.ixnet.Traffic.TrafficItem.find().Generate() + device.applog.info('Applying Traffic') + IxnetworkIxiaClientImpl.ixnet.Traffic.Apply() + finally: + device.applog.info('Check Error if any while Applying Traffic') + self._CheckErrorsLog(device) + elif command == 'stop_protocols': device.applog.info('Stopping All Protocols') IxnetworkIxiaClientImpl.ixnet.StopAllProtocols(Arg1='sync') + protocolsSummary = SVA(IxnetworkIxiaClientImpl.ixnet, 'Protocols Summary') + device.applog.info('Protocols not stopped properly.') + self._CheckErrorsLog(device) + elif command == 'set_protocol': params = kwarg['params'] param = params[0]