Skip to content

Commit afdd252

Browse files
committed
Version 9.00
1 parent 8ab8f4e commit afdd252

File tree

115 files changed

+6460
-661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+6460
-661
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ API library release corresponding to IxNetwork 8.40 EA.
1414

1515
API library release corresponding to IxNetwork 8.50 EA.
1616
This version supports both IxNetwork Windows and Linux API Server.
17-
Connections to IxNetwork Windows on the REST port or to Linux API Server are secured.
17+
Connections to IxNetwork Windows on the REST port or to Linux API Server are secured.
18+
19+
20+
**9.00**
21+
22+
----
23+
24+
API library release corresponding to IxNetwork 9.00 EA.
25+
This version adds support for IPv6.

IxNetwork/IxNetwork.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright 1997 - 2018 by IXIA Keysight
4+
# Copyright 1997 - 2019 by IXIA Keysight
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"),
@@ -21,6 +21,7 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323

24+
2425
import sys
2526
import socket
2627
import select
@@ -39,7 +40,7 @@ class IxNet(object):
3940
"""
4041

4142
def __init__(self):
42-
self._version = '8.50.1501.10'
43+
self._version = '9.00.1915.16'
4344
self.OK = '::ixNet::OK'
4445
self.ERROR = '::ixNet::ERROR'
4546
self._transportType = None
@@ -82,7 +83,13 @@ def _log(self, msg):
8283
if (len(msg) > 1024):
8384
msg = ''.join([msg[:1024], '...'])
8485
print('[{timestamp}] [IxNet] [debug] {msg}'.format(timestamp=dt, msg=msg))
85-
86+
87+
def _is_ipv6(self, hostname):
88+
if len(hostname.split(':')) > 1:
89+
return True
90+
else:
91+
return False
92+
8693
def _detectTransport(self, hostname, port= None):
8794
self._log("Detecting transport type...")
8895

@@ -95,7 +102,10 @@ def _detectTransport(self, hostname, port= None):
95102
else:
96103
usingDefaultPorts = False
97104
try:
98-
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
105+
if self._is_ipv6(hostname):
106+
_socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
107+
else:
108+
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
99109
_socket.settimeout(_timeout)
100110
_socket.setblocking(True)
101111
_socket.connect((hostname, port))

IxNetwork/IxNetworkLegacy.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright 1997 - 2018 by IXIA Keysight
4+
# Copyright 1997 - 2019 by IXIA Keysight
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"),
@@ -65,7 +65,7 @@ def __init__(self):
6565
self._timeout = None
6666
self._transportType = 'TclSocket'
6767
self._OK = '::ixNet::OK'
68-
self._version = '8.50.1501.10'
68+
self._version = '9.00.1915.16'
6969

7070
def setDebug(self, debug):
7171
self._debug = debug
@@ -94,14 +94,23 @@ def _isConnected(self,raiseError=False):
9494
else:
9595
return True
9696

97+
def _is_ipv6(self, hostname):
98+
if len(hostname.split(':')) > 1:
99+
return True
100+
else:
101+
return False
102+
97103
def __initialConnect(self, address, port, options):
98104
# make an initial socket connection
99105
# this will keep trying as it could be connecting to the proxy
100106
# which may not have an available application instance at that time
101107
attempts = 0
102108
while True:
103109
try:
104-
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
110+
if self._is_ipv6(address):
111+
self._socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
112+
else:
113+
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
105114
self._socket.connect((address, port))
106115
break
107116
except (socket.error,):
@@ -128,6 +137,7 @@ def __initialConnect(self, address, port, options):
128137
self._socket.sendall(options.encode('ascii'))
129138
self._connectTokens = str(self.__Recv())
130139
connectTokens = dict(list(zip(self._connectTokens.split()[::2], self._connectTokens.split()[1::2])))
140+
print('connectiontoken is %s' %(connectTokens))
131141
self._proxySocket = self._socket
132142
self._socket = None
133143
self.__initialConnect(address, int(connectTokens['-port']), '')
@@ -166,6 +176,12 @@ def connect(self, address, *args):
166176
serverusername = nameValuePairs['-serverusername']
167177
if '-connectTimeout' in nameValuePairs:
168178
options += ' -connectTimeout ' + nameValuePairs['-connectTimeout']
179+
if '-applicationVersion' in nameValuePairs:
180+
options += ' -applicationVersion ' + nameValuePairs['-applicationVersion']
181+
if '-persistentApplicationVersion' in nameValuePairs:
182+
options += ' -persistentApplicationVersion ' + nameValuePairs['-persistentApplicationVersion']
183+
if '-forceVersion' in nameValuePairs:
184+
options += ' -forceVersion ' + nameValuePairs['-forceVersion']
169185
if '-closeServerOnDisconnect' in nameValuePairs:
170186
options += ' -closeServerOnDisconnect ' + nameValuePairs['-closeServerOnDisconnect']
171187
else:
@@ -519,7 +535,11 @@ def __Recv(self):
519535

520536
if len(self._decoratedResult) > 0 and self._decoratedResult[0].startswith('\01'):
521537
self._decoratedResult[0] = self._decoratedResult[0].replace('\01', '')
522-
return eval(''.join(self._decoratedResult))
538+
try :
539+
return eval(''.join(self._decoratedResult))
540+
except :
541+
self._decoratedResult[0] = self._decoratedResult[0].replace('\01', '').replace('\r\\n', '')
542+
return eval(''.join(self._decoratedResult))
523543
else:
524544
return ''.join(self._decoratedResult)
525545

@@ -533,4 +553,4 @@ def _log(self, msg):
533553
dt = datetime.now().strftime("%a %b %d %X %Y")
534554
if (len(msg) > 1024):
535555
msg = ''.join([msg[:1024], '...'])
536-
print('[{timestamp}] [IxNet] [debug] {msg}'.format(timestamp=dt, msg=msg))
556+
print('[{timestamp}] [IxNet] [debug] {msg}'.format(timestamp=dt, msg=msg))

IxNetwork/IxNetworkSecure.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright 1997 - 2018 by IXIA Keysight
4+
# Copyright 1997 - 2019 by IXIA Keysight
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"),
@@ -21,6 +21,7 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323

24+
2425
import getpass
2526
import io
2627
import os
@@ -66,9 +67,14 @@
6667
missingDependencies.append('backports.ssl')
6768
try:
6869
import urllib3
70+
try:
71+
import urllib3.contrib.pyopenssl as pyopenssl
72+
pyopenssl.inject_into_urllib3()
73+
except :
74+
missingDependencies.append('pyopenssl')
6975
except ImportError:
7076
missingDependencies.append('urllib3')
71-
77+
7278
if 'urllib3' not in missingDependencies and 'requests' not in missingDependencies:
7379
if sys.version_info[0] == 2 and ((sys.version_info[1] == 7 and sys.version_info[2] < 9) or sys.version_info[1] < 7):
7480
import requests.packages.urllib3
@@ -77,7 +83,8 @@
7783
except AttributeError:
7884
raise ImportError('You are using an old urllib3 version which does not support handling the certificate validation warnings. Please upgrade urllib3 using: pip install urllib3 --upgrade')
7985
if 'backports.ssl' not in missingDependencies and hasattr(urllib3.util, 'IS_PYOPENSSL') and not urllib3.util.IS_PYOPENSSL:
80-
missingDependencies.append('pyopenssl')
86+
if 'pyopenssl' not in missingDependencies :
87+
missingDependencies.append('pyopenssl')
8188
else:
8289
try:
8390
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@@ -120,7 +127,7 @@ def _setDefaults(self):
120127
self._async = False
121128
self._timeout = None
122129
self._transportType = 'WebSocket'
123-
self._version = '8.50.1501.10'
130+
self._version = '9.00.1915.16'
124131
self.OK = '::ixNet::OK'
125132
self.ERROR = '::ixNet::ERROR'
126133
self.VERIFY_CERT = False
@@ -172,7 +179,7 @@ def getApiKey(self, hostname, *args):
172179

173180
port = sessionArgs['-port']
174181
apiKeyFile = sessionArgs['-apiKeyFile']
175-
url = 'https://{hostname}:{port}/api/v1/auth/session'.format(hostname=hostname, port=port)
182+
url = 'https://{hostname}:{port}/api/v1/auth/session'.format(hostname=self._ip_encloser(hostname), port=port)
176183
if not self._isConnected(raiseError=False):
177184
self._createHeaders()
178185

@@ -391,7 +398,7 @@ def connect(self, hostname, *args):
391398
self._connectionInfo['sessionUrl'] = '{url}/{id}'.format(url=self._connectionInfo['url'], id=self._connectionInfo['sessionId'])
392399
self._connectionInfo['backendType'] = self._tryGetAttr(session, 'backendType', default='LinuxAPIServer')
393400
self._connectionInfo['wsUrl'] = '{websocket}://{hostname}:{port}/ixnetworkweb/ixnrest/ws/api/v1/sessions/{id}/ixnetwork/globals/ixnet?closeServerOnDisconnect={closeServerOnDisconnect}&clientType={clientType}&clientUsername={clientusername}'.format(websocket=self._connectionInfo['wsVerb'],
394-
hostname=self._connectionInfo['hostname'],
401+
hostname=self._ip_encloser(self._connectionInfo['hostname']),
395402
port=self._connectionInfo['port'],
396403
id=self._connectionInfo['sessionId'],
397404
closeServerOnDisconnect= self._connectionInfo['closeServerOnDisconnect'],
@@ -436,6 +443,7 @@ def connect(self, hostname, *args):
436443
if self._connectionInfo['sessionUrl'] and self._connectionInfo['closeServerOnDisconnect']:
437444
self._cleanUpSession(self._connectionInfo['sessionUrl'])
438445
self._close()
446+
self._deleteSession(self._connectionInfo['sessionUrl'])
439447
portValueString = ''
440448
if '-port' in connectArgs:
441449
portValueString = connectArgs['-port']
@@ -450,8 +458,9 @@ def connect(self, hostname, *args):
450458
def disconnect(self):
451459
if self._isConnected():
452460
self._close()
453-
if self._connectionInfo['closeServerOnDisconnect']:
454-
self._cleanUpSession(self._connectionInfo['sessionUrl'])
461+
# bye, bye self._cleanUpSession() forever
462+
#if self._connectionInfo['closeServerOnDisconnect']:
463+
# self._cleanUpSession(self._connectionInfo['sessionUrl'])
455464
self._setDefaults()
456465
else:
457466
return 'not connected'
@@ -591,10 +600,16 @@ def _createHeaders(self, apiKey=None, apiKeyFile=None):
591600
'Content-Type': 'application/json'
592601
}
593602

603+
def _ip_encloser(self, hostname):
604+
if len(hostname.split(':')) > 1:
605+
return '[{hostname}]'.format(hostname=hostname)
606+
else:
607+
return hostname
608+
594609
def _createUrl(self, verb, hostname, port):
595610
return '{verb}{verbSeparator}{hostname}{portSeparator}{port}/api/v1/sessions'.format(verb=verb,
596611
verbSeparator='://',
597-
hostname=hostname,
612+
hostname=self._ip_encloser(hostname),
598613
portSeparator=':',
599614
port=port)
600615

@@ -606,7 +621,11 @@ def _setConnectionInfo(self, verb, hostname, port, url):
606621
self._connectionInfo['wsVerb'] = 'ws'
607622
else:
608623
self._connectionInfo['wsVerb'] = 'wss'
609-
self._connectionInfo['hostname'] = hostname
624+
m = re.match('\[(?P<hostname>.*)\]', hostname)
625+
if m:
626+
self._connectionInfo['hostname'] = m.group('hostname')
627+
else:
628+
self._connectionInfo['hostname'] = hostname
610629
self._connectionInfo['port'] = port
611630
self._connectionInfo['url'] = url
612631

IxNetwork/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
backports.ssl>=0.0.9; python_version < '2.7.9'
2-
backports.ssl-match-hostname>=3.5.0.1; python_version < '2.7.9'
3-
pyopenssl>=17.5.0; python_version < '2.7.9'
1+
backports.ssl>=0.0.9
2+
backports.ssl-match-hostname>=3.5.0.1
3+
pyopenssl>=17.5.0
44
requests>=2.18.4
55
websocket-client>=0.47.0

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright 1997 - 2018 by IXIA Keysight
3+
Copyright 1997 - 2019 by IXIA Keysight
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ Testing
3535

3636
Documentation
3737
=============
38-
| For general language documentation of IxNetwork API see the `Low Level API Guide <http://downloads.ixiacom.com/library/user_guides/ixnetwork/8.50/EA_8.50_Rev_A/QuickReferenceGuides/LLAPI_reference_guide.pdf>`_ and the `IxNetwork API Help <http://downloads.ixiacom.com/library/user_guides/ixnetwork/8.50/EA_8.50_Rev_A/IxNetwork_HTML5/IxNetwork.htm>`_.
38+
| For general language documentation of IxNetwork API see the `Low Level API Guide <http://downloads.ixiacom.com/library/user_guides/ixnetwork/9.00/EA_9.00_Rev_A/QuickReferenceGuides/LLAPI_reference_guide.pdf>`_ and the `IxNetwork API Help <http://downloads.ixiacom.com/library/user_guides/ixnetwork/9.00/EA_9.00_Rev_A/IxNetwork_HTML5/IxNetwork.htm>`_.
3939
| This will require a login to `Ixia Support <https://support.ixiacom.com/user-guide>`_ web page.
4040
4141

4242
IxNetwork API server / Python Support
4343
=====================================
44-
IxNetwork.py lib 8.50.1501.9 supports:
44+
IxNetwork.py lib 9.00.1915.16 supports:
4545

46-
* Python 2.7, 3.3, 3.4, 3.5 and 3.6
46+
* Python 2.7, 3.3, 3.4, 3.5, 3.6, 3.7
4747
* IxNetwork Windows API server 8.40+
4848
* IxNetwork Web Edition (Linux API Server) 8.50+
4949

0 commit comments

Comments
 (0)