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

"Error in L2/L3 Traffic Apply" response from TrafficItem's Generate() method.
 #29

Closed Brodski closed 5 years ago

Brodski commented 5 years ago

I have some basic code and a basic test (code below) but Ixnetwork.Traffic.TrafficItem.Generate is not working correctly. But I get the error when I try ixnetwork.traffic.apply() (pic below) . 



def doBasicTest():
  IP = '22.254.11.181'
  test_platform = TestPlatform( IP , platform='linux', log_file_name='restpy.log')
  sess = test_platform.Sessions.find(Id=8020)
  ix = sess.Ixnetwork

  ix.LoadConfig(Files('ixNetworkTestSample.ixncfg'))

  traffItem = ix.Traffic.TrafficItem.find()
  tGenerated = traffItem[0].Generate()
  ix.Traffic.Apply()

image

 
I believe the problem is on RestPy's end b/c if I comment out traffItem[0].Generate() and comment out ix.Traffic.Apply() and then use the API browser to run both those methods, ie run a generate() method on the trafficItem and run the Apply method on Traffic, then it will work with no problems. (At /api/v1/sessions/8020/ixnetwork/traffic/trafficItem/2 via clicking Operations then choosing the Generate method and clicking commit, and same-ish thing for traffic.apply()).

Also, if I go into the directory of my python library to [pythonpath]/ixnetwork_restpy/connection.py, and add a sleep command (shown below, line 173) then it works every time.

screen shot 2019-01-16 at 3 56 45 pm

hubertgee commented 5 years ago

Hi Brodski,

Please open a support case by sending an email to support.ix@keysight.commailto:support.ix@keysight.com.

By the looks of your code, since you are connecting to platform=’linux’, your session ID should not be 8020. Linux session ID begins with 1. The session ID 8020 looks like a Windows Connection Mgr session ID. If you are connecting to an existing opened session, please take a look at the below ample script link:

https://github.com/OpenIxia/IxNetwork/blob/master/RestPy/SampleScripts/connectToExistingConfig.py

For basic test, follow this sample script. It has everything you need … https://github.com/OpenIxia/IxNetwork/blob/master/RestPy/SampleScripts/bgpNgpf.py

Also, get the latest ixnetwork_restpy by pip.

Regards, Hubert Gee

From: Brodski notifications@github.com Sent: Wednesday, January 16, 2019 2:51 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [OpenIxia/IxNetwork] "Error in L2/L3 Traffic Apply" response from TrafficItem's Generate() method.
 (#29)

[EXTERNAL]

I have some basic code and a basic test (code below) but Ixnetwork.Traffic.TrafficItem.Generate is not working correctly. But I get the error when I try ixnetwork.traffic.apply() (pic below) . 



def doBasicTest():

IP = '22.254.11.181'

test_platform = TestPlatform( IP , platform='linux', log_file_name='restpy.log')

sess = test_platform.Sessions.find(Id=8020)

ix = sess.Ixnetwork

ix.LoadConfig(Files('ixNetworkTestSample.ixncfg'))

traffItem = ix.Traffic.TrafficItem.find()

tGenerated = traffItem[0].Generate()

ix.Traffic.Apply()

[image]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F18043765%2F51283519-ae88a600-19a5-11e9-92ed-fffafff2db4f.png&data=02%7C01%7C%7C7f51ed1b84554e2b943b08d67c0512f0%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636832758563443795&sdata=4NYafiF4QKh2nbkJ1cIXDj4dbI3NGRIcKJIoF%2BU7cI8%3D&reserved=0

 
I believe the problem is on RestPy's end b/c if I comment out traffItem[0].Generate() and comment out ix.Traffic.Apply() and then use the API browser to run both those methods, ie run a generate() method on the trafficItem and run the Apply method on Traffic, then it will work with no problems. (At /api/v1/sessions/8020/ixnetwork/traffic/trafficItem/2 via clicking Operations then choosing the Generate method and clicking commit, and same-ish thing for traffic.apply()).

Also, if I go into the directory of my python library to [pythonpath]/ixnetwork_restpy/connection.py, and add a sleep command (shown below, line 177) then it works every time.

 [image]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F18043765%2F51283528-b5afb400-19a5-11e9-8f9a-54775faf0324.png&data=02%7C01%7C%7C7f51ed1b84554e2b943b08d67c0512f0%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636832758563453804&sdata=KpnjR5qXbktLgidPpmFChshSyC5XCxvbvIwsy%2FEmBfM%3D&reserved=0

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F29&data=02%7C01%7C%7C7f51ed1b84554e2b943b08d67c0512f0%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636832758563453804&sdata=L9CkI2mZ%2BrrwYeUfqBt8DYIdgAFtdiiDKuFjTVbuxSI%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAhtYX38QqpZPwCuHkc_f5cT267mEwW0Eks5vD6zOgaJpZM4aEHH7&data=02%7C01%7C%7C7f51ed1b84554e2b943b08d67c0512f0%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636832758563463809&sdata=dyvxsJEJYm6oJNPQzujvt15n7QoFXDiiecV3iRpTUB8%3D&reserved=0.

Brodski commented 5 years ago

Hello,

I tried making some changes to my code and looked deeper into the problem but I do not think I am doing anything wrong. The platform is linux, if I put 'windows' then it raises ConnectionError (which the doc describes under TestPlatform.init) occurs when "attempting to connect to a linux host with platform=windows"

I do not think my code is wrong. I looked at the sample pieces and my code essential does the same. If I had illogical code then my code should break whether or not I have the line "time.sleep(5)" written. I could run the code up until ix.LoadConfig(Files('ixNetworkTestSample.ixncfg')) then use Ixia's API Browser to run generate for the trafficItem and it will work (api/v1/sessions/8020/ixnetwork/traffic/trafficItem/operations/generate).

The only slightly new 'discovery' is that if I sleep for 5 seconds after loading the config file (instead of in the connection.py file), then it will work.

def doBasicTest():
  IP = '22.254.11.181'
  test_platform = TestPlatform( IP , platform='linux', log_file_name='restpy.log')
  sess = test_platform.Sessions.find(Id=8020)
  ix = sess.Ixnetwork

  ix.LoadConfig(Files('ixNetworkTestSample.ixncfg'))
  time.sleep(5)
  traffItem = ix.Traffic.TrafficItem.find()
  tGenerated = traffItem[0].Generate()
  ix.Traffic.Apply()
hubertgee commented 5 years ago

Hi Brodski,

Please send an email to support at support.ix@keysight.commailto:support.ix@keysight.com and somebody from the support team will get in touch with you to help you resolve your issue.

Thanks, Hubert Gee

From: Brodski notifications@github.com Sent: Tuesday, January 22, 2019 12:08 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Hubert Gee hubert.gee@keysight.com; State change state_change@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] "Error in L2/L3 Traffic Apply" response from TrafficItem's Generate() method.
 (#29)

[EXTERNAL]

Hello,

I tried making some changes to my code and looked deeper into the problem but I do not think I am doing anything wrong. The platform is linux, if I put 'windows' then it raises ConnectionError (which the doc describes under TestPlatform.init) occurs when "attempting to connect to a linux host with platform=windows"

I do not think my code is wrong. I looked at the sample pieces and my code essential does the same. If I had illogical code then my code should break whether or not I have the line "time.sleep(5)" written. I could run the code up until ix.LoadConfig(Files('ixNetworkTestSample.ixncfg')) then use Ixia's API Browser to run generate for the trafficItem and it will work (api/v1/sessions/8020/ixnetwork/traffic/trafficItem/operations/generate).

The only slightly new 'discovery' is that if I sleep for 5 seconds after loading the config file (instead of in the connection.py file), then it will work. ''' def doBasicTest(): IP = '22.254.11.181' test_platform = TestPlatform( IP , platform='linux', log_file_name='restpy.log') sess = test_platform.Sessions.find(Id=8020) ix = sess.Ixnetwork

ix.LoadConfig(Files('ixNetworkTestSample.ixncfg')) time.sleep(5) traffItem = ix.Traffic.TrafficItem.find() tGenerated = traffItem[0].Generate() ix.Traffic.Apply() '''

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F29%23issuecomment-456544169&data=02%7C01%7C%7C94ceec6ce8d74623bd1c08d680a53fa0%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636837844555871652&sdata=%2F5nRFfCD04WSJ8pfwy3NMUKXgY%2BbNMqVOYlX6zo24Mo%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAhtYX1gKJ0bepldrEoCc9B7ilE9s5swFks5vF2-FgaJpZM4aEHH7&data=02%7C01%7C%7C94ceec6ce8d74623bd1c08d680a53fa0%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636837844555871652&sdata=mR203wHPTE0gYHlZvHhV%2FYHeUoI8VcWlyi2z0PfEgD4%3D&reserved=0.