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

Ethernet destination field cannot be updated #138

Closed ErikCoen closed 1 year ago

ErikCoen commented 1 year ago

I am using the IxNetwork 9.20 and a script like SampleScripts\pcapToRawTrafficItem.py

ethernetStackObj = configElement.Stack.find(DisplayName='Ethernet II')

# Uncomment this to show a list of all the available protocol templates (packet headers)
#for protocolHeader in ixNetwork.Traffic.ProtocolTemplate():
#    ixNetwork.info('\n', protocolHeader.DisplayName)

# NOTE: If you are using virtual ports (IxVM), you must use the Destination MAC address of 
#       the IxVM port from your virtual host (ESX-i host or KVM)
ixNetwork.info('\nConfiguring Ethernet packet header')
ethernetDstField = ethernetStackObj.Field.find(DisplayName='Destination MAC Address')
ethernetDstField.ValueType = 'increment'

At execution of last line, there is python error:

2022-10-24 10:10:43 [ixnetwork_restpy.connection tid:24452] [DEBUG] PATCH http://127.0.0.1:57663/api/v1/sessions/1/ixnetwork/traffic/trafficItem/1/configElement/1/stack/1/field {"valueType": "increment", "id": "1"} 2022-10-24 10:10:43 [ixnetwork_restpy.connection tid:24452] [DEBUG] 400 Bad Request b'{"method":"PATCH","pathAndQuery":"/api/v1/sessions/1/ixnetwork/traffic/trafficItem/1/configElement/1/stack/1/field","errors":[{"code":10000,"detail":"InstanceId is not a string"},{"code":10000,"detail":"System.Exception: InstanceId is not a string\r\n at SDMCsLib.SDMObjIdPiece.GetIdAsString()\r\n at IxNetwork.Traffic2.Publishers.StackFieldHandler.Find(EnterExitSingleObjectHandler_EnterArgs args)\r\n at SDMHelpers.WalkContext.walkTo(SDMObjId objid, Hashtable idMapResponse, EnterReason reason)\r\n at SDMHelpers.SimplePublisher.Commit(ArrayList commitDeltasRequest, Hashtable idMapResponse, ArrayList commitMessages, SDMSandbox track)\r\n at SDMCsLib.SDMPeer.commitPiece(ArrayList deltasForPublisher, Hashtable idMapResponse, ArrayList commitExceptionsResponse, Version version, Boolean bCommitIfUnique)\r\n at SDMCsLib.SDMPeer.SANDBOX_DoCommit(Int32 eventMatch, ArrayList commitDeltasRequest, Hashtable idMapResponse, ArrayList commitExceptionsResponse, Version version, Boolean bCommitIfUnique, eSandboxType sandboxType)\r\n at SDMCsLib.SDMSandbox.DoCommit(Boolean bCommitIfUnique, eSandboxType sandboxType)\r\n at SDMCsLib.RestService.SdmSandbox.Commit(Boolean isAddOperation)\r\n at SDMCsLib.RestService.SdmObject.Patch()\r\n at SDMCsLib.RestService.V1ObjectController.Patch(String path)"}]}' 2022-10-24 10:10:43 [ixnetwork_restpy.connection tid:24452] [DEBUG] Traceback (most recent call last): File "C:/_ws/ixia_python37/IxNetwork-master/RestPy/SampleScripts/pcapToRawTrafficItem.py", line 143, in ethernetDstField.ValueType = 'increment' File "C:_ws\ixia_python37\venv\lib\site-packages\ixnetwork_restpy\testplatform\sessions\ixnetwork\traffic\trafficitem\configelement\stack\field\field.py", line 618, in ValueType self._set_attribute(self._SDM_ATT_MAP["ValueType"], value) File "C:_ws\ixia_python37\venv\lib\site-packages\ixnetwork_restpy\base.py", line 238, in _set_attribute raise e File "C:_ws\ixia_python37\venv\lib\site-packages\ixnetwork_restpy\base.py", line 235, in _set_attribute self._update({name: value}) File "C:_ws\ixia_python37\venv\lib\site-packages\ixnetwork_restpy\base.py", line 425, in _update self._connection._update(href, payload) File "C:_ws\ixia_python37\venv\lib\site-packages\ixnetwork_restpy\connection.py", line 272, in _update return self._send_recv("PATCH", url, payload) File "C:_ws\ixia_python37\venv\lib\site-packages\ixnetwork_restpy\connection.py", line 575, in _send_recv self._process_response_status_code(url, headers, response) File "C:_ws\ixia_python37\venv\lib\site-packages\ixnetwork_restpy\connection.py", line 461, in _process_response_status_code raise BadRequestError(message, response.status_code) ixnetwork_restpy.errors.BadRequestError: InstanceId is not a string System.Exception: InstanceId is not a string at SDMCsLib.SDMObjIdPiece.GetIdAsString() at IxNetwork.Traffic2.Publishers.StackFieldHandler.Find(EnterExitSingleObjectHandler_EnterArgs args) at SDMHelpers.WalkContext.walkTo(SDMObjId objid, Hashtable idMapResponse, EnterReason reason) at SDMHelpers.SimplePublisher.Commit(ArrayList commitDeltasRequest, Hashtable idMapResponse, ArrayList commitMessages, SDMSandbox track) at SDMCsLib.SDMPeer.commitPiece(ArrayList deltasForPublisher, Hashtable idMapResponse, ArrayList commitExceptionsResponse, Version version, Boolean bCommitIfUnique) at SDMCsLib.SDMPeer.SANDBOX_DoCommit(Int32 eventMatch, ArrayList commitDeltasRequest, Hashtable idMapResponse, ArrayList commitExceptionsResponse, Version version, Boolean bCommitIfUnique, eSandboxType sandboxType) at SDMCsLib.SDMSandbox.DoCommit(Boolean bCommitIfUnique, eSandboxType sandboxType) at SDMCsLib.RestService.SdmSandbox.Commit(Boolean isAddOperation) at SDMCsLib.RestService.SdmObject.Patch() at SDMCsLib.RestService.V1ObjectController.Patch(String path) Current Server Errors/Warnings: 10/24/2022 12:10:29 [WARNING] [Traffic Generate required] The Traffic Item was modified. Please perform a Traffic Generate to update the associated traffic Flow Groups

therkong commented 1 year ago

Hi Erik, I believe this issue is fixed with the latest Update. Can you try installing 9.20 Update 3?

ErikCoen commented 1 year ago

Yes, with update3, everything is working. Thanks a lot!