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

is there an equivalent api for capture like takecsvsnapshot in RestPy #104

Closed muthvar1 closed 4 years ago

muthvar1 commented 4 years ago

I am basically looking for an api in RestPy that takes the capture of a given vport and then also saves the file to the local _root_directory. I have the below commands. But this saves it locally on the ixNetworkClient. I need the file transferred to my local _root_directory.

ixnetwork.Vport.find(Name='1/1/13').Capture.HardwareEnabled = True

ixnetwork.StartCapture() ixnetwork.Traffic.Apply() ixnetwork.Traffic.Start() flowStatistics = StatViewAssistant(ixnetwork, 'Flow Statistics') ixnetwork.StopCapture() ixnetwork.SaveCaptureFiles("C:\Results", "trace.pcap")

therkong commented 4 years ago

Hi,

In TestPlatform.Sessions(), there's DownloadFile() to download the file to your local machine. check: https://openixia.github.io/ixnetwork_restpy/#/reference

""" Method Sessions.DownloadFile

Download a file from the IxNetwork session instance

Args

Returns

sessions = TestPlatform('127.0.0.1') \ .Sessions.find() sessions.DownloadFile(remote_filename, local_filename=None)

muthvar1 commented 4 years ago

HI Theresa, Is this DownloadFile a new addition to the SDK? I don't see it in my earlier versions

therkong commented 4 years ago

It’s been there for a while. Please check RestPy API guide: https://openixia.github.io/ixnetwork_restpy/#/reference DownloadFile is under TestPlatform->Sessions

What is your ixnetwork_restpy version?

Regards, Theresa

From: varghese muthalaly notifications@github.com Sent: Thursday, June 11, 2020 1:19 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Theresa Kong theresa.kong@keysight.com; Assign assign@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] is there an equivalent api for capture like takecsvsnapshot in RestPy (#104)

[EXTERNAL]

HI Theresa, Is this DownloadFile a new addition to the SDK? I don't see it in my earlier versions

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/OpenIxia/IxNetwork/issues/104*issuecomment-642906250__;Iw!!I5pVk4LIGAfnvw!2oGRrIqKogWzKUE8QofXwiOpbRlATC4WIQQOpxGmmRvGrhYmgGBMn5-gNlIZ-prDo5cJ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AIRRUUOUOALJGXKKYUMXOIDRWE32XANCNFSM4N3VSBTQ__;!!I5pVk4LIGAfnvw!2oGRrIqKogWzKUE8QofXwiOpbRlATC4WIQQOpxGmmRvGrhYmgGBMn5-gNlIZ-jnBX9Pj$.

ajbalogh commented 4 years ago

https://github.com/OpenIxia/ixnetwork_restpy/blob/master/RELEASENOTES.md#feb2019

On Thu, Jun 11, 2020 at 1:22 PM therkong notifications@github.com wrote:

It’s been there for a while. Please check RestPy API guide: https://openixia.github.io/ixnetwork_restpy/#/reference DownloadFile is under TestPlatform->Sessions

What is your ixnetwork_restpy version?

Regards, Theresa

From: varghese muthalaly notifications@github.com Sent: Thursday, June 11, 2020 1:19 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Theresa Kong theresa.kong@keysight.com; Assign < assign@noreply.github.com> Subject: Re: [OpenIxia/IxNetwork] is there an equivalent api for capture like takecsvsnapshot in RestPy (#104)

[EXTERNAL]

HI Theresa, Is this DownloadFile a new addition to the SDK? I don't see it in my earlier versions

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub< https://urldefense.com/v3/__https:/github.com/OpenIxia/IxNetwork/issues/104*issuecomment-642906250__;Iw!!I5pVk4LIGAfnvw!2oGRrIqKogWzKUE8QofXwiOpbRlATC4WIQQOpxGmmRvGrhYmgGBMn5-gNlIZ-prDo5cJ$>, or unsubscribe< https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AIRRUUOUOALJGXKKYUMXOIDRWE32XANCNFSM4N3VSBTQ__;!!I5pVk4LIGAfnvw!2oGRrIqKogWzKUE8QofXwiOpbRlATC4WIQQOpxGmmRvGrhYmgGBMn5-gNlIZ-jnBX9Pj$>.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OpenIxia/IxNetwork/issues/104#issuecomment-642907498, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHFTFQO2DVO6R3BCECZOUDRWE4GRANCNFSM4N3VSBTQ .

muthvar1 commented 4 years ago

It's weird. I can see it in my version of the codebase in the sessions module. But for some reason, I cannot access the method. I need to debug more.

muthvar1 commented 4 years ago

Sorry, I had accindentally pointed my code base to an older SDK. Corrected it now. But I still see some issue with the file download. Is the expectation for all files to be stored in a manged filePath?

ixnetwork.Vport.find(Name='1/1/13').Capture.HardwareEnabled = True

ixnetwork.StartCapture() ixnetwork.Traffic.Apply() ixnetwork.Traffic.Start() flowStatistics = StatViewAssistant(ixnetwork, 'Flow Statistics') ixnetwork.StopCapture() remote_filename = ixnetwork.SaveCaptureFiles("C:\Results", "capture")[0] print remote_filename C:\Results\1-1-13_HWcatapult.cap session.DownloadFile(remote_filename,local_filename='/local/vamuthal') Traceback (most recent call last): File "", line 1, in session.DownloadFile(remote_filename,local_filename='/local/vamuthal') File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/testplatform/sessions/sessions.py", line 211, in DownloadFile return self._connection._get_file('%s/ixnetwork' % self.href, remote_filename=remote_filename, local_filename=local_filename) File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/connection.py", line 189, in _get_file self._process_response_status_code(response) File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/connection.py", line 215, in _process_response_status_code raise ServerError(response) ServerError: http://10.195.217.111:11009/api/v1/sessions/1/ixnetwork/files?filename=C:%5CResults%5C1-1-13_HWcatapult.cap&deprecated=true => 403 Forbidden {"me thod":"GET","pathAndQuery":"/api/v1/sessions/1/ixnetwork/files?filename=C:%5CResults%5C1-1-13_HWcatapult.cap&deprecated=true","errors":[{"code":403,"detail":" Forbidden: The file path C:\Results\1-1-13_HWcatapult.cap is not under one of the following system managed file paths: C:/Users/ixia/AppData/Local/Ixia (rea d/write)"}]}

muthvar1 commented 4 years ago

Looks like it only allows downloads from specific file systems. I see that it is a server-side error, not sure if it is a restriction on the ixNetwork API server or the Windows system as such. Can someone help explain? I would ideally like to not store the captured files under C:\Users\ixia\AppData\Local\Ixia. This is because we have autopurge routines that run on the client VMs that do not take this folder into consideration.

therkong commented 4 years ago

I will test this out and let you know.

Regards, Theresa

From: varghese muthalaly notifications@github.com Sent: Thursday, June 11, 2020 1:59 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Theresa Kong theresa.kong@keysight.com; Assign assign@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] is there an equivalent api for capture like takecsvsnapshot in RestPy (#104)

[EXTERNAL]

Looks like it only allows downloads from specific file systems. I see that it is a server-side error, not sure if it is a restriction on the ixNetwork API server or the Windows system as such. Can someone help explain? I would ideally like to not store the captured files under C:\Users\ixia\AppData\Local\Ixia. This is because we have autopurge routines that run on the client VMs that do not take this folder into consideration.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/OpenIxia/IxNetwork/issues/104*issuecomment-642924889__;Iw!!I5pVk4LIGAfnvw!yjAOF6YRXu8gY2dV4OQKpCo_XLSo2MHCXrhn_gjrw1U3oTe80QPIegGE3ZVNHT6q2hAu$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AIRRUUJMVVF7LQMEDGFBS6LRWFAQRANCNFSM4N3VSBTQ__;!!I5pVk4LIGAfnvw!yjAOF6YRXu8gY2dV4OQKpCo_XLSo2MHCXrhn_gjrw1U3oTe80QPIegGE3ZVNHZYOHgJG$.

therkong commented 4 years ago

I’d like to open a support ticket to keep track of this… Can you send me your company email account?

Regards, Theresa

From: varghese muthalaly notifications@github.com Sent: Thursday, June 11, 2020 1:59 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Theresa Kong theresa.kong@keysight.com; Assign assign@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] is there an equivalent api for capture like takecsvsnapshot in RestPy (#104)

[EXTERNAL]

Looks like it only allows downloads from specific file systems. I see that it is a server-side error, not sure if it is a restriction on the ixNetwork API server or the Windows system as such. Can someone help explain? I would ideally like to not store the captured files under C:\Users\ixia\AppData\Local\Ixia. This is because we have autopurge routines that run on the client VMs that do not take this folder into consideration.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/OpenIxia/IxNetwork/issues/104*issuecomment-642924889__;Iw!!I5pVk4LIGAfnvw!yjAOF6YRXu8gY2dV4OQKpCo_XLSo2MHCXrhn_gjrw1U3oTe80QPIegGE3ZVNHT6q2hAu$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AIRRUUJMVVF7LQMEDGFBS6LRWFAQRANCNFSM4N3VSBTQ__;!!I5pVk4LIGAfnvw!yjAOF6YRXu8gY2dV4OQKpCo_XLSo2MHCXrhn_gjrw1U3oTe80QPIegGE3ZVNHZYOHgJG$.

therkong commented 4 years ago

I tried out in my setup. Indeed, the capture file must be save under C:\Users\ixia\AppData\Local\Ixia. I checked with our engineer. It's for security reasons that we limit where you can write the files. Did you want to remove the capture files with your autopurge routine? Is it possible to add more paths to your autopurge?

muthvar1 commented 4 years ago

Hi Theresa, I will see if we can add this folder to our auto-purge in that case.

Thanks, Varghese

On Thu, Jun 11, 2020 at 4:34 PM therkong notifications@github.com wrote:

I tried out in my setup. Indeed, the capture file must be save under C:\Users\ixia\AppData\Local\Ixia. I checked with our engineer. It's for security reasons that we limit where you can write the files. Did you want to remove the capture files with your autopurge routine? Is it possible to add more paths to your autopurge?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/OpenIxia/IxNetwork/issues/104#issuecomment-642981822, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDWUCXZRC3OO5YUDC5Q2CLRWFSWTANCNFSM4N3VSBTQ .