From b71ded6e5d62a24e29596d88519580ab3df5bb2c Mon Sep 17 00:00:00 2001 From: Francisco <74398368+fkwilken@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:08:14 -0700 Subject: [PATCH] Optimize VPort Addition, Protocol Timing (#386) Signed-off-by: fkwilken --- .../ixnetwork/ixnetwork_ixia_client_impl.py | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) 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 ab2f4c619..5ea5c5ae7 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 @@ -4,7 +4,7 @@ from dent_os_testbed.lib.traffic.ixnetwork.ixnetwork_ixia_client import IxnetworkIxiaClient from ixnetwork_restpy.assistants.statistics.statviewassistant import StatViewAssistant as SVA -from ixnetwork_restpy import SessionAssistant, Files +from ixnetwork_restpy import SessionAssistant, Files, BatchAdd, BatchFind class IxnetworkIxiaClientImpl(IxnetworkIxiaClient): @@ -105,10 +105,20 @@ def run_connect(self, device, command, *argv, **kwarg): swp_ports = param['swp_ports'] dev_groups = param['dev_groups'] + # Batch Add all ixia ports to prevent 1 at a time restarting + with BatchAdd(IxnetworkIxiaClientImpl.ixnet): + for port in ixia_ports: + IxnetworkIxiaClientImpl.ixnet.Vport.add(Name=port, Location=port.replace(':', ';')) + # Batch Find to retrieve list of added port objects + with BatchFind(IxnetworkIxiaClientImpl.ixnet) as bf: + IxnetworkIxiaClientImpl.ixnet.Vport.find() + # Use Batch Find results to create name-addressable vport dict + vport_objects = {vport.Name: vport for vport in bf.results.vport} + vports = {} - for port, sport in zip(ixia_ports, swp_ports): - # Specify Location on Port Add to simplify assignment - vports[port] = (IxnetworkIxiaClientImpl.ixnet.Vport.add(Name=port, Location=port.replace(':', ';')), sport) + for port, swp_port in zip(ixia_ports, swp_ports): + # Vports dict uses port name to store vport object and swp port name + vports[port] = (vport_objects[port], swp_port) device.applog.info('Assigning ports') IxnetworkIxiaClientImpl.ixnet.AssignPorts(True) @@ -762,7 +772,12 @@ def run_protocol(self, device, command, *argv, **kwarg): if command == 'start_protocols': device.applog.info('Starting All Protocols') IxnetworkIxiaClientImpl.ixnet.StartAllProtocols(Arg1='sync') - time.sleep(15) + # Check that Protocols are Started and Up + protocolsSummary = SVA(IxnetworkIxiaClientImpl.ixnet, 'Protocols Summary') + device.applog.info('Waiting for Protocols for up to 20 seconds') + protocolsSummary.CheckCondition('Sessions Not Started', SVA.EQUAL, 0, Timeout=10, RaiseException=False) + protocolsSummary.CheckCondition('Sessions Down', SVA.EQUAL, 0, Timeout=10, RaiseException=False) + for ep in IxnetworkIxiaClientImpl.ip_eps: device.applog.info('Sending ARP on ' + ep.Name) ep.Start()