OpenIxia / IxNetwork

A central location for IxNetwork sample scripts and utilities. Please also visit http://openixia.com
MIT License
50 stars 59 forks source link

How to start-all/stop-all protocols with Restpy ? #86

Closed sshuguan closed 4 years ago

sshuguan commented 4 years ago
  1. On ixia GUI (home tab), there are Protocols->Start-All (or Stop-All) buttons. What are corresponding Restpy APIs to achieve the same operations ?
  2. How do I start/stop Dhcp and Dot1x protocols by Restpy APIs ? (no such method or attributes under ...->globals->protocolStacks->dot1xglobals (or dhcpglobals)
ajbalogh commented 4 years ago
# start and stop all protocols
from ixnetwork_restpy.testplatform.testplatform import TestPlatform

testplatform = TestPlatform('127.0.0.1')
sessions = testplatform.Sessions.add()
ixnetwork = sessions.Ixnetwork
ixnetwork.StartAllProtocols()
ixnetwork.StopAllProtocols()
# start and stop dhcp protocols
from ixnetwork_restpy.testplatform.testplatform import TestPlatform

testplatform = TestPlatform('127.0.0.1')
sessions = testplatform.Sessions.add()
ixnetwork = sessions.Ixnetwork
dhcp = ixnetwork.Vport.find().ProtocolStack.Ethernet.find().DhcpEndpoint.find()
dhcp.Start()
dhcp.Stop()
# start and stop dot1x protocols
from ixnetwork_restpy.testplatform.testplatform import TestPlatform

testplatform = TestPlatform('127.0.0.1')
sessions = testplatform.Sessions.add()
ixnetwork = sessions.Ixnetwork
dot1x= ixnetwork.Vport.find().ProtocolStack.Ethernet.find().Dot1x.find()
dot1x.Dot1xStart()
dot1x.Dot1xStop()
sshuguan commented 4 years ago

thanks.

sshuguan commented 4 years ago

There are "Exception type: IndexError" when Dot1xStop() and Dot1xStop() executes:

2020-01-07 14:21:24,758 utils ERROR Exception type: IndexError 2020-01-07 14:21:24,758 utils ERROR Exception message: list index out of range 2020-01-07 14:21:24,760 utils ERROR Stack trace: /home/sshanggu/automation/library/ixrest.py, Line 223 getattr(vpp, 'Dot1x'+action.capitalize())(), Func: protocol 2020-01-07 14:21:24,760 utils ERROR Stack trace: /usr/local/lib/python3.7/site-packages/ixnetwork_restpy/testplatform/sessions/ixnetwork/vport/protocolstack/dot1x_fc69959d1d61682e346651101176cfda.py, Line 211 return self._execute('dot1xStop', payload=payload, response_object=None), Func: Dot1xStop 2020-01-07 14:21:24,760 utils ERROR Stack trace: /usr/local/lib/python3.7/site-packages/ixnetwork_restpy/base.py, Line 284 url = self._properties['href'], Func: _execute 2020-01-07 14:21:24,761 utils ERROR Stack trace: /usr/local/lib/python3.7/site-packages/ixnetwork_restpy/base.py, Line 115 return self._object_properties[self._index], Func: _properties

any clues? thanks

ajbalogh commented 4 years ago

It appears that your utility library bypasses the actual Dot1xStart function in the library. The Dot1xStart function inserts any required hrefs as part of the payload which may be missing. Also are you using dot1x protocols from legacy protocolStack or from topology?

On Tue, Jan 7, 2020 at 11:30 AM sshanggu notifications@github.com wrote:

There are "Exception type: IndexError" when Dot1xStop() and Dot1xStop() executes:

2020-01-07 14:21:24,758 utils ERROR Exception type: IndexError 2020-01-07 14:21:24,758 utils ERROR Exception message: list index out of range 2020-01-07 14:21:24,760 utils ERROR Stack trace: /home/sshanggu/automation/library/ixrest.py, Line 223 getattr(vpp, 'Dot1x'+action.capitalize())(), Func: protocol 2020-01-07 14:21:24,760 utils ERROR Stack trace: /usr/local/lib/python3.7/site-packages/ixnetwork_restpy/testplatform/sessions/ixnetwork/vport/protocolstack/dot1x_fc69959d1d61682e346651101176cfda.py, Line 211 return self._execute('dot1xStop', payload=payload, response_object=None), Func: Dot1xStop 2020-01-07 14:21:24,760 utils ERROR Stack trace: /usr/local/lib/python3.7/site-packages/ixnetwork_restpy/base.py, Line 284 url = self._properties['href'], Func: _execute 2020-01-07 14:21:24,761 utils ERROR Stack trace: /usr/local/lib/python3.7/site-packages/ixnetwork_restpy/base.py, Line 115 return self._object_properties[self._index], Func: _properties

any clues? thanks

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/OpenIxia/IxNetwork/issues/86?email_source=notifications&email_token=AHHFTFVIAL4VYWKMHEUEOQDQ4TJ3ZA5CNFSM4J565H72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJ73JI#issuecomment-571735461, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHFTFU2VO7562RXXP22BJDQ4TJ3ZANCNFSM4J565H7Q .

sshuguan commented 4 years ago

the dot1x protocol is from protocolStack. below are part of my codes:

...... ixvps = ixnetwork.Vport.find() for vp in ixvps: vpp = vp.ProtocolStack.Ethernet.find().Dot1x.find() vpp.Dot1xStop() # it throws Exception IndexError vpp.Dot1xStart() # it throws Exception IndexError

ajbalogh commented 4 years ago

you should confirm that you have at least one Dot1x instance. the following does not give me an indexerror.

from ixnetwork_restpy.testplatform.testplatform import TestPlatform

testplatform = TestPlatform('127.0.0.1') sessions = testplatform.Sessions.add() ixnetwork = sessions.Ixnetwork ixnetwork.NewConfig() ixnetwork.Vport.add().ProtocolStack.EthernetEndpoint.add().Range.add().Dot1xRange.add() dot1x = ixnetwork.Vport.find().ProtocolStack.EthernetEndpoint.find().Dot1x.find() assert(len(dot1x) == 1) dot1x.Dot1xStart()

On Tue, Jan 7, 2020 at 12:18 PM sshanggu notifications@github.com wrote:

the dot1x protocol is from protocolStack. below are part of my codes:

...... ixvps = ixnetwork.Vport.find() for vp in ixvps: vpp = vp.ProtocolStack.Ethernet.find().Dot1x.find() vpp.Dot1xStop() # it throws Exception IndexError vpp.Dot1xStart() # it throws Exception IndexError

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/OpenIxia/IxNetwork/issues/86?email_source=notifications&email_token=AHHFTFVSLHF74CNVOQ7OVTDQ4TPQPA5CNFSM4J565H72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIKEIVI#issuecomment-571753557, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHFTFUTLZRMYSNLV3MELZ3Q4TPQPANCNFSM4J565H7Q .

sshuguan commented 4 years ago

trying. thanks