Skip to content

Commit

Permalink
use _get_addr_port to extract addr and port
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutshkumr committed Jan 27, 2021
1 parent 5313a3a commit a0ad513
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.1.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
],
extras_require={
'dev': [
'snappi==0.1.16',
'snappi>=0.1.16,<0.2.0',
'pytest',
'flake8==3.8.4',
'dpkt==1.9.4',
Expand Down
23 changes: 18 additions & 5 deletions snappi_ixnetwork/ixnetworkapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class Api(snappi.Api):
This is not required when connecting to single session environments
"""
def __init__(self,
address='127.0.0.1',
port='11009',
host=None,
username='admin',
password='admin',
license_servers=[],
Expand All @@ -39,9 +38,10 @@ def __init__(self,
- username (str): The username to be used for authentication
- password (str): The password to be used for authentication
"""
super(Api, self).__init__()
self._address = address
self._port = port
super(Api, self).__init__(
host='https://127.0.0.1:11009' if host is None else host
)
self._address, self._port = self._get_addr_port(self.host)
self._username = username
self._password = password
self._license_servers = license_servers
Expand All @@ -55,6 +55,19 @@ def __init__(self,
self.ngpf = Ngpf(self)
self.traffic_item = TrafficItem(self)

def _get_addr_port(self, host):
items = host.split('/')
items = items[-1].split(':')

addr = items[0]
if len(items) == 2:
return addr, items[-1]
else:
if host.startswith('https'):
return addr, '443'
else:
return addr, '80'

@property
def config(self):
return self._config
Expand Down

0 comments on commit a0ad513

Please sign in to comment.