openixia / ixnetwork_restpy Goto Github PK
View Code? Open in Web Editor NEWThe IxNetwork python client.
Home Page: https://openixia.github.io/ixnetwork_restpy/#/
License: MIT License
The IxNetwork python client.
Home Page: https://openixia.github.io/ixnetwork_restpy/#/
License: MIT License
IPv6 redirects are not handled properly. I've got below exception while. trying to connect to IPv6 API server.
requests.exceptions.InvalidURL: Failed to parse: https://[2600:111/api/v1/sessions
The issue is only seen with Windows based IxNetwork 9.05. IxNetwork started redirecting requests from HTTP to HTTPS protocol.
When ixetwork-restpy receives HTTP redirect it executes this part of the code
Link to the code
if str(response.status_code).startswith('3'):
url = response.headers['location']
if url.find('://') != -1:
self._scheme = url[:url.find('://')]
self._hostname = url[url.find('://')+3:url.find('/', url.find('://')+3)]
if self._scheme == 'https':
self._rest_port = 443
host_pieces = self._hostname.split(':') #IPv6 address/port wrongly split using colon
if len(host_pieces) > 1:
self._hostname = host_pieces[0]
self._rest_port = host_pieces[1]
Request:
method:POST
url:http://[2600:111:111:111::c]:11009/api/v1/auth/session
data:{"username": "admin", "password": "admin"}
headers:{'X-Api-Key': None, 'User-Agent': 'ixnetwork-restpy', 'content-type': 'application/json', 'Content-Type': 'application/json'}
Response:
status:307
headers:{'Location': 'https://[2600:111:111:111::c]:11009/api/v1/auth/session',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '* ',
'Connection': 'Close'}
Hi!
Great project.
Is it possible to change ipv4.prefix? Is there the setter?
ethernet = deviceGroup.Ethernet.add(Name='eth1'))
ipv4 = ethernet.Ipv4.add(Name='ip1')
ipv4.Address.Increment(start_value='1.1.1.1', step_value='1.0.0.0')
ipv4.GatewayIp.Increment(start_value='1.1.1.0', step_value='1.0.0.0')
ipv4.Prefix = 31?
Thank you.
If a user issues the following RestPy command ...
ix_network.Topology.find(Name=src_port_name).DeviceGroup.find(Name='Ethernet 19')
... and the 'src_port_name' variable does not contain a valid name, the error would be something like this:
Traceback (most recent call last):
File "/home/lab/fb_gnmi/gNMI-API/venv/lib/python3.7/site-packages/ixnetwork_restpy/base.py", line 136, in _get_attribute
return self._properties[name]
File "/home/lab/fb_gnmi/gNMI-API/venv/lib/python3.7/site-packages/ixnetwork_restpy/base.py", line 122, in _properties
return self._object_properties[self._index]
IndexError: list index out of range
At this point, it is not possible to know if the topology or the deviceGroup name is invalid. Currently the best practice is to search for the topology first and verify if it returns an empty container and proceed next to the deviceGroup. This breaks the powerful chaining capability of the library.
I would propose in response to the initial RestPy command to instead of returning a generic 'list index out of range', to return an exception like: "Error: Topology not found" or something similar so the user know right away where the calling chain is broken.
ixnetwork_restpy$ python setup.py develop
running develop
running egg_info
creating ixnetwork_restpy.egg-info
writing ixnetwork_restpy.egg-info/PKG-INFO
writing dependency_links to ixnetwork_restpy.egg-info/dependency_links.txt
writing requirements to ixnetwork_restpy.egg-info/requires.txt
writing top-level names to ixnetwork_restpy.egg-info/top_level.txt
writing manifest file 'ixnetwork_restpy.egg-info/SOURCES.txt'
error: package directory 'uhd_restpy' does not exist
workaround:
diff --git a/setup.py b/setup.py
index 7b72e95b..34adaa4a 100644
--- a/setup.py
+++ b/setup.py
@@ -56,7 +56,7 @@ setup(
'Programming Language :: Python :: 3',
],
keywords='ixnetwork performance traffic generator real world ixia automation',
- packages=['ixnetwork_restpy', 'uhd_restpy'],
+ packages=['ixnetwork_restpy'],
include_package_data=True,
python_requires='>=2.7, <4',
install_requires=['requests', 'websocket-client'],
Need an option to avoid Restpy messages to stdout and log the messages only to log_file_name passed as an argument
Hi,
I'm trying to add LAG using the following code but it fails. Are any additional steps required to setup a LAG ?
I get no errors. Simply "unconfigured" is printed 3 times. When I go to IxNetwork GUI it seems LAG is added but only partially. It's not listed under Ports/LAGs but when I click "Add LAGs" dialog windows is opened that shows the LAG was added (it's present on the right side of the window).
I use IxNetwork API server (9.10 Update1 and IxOS 9.10 Patch 1) and NOVUS100GE8Q28+FAN card. I managed to add and start LAG using IxNetwork GUI so I assume my setup is ok.
`tpl = TestPlatform('10.10.0.222', 11029)
ixnetwork = tpl.Sessions.find().Ixnetwork
a1 = ixnetwork.Vport.find(Name="access1")
a2 = ixnetwork.Vport.find(Name="access2")
ixnetwork.Lag.add("lag1", [a1, a2])
ixnetwork.Lag.find().Start()
print(ixnetwork.Lag.find().AggregationStatus)
sleep(5)
print(ixnetwork.Lag.find().AggregationStatus)
sleep(5)
print(ixnetwork.Lag.find().AggregationStatus)
sleep(5)
`
To assist users make available an option to trace the entire http request and response.
Log a warning message when the option is enabled as this will be a performance hit and can possibly create large logs.
e.g.,
TestPlatform.Trace = 'request_response_all'
In RESTAPI Browser there is an option to regenerate multiple traffic items in a single-post command whereas, in RESTpy, we have to loop through each traffic item and then regenerate. Is there a way to do the same in RESTpy?
If the same thing is achieved using RESTpy, this would save time if we have a huge number of traffic items.
In order to script using Rest.Py IxNework Configuration - script takes up some considerable amount of time. In underneath Rest.Py makes several incremental call ( http patch/push ) with IxNetwork.
Idea is to reduce this configuration time . This can be achieved by committing configuration to IxNetwork only once. ( communication with IxNetwork is made only once. )
For that we can introduce an assistance in Rest.Py - Config Assistance to build up configuration at client side.
Hi All,
I don't really know if what I'm trying to achieve is doable or not.
I've manually created a .ixncfg file with a simple test and what I'm trying to achieve is to load this file and start it
from ixnetwork_restpy import SessionAssistant, Files, TestPlatform
from time import sleep
# create a test tool session
session_assistant = SessionAssistant(IpAddress='1.1.1.1',UserName='admin', Password='admin',
LogLevel=SessionAssistant.LOGLEVEL_INFO,
ClearConfig=True)
ixnetwork = session_assistant.Ixnetwork
ixnetwork.LoadConfig(Files('test.ixncfg'))
ixnetwork.StartAllProtocols()
but I'm getting all the time the same error
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [INFO] using python version 2.7.17 (default, Feb 27 2021, 15:10:58)
[GCC 7.5.0]
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [INFO] using ixnetwork-restpy version 1.1.3
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [WARNING] Verification of certificates is disabled
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [INFO] Determining the platform and rest_port using the 10.51.158.48 address...
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [WARNING] Unable to connect to http://10.51.158.48:11009.
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [WARNING] Unable to connect to https://10.51.158.48:11009.
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [WARNING] Unable to connect to http://10.51.158.48:443.
2021-11-17 17:42:10 [ixnetwork_restpy.connection] [INFO] Connection established to `https://10.51.158.48:443 on linux`
2021-11-17 17:42:27 [ixnetwork_restpy.connection] [INFO] Using IxNetwork api server version 9.10.2007.7
2021-11-17 17:42:27 [ixnetwork_restpy.connection] [INFO] User info IxNetwork/ixnetworkweb/admin-50-30366
ixnetwork_restpy.errors.BadRequestError: System Exception Caught. Exception Text: Port is not owned by this user
Port is not owned by this user
System Exception Caught. Exception Text: Port is not owned by this user
Port is not owned by this user
I would like to know if it's possible and if so, what I'm doing wrong
Thanks
Using new Rest.Py Config assistance (#47) , user will be able to save configuration in json format.
This allow in future to extend various other format like yml or oprenapi format.
Invalid method name None in
ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\queueproperty_3j0uxvldwvzl3f1zxvluhjvcgvydhk.py", line 50
Are these method names starting with digit valid ?
*** Error compiling 'C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\advertisedfeatures.py'...
File "C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\advertisedfeatures.py", line 40
def 100MbFd(self):
^
SyntaxError: invalid syntax
*** Error compiling 'C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\currentfeatures.py'...
File "C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\currentfeatures.py", line 40
def 100MbFd(self):
^
SyntaxError: invalid syntax
*** Error compiling 'C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\peeradvertisedfeatures.py'...
File "C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\peeradvertisedfeatures.py", line 40
def 100MbFd(self):
^
SyntaxError: invalid syntax
*** Error compiling 'C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\queueproperty.py'...
File "C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\queueproperty.py", line 52
def None(self):
^
SyntaxError: invalid syntax
*** Error compiling 'C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\supportedfeatures.py'...
File "C:\Windows\TEMP\pip-install-ttyyhl1f\ixnetwork-restpy\ixnetwork_restpy\testplatform\sessions\ixnetwork\vport\protocols\openflow\supportedfeatures.py", line 40
def 100MbFd(self):
^
SyntaxError: invalid syntax
It looks like something is broken in 1.0.58 which impacts the import in python 2.7. This issue is not there with python3.x or version 1.0.57.
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> from ixnetwork_restpy import SessionAssistant
>>> pkg_resources.get_distribution("ixnetwork_restpy").version
'1.0.58'
>>> quit()
me@my-dev:~$ python2.7
Python 2.7.18rc1 (default, Apr 7 2020, 12:05:55)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> from ixnetwork_restpy import SessionAssistant
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name SessionAssistant
>>> pkg_resources.get_distribution("ixnetwork_restpy").version
'1.0.58'
>>> quit()
me@my-dev:~$
Downgraded to package version 1.0.57, this issue is gone
me@me-dev:~$ pip2.7 install ixnetwork_restpy==1.0.57
me@me-dev:~$ python2.7
Python 2.7.18rc1 (default, Apr 7 2020, 12:05:55)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> from ixnetwork_restpy import SessionAssistant
>>> pkg_resources.get_distribution("ixnetwork_restpy").version
'1.0.57'
>>>
Hi there,
I am trying to completely disable auto instrumentation on a traffic item.
In the IxExplorer GUI, I can see the option and remove it. Please let me know how to completely disable AutoInstrumentation from scripts.
But when I try to setup this via restpy script using below option, it does not work.
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:794: ------------------------------------------
self.vports_obj[vport_name].L1Config.AresOneFourHundredGigLan.AutoInstrumentation = 'endOfFrame'
File "/usr/local/lib/python2.7/dist-packages/ixnetwork_restpy/testplatform/sessions/ixnetwork/vport/l1config/aresonefourhundredgiglan/aresonefourhundredgiglan.py", line 47, in AutoInstrumentation
self._set_attribute('autoInstrumentation', value)
File "/usr/local/lib/python2.7/dist-packages/ixnetwork_restpy/base.py", line 141, in _set_attribute
raise e
BadRequestError: Port does not support 'endOfFrame'
testplatform/sessions/sessions.py, class Session, method GetFileList(self, remote_directory=None)
Line 325:
href = '%s?absolute=%s'
should be:
href = '%s?absolute=%s' % (href, remote_directory)
Fixes for both available in new branch.
Please refer the following script.
from ixnetwork_restpy import SessionAssistant
session_assistant = SessionAssistant(IpAddress='127.0.0.1', UserName='admin', Password='admin',
LogLevel=SessionAssistant.LOGLEVEL_INFO, ClearConfig=True)
conf_assist = session_assistant.ConfigAssistant()
config = conf_assist.config
vport = config.Vport.add()
ethernet = config.Topology.add(Vports=vport).DeviceGroup.add().Ethernet.add()
ethernet.Mac.Single("00:11:00:00:22:00")
conf_assist.commit()
# modifying multivalue
ethernet.Mac.Increment(start_value="00:11:00:00:22:00", step_value="00:00:00:00:22:00")
conf_assist.commit()
Gives the following error
Traceback (most recent call last):
File "C:/pycharm_projs/res/src/vlan test.py", line 43, in <module>
ethernet.Mac.Increment(start_value="00:11:00:00:22:00", step_value="00:00:00:00:22:00")
File "C:\pycharm_projs\res\venv\lib\site-packages\ixnetwork_restpy\testplatform\sessions\ixnetwork\topology\ethernet_18677f1f170027c217563a3250b1f635.py", line 770, in Mac
return Multivalue(self, self._get_attribute(self._SDM_ATT_MAP['Mac']))
File "C:\pycharm_projs\res\venv\lib\site-packages\ixnetwork_restpy\base.py", line 199, in _get_attribute
return self._properties[name]
KeyError: 'mac'
Hi,
I am using below function to set IeeL1Defaults on Novus 100G / 25G port speed. But after updating to Active IxOS Version : 9.00.1900.10 , I see ports come up with IEEE/Consortion defaults enabled.
Is there any additional configuration required to turn off IEEE L1 defaults and AN to disable?
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.IeeeL1Defaults = False
if an == "off":
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.EnableAutoNegotiation = False
if fec_mode == "off":
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.EnableRsFec = False
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.IeeeL1Defaults = False
Hi!
I'm trying to change SendP2PHellosToUnicastMac and I take this example:
from ixnetwork_restpy.testplatform.testplatform import TestPlatform
testplatform = TestPlatform('****')
sessions = testplatform.Sessions.add(ApplicationType='ixnrest', Name=None)
ixnetwork = sessions.Ixnetwork
vport = ixnetwork.Vport.add(ConnectedTo=None, IsPullOnly=None, Name=None, RxMode=None, TraceEnabled=None, TraceLevel=None, TraceTag=None, TransmitIgnoreLinkStatus=None, TxGapControlMode=None, TxMode=None, Type=None, UseGlobalSettings=None)
protocols = vport.Protocols.add()
isis = protocols.Isis
testplatform.info(isis.SendP2PHellosToUnicastMac)
In running I got the error:
skayres@hfts4:~/dev_autotest/test_automation$ python p2p.py
2019-09-26 13:40:59 [ixnetwork_restpy.connection] [INFO] using python version 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516]
2019-09-26 13:40:59 [ixnetwork_restpy.connection] [INFO] using ixnetwork-restpy version 1.0.41
2019-09-26 13:40:59 [ixnetwork_restpy.connection] [INFO] The package will automatically determine the test tool platform and rest_port using the ****** address...
2019-09-26 13:40:59 [ixnetwork_restpy.connection] [INFO] Unable to connect to test tool at http://****:443.
2019-09-26 13:40:59 [ixnetwork_restpy.connection] [INFO] Unable to connect to test tool at https://****:443.
2019-09-26 13:40:59 [ixnetwork_restpy.connection] [INFO] Connection established to `http://****:11009 on windows`
Traceback (most recent call last):
File "p2p.py", line 8, in <module>
protocols = vport.Protocols.add()
File "/usr/local/lib/python2.7/dist-packages/ixnetwork_restpy/testplatform/sessions/ixnetwork/vport/protocols/protocols.py", line 408, in add
return self._create(locals())
File "/usr/local/lib/python2.7/dist-packages/ixnetwork_restpy/base.py", line 233, in _create
properties = self._connection._create(url, payload)
File "/usr/local/lib/python2.7/dist-packages/ixnetwork_restpy/connection.py", line 188, in _create
return self._send_recv('POST', url, payload)
File "/usr/local/lib/python2.7/dist-packages/ixnetwork_restpy/connection.py", line 376, in _send_recv
self._process_response_status_code(response)
File "/usr/local/lib/python2.7/dist-packages/ixnetwork_restpy/connection.py", line 280, in _process_response_status_code
raise BadRequestError(response)
ixnetwork_restpy.errors.BadRequestError: https://****:11009/api/v1/sessions/1/ixnetwork/vport/2/protocols => 400 Bad Request {"method":"POST","pathAndQuery":"/api/v1/sessions/1/ixnetwork/vport/2/protocols","errors":[{"code":10000,"detail":"\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430."}]}
skayres@hfts4:~/dev_autotest/test_automation$ pip list | grep ixnetwork
ixnetwork-restpy 1.0.41
What I'm wrong?
Thank you!
Hi,
I am using ixnetwork_restpy 1.0.47 and call TestPlatform(...) as below:
from ixnetwork_restpy.testplatform.testplatform import TestPlatform
testpl = TestPlatform(myserver, rest_port=myrestport, log_file_name=mylogfile)
problem:
how can I make TestPlatform(...) append log lines rather than override them ?
Best regards,
sshuguan
Suppose for a same vport, we create mutliple data or multiple control captures.
When I try to download each capture files, the command SaveCaptureFiles(Arg1=...) returns me only the latest data and the latest control capture.
On the following screenshot, I have 1 control capture and 2 data captures
When I use the SaveCaptureFiles() method, it returns only:
['C:\\Users\\aseitz\\AppData\\Local\\Ixia\\IxNetwork\\vport_site1_HW.cap', 'C:\\Users\\aseitz\\AppData\\Local\\Ixia\\IxNetwork\\vport_site1_SW.cap', 'C:\\Users\\aseitz\\AppData\\Local\\Ixia\\IxNetwork\\vport_site2_HW.cap', 'C:\\Users\\aseitz\\AppData\\Local\\Ixia\\IxNetwork\\vport_site2_SW.cap']
How can I do to retrieve all captures, not only the latest?
SessionAssitant doesn't work with ApiKey argument
from ixnetwork_restpy import SessionAssistant
ip = "172.0.0.1"
user = "admin"
password = "admin
sa = SessionAssistant(ip, UserName=user, Password=password)
key = sa.TestPlatform.ApiKey
print(key)
sa2 = SessionAssistant(ip, ApiKey=key)
print(sa2.Session)
I propose a correction inside #31
Hi!
Ixnetwork version:
v8.52.1904.2
Couldn't you add a sample how to get IPv4learnedInfo for BGP session?
I try something like this:
topology1 = ixnetwork.Topology.find()
device_group1 = topology1.DeviceGroup.find()
ipv4_loopback1 = device_group1.Ipv4Loopback.find()
bgp_ipv4_peers = ipv4_loopback1.BgpIpv4Peer.find()
response = bgp_ipv4_peers.GetIPv4LearnedInfo('1-3')
And I get 404 error from IxNetwork:
2019-08-02 06:40:12 [ixnetwork_restpy.connection] [DEBUG] POST https://10.27.150.146:11009/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ipv4Loopback/2/bgpIpv4Peer/1/operations/getipv4learnedinfo {"Arg1": "/ap
i/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ipv4Loopback/2/bgpIpv4Peer/1", "Arg2": "1"}
DEBUG:ixnetwork_restpy.connection:POST https://10.27.150.146:11009/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ipv4Loopback/2/bgpIpv4Peer/1/operations/getipv4learnedinfo {"Arg1": "/api/v1/sessions/1/ixnetwor
k/topology/1/deviceGroup/1/ipv4Loopback/2/bgpIpv4Peer/1", "Arg2": "1"}
DEBUG:urllib3.connectionpool:Resetting dropped connection: 10.27.150.146
DEBUG:urllib3.connectionpool:https://10.27.150.146:11009 "POST /api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ipv4Loopback/2/bgpIpv4Peer/1/operations/getipv4learnedinfo HTTP/1.1" 404 236
2019-08-02 06:40:12 [ixnetwork_restpy.connection] [DEBUG] 404 Not Found
DEBUG:ixnetwork_restpy.connection:404 Not Found
When I use the API browser I get the correct response. The difference in the requests is:
API Browser:
POST:/api/v1/sessions/1/ixnetwork/topology/deviceGroup/ipv4Loopback/bgpIpv4Peer/operations/getipv4learnedinfo
ixnetwork_restpy: POST:/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ipv4Loopback/2/bgpIpv4Peer/1/operations/getipv4learnedinfo
Thank you.
Hi!
Couldn't you provide the sample how to change 'Level Type' attribute for an isis router?
I didn't found this attribute via API browser and in isis*.py classes of ixnetwork_restpy.
Thank you!
I generally use Type annotation inside my functions and in this purpose I import your basic type like Ethernet.
I have recently update your lib and i have notice a changement of th import strategie.
It would be nice to have a simplified way to access to Type of your lib.
release 1.0.30
from ixnetwork_restpy.testplatform.sessions.ixnetwork.topology.ethernet import Ethernet
release 1.0.58
from ixnetwork_restpy.testplatform.sessions.ixnetwork.topology.ethernet_18677f1f170027c217563a3250b1f635 import Ethernet
IxNetwork: 8.42.1250.2 EA
Python: 3.7.3
Getting the following error when calling:
traffic_statistics = StatViewAssistant(ixNetwork, 'Traffic Item Statistics')
Traceback (most recent call last):
File "Ixia\ixnetwork_restpy\base.py", line 118, in _get_attribute
return self._properties[name]
File "Ixia\ixnetwork_restpy\base.py", line 104, in _properties
return self._object_properties[self._index]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Ixia\test-high-level.py", line 74, in <module>
traffic_statistics = StatViewAssistant(ixNetwork, 'Traffic Item Statistics')
File "Ixia\ixnetwork_restpy\assistants\statistics\statviewassistant.py", line 93, in __init__
self._is_view_ready
File "Ixia\ixnetwork_restpy\assistants\statistics\statviewassistant.py", line 143, in _is_view_ready
if self._View.Data.IsReady is True:
File "Ixia\ixnetwork_restpy\testplatform\sessions\ixnetwork\statistics\view\data\data.py", line 161, in IsReady
return self._get_attribute('isReady')
File "Ixia\ixnetwork_restpy\base.py", line 120, in _get_attribute
raise NotFoundError('The attribute %s is not in the internal list of object dicts. (%s)' % (name, e))
ixnetwork_restpy.errors.NotFoundError: The attribute isReady is not in the internal list of object dicts. (list index out of range)
Thanks.
Version information
v1.1.1
Describe the bug
The .find() method on any object has increased.
To Reproduce
Using the GUI, create an empty config and add 5000 interfaces to a single vport. Then use IxNetwork.Vport.find().Interface.find() to retrieve all interfaces.
Expected behavior
The .find() operation should complete within a few seconds as opposed to approx 40 seconds.
Additional context
N/A
In connection.py, class Connection, method _send_recv, lines 406-427 is a while True loop. This polls the API server for completion of an async operation. Line 412 is sleep(1) to sleep 1 second between http GET polls. It would be useful to make this an optional parameter passed in to init and various methods using _execute, default value 1 (retaining existing behavior) so that if running long operations in constrained environments cycles and traffic are not wasted constantly checking for "are we there yet?" results.
Hello,
when i use update method for setting Auto Neg (shown in commented out code below), port does not set Auto Neg = False. This is with IxOS 9.00 patch2 and Novus Hundred Gig cards. I had to use direct assignment and that works correctly.
def set_port_an(self, vport_name, an="off"):
'''
method to set autoneg mode based on portname
vport: <string> port name
an: <string> off (default) | on
if an == "off":
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.update(IeeeL1Defaults=False, EnableAutoNegotiation=False)
else:
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.update(IeeeL1Defaults=True, EnableAutoNegotiation=True)
'''
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.IeeeL1Defaults = False
if an == "off":
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.EnableAutoNegotiation = False
else:
self.vports_obj[vport_name].L1Config.NovusHundredGigLan.EnableAutoNegotiation = True
I would like to have custom logic to start the ixnetwork session, but currently Sessions.find(Id=xxx)
automatically starts the session if found.
This does not align with how find()
works on other objects. Could an option be added to avoid this automatic start? Or is there another possibility?
When attempting to generate a TestConfig object from a Rfc2544throughput object a SyntaxError is generated:
>>> ixSession.Ixnetwork.QuickTest.Rfc2544throughput.add().TestConfig()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/haydnb/svt_scripts/3007_ixnetwork/ixnetwork_restpy/testplatform/sessions/ixnetwork/quicktest/rfc2544throughput_2993ee9d3aa1842ea5cbff3edf8a2923.py", line 92, in TestConfig
from ixnetwork_restpy.testplatform.sessions.ixnetwork.quicktest.testconfig_81b75f11abcc4096f93d5a7b6bf03b10 import TestConfig
File "/home/haydnb/svt_scripts/3007_ixnetwork/ixnetwork_restpy/testplatform/sessions/ixnetwork/quicktest/testconfig_81b75f11abcc4096f93d5a7b6bf03b10.py", line 3517
tep_latency_scaleAccLoss=None, Step_step_latency_thresholdAccLoss=None, Step_step_peak_FrameLossUnit=None, Step_step_peak_initialValue=None, Step_step_peak_maxValue=None, Step_step_peak_stepTolerance=None, Step_step_peak_stepValue=None, Step_step_seq_enableAccLoss=None, Step_step_seq_modeAccLoss=None, Step_step_seq_thresholdAccLoss=None, StopTestOnHighLoss=None, SupportedTrafficTypes=None, Tolerance=None, TrafficType=None, TxDelay=None, UnchangedInitial=None, UnchangedValueList=None, UsePercentOffsets=None, UseTiLoss=None):
^
SyntaxError: more than 255 arguments
>>>
Other quicktests do not thave this problem. For example:
QuickTest.Rfc3918scaleGroup.add().TestConfig()
returns successfully.
See the following output from a python3 shell:
Python 3.4.3 (default, Nov 12 2018, 22:25:49)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ixnetwork_restpy import SessionAssistant, Files
>>> ixnetworkAPIServerIP = "192.168.1.1"
>>> ixnetworkAPIServerRestPort = 11009
>>> ixSession = SessionAssistant(IpAddress=ixnetworkAPIServerIP, RestPort = ixnetworkAPIServerRestPort, ClearConfig=True, LogFilename='restpy.log')
>>> ixn = ixSession.Ixnetwork
>>> qt=ixn.QuickTest.Rfc2544throughput.add()
>>> type(qt)
<class 'ixnetwork_restpy.testplatform.sessions.ixnetwork.quicktest.rfc2544throughput_2993ee9d3aa1842ea5cbff3edf8a2923.Rfc2544throughput'>
>>> qtTc = qt.TestConfig()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/ixnetwork_restpy/testplatform/sessions/ixnetwork/quicktest/rfc2544throughput_2993ee9d3aa1842ea5cbff3edf8a2923.py", line 92, in TestConfig
from ixnetwork_restpy.testplatform.sessions.ixnetwork.quicktest.testconfig_81b75f11abcc4096f93d5a7b6bf03b10 import TestConfig
File "/ixnetwork_restpy/testplatform/sessions/ixnetwork/quicktest/testconfig_81b75f11abcc4096f93d5a7b6bf03b10.py", line 3517
tep_latency_scaleAccLoss=None, Step_step_latency_thresholdAccLoss=None, Step_step_peak_FrameLossUnit=None, Step_step_peak_initialValue=None, Step_step_peak_maxValue=None, Step_step_peak_stepTolerance=None, Step_step_peak_stepValue=None, Step_step_seq_enableAccLoss=None, Step_step_seq_modeAccLoss=None, Step_step_seq_thresholdAccLoss=None, StopTestOnHighLoss=None, SupportedTrafficTypes=None, Tolerance=None, TrafficType=None, TxDelay=None, UnchangedInitial=None, UnchangedValueList=None, UsePercentOffsets=None, UseTiLoss=None):
^
SyntaxError: more than 255 arguments
According the API documentation, we should be able to choose a name for dataActiveCapture and controlActiveCapture
however, when I try to modify this field, I get an error:
{
"method": "PATCH",
"pathAndQuery": "/api/v1/sessions/1/ixnetwork/vport/1/capture",
"errors": [
{
"code": 5500,
"detail": "Invalid control active capture name"
}
]
}
Is there a specific syntax to apply?
Hi!
IxNetwork version: 8.50.1501.9 EA
I can't find how to change VlanId. Only get_attribute is available.
ethernet_1 = device_group_1.Ethernet.add(UseVlans=UseVlans, VlanCount=VlanCount)
ethernet_1.Mac.Increment(start_value=start_mac, step_value='00:00:00:00:00:01')
# not work:
ethernet_1.Vlan.VlanId = '1,2,3,4,5')
# No increment on VLAN:
ethernet_1.Vlan.Increment(start_value=1, step_value=1)
# Can't set attribute
setattr(ethernet_1.Vlan, 'VlanId', '1 2 3 4 5')
setattr(ethernet_1.Vlan, 'vlanId', '1, 2, 3, 4, 5')
Couldn't you provide some info please.
Thank you!
Currently users are making typos and there is an expectation that certain values are being set when in reality they are not.
The library should not allow dynamic properties and raise an error when it occurs.
I use CsvLogging to save traffic item trace. It works fine but for the first traffic run only.
When I start traffic again and enable logging results seems to be appended to results file.
The result is csv file fomated like this:
<headers row>
<first run data rows>
<headers row>
<second run data rows>
Is it expected behavior ? Is there any way to reset csv file between traffic runs ?
Any reason why files here were renamed with some kind of hash at the end?
https://github.com/OpenIxia/ixnetwork_restpy/tree/master/ixnetwork_restpy/testplatform/sessions/ixnetwork/topology
For instance
bgpipv4peer_9dd9eddcf2bd784d82d8a016e392f035.py
Is it a permanent change or an error?
hi team,
in my tests, Session.GetObjectFromHref() returns None for multivalue hrefs.
This is due to the fact that the href for those derives directly under IxNetwork, e.g.
/api/v1/sessions/8020/ixnetwork/multivalue/2
however IxNetwork has not attribute "Multivalue"
so the search fails (using own debug prints):
node Ixnetwork[0]: /api/v1/sessions/8020/ixnetwork/ piece multivalue
'Ixnetwork' object has no attribute 'Multivalue'
def GetObjectFromHref(self, href):
"""Given an href get the corresponding object
References are used to establish relationships between disparate nodes.
This allows a user to get an object using a reference from a node.
For example:
A /vport node has a ConnectedTo property that is a reference to an /availableHardware/chassis/card/port node.
A user can get a vport and use this method to get the port node in order to clear ownership
Args
----
- href (str): A valid href reference
Returns
-------
obj: If the reference is valid an ixnetwork_restpy object or None if the reference cannot be resolved
"""
try:
node = self
for piece in href[href.find('ixnetwork'):].split('/'):
if piece.isdigit():
for item in node:
if item.href.split('/').pop() == piece:
node = node._read(item.href)
break
else:
class_name = '%s%s' % (piece[0].upper(), piece[1:])
node = getattr(node, class_name)
if hasattr(node, 'find') is True:
node.find()
return node
except:
return None
is there an alternative way to locate multivalue objects from its href number .... ?
best regards Stefan
I am using ixNetwork.Traffic.Apply().
I'm looking to apply this in a non-blocking way. At present, it blocks until the items are applied.
Version
couldn't find a file version number, but it is ixnetwork-restpy 1.1.1
Problem
ixnetwork_restpy/connection.py - line 475 references "response". However the response is only assigned in the first if statement on line 464 of the same file.
Solution
check if response exists, if not try a session request, then return as originally planned.
Notes
It's generally not good practice to have multiple returns, it might be worth investigating if its possible to have a response status code variable assigned, with a single return at the end
General
Thanks of the effort and the code. Very much apprieciated.
Docstring starting at line 171 of
ixnetwork_restpy/testplatform/sessions/ixnetwork/vport/protocols/router_byb3rvy29scy9vc3bmvjmvcm91dgvy.py is invalid
It should be raw string or not use backslash character.
Currently we find protocol and relevant field in order to set that parameter. We will extend Rest.Py protocol/template so that actual protocol and field information is made available to user as class properties.
to user as class properties.
For example:
# Current way of scripting :
tr1 = traffic.TrafficItem.add(Name='RAW TCP', BiDirectional=False, TrafficType='raw',TrafficItemType='l2L3')
configElement = tr1.ConfigElement.find()[0]
ethernetStackObj = configElement.Stack.find(DisplayName='Ethernet II')
ethernetSrcField = ethernetStackObj.Field.find(DisplayName='Source MAC Address')
ethernetSrcField.SingleValue = '00:11:00:00:22:00'
ipv4ProtocolTemplate = traffic.ProtocolTemplate.find(DisplayName='IPv4')
# Proposed way of scripting :
tr1 = traffic.add(Name='RAW TCP', BiDirectional=False, TrafficType='raw', TrafficItemType='l2L3')
stack = tr1.ConfigElement.Stack
eth_st = stack.Ethernet_II.add()
eth_st.Destination_MAC_Address.Single('00:33:00:11:22:00')
ipv4_st = stack.IPv4.add()
An import for BadRequestError
is missing in ixnetwork_restpy/testplatform/sessions/sessions.py
ixnetwork_restpy/testplatform/sessions/sessions.py in Start(self)
167 break
168 elif time.time() - start > 300:
--> 169 raise BadRequestError('Unable to start session %s after %s seconds' % (id, time.time() - start))
170 time.sleep(5)
171 return self
NameError: name 'BadRequestError' is not defined
# this will fail and needs to be supported
testplatform = TestPlatform('2620:10d:c0a8:21::2a')
# this will not fail
testplatform = TestPlatform('[2620:10d:c0a8:21::2a]')
New features:
Currently the ixnetwork.LoadConfig is taking a lot of time waiting for larger configurations to load. Requesting non blocking way to load configuration (Similar async way is found in ixnetwork.StartAllProtocols)
Hi,
I'm trying to use statistics CSV logging. Because timestamps in result csv file seems to count from session start I need to find sessions start time to get usable timestamps.
I tried the following code (it's based on sample from docs)
from ixnetwork_restpy import TestPlatform
tpl = TestPlatform('10.10.0.222', 11029)
ixnetwork = tpl.Sessions.find().Ixnetwork
tl = ixnetwork.Timeline
print(tl.StartTime)
but it gives me NotFoundError
ixnetwork_restpy.errors.NotFoundError: The attribute startTime is not in the internal list of object dicts.
If there is a find method execute that prior to executing a property accessor.
Check the number of encapsulated resources using the len method.
list index out of range
I'm using IxNetwork 9.10.2007.7 and ixnetwork_restpy 1.0.59.
I appreciate any clues.
Want to be able to find resources on the server by drilling down into a resources multivalue values.
e.g.,
""" find by ip address
this should return all objects where the address multivalue matches 1.1.1.1
"""
matches = ixnetwork.Topology.find().DeviceGroup.find().Ethernet.find().Ipv4.find(Address='1.1.1.1')
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.