Skip to content

Commit

Permalink
Add a is_connected Api method to EmuClient
Browse files Browse the repository at this point in the history
-- Add is_connected method to EmuClient
-- Add the method to the Emu proxy as syntactic sugar

Signed-off-by: Bes Dollma <[email protected]>
  • Loading branch information
bdollma committed Jul 23, 2021
1 parent f9c3120 commit 4cb76d6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/trex_stateless.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6190,6 +6190,8 @@ if not master_daemon.is_stl_rpc_proxy_running():
===== Emu Methods:

* connect
* is_connected
* disconnect
* load_profile
* remove_profile
* add_ns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ def set_timeout(self, timeout_sec):
self.conn.rpc.set_timeout_sec(timeout_sec)

@client_api('command', False)
def connect (self):
def connect(self):
"""
Connects to the Emulation server
Expand All @@ -1941,15 +1941,32 @@ def connect (self):
+ :exc:`TRexError`
"""

# cleanup from previous connection
self._disconnect()

rc = self._connect()
if not rc:
self._disconnect()
raise TRexError(rc.err())

@client_api('getter', False)
def is_connected(self):
"""
Indicate if the connection is established to the server.
:parameters:
None
:return:
True if the connection is established to the server
o.w False
:raises:
None
"""
return self.conn.is_connected()

@client_api('command', True)
def acquire(self, force = False):
pass
Expand All @@ -1959,7 +1976,7 @@ def release(self, force = False):
pass

@client_api('command', False)
def disconnect (self, release_ports = True):
def disconnect(self, release_ports = True):
"""
Disconnects from the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def verify_hlt(res):
print('Removing profile...')
res = verify(server.emu_remove_profile())

print('Disconnecting from Emu Server')
verify(server.emu_disconnect())

else:
print('Could not find path of icmp profile, skipping')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ def run_server(port = 8095, emu = False):
]
emu_methods = [
'connect',
'is_connected',
'disconnect',
'load_profile',
'remove_profile',
'add_ns',
Expand Down

0 comments on commit 4cb76d6

Please sign in to comment.