ajbalogh / ixnetwork_client_python Goto Github PK
View Code? Open in Web Editor NEWIxNetwork REST API python client
License: MIT License
IxNetwork REST API python client
License: MIT License
Hi,
When we are making thousands of requests to Ixnetwork rest port from ixn_client_python, it rejects the request sometimes(very rarely, once in thousands). This give an connection refused error at socket interface and disrupts the automation scripts. We can try catch in our scripts or may try with some sleep, but that will not be the best possible solution.
Can we put a try catch block in IxnHttp.py line 188, and retry for a few times before discarding the request?
Or there will be any collateral if we do that.
Traceback (most recent call last): File "ConfigConverter.py", line 122, in <module> config_convertor.convert() File "ConfigConverter.py", line 35, in convert N2xConverter(self._from_tree, self._ixnhttp).convert() File "/home/subha/PycharmProjects/configuration_converter/N2xConverter.py", line 51, in convert N2XconvertStreamGroupList(self) File "/home/subha/PycharmProjects/configuration_converter/N2XconvertStreamGroupList.py", line 19, in __init__ self._convert_agt_stream_group_list() File "/home/subha/PycharmProjects/configuration_converter/N2XconvertStreamGroupList.py", line 439, in _convert_agt_stream_group_list frameSize = self.highLevelStream.query.clear().node('frameSize', properties=['*']).go().frameSize File "/home/subha/configuration_converter/lib/python3.5/site-packages/ixnetwork/IxnQuery.py", line 97, in go async_response = self._ixnhttp.post('/operations/query', self._query) File "/home/subha/configuration_converter/lib/python3.5/site-packages/ixnetwork/IxnHttp.py", line 152, in post response = self._send_recv('POST', url, payload, fid, file_content) File "/home/subha/configuration_converter/lib/python3.5/site-packages/ixnetwork/IxnHttp.py", line 188, in _send_recv self._connection.request(method, url, json.dumps(payload), headers) File "/usr/lib/python3.5/http/client.py", line 1106, in request self._send_request(method, url, body, headers) File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request self.endheaders(body) File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders self._send_output(message_body) File "/usr/lib/python3.5/http/client.py", line 934, in _send_output self.send(msg) File "/usr/lib/python3.5/http/client.py", line 877, in send self.connect() File "/usr/lib/python3.5/http/client.py", line 849, in connect (self.host,self.port), self.timeout, self.source_address) File "/usr/lib/python3.5/socket.py", line 711, in create_connection raise err File "/usr/lib/python3.5/socket.py", line 702, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused
Hi,
We are testing the usability of ixnetwork_client_python, with headless ixnetwork centos based rest api.
While testing with the simplest sample (ixnetwork/samples/sessions/create_new_session.py) we found this error -
Traceback (most recent call last):
File "/home/subha/PycharmProjects/ixnetwork_client_python/ixnetwork/samples/sessions/create_new_session.py", line 16, in <module>
session = ixnhttp.create_session()
File "/home/subha/PycharmProjects/ixnetwork_client_python/ixnetwork/IxnHttp.py", line 86, in create_session
self.post('/api/v1/sessions/%s/operations/start' % session.id, payload=body)
File "/home/subha/PycharmProjects/ixnetwork_client_python/ixnetwork/IxnHttp.py", line 153, in post
response = self._process_async_response(url, response)
File "/home/subha/PycharmProjects/ixnetwork_client_python/ixnetwork/IxnHttp.py", line 134, in _process_async_response
response = self._send_recv('GET', response.url)
File "/home/subha/PycharmProjects/ixnetwork_client_python/ixnetwork/IxnHttp.py", line 205, in _send_recv
response = requests.request(method, url, data=None, headers=headers, verify=self._verify_cert)
File "/home/subha/configuration_converter/lib/python3.5/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/home/subha/configuration_converter/lib/python3.5/site-packages/requests/sessions.py", line 498, in request
prep = self.prepare_request(req)
File "/home/subha/configuration_converter/lib/python3.5/site-packages/requests/sessions.py", line 441, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/home/subha/configuration_converter/lib/python3.5/site-packages/requests/models.py", line 309, in prepare
self.prepare_url(url, params)
File "/home/subha/configuration_converter/lib/python3.5/site-packages/requests/models.py", line 377, in prepare_url
raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: 10.117.159.205:443https:
Build -
ixnetwork-rest==0.55a57
ixnetwork headless server (spyder) -8.50EA
P.S -> The session is getting successfully created.
Ixnetwork client: 8.40 EA
While performing post operation for some multivalue patterns - repeatableRandomRange, repeatableRandom.
Ixnetwork returns error.
request type: POST
URL: /api/v1/sessions/<session_id>/ixnetwork/multivalue/<id>/random
response:
{
"links": [
{
"rel": "self",
"method": "GET",
"href": "/api/v1/sessions/<session_id>/ixnetwork/multivalue/<id>/random"
}
]
}
But for
request type: POST
URL: /api/v1/sessions/<session_id>/ixnetwork/multivalue/<id>/repeatableRandomRange
response:
{
"method": "POST",
"pathAndQuery": "/api/v1/sessions/<session_id>/ixnetwork/multivalue/<id>/repeatableRandomRange",
"errors": [
{
"code": 10000,
"detail": "One of the identified items was in an invalid format."
}
]
}
Hi @ajbalogh ,
Trying to export a config in ixncfg format rather than the default json version.
This piece of code is throwing error -
Are we using in the correct way? Or is it a bug?
from ixnetwork import IxnHttp, IxnConfigManagement
ixnhttp = IxnHttp(host, rest_port=rest_port)
ixnhttp.auth('admin', 'admin')
ixnhttp.create_session()
# made a configuration
# now trying to export in ixncfg
config_mgmt = IxnConfigManagement(ixnhttp)
xpaths = [
'/vport/descendant-or-self::*',
'/topology/descendant-or-self::*',
'/traffic/descendant-or-self::*'
]
config_mgmt.export_config(xpaths=xpaths, local_filename=converted_filename,export_format = 'ixncfg')
Hi,
We use the delete method of IxnObject class,
which used to work perfectly in IxNetwork 8.40EA but now we are moving to IxNetwork 8.50EA and it is not working.
The following snippet should create an IxnObject instance and delete it.
w_topology = ixnhttp.root.create_child('topology')
w_topology.delete()
This is the traceback we are getting for 8.50EA
Exception: 405 Method Not Allowed {"Message":"The requested resource does not support http method 'DELETE'."}
Can you please look into it?
Ixn...Emulation classes should offer the functionality to find a child emulation host using a parent host
find a specific ethernet emulation using a virtual port name
eth = IxnEthernetEmulation(ixnhttp).find(vport_name='PE2-6/8')
find the igmp host emulation using the eth emulation host
igmp = IxnIgmpHostEmulation(ixnhtt).find(eth)
Hi,
I'm testing ixnetwork_client_python with IxNetwork Connection Manager 8.40.1124.8 in GUI mode.
I was able to use the API to create a few sessions. However, when I tried to connect to existing sessions, I got a 404 error.
It turned out the Connection Manager does not like GET request /api/v1/sessions?links=true. If I manually issue _send_recv('GET', '/api/v1/sessions') then I could query a list of sessions in the Connection manager.
What is the best way to address this issue?
Patrick
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.