Connection wrappers

Asyncio ESL connection abstactions

class switchio.connection.Connection(host, port='8021', password='ClueCon', loop=None, autorecon=30)

An ESL connection implemented using an asyncio TCP protocol.

Consider this API threadsafe.

Parameters:autorecon (int or bool) – Enable reconnection attempts on loss of a server connection. An integer value specifies the of number seconds to spend re-trying the connection before bailing. A bool of ‘True’ will poll indefinitely and ‘False’ will not poll at all.
api(cmd, errcheck=True, block=False, timeout=0.5)

Invoke api command (with error checking by default).

cmd(cmd)

Return the string-body output from invoking a command.

connect(host=None, port=None, password=None, loop=None, block=True, timeout=0.5)

Connect the underlying protocol.

If block is set to false returns a coroutine.

execute(uuid, app, arg='', params='', loops=1)

Execute a dialplan app with argument arg.

recv_event()

Retreive the latest queued event.

subscribe(event_types, fmt='plain')

Subscribe connection to receive events for all names in event_types

exception switchio.connection.ConnectionError

Failed to connect to ESL

switchio.connection.connect_and_auth(host, port, password, prot, loop, log, timeout=0.5)

Try to create a connection and authenticate to the target FS ESL.

switchio.connection.get_connection(host, port=8021, password='ClueCon', loop=None)

ESL connection factory.

switchio.connection.run_in_order_threadsafe(awaitables, loop, timeout=0.5, block=True)

“Given a sequence of awaitables, schedule each threadsafe in order optionally blocking until completion.

Returns a concurrent.futures.Future which can be used to wait on the result returned from the last awaitable. If block is True the final result will be waited on before returning control to the caller.